Started implementing Resleeving UI

This commit is contained in:
danielyxie
2019-01-16 21:15:00 -08:00
parent 6d8d25e0bb
commit 19f65de555
6 changed files with 37 additions and 11 deletions
+2 -2
View File
@@ -31,9 +31,9 @@ export class Resleeve extends Person {
// Get total base Augmentation cost for this re-sleeve
let totalAugmentationCost: number = 0;
for (let i = 0; i < this.augmentations.length; ++i) {
const aug: Augmentation | null = Augmentations[this.augmentations[i]];
const aug: Augmentation | null = Augmentations[this.augmentations[i].name];
if (aug == null) {
console.error(`Could not find Augmentation ${this.augmentations[i]}`);
console.error(`Could not find Augmentation ${this.augmentations[i].name}`);
continue;
}
totalAugmentationCost += aug!.baseCost;
+8 -4
View File
@@ -21,7 +21,7 @@ import { getRandomInt } from "../../../utils/helpers/getRandomInt";
// Executes the actual re-sleeve when one is purchased
export function resleeve(r: Resleeve, p: IPlayer) {
export function resleeve(r: Resleeve, p: IPlayer):void {
// Set the player's exp
p.hacking_exp = r.hacking_exp;
p.strength_exp = r.strength_exp;
@@ -36,7 +36,7 @@ export function resleeve(r: Resleeve, p: IPlayer) {
p.augmentations.length = 0;
for (let i = 0; i < r.augmentations.length; ++i) {
p.augmentations.push(new PlayerOwnedAugmentation(r.augmentations[i]));
p.augmentations.push(new PlayerOwnedAugmentation(r.augmentations[i].name));
}
p.reapplyAllAugmentations(true);
@@ -64,10 +64,14 @@ export function generateResleeves(): Resleeve[] {
const baseNumAugs: number = Math.ceil((i + 1) / 2);
const numAugs: number = getRandomInt(baseNumAugs, baseNumAugs + 2);
for (let a = 0; a < numAugs; ++a) {
// We'll ignore Aug prerequisites for this
const augKeys: string[] = Object.keys(Augmentations);
r.augmentations.push(TODO);
const randKey: string = augKeys[getRandomInt(0, augKeys.length - 1)];
const randAug: Augmentation | null = Augmentations[randKey];
r.augmentations.push({name: randAug!.name, level: 1});
}
ret.push(r);
}
return ret;
@@ -0,0 +1,19 @@
/**
* Module for handling the Re-sleeving UI
*/
import { Resleeve } from "./Resleeve";
import { generateResleeves,
resleeve } from "./Resleeving";
import { IMap } from "../../types";
import { numeralWrapper } from "../../ui/numeralFormat";
import { Page,
routing } from "../../ui/navigationTracking";
import { createElement } from "../../../utils/uiHelpers/createElement";
import { createOptionElement } from "../../../utils/uiHelpers/createOptionElement";
import { getSelectValue } from "../../../utils/uiHelpers/getSelectData";
import { removeChildrenFromElement } from "../../../utils/uiHelpers/removeChildrenFromElement";
import { removeElement } from "../../../utils/uiHelpers/removeElement";
import { removeElementById } from "../../../utils/uiHelpers/removeElementById";