bitburner-src/src/Gang/GangMemberUpgrade.ts

66 lines
2.6 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 {
name: string;
cost: number;
2021-06-17 23:37:05 +02:00
type: UpgradeType;
2021-06-14 21:42:38 +02:00
desc: string;
mults: IMults;
2021-06-17 23:37:05 +02:00
constructor(name = "", cost = 0, type: UpgradeType = UpgradeType.Weapon, mults: IMults = {}) {
2021-06-14 21:42:38 +02:00
this.name = name;
this.cost = cost;
this.type = type;
this.mults = mults;
this.desc = this.createDescription();
}
createDescription(): string {
2021-08-15 20:09:58 +02:00
const lines = ["Effects:"];
2021-06-14 21:42:38 +02:00
if (this.mults.str != null) {
2021-08-15 20:09:58 +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-06-14 21:42:38 +02:00
}
if (this.mults.def != null) {
2021-08-15 20:09:58 +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-06-14 21:42:38 +02:00
}
if (this.mults.dex != null) {
2021-08-15 20:09:58 +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-06-14 21:42:38 +02:00
}
if (this.mults.agi != null) {
2021-08-15 20:09:58 +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-06-14 21:42:38 +02:00
}
if (this.mults.cha != null) {
2021-08-15 20:09:58 +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-06-14 21:42:38 +02:00
}
if (this.mults.hack != null) {
2021-08-15 20:09:58 +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
}
return lines.join("<br>");
}
2021-06-16 08:26:10 +02:00
// User friendly version of type.
getType(): string {
switch (this.type) {
2021-06-17 23:37:05 +02:00
case UpgradeType.Weapon:
2021-06-16 08:26:10 +02:00
return "Weapon";
2021-06-17 23:37:05 +02:00
case UpgradeType.Armor:
2021-06-16 08:26:10 +02:00
return "Armor";
2021-06-17 23:37:05 +02:00
case UpgradeType.Vehicle:
2021-06-16 08:26:10 +02:00
return "Vehicle";
2021-06-17 23:37:05 +02:00
case UpgradeType.Rootkit:
2021-06-16 08:26:10 +02:00
return "Rootkit";
2021-06-17 23:37:05 +02:00
case UpgradeType.Augmentation:
2021-06-16 08:26:10 +02:00
return "Augmentation";
default:
return "";
}
}
2021-06-14 21:42:38 +02:00
}