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}
+6 -5
View File
@@ -1,26 +1,27 @@
import type {Adventurer} from "@/classes/Adventurer";
import type {QuestRank} from "@/classes/QuestRank";
export class Quest {
id: string;
rank: QuestRank;
title: string;
text: string;
adventurers: Array<Adventurer>;
progressPoints: number;
maxProgress: number;
expReward: number;
goldReward: number;
constructor(id: string, title: string, text: string, maxProgress: number, expReward: number) {
constructor(id: string, rank: QuestRank, title: string, text: string, maxProgress: number, expReward: number, goldReward: number) {
this.id = id;
this.rank = rank;
this.title = title;
this.text = text;
this.maxProgress = maxProgress;
this.expReward = expReward;
this.goldReward = goldReward;
this.progressPoints = 0;
this.adventurers = [];
}
}
export function createRandomQuest(budget: number) {
}
+13
View File
@@ -0,0 +1,13 @@
export enum QuestRank {
S = "S",
A = "A",
B = "B",
C = "C",
D = "D",
E = "E",
F = "F",
}
export function getFromString(string: keyof typeof QuestRank): QuestRank {
return QuestRank[string];
}