Merge pull request #16 from smthbh/Update-QuestCompare
Update quest compare
This commit is contained in:
commit
869f74d4f9
5 changed files with 104 additions and 6 deletions
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
|
|
|||
17
src/armory/types/QuestTypes.ts
Normal file
17
src/armory/types/QuestTypes.ts
Normal file
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -63,10 +63,48 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{{! Add this section before the categories loop }}
|
||||
<div class="quests-table" style="margin-bottom: 20px;">
|
||||
<h2 class="is-size-4 category-header collapsible expanded">
|
||||
Active Quests
|
||||
<span class="collapse-icon">▼</span>
|
||||
</h2>
|
||||
|
||||
<div class="category-content expanded">
|
||||
<table class="table is-striped is-hoverable is-fullwidth">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Quest</th>
|
||||
<th>Area (Level)</th>
|
||||
<th>{{data.char1.name}}</th>
|
||||
<th>{{data.char2.name}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each (getActiveQuests data.categories)}}
|
||||
<tr class="{{getDiffClass this}}">
|
||||
<td class="quest-name">
|
||||
<a href="{{@root.wowhead}}/quest={{this.id}}">{{this.title}}</a>
|
||||
</td>
|
||||
<td class="quest-level">{{this.category}} ({{this.questLevel}})</td>
|
||||
<td class="quest-status {{this.char1Status}}">{{this.char1Status}}</td>
|
||||
<td class="quest-status {{this.char2Status}}">{{this.char2Status}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{#each data.categories as |quests category|}}
|
||||
<div class="quests-table" style="margin-bottom: 20px;">
|
||||
<h2 class="is-size-4 category-header collapsible">
|
||||
{{@key}}
|
||||
{{#with (getDiffCount this)}}
|
||||
{{#if this}}
|
||||
<span class="diff-count">({{this}} different)</span>
|
||||
{{/if}}
|
||||
{{/with}}
|
||||
<span class="collapse-icon">▼</span>
|
||||
</h2>
|
||||
|
||||
|
|
|
|||
|
|
@ -142,3 +142,19 @@ tr.quest-missing-2 td:nth-child(4) {
|
|||
.quest-compare-section .select select {
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
.diff-count {
|
||||
font-size: 0.8em;
|
||||
color: #ffdd57;
|
||||
margin-left: 10px;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.quest-status.In.Progress {
|
||||
color: #4CAF50;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.quest-category {
|
||||
font-style: italic;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue