add active quests section
This commit is contained in:
parent
0731ec2663
commit
40c7755ae7
4 changed files with 84 additions and 6 deletions
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
|
|
|||
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,6 +63,39 @@
|
|||
</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">
|
||||
|
|
|
|||
|
|
@ -149,3 +149,12 @@ tr.quest-missing-2 td:nth-child(4) {
|
|||
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