Finished ResleeveUI implementation (untested)

This commit is contained in:
danielyxie
2019-01-17 07:40:43 -08:00
parent 19f65de555
commit 10231b6c66
11 changed files with 320 additions and 73 deletions
+15 -51
View File
@@ -1,61 +1,12 @@
// Base class representing a person-like object
import { Augmentation } from "../Augmentation/Augmentation";
import { Augmentations } from "../Augmentation/Augmentations";
import { IPlayerOwnedAugmentation } from "../Augmentation/PlayerOwnedAugmentation";
import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers";
import { Cities } from "../Locations/Cities";
import { CONSTANTS } from "../Constants";
import { IMap } from "../types";
// Interface for an object that represents the player (PlayerObject)
// Used because at the time of implementation, the PlayerObject
// cant be converted to TypeScript.
//
// Only contains the needed properties for Sleeve implementation
export interface IPlayer {
augmentations: IPlayerOwnedAugmentation[];
companyName: string;
factions: string[];
jobs: IMap<string>;
money: any;
queuedAugmentations: IPlayerOwnedAugmentation[];
hacking_skill: number;
strength: number;
defense: number;
dexterity: number;
agility: number;
charisma: number;
intelligence: number;
hacking_exp: number;
strength_exp: number;
defense_exp: number;
dexterity_exp: number;
agility_exp: number;
charisma_exp: number;
crime_success_mult: number;
gainHackingExp(exp: number): void;
gainStrengthExp(exp: number): void;
gainDefenseExp(exp: number): void;
gainDexterityExp(exp: number): void;
gainAgilityExp(exp: number): void;
gainCharismaExp(exp: number): void;
gainMoney(money: number): void;
loseMoney(money: number): void;
reapplyAllAugmentations(resetMultipliers: boolean): void;
startCrime(crimeType: string,
hackExp: number,
strExp: number,
defExp: number,
dexExp: number,
agiExp: number,
chaExp: number,
money: number,
time: number,
singParams: any): void;
}
// Interface that defines a generic object used to track experience/money
// earnings for tasks
export interface ITaskTracker {
@@ -147,6 +98,19 @@ export abstract class Person {
constructor() {}
/**
* Updates this object's multipliers for the given augmentation
*/
applyAugmentation(aug: Augmentation, reapply=false) {
for (const mult in aug.mults) {
if ((<any>this)[mult] == null) {
console.warn(`Augmentation has unrecognized multiplier property: ${mult}`);
} else {
(<any>this)[mult] *= aug.mults[mult];
}
}
}
/**
* Given an experience amount and stat multiplier, calculates the
* stat level. Stat-agnostic (same formula for every stat)