structure optimisation
All checks were successful
Deploy Sokko G / deploy (push) Successful in 6s

This commit is contained in:
Shinuwa 2026-07-22 22:49:36 +02:00
parent 34523e78b1
commit 5c86fd2ceb
19 changed files with 724 additions and 519 deletions

View file

@ -0,0 +1,76 @@
export const INITIAL_MHWILDS_STATE = {
loaded: false,
loading: false,
error: "",
translations: {},
monsters: [],
endemic: [],
filterOptions: { monsters: [], endemic: [] },
filterOptionKeys: { monsters: "", endemic: "" }
};
export const INITIAL_DIABLO4_STATE = {
loaded: false,
loading: false,
error: "",
affixes: [],
filterOptions: { affixes: [] },
categoryMap: {},
filterOptionKeys: { affixes: "" }
};
export async function loadMhwildsData() {
const [monstersResponse, endemicResponse, translationsResponse] = await Promise.all([
fetch("/data/mhwilds/monsters.json"),
fetch("/data/mhwilds/endemic_life.json"),
fetch("/data/mhwilds/i18n/fr.json")
]);
if (!monstersResponse.ok || !endemicResponse.ok || !translationsResponse.ok) {
throw new Error("Impossible de charger les données Monster Hunter Wilds.");
}
const [monstersJson, endemicJson, translations] = await Promise.all([
monstersResponse.json(),
endemicResponse.json(),
translationsResponse.json()
]);
const monsterFilterKey = Object.keys(monstersJson).find((key) => key !== "monsters") || "";
const endemicFilterKey = Object.keys(endemicJson).find((key) => key !== "endemicLife" && key !== "aquaticLife") || "";
return {
loaded: true,
loading: false,
error: "",
translations,
monsters: monstersJson.monsters || [],
endemic: [...(endemicJson.endemicLife || []), ...(endemicJson.aquaticLife || [])],
filterOptions: {
monsters: monstersJson[monsterFilterKey] || [],
endemic: endemicJson[endemicFilterKey] || []
},
filterOptionKeys: {
monsters: monsterFilterKey,
endemic: endemicFilterKey
}
};
}
export async function loadDiablo4Data() {
const response = await fetch("/data/diablo4/affixes_types.json");
if (!response.ok) throw new Error("Impossible de charger les données Diablo IV.");
const payload = await response.json();
const filterKey = Object.keys(payload).find((key) => key !== "affixes") || "";
const categories = payload[filterKey] || [];
return {
loaded: true,
loading: false,
error: "",
affixes: payload.affixes || [],
filterOptions: { affixes: categories },
categoryMap: Object.fromEntries(categories.map((category) => [category.id, category])),
filterOptionKeys: { affixes: filterKey }
};
}