From ff5e5e241117d3dd4bc46099df181f34cda9bcd8 Mon Sep 17 00:00:00 2001 From: YouHaveTrouble Date: Sun, 19 Mar 2023 13:22:24 +0100 Subject: [PATCH] guild upgrades, enum for quest ranks and quests now persist while clicking onto another tab --- src/App.vue | 87 ++++++++++++++-- src/classes/Guild.ts | 29 +++++- src/classes/Quest.ts | 11 +- src/classes/QuestRank.ts | 13 +++ src/views/HomeView.vue | 4 +- src/views/QuestView.vue | 211 ++++++++++++++------------------------- 6 files changed, 202 insertions(+), 153 deletions(-) create mode 100644 src/classes/QuestRank.ts diff --git a/src/App.vue b/src/App.vue index d97111c..a0c25ff 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,6 +1,5 @@ +import {RouterLink, RouterView} from 'vue-router' diff --git a/src/classes/Guild.ts b/src/classes/Guild.ts index 4ee8fb3..1bc1960 100644 --- a/src/classes/Guild.ts +++ b/src/classes/Guild.ts @@ -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"; } -} \ No newline at end of file + + 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} \ No newline at end of file diff --git a/src/classes/Quest.ts b/src/classes/Quest.ts index bac587a..c38475d 100644 --- a/src/classes/Quest.ts +++ b/src/classes/Quest.ts @@ -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; 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) { - -} diff --git a/src/classes/QuestRank.ts b/src/classes/QuestRank.ts new file mode 100644 index 0000000..c594562 --- /dev/null +++ b/src/classes/QuestRank.ts @@ -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]; +} \ No newline at end of file diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 02bee0e..0eaf7d0 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -9,9 +9,9 @@

Guild level: {{ guild.level }}

-
diff --git a/src/views/QuestView.vue b/src/views/QuestView.vue index a17cef1..94a2d92 100644 --- a/src/views/QuestView.vue +++ b/src/views/QuestView.vue @@ -5,25 +5,25 @@
-

{{missive.title}}

-

{{missive.text}}

+

{{ missive.title }}

+

{{ missive.text }}