Add Aniimo elemental matchup calculator
All checks were successful
Validate and deploy Sokko G / validate (push) Successful in 18m14s
Validate and deploy Sokko G / deploy (push) Successful in 10s

This commit is contained in:
Shinuwa 2026-10-31 09:43:04 +01:00
parent 72b3b15c7e
commit 243465720f
15 changed files with 518 additions and 10 deletions

View file

@ -120,3 +120,11 @@
{"id":"int-6226671effacd330ce9b863270839c98","kind":"field_change","created_at":"2026-10-30T12:57:10.175823112Z","actor":"Shinuwa","issue_id":"sokko-g-2gj","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Le test attend le chargement lazy stable et déclenche le geste aux coordonnées réelles ; 20 répétitions ciblées et check:full réussis."}}
{"id":"int-5f04344a759a5f822ac1c55320dabfcf","kind":"field_change","created_at":"2026-10-30T13:00:48.471198857Z","actor":"Shinuwa","issue_id":"sokko-g-2gj","extra":{"field":"status","new_value":"open","old_value":"closed"}}
{"id":"int-738633fa3740487a9b8bb0ff05de3b5a","kind":"field_change","created_at":"2026-10-30T13:10:47.886359117Z","actor":"Shinuwa","issue_id":"sokko-g-2gj","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Shared pointer helper adopted by all existing left-button drag scenarios; repeated and full validation pass."}}
{"id":"int-81fc2cfcd96ac7efd52ae604c9d2b8ab","kind":"field_change","created_at":"2026-10-30T22:49:35.915886992Z","actor":"Shinuwa","issue_id":"sokko-g-33g","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Implemented Aniimo element guide and sourced matchup matrix. Verified single/dual calculations, keyboard selection, 768/1440 layouts, retry handling and screenshots. npm run check:full passed: 182 Node tests, 205 development E2E tests, 2 production E2E tests."}}
{"id":"int-92715c2b8c2e5abe38b5637bff3cb11c","kind":"field_change","created_at":"2026-10-31T07:44:11.871203537Z","actor":"Shinuwa","issue_id":"sokko-g-mz5","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Enlarged element icons and replaced matchup rows with grouped cards carrying explicit offensive and defensive labels. Verified content grouping, keyboard selection, no overflow at 768/1440, retry behavior, Node contracts, development E2E and production E2E. npm run check:full passed."}}
{"id":"int-dc4119a02712be0d1c69a6de51f076b4","kind":"field_change","created_at":"2026-10-31T08:14:38.748010301Z","actor":"Shinuwa","issue_id":"sokko-g-zgg","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Replaced the calculator glyph with a Fire/Water/Grass triangle, spaced and normalized the element picker buttons, restored desktop attack/defense columns, and compacted result cards with 28px icons. Targeted Aniimo E2E: 21 passed. npm run check passed."}}
{"id":"int-1e6508098acb8047dbc81983a664994f","kind":"field_change","created_at":"2026-10-31T08:21:52.407175223Z","actor":"Shinuwa","issue_id":"sokko-g-681","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Wrapped attack and defense in separate NDS panels, fixed attack groups to three columns and defense groups to two, and equalized card heights. Verified at 768/1440 with exact grid and height assertions. npm run check passed."}}
{"id":"int-f53490f43d66a6709d15eb386867043d","kind":"field_change","created_at":"2026-10-31T08:29:22.208115583Z","actor":"Shinuwa","issue_id":"sokko-g-3g2","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Defense now uses three equal columns per row like attack. Card height and internal spacing were tuned to preserve labels and avoid overflow at 768/1440. Targeted E2E and npm run check passed."}}
{"id":"int-5c8e3e28b73065d97bd2d9bd58948c33","kind":"field_change","created_at":"2026-10-31T08:31:28.547956378Z","actor":"Shinuwa","issue_id":"sokko-g-tl2","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Added a dedicated elemental skill section heading with an editorial label and gold NDS badge for the active element. Verified accessible names and rendering at 768/1440. npm run check passed."}}
{"id":"int-45ab8c8a76f0eb3cb5b35a7df31198a7","kind":"field_change","created_at":"2026-10-31T08:35:22.634614095Z","actor":"Shinuwa","issue_id":"sokko-g-px7","extra":{"field":"status","new_value":"in_progress","old_value":"open"}}
{"id":"int-60f33ea25bfb213bc547cd9bf1d052dc","kind":"field_change","created_at":"2026-10-31T08:40:39.905104579Z","actor":"Shinuwa","issue_id":"sokko-g-px7","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Refined skill heading alignment, content-driven card heights, four-column element grids, and removed the calculator footnote."}}

View file

