bitburner-src/src/Gang/GangMemberUpgrade.ts

67 lines
2.3 KiB
TypeScript
Raw Normal View History

2021-06-17 23:37:05 +02:00
import { IMults, UpgradeType } from "./data/upgrades";
2021-08-15 20:09:58 +02:00
import { numeralWrapper } from "../ui/numeralFormat";
2021-06-14 21:42:38 +02:00
export class GangMemberUpgrade {
2021-09-05 01:09:30 +02:00
name: string;
cost: number;
type: UpgradeType;
desc: string;
mults: IMults;
2021-06-14 21:42:38 +02:00
2021-09-09 05:47:34 +02:00
constructor(name = "", cost = 0, type: UpgradeType = UpgradeType.Weapon, mults: IMults = {}) {
2021-09-05 01:09:30 +02:00
this.name = name;
this.cost = cost;
this.type = type;
this.mults = mults;
2021-06-14 21:42:38 +02:00
2021-09-05 01:09:30 +02:00
this.desc = this.createDescription();
}
2021-06-14 21:42:38 +02:00
2021-09-05 01:09:30 +02:00
createDescription(): string {
const lines = ["Effects:"];
if (this.mults.str != null) {
2021-09-09 05:47:34 +02:00
lines.push(`+${numeralWrapper.formatPercentage(this.mults.str - 1, 0)} strength skill`);
lines.push(`+${numeralWrapper.formatPercentage((this.mults.str - 1) / 4, 2)} strength exp`);
2021-09-05 01:09:30 +02:00
}
if (this.mults.def != null) {
2021-09-09 05:47:34 +02:00
lines.push(`+${numeralWrapper.formatPercentage(this.mults.def - 1, 0)} defense skill`);
lines.push(`+${numeralWrapper.formatPercentage((this.mults.def - 1) / 4, 2)} defense exp`);
2021-09-05 01:09:30 +02:00
}
if (this.mults.dex != null) {
2021-09-09 05:47:34 +02:00
lines.push(`+${numeralWrapper.formatPercentage(this.mults.dex - 1, 0)} dexterity skill`);
lines.push(`+${numeralWrapper.formatPercentage((this.mults.dex - 1) / 4, 2)} dexterity exp`);
2021-09-05 01:09:30 +02:00
}
if (this.mults.agi != null) {
2021-09-09 05:47:34 +02:00
lines.push(`+${numeralWrapper.formatPercentage(this.mults.agi - 1, 0)} agility skill`);
lines.push(`+${numeralWrapper.formatPercentage((this.mults.agi - 1) / 4, 2)} agility exp`);
2021-09-05 01:09:30 +02:00
}
if (this.mults.cha != null) {
2021-09-09 05:47:34 +02:00
lines.push(`+${numeralWrapper.formatPercentage(this.mults.cha - 1, 0)} charisma skill`);
lines.push(`+${numeralWrapper.formatPercentage((this.mults.cha - 1) / 4, 2)} charisma exp`);
2021-09-05 01:09:30 +02:00
}
if (this.mults.hack != null) {
2021-09-09 05:47:34 +02:00
lines.push(`+${numeralWrapper.formatPercentage(this.mults.hack - 1, 0)} hacking skill`);
lines.push(`+${numeralWrapper.formatPercentage((this.mults.hack - 1) / 4, 2)} hacking exp`);
2021-06-14 21:42:38 +02:00
}
2021-09-05 01:09:30 +02:00
return lines.join("<br>");
}
2021-06-14 21:42:38 +02:00
2021-09-05 01:09:30 +02:00
// User friendly version of type.
getType(): string {
switch (this.type) {
case UpgradeType.Weapon:
return "Weapon";
case UpgradeType.Armor:
return "Armor";
case UpgradeType.Vehicle:
return "Vehicle";
case UpgradeType.Rootkit:
return "Rootkit";
case UpgradeType.Augmentation:
return "Augmentation";
default:
return "";
2021-06-16 08:26:10 +02:00
}
2021-09-05 01:09:30 +02:00
}
}