guild upgrades, enum for quest ranks and quests now persist while clicking onto another tab

This commit is contained in:
2023-03-19 13:22:24 +01:00
parent 3ccab02cc8
commit ff5e5e2411
6 changed files with 202 additions and 153 deletions
+28 -1
View File
@@ -1,9 +1,36 @@
export class Guild {
gold: number;
level: number;
displayUpgradeCost: number|string;
constructor(level: number, gold: number) {
this.gold = gold;
this.level = level;
this.displayUpgradeCost = this.getUpgradeCost() ?? "Max level";
}
}
upgrade(): void {
const cost = this.getUpgradeCost();
if (cost === null) return;
if (this.gold < cost) return;
this.gold -= cost;
this.level += 1;
if (this.level > 7) {
this.displayUpgradeCost = "Max level";
}
}
getUpgradeCost(): number|null {
return upgradeCosts[this.level] ?? null;
}
}
const upgradeCosts = {
"1": 1000,
"2": 2500,
"3": 5000,
"4": 10000,
"5": 25000,
"6": 50000,
"7": 100000,
} as {[index:string]: number}