@ -906,6 +906,29 @@ Date picker et menus compacts :
- recherche, Prismana, régions, rôles, éléments et niveaux actifs sont rappelés sous la barre par des badges supprimables individuellement ;
- les menus restent ouverts pendant une sélection multiple et se ferment au clic extérieur, à `Escape` ou quand le focus quitte le menu.
### Calculateur des affinités Aniimo
La page `/games/aniimo/elements` est accessible depuis l'accueil du jeu. Le sélecteur
affiche les neuf éléments avec icône et nom dans des boutons NDS à état
`aria-pressed`. Deux éléments peuvent être actifs ; les autres sont alors
désactivés jusqu'au retrait d'un élément ou à l'effacement de la sélection.
La carte d'accueil du guide remplace l'icône de calculatrice par trois icônes
d'éléments en triangle. La sélection utilise des icônes de 48 px au-dessus des noms,
dans des boutons espacés de 12 px. Les résultats affichent des icônes compactes de
24 px avec leur nom, regroupées par quatre dans des boxes NDS par multiplicateur. Les sections
Attaque et Défense utilisent chacune un panneau NDS et forment deux colonnes à partir
de 1100 px, puis s'empilent en dessous. Dans chaque compétence, les trois groupes
offensifs et défensifs utilisent trois colonnes régulières. Les boxes utilisent
une hauteur pilotée par leur contenu, égale au sein de chaque rangée, et repassent
sur une colonne quand leur panneau mesure moins de 460 px. Chaque compétence
sélectionnée est introduite par une barre `nds-section-heading` : le libellé
« Compétence » et le badge doré contenant l'icône et le nom de l'élément sont
regroupés à gauche. Elle conserve ses propres groupes offensifs (« Peu efficace », « Efficacité normale »,
« Efficace »). Les groupes défensifs vont de « Très résistant » à « Très vulnérable »
et affichent le produit des affinités sélectionnées. Les groupes vides sont omis.
Chaque box associe un libellé explicite, le multiplicateur numérique et la liste
des éléments ; le vert signale un avantage et le rouge un désavantage.
### Liaison des guides aux checklists
Dans la toolbox latérale, chaque checklist compatible avec le guide ouvert expose

View file

