diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e469842..32024ee 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,4 +10,4 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 - run: npm ci - - run: npm run lint -- --max-warnings=4 + - run: npm run lint -- --max-warnings=0 diff --git a/src/armory/Armory.ts b/src/armory/Armory.ts index 5ab9f66..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,18 +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: 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..392f1ef --- /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 5a77e24..b434bff 100644 --- a/static/character-quests-compare.hbs +++ b/static/character-quests-compare.hbs @@ -63,10 +63,48 @@ +{{! Add this section before the categories loop }} +