Add standalone Pokémon Legends: Arceus POC tracker (Hisui 242 Pokédex, Research Tasks & RL10 mode, Satchel MP & Save Mythicals toggles, Noble/story battles, saves/movesets), bundle local sprite packs across all three trackers into Git/Docker/Nginx with attribution credits, and update Hub landing page & unified server/tests.
79 lines
2.8 KiB
JavaScript
79 lines
2.8 KiB
JavaScript
function readSaveSummary(storage, prefix, defaultGameId, gameLabels) {
|
|
try {
|
|
if (!storage) return null;
|
|
const rawMeta = storage.getItem(`${prefix}app-meta`);
|
|
const meta = rawMeta ? JSON.parse(rawMeta) : null;
|
|
const gameId = meta?.activeGameId || defaultGameId;
|
|
const gameMeta = meta?.gameProfiles?.[gameId] || meta?.profilesByGame?.[gameId];
|
|
const profileId = gameMeta?.activeProfileId || 'default';
|
|
const profileName =
|
|
gameMeta?.profiles?.find((p) => p.id === profileId)?.name || 'Default';
|
|
const profileCount = gameMeta?.profiles?.length || 1;
|
|
const saveKey = profileId === 'default' ? `${prefix}${gameId}` : `${prefix}${gameId}:${profileId}`;
|
|
const rawSave = storage.getItem(saveKey);
|
|
if (!rawSave) return null;
|
|
const parsed = JSON.parse(rawSave);
|
|
const caughtCount = Array.isArray(parsed?.caught) ? parsed.caught.length : 0;
|
|
const rl10Count = Array.isArray(parsed?.rl10) ? parsed.rl10.length : null;
|
|
const progressMode = parsed?.progressMode || 'caught';
|
|
const gameLabel = gameLabels[gameId] || gameId;
|
|
return {
|
|
gameLabel,
|
|
profileName,
|
|
profileCount,
|
|
caughtCount,
|
|
rl10Count,
|
|
progressMode,
|
|
};
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
export function renderSavePills(doc = globalThis.document, storage = globalThis.localStorage) {
|
|
const orasEl = doc?.getElementById('oras-save-badge');
|
|
if (orasEl) {
|
|
const info = readSaveSummary(storage, 'poc-tracker:v1:', 'alpha-sapphire', {
|
|
'alpha-sapphire': 'Alpha Sapphire',
|
|
'omega-ruby': 'Omega Ruby',
|
|
});
|
|
if (info) {
|
|
orasEl.textContent = `Saved (${info.gameLabel} · ${info.profileName}): ${info.caughtCount} caught`;
|
|
orasEl.classList.add('has-save');
|
|
} else {
|
|
orasEl.textContent = 'Ready for a new run';
|
|
}
|
|
}
|
|
|
|
const lumiEl = doc?.getElementById('lumi-save-badge');
|
|
if (lumiEl) {
|
|
const info = readSaveSummary(storage, 'lumi-poc-tracker:v1:', 'luminescent-platinum', {
|
|
'luminescent-platinum': 'Luminescent Platinum',
|
|
});
|
|
if (info) {
|
|
lumiEl.textContent = `Saved (${info.profileName}): ${info.caughtCount} caught`;
|
|
lumiEl.classList.add('has-save');
|
|
} else {
|
|
lumiEl.textContent = 'Ready for a new run';
|
|
}
|
|
}
|
|
|
|
const plaEl = doc?.getElementById('pla-save-badge');
|
|
if (plaEl) {
|
|
const info = readSaveSummary(storage, 'pla-poc-tracker:v1:', 'legends-arceus', {
|
|
'legends-arceus': 'Legends: Arceus',
|
|
});
|
|
if (info) {
|
|
const rl10Text = Number.isInteger(info.rl10Count) ? ` · ${info.rl10Count} RL10` : '';
|
|
plaEl.textContent = `Saved (${info.profileName}): ${info.caughtCount} caught${rl10Text}`;
|
|
plaEl.classList.add('has-save');
|
|
} else {
|
|
plaEl.textContent = 'Ready for a new run';
|
|
}
|
|
}
|
|
}
|
|
|
|
if (typeof globalThis.document !== 'undefined') {
|
|
renderSavePills();
|
|
}
|