@ -0,0 +1,95 @@
// Rôle : vérifie les groupes d'affinités Aniimo, leurs libellés et la sélection au clavier aux largeurs bureau.
import { test, expect } from "@playwright/test";
for (const width of [768, 1440]) {
test(`element guide supports single and dual types at ${width}px`, async ({ page }) => {
// Le premier parcours comprend la compilation à froid des pages de jeu par Vite.
test.setTimeout(60000);
await page.setViewportSize({ width, height: 1000 });
await page.goto("/#/games/aniimo");
const homeIcon = page.locator('a[href="#/games/aniimo/elements"] .aniimo-elements-home-icon');
await expect(homeIcon.locator("img")).toHaveCount(3);
const homeIconPositions = await homeIcon.locator("img").evaluateAll((images) => images.map((image) => ({ x: image.offsetLeft, y: image.offsetTop })));
expect(homeIconPositions).toEqual([{ x: 34, y: 0 }, { x: 68, y: 42 }, { x: 0, y: 42 }]);
await page.getByRole("link", { name: /Faiblesses et résistances/ }).click();
const picker = page.getByRole("group", { name: "Éléments de l’Aniimo" });
await expect(picker.getByRole("button")).toHaveCount(9);
await expect(picker).toHaveCSS("column-gap", "12px");
await expect(page.getByText("Sélectionnez un élément pour afficher ses affinités.")).toBeVisible();
const water = picker.getByRole("button", { name: "Eau", exact: true });
await water.focus();
await page.keyboard.press("Enter");
await expect(water).toHaveAttribute("aria-pressed", "true");
const attack = page.getByRole("region", { name: "En attaque" });
const defense = page.getByRole("region", { name: "En défense" });
await expect(attack).toHaveClass(/nds-panel/);
await expect(defense).toHaveClass(/nds-panel/);
const group = (panel, name) => panel.getByRole("region", { name, exact: true });
const waterAttack = attack.getByRole("region", { name: /Compétence.*Eau/ });
const skillHeading = waterAttack.getByRole("heading", { level: 3, name: /Compétence.*Eau/ });
await expect(skillHeading).toHaveClass(/nds-section-heading/);
await expect(skillHeading).toHaveCSS("justify-content", "flex-start");
await expect(skillHeading).toHaveCSS("column-gap", "12px");
await expect(skillHeading.locator(".aniimo-skill-element")).toContainText("Eau");
await expect(group(waterAttack, "Efficace")).toContainText("×1,6");
await expect(group(waterAttack, "Efficace").getByRole("listitem")).toHaveText(["Feu", "Roche"]);
await expect(group(defense, "Résistant")).toContainText("×0,625");
await expect(group(defense, "Résistant").getByRole("listitem")).toContainText(["Feu", "Eau", "Roche", "Ténèbres"]);
await expect(water.locator("img")).toHaveCSS("width", "48px");
await expect(waterAttack.locator("li img").first()).toHaveCSS("width", "24px");
const ice = picker.getByRole("button", { name: "Glace", exact: true });
await ice.focus();
await page.keyboard.press("Space");
await expect(ice).toHaveAttribute("aria-pressed", "true");
await expect(picker.getByRole("button", { name: "Feu", exact: true })).toBeDisabled();
const iceAttack = attack.getByRole("region", { name: /Compétence.*Glace/ });
await expect(group(waterAttack, "Efficace").getByRole("listitem")).toHaveText(["Feu", "Roche"]);
await expect(group(iceAttack, "Peu efficace")).toContainText("×0,625");
await expect(group(iceAttack, "Peu efficace").getByRole("listitem")).toHaveText(["Feu", "Roche", "Glace"]);
await expect(group(defense, "Dégâts normaux")).toContainText("×1");
await expect(group(defense, "Dégâts normaux").getByRole("listitem")).toHaveText(["Feu", "Électrique", "Roche", "Vent", "Glace", "Sacré"]);
expect(await group(defense, "Dégâts normaux").locator(".aniimo-matchup-members").evaluate((element) => globalThis.getComputedStyle(element).gridTemplateColumns.split(" ").length)).toBe(4);
await expect(group(defense, "Très résistant")).toContainText("×0,390625");
await expect(group(defense, "Très résistant").getByRole("listitem")).toHaveText(["Eau"]);
await expect(waterAttack.getByRole("listitem")).toHaveCount(9);
await expect(iceAttack.getByRole("listitem")).toHaveCount(9);
await expect(defense.getByRole("listitem")).toHaveCount(9);
expect(await page.evaluate(() => globalThis.document.documentElement.scrollWidth <= globalThis.innerWidth)).toBe(true);
for (const panel of [attack, defense]) {
expect(await panel.evaluate((element) => element.scrollWidth <= element.clientWidth)).toBe(true);
}
const resultColumns = await page.locator(".aniimo-matchup-panels").evaluate((element) => globalThis.getComputedStyle(element).gridTemplateColumns.split(" ").length);
expect(resultColumns).toBe(width === 1440 ? 2 : 1);
const groupColumns = await page.locator(".aniimo-matchup-groups").evaluateAll((groups) => groups.map((group) => ({
mode: group.dataset.mode,
columns: globalThis.getComputedStyle(group).gridTemplateColumns.split(" ").length,
heights: [...group.children].map((card) => Math.round(card.getBoundingClientRect().height)),
fits: [...group.children].every((card) => card.scrollHeight <= card.clientHeight)
})));
for (const groupLayout of groupColumns) {
expect(groupLayout.columns).toBe(3);
expect(Math.max(...groupLayout.heights)).toBeLessThan(244);
expect(groupLayout.fits).toBe(true);
}
await page.screenshot({ path: test.info().outputPath(`aniimo-elements-${width}.png`), fullPage: true });
await ice.click();
await expect(picker.getByRole("button", { name: "Feu", exact: true })).toBeEnabled();
await page.getByRole("button", { name: "Effacer la sélection" }).click();
await expect(attack).toHaveCount(0);
await expect(picker.getByRole("button", { pressed: true })).toHaveCount(0);
await picker.getByRole("button", { name: "Ténèbres", exact: true }).click();
await picker.getByRole("button", { name: "Herbe", exact: true }).click();
await expect(group(defense, "Très vulnérable")).toContainText("×2,56");
await expect(group(defense, "Très vulnérable").getByRole("listitem")).toHaveText(["Vent"]);
});
}
test("element chart loading failure can be retried on the direct guide route", async ({ page }) => {
let fail = true;
await page.route("**/data/aniimo/elements.json", (route) => fail ? route.fulfill({ status: 503, body: "unavailable" }) : route.continue());
await page.goto("/#/games/aniimo/elements");
await expect(page.getByRole("alert")).toContainText("Impossible de charger Aniimo");
fail = false;
await page.getByRole("button", { name: "Réessayer" }).click();
await expect(page.getByRole("group", { name: "Éléments de l’Aniimo" })).toBeVisible();
});

View file

