Skip to content

Commit

Permalink
Merge pull request #1438 from ThingEngineering/main
Browse files Browse the repository at this point in the history
Deploy
  • Loading branch information
madcowfred authored Feb 18, 2025
2 parents 02f74a8 + 7e8a732 commit ddb1b7b
Show file tree
Hide file tree
Showing 21 changed files with 70 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import type { StaticDataProfession } from '@/shared/stores/static/types'
import Collectibles from './CharacterProfessionsCollectibles.svelte'
import Equipment from '@/components/professions/ProfessionsEquipment.svelte'
import Equipment from '@/components/professions/Equipment.svelte'
import Profession from './CharacterProfessionsProfession.svelte'
import Sidebar from './CharacterProfessionsSidebar.svelte'
import Traits from './CharacterProfessionsTraits.svelte'
Expand Down
10 changes: 9 additions & 1 deletion apps/frontend/components/journal/JournalOptions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
state.showMounts ? 'M' : '-',
state.showPets ? 'P' : '-',
state.showRecipes ? 'R' : '-',
state.showTokens ? 'O' : '-',
state.showTrash ? 'T' : '-',
]
if (!byMisc.some((c) => c === '-')) {
Expand Down Expand Up @@ -193,8 +194,15 @@
bind:value={$journalState.showRecipes}
>Recipes</CheckboxInput>
</button>

<button>
<CheckboxInput
name="show_tokens"
bind:value={$journalState.showTokens}
>Tokens</CheckboxInput>
</button>

<button class="margin-left">
<CheckboxInput
name="show_trash"
bind:value={$journalState.showTrash}
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/components/professions/Professions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import getSavedRoute from '@/utils/get-saved-route'
import type { MultiSlugParams } from '@/types'
import Subnav from './ProfessionsSubnav.svelte'
import View from './ProfessionsView.svelte'
import Subnav from './Subnav.svelte'
import View from './View.svelte'
export let params: MultiSlugParams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import Equipment from './equipment/Equipment.svelte'
import DragonflightKnowledge from './knowledge/DragonflightKnowledge.svelte'
import KnowledgeV2 from './knowledge/KnowledgeV2.svelte';
import Overview from './overview/ProfessionsOverview.svelte'
import Overview from './overview/Overview.svelte'
import PatronOrders from './patron-orders/PatronOrders.svelte';
import Recipes from './recipes/ProfessionsRecipes.svelte'
import Recipes from './recipes/Recipes.svelte'
export let params: MultiSlugParams
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import { staticStore } from '@/shared/stores/static'
import getSavedRoute from '@/utils/get-saved-route'
import Sidebar from './ProfessionsOverviewSidebar.svelte'
import Table from './ProfessionsOverviewTable.svelte'
import Sidebar from './Sidebar.svelte'
import Table from './Table.svelte'
export let slug: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import CharacterTable from '@/components/character-table/CharacterTable.svelte'
import CharacterTableHead from '@/components/character-table/CharacterTableHead.svelte'
import Profession from './ProfessionsOverviewTableProfession.svelte'
import Profession from './TableProfession.svelte'
import WowthingImage from '@/shared/components/images/sources/WowthingImage.svelte'
export let profession: StaticDataProfession
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import { staticStore } from '@/shared/stores/static'
import getSavedRoute from '@/utils/get-saved-route'
import Sidebar from './ProfessionsRecipesSidebar.svelte'
import View from './ProfessionsRecipesView.svelte'
import Sidebar from './Sidebar.svelte'
import View from './View.svelte'
export let slug1: string
export let slug2: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import type { StaticDataProfession} from '@/shared/stores/static/types'
import type { Character } from '@/types'
import Equipment from '@/components/professions/ProfessionsEquipment.svelte'
import Equipment from '@/components/professions/Equipment.svelte'
import WowthingImage from '@/shared/components/images/sources/WowthingImage.svelte'
export let character: Character
Expand Down
4 changes: 4 additions & 0 deletions apps/frontend/data/difficulty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,7 @@ export const lockoutDifficultyOrder: number[] = [

0, // World Boss
]

export const lockoutDifficultyOrderMap: Record<number, number> = Object.fromEntries(
lockoutDifficultyOrder.map((value, index) => [value, index])
)
12 changes: 11 additions & 1 deletion apps/frontend/stores/journal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ export class JournalDataStore extends WritableFancyStore<JournalData> {
console.time('JournalDataStore.initialize');

data.expandedItem = {};
data.instanceById = {};

for (const [tokenId, itemIds] of getNumberKeyedEntries(data.itemExpansion)) {
for (const itemId of itemIds) {
(data.expandedItem[itemId] ||= []).push(tokenId);
}
}

for (let tierIndex = 0; tierIndex < data.tiers.length; tierIndex++) {
const tier = data.tiers[tierIndex];
if (!tier) { continue; }

for (const tier of data.tiers.filter((tier) => tier !== null)) {
for (const extraTier of extraTiers) {
if (extraTier.id !== 1000099) {
extraTier.subTiers.push({
Expand All @@ -36,8 +41,13 @@ export class JournalDataStore extends WritableFancyStore<JournalData> {
}
}

let order = (tierIndex + 1) * 100;
for (const instance of tier.instances.filter((instance) => instance !== null)) {
if (instance.encountersRaw !== null) {
data.instanceById[instance.id] = instance;

instance.order = order--;

instance.encounters = instance.encountersRaw.map(
(encounterArray) => new JournalDataEncounter(...encounterArray),
);
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/stores/lazy/journal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export function doJournal(stores: LazyStores): LazyJournal {
const groupSeen = new Set<string>();

let filteredItems = getFilteredItems(
stores.journalData,
stores.journalState,
group,
classMask,
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/stores/local-storage/journal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class JournalState {
public showMounts = true;
public showPets = true;
public showRecipes = true;
public showTokens = true;
public showTrash = true;

public showDungeonNormal = true;
Expand Down
33 changes: 25 additions & 8 deletions apps/frontend/stores/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import uniq from 'lodash/uniq';
import type { DateTime } from 'luxon';
import { get } from 'svelte/store';

import { difficultyMap, lockoutDifficultyOrder } from '@/data/difficulty';
import { difficultyMap, lockoutDifficultyOrder, lockoutDifficultyOrderMap } from '@/data/difficulty';
import { seasonMap } from '@/data/dungeon';
import { slotOrder } from '@/data/inventory-slot';
import { singleLockoutRaids } from '@/data/raid';
Expand Down Expand Up @@ -43,6 +43,7 @@ import type { ItemData, ItemDataItem } from '@/types/data/item';
import type { ContainsItems, HasNameAndRealm, UserItem } from '@/types/shared';
import type { ManualData } from '@/types/data/manual';

import { journalStore } from './journal';
import { manualStore } from './manual';
import { userModifiedStore } from './user-modified';

Expand Down Expand Up @@ -171,6 +172,7 @@ export class UserDataStore extends WritableFancyStore<UserData> {
console.time('UserDataStore.setup');

const itemData = get(itemStore);
const journalData = get(journalStore);
const manualData = get(manualStore);
const staticData = get(staticStore);

Expand Down Expand Up @@ -242,10 +244,24 @@ export class UserDataStore extends WritableFancyStore<UserData> {
(character.hidden ||
settingsData.characters.ignoredCharacters?.includes(character.id)) === true;

// Addon gets the wrong ID for Uldir for some reason?
if (character.lockouts?.[1028]) {
character.lockouts[1031] = character.lockouts[1028];
character.lockouts[1028] = null;
for (const [key, lockout] of Object.entries(character.lockouts || {})) {
// Addon gets the wrong ID for Uldir for some reason?
if (key.startsWith('1028-')) {
character.lockouts[key.replace('1028', '1031')] = lockout;
}
// Ulduar tree elders show as unkilled, ugh
if (key.startsWith('759-') && lockout.bosses[12].dead) {
lockout.maxBosses = 14;
const newBosses = lockout.bosses.slice(0, 9); // up to Thorim
for (let i = 9; i <= 11; i++) {
if (lockout.bosses[i].dead) {
lockout.maxBosses++;
newBosses.push(lockout.bosses[i]);
}
}
newBosses.push(...lockout.bosses.slice(12)); // Freya onwards
lockout.bosses = newBosses;
}
}

for (const [key, lockout] of Object.entries(character.lockouts || {})) {
Expand Down Expand Up @@ -327,14 +343,15 @@ export class UserDataStore extends WritableFancyStore<UserData> {

userData.allLockouts = sortBy(userData.allLockouts, (diff /*: InstanceDifficulty*/) => {
const instance = staticData.instances[diff.instanceId];
const journalInstance = journalData.instanceById[diff.instanceId];
if (!diff.difficulty || !instance) {
return 'z';
}

const orderIndex = lockoutDifficultyOrder.indexOf(diff.difficulty.id);
const orderIndex = lockoutDifficultyOrderMap[diff.difficulty.id] || 99;
return [
leftPad(100 - instance.expansion, 2, '0'),
leftPad(orderIndex >= 0 ? orderIndex : 99, 2, '0'),
leftPad(journalInstance?.order || 9999, 4, '0'),
leftPad(orderIndex, 2, '0'),
instance.shortName,
diff.difficulty.shortName,
].join('|');
Expand Down
2 changes: 2 additions & 0 deletions apps/frontend/types/data/journal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface JournalData {

// calculated
expandedItem: Record<number, number[]>;
instanceById: Record<number, JournalDataInstance>
}

export interface JournalDataTier {
Expand All @@ -27,6 +28,7 @@ export interface JournalDataInstance {
encounters: JournalDataEncounter[];
encountersRaw: JournalDataEncounterArray[];
isRaid?: boolean;
order?: number;
}

export class JournalDataEncounter {
Expand Down
8 changes: 6 additions & 2 deletions apps/frontend/utils/journal/get-filtered-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Constants } from '@/data/constants'
import type { JournalState } from '@/stores/local-storage'
import {
JournalDataEncounterItemAppearance,
type JournalData,
type JournalDataEncounterItem,
type JournalDataEncounterItemGroup,
} from '@/types/data'
Expand All @@ -28,13 +29,13 @@ const weaponGroups = Object.fromEntries([
].map((name) => [name, true]))

export default function getFilteredItems(
journalData: JournalData,
journalState: JournalState,
group: JournalDataEncounterItemGroup,
classMask: number,
instanceExpansion: number,
): JournalDataEncounterItem[] {
const items: JournalDataEncounterItem[] = []

for (const item of group.items) {
let keep = true

Expand All @@ -44,7 +45,10 @@ export default function getFilteredItems(
}

// Filter types
if (keep && group.name === 'Cloth') {
if (keep && journalData.expandedItem[item.id]) {
keep = journalState.showTokens;
}
else if (keep && group.name === 'Cloth') {
keep = journalState.showCloth
}
else if (keep && group.name === 'Leather') {
Expand Down

0 comments on commit ddb1b7b

Please sign in to comment.