mirror of
https://github.com/YouHaveTrouble/GuildMaster.git
synced 2026-05-12 06:26:59 +00:00
guild upgrades, enum for quest ranks and quests now persist while clicking onto another tab
This commit is contained in:
+28
-1
@@ -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}
|
||||
@@ -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) {
|
||||
|
||||
}
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
Reference in New Issue
Block a user