From 40c7755ae7e3c5e3a36ee126922367cac373a819 Mon Sep 17 00:00:00 2001 From: smthbh Date: Tue, 29 Apr 2025 08:59:46 -0400 Subject: [PATCH] add active quests section --- src/armory/Armory.ts | 31 +++++++++++++++++++++------ src/armory/types/QuestTypes.ts | 17 +++++++++++++++ static/character-quests-compare.hbs | 33 +++++++++++++++++++++++++++++ static/css/character-quests.css | 9 ++++++++ 4 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 src/armory/types/QuestTypes.ts diff --git a/src/armory/Armory.ts b/src/armory/Armory.ts index b301530..c9ff9cd 100644 --- a/src/armory/Armory.ts +++ b/src/armory/Armory.ts @@ -14,6 +14,7 @@ import { IndexController } from "./controllers/IndexController"; import { CharacterController } from "./controllers/CharacterController"; import { GuildController } from "./controllers/GuildController"; import { ArenaController } from "./controllers/ArenaController"; +import { IQuest, IQuestComparison } from './types/QuestTypes'; export class Armory { public characterCustomization: CharacterCustomization; @@ -102,26 +103,44 @@ export class Armory { helpers: { // eslint-disable-next-line @typescript-eslint/no-var-requires ...require("handlebars-helpers")(), - eq: function(a: any, b: any) { - return a === b; - }, - hasInProgressQuests: function(quests: any[]) { + hasInProgressQuests: function(quests: IQuest[]): boolean { return quests.some(quest => quest.status === 'In Progress'); }, - getDiffClass: function(quest: any) { + getDiffClass: function(quest: IQuestComparison): string { if (!quest.char1Status && !quest.char2Status) return ''; if (!quest.char1Status) return 'quest-missing-1'; if (!quest.char2Status) return 'quest-missing-2'; if (quest.char1Status !== quest.char2Status) return 'quest-diff'; return ''; }, - getDiffCount: function(quests: any[]): number { + getDiffCount: function(quests: IQuestComparison[]): number { return quests.reduce((count, quest) => { if (!quest.char1Status && quest.char2Status) return count + 1; if (quest.char1Status && !quest.char2Status) return count + 1; if (quest.char1Status !== quest.char2Status) return count + 1; return count; }, 0); + }, + getActiveQuests: function(categories: { [key: string]: IQuestComparison[] }): (IQuestComparison & { category: string })[] { + const activeQuests: (IQuestComparison & { category: string })[] = []; + Object.entries(categories).forEach(([category, quests]) => { + quests.forEach(quest => { + if (quest.char1Status === 'In Progress' || quest.char2Status === 'In Progress') { + activeQuests.push({ + ...quest, + category + }); + } + }); + }); + return activeQuests.sort((a, b) => { + // First sort by category + const categoryCompare = a.category.localeCompare(b.category); + if (categoryCompare !== 0) return categoryCompare; + + // Then by title within same category + return a.title.localeCompare(b.title); + }); } }, }), diff --git a/src/armory/types/QuestTypes.ts b/src/armory/types/QuestTypes.ts new file mode 100644 index 0000000..a924193 --- /dev/null +++ b/src/armory/types/QuestTypes.ts @@ -0,0 +1,17 @@ +export interface IQuest { + id: number; + title: string; + status: 'Completed' | 'In Progress'; + minLevel: number; + questLevel: number; + questSortID: number; +} + +export interface IQuestComparison { + id: number; + title: string; + questLevel: number; + char1Status?: 'Completed' | 'In Progress'; + char2Status?: 'Completed' | 'In Progress'; + category?: string; +} \ No newline at end of file diff --git a/static/character-quests-compare.hbs b/static/character-quests-compare.hbs index 558c82c..b434bff 100644 --- a/static/character-quests-compare.hbs +++ b/static/character-quests-compare.hbs @@ -63,6 +63,39 @@ +{{! Add this section before the categories loop }} +
+

+ Active Quests + +

+ +
+ + + + + + + + + + + {{#each (getActiveQuests data.categories)}} + + + + + + + {{/each}} + +
QuestArea (Level){{data.char1.name}}{{data.char2.name}}
+ {{this.title}} + {{this.category}} ({{this.questLevel}}){{this.char1Status}}{{this.char2Status}}
+
+
+ {{#each data.categories as |quests category|}}

diff --git a/static/css/character-quests.css b/static/css/character-quests.css index 688f311..e54cc68 100644 --- a/static/css/character-quests.css +++ b/static/css/character-quests.css @@ -148,4 +148,13 @@ tr.quest-missing-2 td:nth-child(4) { color: #ffdd57; margin-left: 10px; font-weight: normal; +} + +.quest-status.In.Progress { + color: #4CAF50; + font-weight: bold; +} + +.quest-category { + font-style: italic; } \ No newline at end of file