@ -139,7 +139,7 @@ test("catalogue, overview and deferred Aniimo loading preserve filters across na
await page.locator('a[href="#/games/aniimo/aniimos"]').click();
await expect(cards(page)).toHaveCount(3);
await expect(page.getByRole("searchbox")).toHaveValue("EMBERPUP");
expect(requests).toHaveLength(5);
expect(requests).toHaveLength(6);
});
test("Aniimo exposes its regions list", async ({ page }) => {

View file

@ -11,7 +11,8 @@ export default [
"website/dist/**",
"playwright-report/**",
"test-results/**",
".codex-home/**"
".codex-home/**",
".aws/**"
]
},
js.configs.recommended,

View file

@ -0,0 +1,59 @@
// Rôle : valide la table des éléments Aniimo et les calculs directionnels simples et doubles.
import { readFile, access } from "node:fs/promises";
import { test } from "node:test";
import assert from "node:assert/strict";
import { calculateElementMatchups } from "../website/src/features/games/aniimo/elementMatchups.js";
const readJson = async (file) => JSON.parse(await readFile(`website/public/data/aniimo/${file}`, "utf8"));
const chart = await readJson("elements.json");
test("element chart covers every catalogue element, translation and icon without implicit neutral cells", async () => {
const catalogue = await readJson("aniimos.json");
const elements = [...new Set(catalogue.flatMap((aniimo) => aniimo.variations.flatMap((variant) => variant.elements)))].sort();
assert.deepEqual([...chart.elements].sort(), elements);
assert.equal(chart.elements.length, 9);
assert.deepEqual(Object.keys(chart.matchups).sort(), elements);
assert.equal(chart.dualDefenseRule, "multiply");
assert.equal(new URL(chart.source.url).protocol, "https:");
assert.match(chart.source.checkedOn, /^\d{4}-\d{2}-\d{2}$/);
for (const language of ["fr", "en"]) {
const dictionary = await readJson(`i18n/${language}.json`);
for (const element of elements) assert.ok(dictionary[element]?.trim());
}
for (const element of elements) {
await access(`website/public/static/img/aniimo/${element}.webp`);
assert.deepEqual(Object.keys(chart.matchups[element]).sort(), elements);
assert.ok(Object.values(chart.matchups[element]).every((value) => [0.625, 1, 1.6].includes(value)));
}
});
const row = (selected, element) => calculateElementMatchups(chart, selected).find((result) => result.element === element);
test("single elements preserve directional matchups and Dark's neutral mirror", () => {
assert.equal(row(["electric"], "water").attack[0].multiplier, 1.6);
assert.equal(row(["electric"], "water").defense, 1);
assert.equal(row(["dark"], "dark").defense, 1);
assert.equal(row(["fire"], "fire").defense, 0.625);
});
test("dual defense combines weaknesses, resistances and cancellation without floating point noise", () => {
assert.equal(row(["dark", "grass"], "wind").defense, 2.56);
assert.equal(row(["fire", "rock"], "ice").defense, 0.390625);
assert.equal(row(["water", "ice"], "fire").defense, 1);
assert.equal(row(["water", "ice"], "grass").defense, 1.6);
assert.equal(row(["water", "ice"], "dark").defense, 0.625);
assert.deepEqual(row(["ice", "water"], "fire").defense, row(["water", "ice"], "fire").defense);
});
test("dual offense keeps each skill's element separate instead of multiplying them", () => {
assert.deepEqual(row(["water", "ice"], "fire").attack, [
{ element: "water", multiplier: 1.6 }, { element: "ice", multiplier: 0.625 }
]);
});
test("empty and invalid selections cannot produce misleading multipliers", () => {
assert.equal(calculateElementMatchups(chart, []), null);
assert.deepEqual(calculateElementMatchups(chart, ["fire", "fire"]), calculateElementMatchups(chart, ["fire"]));
assert.throws(() => calculateElementMatchups(chart, ["unknown"]), RangeError);
assert.throws(() => calculateElementMatchups(chart, ["fire", "water", "ice"]), RangeError);
});

View file

@ -172,7 +172,8 @@ test("loader passes cancellation to all requests and reports failed responses",
const controller = new AbortController();
const listIndex = await readJson("aniimo/lists/index.json");
const regions = await readJson("aniimo/lists/regions.json");
const bodies = [aniimos, fr, en, listIndex, regions];
const elementChart = await readJson("aniimo/elements.json");
const bodies = [aniimos, fr, en, listIndex, elementChart, regions];
context.mock.method(globalThis, "fetch", async (url, options) => {
calls.push({ url, options });
const body = bodies[calls.length - 1];
@ -183,7 +184,8 @@ test("loader passes cancellation to all requests and reports failed responses",
assert.equal(result.lists.length, 1);
assert.equal(result.lists[0].id, "regions");
assert.equal(result.lists[0].itemCount, 14);
assert.equal(calls.length, 5);
assert.deepEqual(result.elementChart, elementChart);
assert.equal(calls.length, 6);
assert.ok(calls.every((call) => call.options.signal === controller.signal));
globalThis.fetch.mock.mockImplementation(async () => ({ ok: false }));
await assert.rejects(loadAniimoData(controller.signal), /indisponibles/);

View file

@ -141,6 +141,27 @@ export function validateSiteContent(site) {
"aniimo.stats.m_def",
"aniimo.stats.break",
"aniimo.stats.regen",
"aniimo.elementCalculator.title",
"aniimo.elementCalculator.homeDescription",
"aniimo.elementCalculator.description",
"aniimo.elementCalculator.selection",
"aniimo.elementCalculator.reset",
"aniimo.elementCalculator.hint",
"aniimo.elementCalculator.limit",
"aniimo.elementCalculator.empty",
"aniimo.elementCalculator.attack",
"aniimo.elementCalculator.defense",
"aniimo.elementCalculator.attackHelp",
"aniimo.elementCalculator.defenseHelp",
"aniimo.elementCalculator.skill",
"aniimo.elementCalculator.attackBands.low",
"aniimo.elementCalculator.attackBands.normal",
"aniimo.elementCalculator.attackBands.high",
"aniimo.elementCalculator.defenseBands.veryLow",
"aniimo.elementCalculator.defenseBands.low",
"aniimo.elementCalculator.defenseBands.normal",
"aniimo.elementCalculator.defenseBands.high",
"aniimo.elementCalculator.defenseBands.veryHigh",
"aniimo.title",
"aniimo.description",
"aniimo.homeDescription",

View file

@ -0,0 +1,119 @@
{
"source": {
"url": "https://aniimoguide.com/elements",
"checkedOn": "2026-10-30"
},
"dualDefenseRule": "multiply",
"elements": [
"fire",
"water",
"grass",
"electric",
"rock",
"wind",
"dark",
"ice",
"holy"
],
"matchups": {
"fire": {
"fire": 0.625,
"water": 0.625,
"grass": 1.6,
"electric": 1,
"rock": 0.625,
"wind": 1,
"dark": 1,
"ice": 1.6,
"holy": 0.625
},
"water": {
"fire": 1.6,
"water": 0.625,
"grass": 0.625,
"electric": 1,
"rock": 1.6,
"wind": 1,
"dark": 1,
"ice": 0.625,
"holy": 0.625
},
"grass": {
"fire": 0.625,
"water": 1.6,
"grass": 0.625,
"electric": 1,
"rock": 1.6,
"wind": 1,
"dark": 1,
"ice": 1,
"holy": 0.625
},
"electric": {
"fire": 1,
"water": 1.6,
"grass": 1,
"electric": 0.625,
"rock": 0.625,
"wind": 1.6,
"dark": 1,
"ice": 0.625,
"holy": 1
},
"rock": {
"fire": 1.6,
"water": 0.625,
"grass": 0.625,
"electric": 1,
"rock": 0.625,
"wind": 1,
"dark": 0.625,
"ice": 1.6,
"holy": 1
},
"wind": {
"fire": 1,
"water": 1,
"grass": 1.6,
"electric": 0.625,
"rock": 1,
"wind": 0.625,
"dark": 1.6,
"ice": 1,
"holy": 1
},
"dark": {
"fire": 1,
"water": 0.625,
"grass": 1.6,
"electric": 1.6,
"rock": 1,
"wind": 0.625,
"dark": 1,
"ice": 1,
"holy": 1.6
},
"ice": {
"fire": 0.625,
"water": 1.6,
"grass": 1,
"electric": 1.6,
"rock": 0.625,
"wind": 1,
"dark": 1,
"ice": 0.625,
"holy": 1
},
"holy": {
"fire": 1,
"water": 1,
"grass": 1,
"electric": 0.625,
"rock": 1,
"wind": 1.6,
"dark": 1.6,
"ice": 1,
"holy": 0.625
}
}
}

View file

@ -2943,6 +2943,33 @@
"resultsCreateError": "Impossible de créer la checklist."
},
"aniimo": {
"elementCalculator": {
"title": "Faiblesses et résistances",
"homeDescription": "Comparez les affinités en attaque et en défense, pour un ou deux éléments.",
"description": "Sélectionnez les éléments de votre Aniimo pour comparer les dégâts infligés et reçus.",
"selection": "Éléments de l’Aniimo",
"reset": "Effacer la sélection",
"hint": "Choisissez un ou deux éléments. Cliquez à nouveau sur un élément pour le retirer.",
"limit": "Deux éléments sélectionnés. Retirez-en un pour en choisir un autre.",
"empty": "Sélectionnez un élément pour afficher ses affinités.",
"attack": "En attaque",
"defense": "En défense",
"attackHelp": "Les cibles sont regroupées selon les dégâts infligés par chaque élément de compétence.",
"defenseHelp": "Les attaques reçues sont regroupées selon les dégâts subis par votre Aniimo.",
"skill": "Compétence",
"attackBands": {
"low": "Peu efficace",
"normal": "Efficacité normale",
"high": "Efficace"
},
"defenseBands": {
"veryLow": "Très résistant",
"low": "Résistant",
"normal": "Dégâts normaux",
"high": "Vulnérable",
"veryHigh": "Très vulnérable"
}
},
"title": "Aniimos",
"description": "Filtrez les variantes par nom, région, éléments, rôle et compétences de logis, puis retournez les cartes pour consulter leurs capacités.",
"homeDescription": "Recherche par nom, région, rôle, éléments et compétences de logis.",

View file

@ -0,0 +1,73 @@
// Rôle : regroupe les affinités Aniimo par multiplicateur après sélection d'un ou deux éléments.
import { useState } from "react";
import { GameBreadcrumb } from "../GameBreadcrumb.jsx";
import { aniimoAsset, aniimoLabel } from "./utils.js";
import { calculateElementMatchups } from "./elementMatchups.js";
const formatMultiplier = (value) => `×${value.toLocaleString("fr-FR", { maximumFractionDigits: 6 })}`;
function ElementLabel({ element, t, size = 40, compact = false }) {
const label = t(element);
return <span className="aniimo-matchup-element" title={compact ? label : undefined}>
<img src={aniimoAsset(element)} width={size} height={size} alt="" />
<span>{label}</span>
</span>;
}
function MatchupGroups({ entries, prefix, defense = false, content, t }) {
const groups = new Map();
for (const { element, multiplier } of entries) {
if (!groups.has(multiplier)) groups.set(multiplier, []);
groups.get(multiplier).push(element);
}
const Heading = defense ? "h3" : "h4";
return <div className="aniimo-matchup-groups" data-mode={defense ? "defense" : "attack"}>
{[...groups].sort(([left], [right]) => right - left).map(([value, elements]) => {
const favorable = defense ? value < 1 : value > 1;
const band = value > 1.6 ? "veryHigh" : value > 1 ? "high" : value === 1 ? "normal" : value < 0.625 ? "veryLow" : "low";
const label = (defense ? content.defenseBands : content.attackBands)[band];
const titleId = `${prefix}-${value}`;
return <section key={value} className="nds-card aniimo-matchup-box" aria-labelledby={titleId}>
<div className="aniimo-matchup-box-heading">
<Heading id={titleId}>{label}</Heading>
<span className="nds-badge aniimo-multiplier" data-variant={value === 1 ? "neutral" : favorable ? "success" : "danger"}>{formatMultiplier(value)}</span>
</div>
<ul className="aniimo-matchup-members">{elements.map((element) => <li key={element}><ElementLabel element={element} t={t} size={24} compact /></li>)}</ul>
</section>;
})}
</div>;
}
export function AniimoElements({ game, aniimo, content }) {
const [selected, setSelected] = useState([]);
const chart = aniimo.elementChart;
const t = (key) => aniimoLabel(aniimo.translations, key);
const results = calculateElementMatchups(chart, selected);
const toggle = (element) => setSelected((current) => current.includes(element) ? current.filter((value) => value !== element) : current.length < 2 ? [...current, element] : current);
return <>
<section className="page-heading game-heading"><div><GameBreadcrumb game={game} /><h1>{content.title}</h1><p>{content.description}</p></div></section>
<section className="aniimo-elements-guide">
<section className="nds-panel aniimo-element-picker" aria-labelledby="aniimo-element-selection">
<div className="aniimo-element-picker-heading"><h2 id="aniimo-element-selection">{content.selection}</h2><button className="nds-button" data-variant="ghost" data-size="sm" type="button" disabled={!selected.length} onClick={() => setSelected([])}>{content.reset}</button></div>
<div className="aniimo-element-options" role="group" aria-labelledby="aniimo-element-selection" aria-describedby="aniimo-element-help">
{chart.elements.map((element) => <button key={element} className="nds-button" data-variant="secondary" type="button" aria-pressed={selected.includes(element)} disabled={selected.length === 2 && !selected.includes(element)} onClick={() => toggle(element)}><ElementLabel element={element} t={t} size={48} /></button>)}
</div>
<p id="aniimo-element-help" className="aniimo-matchup-help" role="status">{selected.length === 2 ? content.limit : content.hint}</p>
</section>
{results ? <div className="aniimo-matchup-panels">
<section className="nds-panel aniimo-matchup-panel" aria-labelledby="aniimo-attack-title">
<h2 id="aniimo-attack-title">{content.attack}</h2><p>{content.attackHelp}</p>
{selected.map((element, index) => <section key={element} className="aniimo-attack-element" aria-labelledby={`aniimo-attack-${element}`}>
<h3 id={`aniimo-attack-${element}`} className="nds-section-heading aniimo-skill-heading"><span className="aniimo-skill-label">{content.skill}</span><span className="nds-badge aniimo-skill-element" data-variant="gold"><ElementLabel element={element} t={t} size={28} /></span></h3>
<MatchupGroups entries={results.map((row) => ({ element: row.element, multiplier: row.attack[index].multiplier }))} prefix={`aniimo-attack-${element}-band`} content={content} t={t} />
</section>)}
</section>
<section className="nds-panel aniimo-matchup-panel" aria-labelledby="aniimo-defense-title">
<h2 id="aniimo-defense-title">{content.defense}</h2><p>{content.defenseHelp}</p>
<MatchupGroups entries={results.map((row) => ({ element: row.element, multiplier: row.defense }))} prefix="aniimo-defense-band" defense content={content} t={t} />
</section>
</div> : <p className="nds-empty-state">{content.empty}</p>}
</section>
</>;
}

View file

@ -1,4 +1,4 @@
// Rôle : assemble l'accueil Aniimo et la grille filtrable de ses variantes.
// Rôle : assemble l'accueil Aniimo, ses guides et la grille filtrable de ses variantes.
import { useMemo } from "react";
import { CopyChecklistItemsButton } from "../CopyChecklistItemsButton.jsx";
import { GuideChecklistPageControls } from "../GuideChecklistControls.jsx";
@ -8,6 +8,7 @@ import { GameBreadcrumb } from "../GameBreadcrumb.jsx";
import { AniimoCard } from "./AniimoCard.jsx";
import { AniimoFilters } from "./AniimoFilters.jsx";
import { AniimoLists } from "./AniimoLists.jsx";
import { AniimoElements } from "./AniimoElements.jsx";
import { getAniimoStatsMax, aniimoLabel, filterAniimoVariants, groupAniimoVariants } from "./utils.js";
function AniimoListing({ game, aniimo, filters, setFilters, content }) {
@ -61,14 +62,16 @@ export function AniimoPage({ category, game, aniimo, filters, setFilters, siteCo
if (aniimo.error) return <section className="empty nds-empty-state" role="alert"><h1>{content.error}</h1><p>{aniimo.error}</p><button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={aniimo.retry}>{siteContent.gamesPage.retryLabel}</button></section>;
return <AniimoLists game={game} aniimo={aniimo} linkedToolboxId={links?.[game.id] || ""} actions={actions} />;
}
if (category !== "aniimos") return <>
if (!["aniimos", "elements"].includes(category)) return <>
<section className="game-hero" style={{ "--game-hero-image": `url("${game.images.heroBg}")` }}><div><p className="eyebrow">{game.eyebrow}</p><h1>{game.title}</h1><p>{game.summary}</p></div></section>
<section className="game-home-grid">
<a className="feature game-home-card aniimo-home-card" href="#/games/aniimo/aniimos"><img src={game.images.aniimosCover} alt="" /><strong>{content.title}</strong><span>{content.homeDescription}</span></a>
<a className="feature game-home-card" href="#/games/aniimo/elements"><span className="game-home-card-icon" aria-hidden="true"><span className="aniimo-elements-home-icon"><img src="/static/img/aniimo/fire.webp" alt="" /><img src="/static/img/aniimo/water.webp" alt="" /><img src="/static/img/aniimo/grass.webp" alt="" /></span></span><strong>{content.elementCalculator.title}</strong><span>{content.elementCalculator.homeDescription}</span></a>
<a className="feature game-home-card" href="#/games/aniimo/lists"><span className="game-home-card-icon" aria-hidden="true"><span className="module-icon-svg module-icon-checklist" /></span><strong>Listes</strong><span>Données copiables au format checklist pour préparer vos suivis.</span></a>
</section>
</>;
if (aniimo.loading || !aniimo.loaded) return <section className="empty nds-empty-state" aria-busy="true"><h1>{content.loading}</h1></section>;
if (aniimo.error) return <section className="empty nds-empty-state" role="alert"><h1>{content.error}</h1><p>{aniimo.error}</p><button className="nds-button" data-size="sm" data-variant="primary" type="button" onClick={aniimo.retry}>{siteContent.gamesPage.retryLabel}</button></section>;
if (category === "elements") return <AniimoElements game={game} aniimo={aniimo} content={content.elementCalculator} />;
return <AniimoListing game={game} aniimo={aniimo} filters={filters} setFilters={setFilters} content={content} />;
}

View file

@ -0,0 +1,14 @@
// Rôle : calcule les affinités offensives et défensives pour un ou deux éléments Aniimo.
export function calculateElementMatchups(chart, selected) {
const elements = [...new Set(selected)];
if (!elements.length) return null;
if (elements.length > 2 || elements.some((element) => !chart.elements.includes(element))) {
throw new RangeError("Select one or two known Aniimo elements.");
}
return chart.elements.map((element) => ({
element,
// Chaque compétence conserve son propre élément en attaque.
attack: elements.map((attacker) => ({ element: attacker, multiplier: chart.matchups[attacker][element] })),
defense: Number(elements.reduce((value, defender) => value * chart.matchups[element][defender], 1).toFixed(6))
}));
}

View file

@ -143,10 +143,11 @@ export async function loadAniimoData(signal) {
fetch("/data/aniimo/aniimos.json", { signal }),
fetch("/data/aniimo/i18n/fr.json", { signal }),
fetch("/data/aniimo/i18n/en.json", { signal }),
fetch("/data/aniimo/lists/index.json", { signal })
fetch("/data/aniimo/lists/index.json", { signal }),
fetch("/data/aniimo/elements.json", { signal })
]);
if (responses.some((response) => !response.ok)) throw new Error("Les données Aniimo sont indisponibles.");
const [aniimos, translations, englishTranslations, listIndex] = await Promise.all(responses.map((response) => response.json()));
const [aniimos, translations, englishTranslations, listIndex, elementChart] = await Promise.all(responses.map((response) => response.json()));
const lists = await loadGameLists("aniimo", listIndex, signal);
return { loaded: true, loading: false, error: "", translations, englishTranslations, lists, ...prepareAniimoData(aniimos, translations, englishTranslations) };
return { loaded: true, loading: false, error: "", translations, englishTranslations, lists, elementChart, ...prepareAniimoData(aniimos, translations, englishTranslations) };
}

View file

@ -1,7 +1,69 @@
// Rôle : adapte les filtres et cartes Aniimo aux portraits verticaux et aux variantes.
// Rôle : adapte les filtres, cartes et groupes d'affinités Aniimo.
@use "design-system/surfaces";
.aniimo-home-card img { padding: 0 15%; object-fit: cover; object-position: 50% 38%; }
.aniimo-elements-home-icon { position: relative; display: block; width: 116px; height: 90px; }
.game-home-card .aniimo-elements-home-icon img {
position: absolute;
width: 48px;
height: 48px;
padding: 0;
border: 0;
background: none;
object-fit: contain;
filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.34));
&:first-child { top: 0; left: 34px; }
&:nth-child(2) { right: 0; bottom: 0; }
&:last-child { bottom: 0; left: 0; }
}
.aniimo-elements-guide { display: grid; gap: var(--space-5); }
.aniimo-element-picker { display: grid; gap: var(--space-3); padding: var(--space-5); }
.aniimo-element-picker-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-3); }
.aniimo-element-picker h2, .aniimo-matchup-panel h2 { margin: 0; font-size: var(--font-size-lg); }
.aniimo-element-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: var(--space-3); }
.aniimo-element-options .nds-button { min-width: 0; min-height: 96px; padding: var(--space-3) var(--space-2); }
.aniimo-matchup-element { display: inline-flex; align-items: center; gap: var(--space-2); }
.aniimo-matchup-element img { flex-shrink: 0; object-fit: contain; }
.aniimo-element-options .aniimo-matchup-element, .aniimo-matchup-members .aniimo-matchup-element { flex-direction: column; }
.aniimo-matchup-help { margin: 0; color: var(--color-text-secondary); font-size: var(--font-size-sm); }
.aniimo-matchup-panels { display: grid; gap: var(--space-6); align-items: start; }
.aniimo-matchup-panel {
min-width: 0;
padding: var(--space-5);
container-type: inline-size;
> p { color: var(--color-text-secondary); font-size: var(--font-size-sm); margin: var(--space-1) 0 var(--space-3); }
}
.aniimo-attack-element + .aniimo-attack-element { margin-top: var(--space-4); }
.nds-section-heading.aniimo-skill-heading {
align-items: center;
justify-content: flex-start;
gap: var(--space-3);
margin: 0 0 var(--space-2);
padding: var(--space-2) var(--space-3);
border-left: 2px solid var(--color-accent-gold);
border-radius: var(--radius-md);
background: linear-gradient(90deg, rgba(246, 196, 83, 0.08), rgba(139, 92, 246, 0.08));
}
.aniimo-skill-label { color: var(--color-text-secondary); font-size: var(--font-size-xs); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.aniimo-skill-element { flex-shrink: 0; }
.aniimo-skill-element .aniimo-matchup-element { gap: 6px; color: var(--color-text-primary); font-size: var(--font-size-sm); }
.aniimo-matchup-groups { display: grid; align-items: stretch; gap: var(--space-2); }
.aniimo-matchup-groups[data-mode="attack"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.aniimo-matchup-groups[data-mode="defense"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.aniimo-matchup-box { min-width: 0; min-height: 112px; height: 100%; padding: var(--space-2); }
.aniimo-matchup-box-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: var(--space-1); padding: var(--space-1) var(--space-1) 0; }
.aniimo-matchup-box-heading :is(h3, h4) { margin: 0; font-size: var(--font-size-sm); }
.aniimo-matchup-members { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2) var(--space-1); list-style: none; margin: var(--space-2) 0 0; padding: 0; }
.aniimo-matchup-members .aniimo-matchup-element { width: 100%; min-width: 0; gap: var(--space-1); }
.aniimo-matchup-members .aniimo-matchup-element > span { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aniimo-matchup-members li { min-width: 0; text-align: center; font-size: 10px; }
.aniimo-multiplier { white-space: nowrap; font-variant-numeric: tabular-nums; font-size: var(--font-size-xs); }
@media (min-width: 1100px) {
.aniimo-matchup-panels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container (max-width: 460px) {
.aniimo-matchup-groups[data-mode] { grid-template-columns: 1fr; }
}
.aniimo-layout .game-results { min-width: 0; }
.aniimo-filters { min-width: 0; }
.aniimo-filters .nds-filter-advanced-options { flex: 1 1 auto; }