Add an Easy mirror before Normal and let every companion help
Easy is a square 4 x 4 picture drawn for each player, with green outlines, where any two pieces swap; it is scored against the free minimum and pays 5 plus 1 per move left. The three mirrors open one after another (Easy, Normal, Hard) and the Guild quest is done with all three. Migration 31 rebuilds mirror_games to accept the new mode. The mirror page shows three illustrated cards, Easy painted with Codex. Bravery now places a misplaced piece for free, since swapping anywhere means nothing in Easy. Each of the five companions can help once per game instead of two in all. Mirror styles now win over the global button hover, so placed pieces keep their green outline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4321559831
commit
ebb220d532
18 changed files with 276 additions and 146 deletions
|
|
@ -2565,7 +2565,7 @@ test("an administrator opens expeditions and a player leaves alone, follows the
|
|||
await setServerClock(0);
|
||||
});
|
||||
|
||||
test("an administrator opens the broken mirror and a player rebuilds the normal picture, then starts the shared hard one", async ({ page }) => {
|
||||
test("an administrator opens the broken mirror and a player rebuilds the easy and normal pictures, then starts the shared hard one", async ({ page }) => {
|
||||
test.setTimeout(120_000);
|
||||
await page.goto("/#/cards");
|
||||
await page.getByRole("button", { name: "Version développement", exact: true }).click();
|
||||
|
|
@ -2583,45 +2583,65 @@ test("an administrator opens the broken mirror and a player rebuilds the normal
|
|||
await expect(quest.getByRole("link", { name: "Jouer", exact: true })).toBeVisible();
|
||||
await quest.getByRole("link", { name: "Jouer", exact: true }).click();
|
||||
await expect(page).toHaveURL(/#\/cards\/mirror$/);
|
||||
// Deux cartes : le Normal à jouer, le Difficile verrouillé tant que le Normal n'est pas terminé.
|
||||
// Trois cartes : le Facile à jouer, le Normal et le Difficile verrouillés tant que le miroir précédent n'est pas terminé.
|
||||
const easyCard = page.getByRole("article", { name: "Facile", exact: true });
|
||||
const normalCard = page.getByRole("article", { name: "Normal", exact: true });
|
||||
const hardCard = page.getByRole("article", { name: "Difficile", exact: true });
|
||||
await expect(normalCard).toContainText("16 morceaux");
|
||||
await expect(easyCard).toContainText("16 morceaux");
|
||||
await expect(normalCard).toContainText("Terminez d’abord le Facile du jour.");
|
||||
await expect(hardCard).toContainText("Terminez d’abord le Normal du jour.");
|
||||
await expect(hardCard.getByRole("button", { name: "Jouer", exact: true })).toBeDisabled();
|
||||
await normalCard.getByRole("button", { name: "Jouer", exact: true }).click();
|
||||
await easyCard.getByRole("button", { name: "Jouer", exact: true }).click();
|
||||
|
||||
// 16 morceaux, une image mélangée en blob ; on n'échange que dans la même rangée ou la même colonne.
|
||||
// 16 morceaux, une image mélangée en blob ; en Facile, n'importe quels morceaux s'échangent.
|
||||
const board = page.getByRole("group", { name: "Morceaux de l’illustration" });
|
||||
const pieces = board.getByRole("button");
|
||||
await expect(pieces).toHaveCount(16);
|
||||
await expect.poll(() => pieces.first().evaluate((element) => element.style.backgroundImage)).toMatch(/^url\("blob:/);
|
||||
const left = page.locator(".nebula-mirror-left strong");
|
||||
const startLeft = Number(await left.textContent());
|
||||
await pieces.nth(0).click();
|
||||
await expect(pieces.nth(5)).toHaveAttribute("data-off", "true");
|
||||
await expect(pieces.nth(3)).toHaveAttribute("data-legal", "true");
|
||||
await expect(pieces.nth(5)).toHaveAttribute("data-legal", "true");
|
||||
await pieces.nth(0).click();
|
||||
|
||||
// La place des morceaux ne sort pas du serveur : le parcours la lit en base, comme la réponse de la Carte du jour.
|
||||
const { path: databasePath } = JSON.parse(await readFile(join(tmpdir(), "sokkog-cards-e2e-db.json"), "utf8"));
|
||||
const { solve } = await import("../services/cards/mirror-rules.js");
|
||||
const nextMove = (mode, cols) => {
|
||||
const nextMove = (mode) => {
|
||||
const database = new DatabaseSync(databasePath, { readOnly: true });
|
||||
const row = database.prepare("SELECT g.status, g.state_json FROM mirror_games AS g JOIN players ON players.id = g.player_id WHERE players.discord_id = 'dev-admin' AND g.mode = ? ORDER BY g.day DESC LIMIT 1").get(mode);
|
||||
database.close();
|
||||
return row.status === "playing" ? solve(JSON.parse(row.state_json).pos, cols).first : null;
|
||||
if (row.status !== "playing") return null;
|
||||
const { pos } = JSON.parse(row.state_json);
|
||||
if (mode !== "easy") return solve(pos, 4).first;
|
||||
const piece = pos.findIndex((cell, index) => cell !== index);
|
||||
return [pos[piece], piece];
|
||||
};
|
||||
const left = page.locator(".nebula-mirror-left strong");
|
||||
const rebuild = async (mode) => {
|
||||
const startLeft = Number(await left.textContent());
|
||||
let swaps = 0;
|
||||
for (let move = nextMove(mode); move; move = nextMove(mode)) {
|
||||
await pieces.nth(move[0]).click();
|
||||
await pieces.nth(move[1]).click();
|
||||
swaps += 1;
|
||||
// Chaque échange compte : le nombre restant baisse, jusqu'au résultat.
|
||||
await expect(page.locator(`.nebula-mirror-left strong:text-is("${startLeft - swaps}"), .nebula-mirror-result`).first()).toBeVisible();
|
||||
}
|
||||
return startLeft - swaps;
|
||||
};
|
||||
await pieces.nth(0).click();
|
||||
let swaps = 0;
|
||||
for (let move = nextMove("normal", 4); move; move = nextMove("normal", 4)) {
|
||||
await pieces.nth(move[0]).click();
|
||||
await pieces.nth(move[1]).click();
|
||||
swaps += 1;
|
||||
// Chaque échange compte : le nombre restant baisse, jusqu'au résultat.
|
||||
await expect(page.locator(`.nebula-mirror-left strong:text-is("${startLeft - swaps}"), .nebula-mirror-result`).first()).toBeVisible();
|
||||
}
|
||||
const result = page.getByRole("region", { name: "Image reconstituée !" });
|
||||
await expect(result).toContainText(`+${10 + startLeft - swaps} poussière`);
|
||||
const easyLeft = await rebuild("easy");
|
||||
await expect(result).toContainText(`+${5 + easyLeft} poussière`);
|
||||
|
||||
// Le Normal s'ouvre ensuite : on n'échange que dans la même rangée ou la même colonne.
|
||||
await page.getByRole("button", { name: "Jouer le Normal", exact: true }).click();
|
||||
await expect(pieces).toHaveCount(16);
|
||||
await expect.poll(() => pieces.first().evaluate((element) => element.style.backgroundImage)).toMatch(/^url\("blob:/);
|
||||
await pieces.nth(0).click();
|
||||
await expect(pieces.nth(5)).toHaveAttribute("data-off", "true");
|
||||
await expect(pieces.nth(3)).toHaveAttribute("data-legal", "true");
|
||||
await pieces.nth(0).click();
|
||||
const normalLeft = await rebuild("normal");
|
||||
await expect(result).toContainText(`+${10 + normalLeft} poussière`);
|
||||
await expect(result).toContainText("Illustration :");
|
||||
|
||||
// Le Difficile s'ouvre ensuite : 35 morceaux, sans contour vert.
|
||||
|
|
@ -2633,6 +2653,7 @@ test("an administrator opens the broken mirror and a player rebuilds the normal
|
|||
await page.setViewportSize({ width: 1280, height: 720 });
|
||||
// « Changer de miroir » ramène aux deux cartes, avec l'état de chaque partie.
|
||||
await page.getByRole("button", { name: "Changer de miroir", exact: true }).click();
|
||||
await expect(easyCard).toContainText("Reconstituée");
|
||||
await expect(normalCard).toContainText("Reconstituée");
|
||||
await expect(hardCard.getByRole("button", { name: "Reprendre", exact: true })).toBeVisible();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue