2019-01-15 14:11:14 +01:00
|
|
|
/**
|
|
|
|
* Implements the Resleeve class, which defines a new body
|
|
|
|
* that the player can "re-sleeve" into.
|
|
|
|
*/
|
|
|
|
import { Person } from "../Person";
|
|
|
|
|
|
|
|
import { Augmentation } from "../../Augmentation/Augmentation";
|
|
|
|
import { Augmentations } from "../../Augmentation/Augmentations";
|
|
|
|
|
2019-01-17 16:40:43 +01:00
|
|
|
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../../utils/JSONReviver";
|
|
|
|
|
2019-01-15 14:11:14 +01:00
|
|
|
export class Resleeve extends Person {
|
2019-01-17 16:40:43 +01:00
|
|
|
|
2019-01-15 14:11:14 +01:00
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
getCost(): number {
|
|
|
|
// Each experience point adds this to the cost
|
2021-04-30 05:52:56 +02:00
|
|
|
const CostPerExp = 25e3;
|
2019-01-15 14:11:14 +01:00
|
|
|
|
2019-01-22 05:39:52 +01:00
|
|
|
// Final cost is multiplied by this constant ^ # Augs
|
2021-04-30 05:52:56 +02:00
|
|
|
const NumAugsExponent = 1.2;
|
2019-01-15 14:11:14 +01:00
|
|
|
|
|
|
|
// Get total exp in this re-sleeve
|
2021-04-30 05:52:56 +02:00
|
|
|
const totalExp: number = this.hacking_exp +
|
2019-01-15 14:11:14 +01:00
|
|
|
this.strength_exp +
|
|
|
|
this.defense_exp +
|
|
|
|
this.dexterity_exp +
|
|
|
|
this.agility_exp +
|
|
|
|
this.charisma_exp;
|
|
|
|
|
|
|
|
// Get total base Augmentation cost for this re-sleeve
|
2021-04-30 05:52:56 +02:00
|
|
|
let totalAugmentationCost = 0;
|
2019-01-15 14:11:14 +01:00
|
|
|
for (let i = 0; i < this.augmentations.length; ++i) {
|
2019-01-17 06:15:00 +01:00
|
|
|
const aug: Augmentation | null = Augmentations[this.augmentations[i].name];
|
2019-01-15 14:11:14 +01:00
|
|
|
if (aug == null) {
|
2019-01-17 06:15:00 +01:00
|
|
|
console.error(`Could not find Augmentation ${this.augmentations[i].name}`);
|
2019-01-15 14:11:14 +01:00
|
|
|
continue;
|
|
|
|
}
|
2021-05-01 09:17:31 +02:00
|
|
|
totalAugmentationCost += aug.startingCost;
|
2019-01-15 14:11:14 +01:00
|
|
|
}
|
|
|
|
|
2019-01-22 05:39:52 +01:00
|
|
|
return (totalExp * CostPerExp) + (totalAugmentationCost * Math.pow(NumAugsExponent, this.augmentations.length));
|
2019-01-15 14:11:14 +01:00
|
|
|
}
|
|
|
|
|
2019-01-17 16:40:43 +01:00
|
|
|
/**
|
|
|
|
* Serialize the current object to a JSON save state.
|
|
|
|
*/
|
|
|
|
toJSON(): any {
|
|
|
|
return Generic_toJSON("Resleeve", this);
|
|
|
|
}
|
2021-05-01 09:17:31 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initiatizes a Resleeve object from a JSON save state.
|
|
|
|
*/
|
|
|
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
|
|
static fromJSON(value: any): Resleeve {
|
|
|
|
return Generic_fromJSON(Resleeve, value.data);
|
|
|
|
}
|
2019-01-15 14:11:14 +01:00
|
|
|
}
|
2019-01-17 16:40:43 +01:00
|
|
|
|
|
|
|
Reviver.constructors.Resleeve = Resleeve;
|