Rename mirror swaps to moves and give each helper its own kind of help
On screen, a swap is now a move. The five helps no longer all save a move: Bravery frees the next move from the row or column rule, Orientation shows where a chosen piece goes, Fortune doubles the reward of a rebuilt picture, Endurance takes back the last move and Balanced shows the model for five seconds. The model is visible until the first move only: the server no longer sends it afterwards, except during that help and at the end. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9cf48ea0d0
commit
ddb3b81278
14 changed files with 152 additions and 99 deletions
|
|
@ -284,9 +284,9 @@ test("a game without swaps left is lost and pays nothing", (t) => {
|
|||
assert.equal(mirror.view(player.id).hardLock, null);
|
||||
});
|
||||
|
||||
test("helpers come from a ready daily team, are chosen before the first swap and help once each", (t) => {
|
||||
test("helpers come from a ready daily team, are chosen before the first move and help once each", (t) => {
|
||||
const context = game(t, { team: true });
|
||||
const { mirror, player, db } = context;
|
||||
const { mirror, player, db, clock, service } = context;
|
||||
mirror.start(player.id, { day: DAY, mode: "normal" });
|
||||
assert.deepEqual(mirror.view(player.id).team, []);
|
||||
refuses("MIRROR_HELPER_INVALID", () => mirror.chooseHelpers(player.id, { day: DAY, mode: "normal", cardIds: ["starvoid-dragon"] }));
|
||||
|
|
@ -294,6 +294,9 @@ test("helpers come from a ready daily team, are chosen before the first swap and
|
|||
const helpers = mirror.view(player.id).team;
|
||||
assert.equal(helpers.length, team.companions.length);
|
||||
refuses("MIRROR_INVALID", () => mirror.chooseHelpers(player.id, { day: DAY, mode: "normal", cardIds: helpers.slice(0, 3).map((helper) => helper.cardId) }));
|
||||
// Le modèle se voit jusqu'au premier mouvement.
|
||||
assert.equal(mirror.view(player.id).games.normal.modelOpen, true);
|
||||
assert.deepEqual(mirror.image(player.id, "normal", { model: true }).at, Array.from({ length: 16 }, (_, piece) => piece));
|
||||
|
||||
// Coups de main forcés pour l'essai : un compagnon de chaque sorte.
|
||||
const chosen = helpers.slice(0, 2).map((helper) => helper.cardId);
|
||||
|
|
@ -304,36 +307,50 @@ test("helpers come from a ready daily team, are chosen before the first swap and
|
|||
state.used = {};
|
||||
db.prepare("UPDATE mirror_games SET state_json = ? WHERE player_id = ? AND mode = 'normal'").run(JSON.stringify(state), player.id);
|
||||
};
|
||||
const use = (cardId, help) => mirror.useHelp(player.id, { day: DAY, mode: "normal", cardId, help, moves: mirror.view(player.id).games.normal.moves }).mirror.games.normal;
|
||||
const moves = () => mirror.view(player.id).games.normal.moves;
|
||||
const use = (cardId, help, cell) => mirror.useHelp(player.id, { day: DAY, mode: "normal", cardId, help, moves: moves(), cell }).mirror.games.normal;
|
||||
const swapNormal = (from, to) => mirror.swap(player.id, { day: DAY, mode: "normal", from, to, moves: moves() }).mirror.games.normal;
|
||||
|
||||
force([["endurance"], ["bravoure", "endurance"]]);
|
||||
const limit = mirror.view(player.id).games.normal.limit;
|
||||
assert.equal(use(chosen[0], "endurance").limit, limit + 1);
|
||||
refuses("MIRROR_HELP_USED", () => use(chosen[0], "endurance"));
|
||||
// Bravoure : le prochain mouvement se fait n'importe où, une seule fois.
|
||||
force([["bravoure"], ["endurance"]]);
|
||||
assert.equal(use(chosen[0], "bravoure").freeSwap, true);
|
||||
refuses("MIRROR_HELP_USED", () => use(chosen[0], "bravoure"));
|
||||
refuses("MIRROR_HELPER_INVALID", () => use(chosen[1], "fortune"));
|
||||
// Bravoure : le prochain échange se fait n'importe où, une seule fois.
|
||||
assert.equal(use(chosen[1], "bravoure").freeSwap, true);
|
||||
const free = mirror.swap(player.id, { day: DAY, mode: "normal", from: 0, to: 5, moves: mirror.view(player.id).games.normal.moves }).mirror.games.normal;
|
||||
const free = swapNormal(0, 5);
|
||||
assert.equal(free.freeSwap, false);
|
||||
refuses("MIRROR_SWAP_INVALID", () => mirror.swap(player.id, { day: DAY, mode: "normal", from: 0, to: 5, moves: free.moves }));
|
||||
refuses("MIRROR_SWAP_INVALID", () => swapNormal(0, 5));
|
||||
refuses("MIRROR_HELPERS_LOCKED", () => mirror.chooseHelpers(player.id, { day: DAY, mode: "normal", cardIds: chosen }));
|
||||
// Après le premier mouvement, le modèle ne sort plus du serveur.
|
||||
assert.equal(free.modelOpen, false);
|
||||
refuses("MIRROR_MODEL_HIDDEN", () => mirror.image(player.id, "normal", { model: true }));
|
||||
|
||||
// Équilibré : reprend le dernier échange et le rend.
|
||||
force([[BALANCED_HELP], ["orientation"]]);
|
||||
const undone = use(chosen[0], BALANCED_HELP);
|
||||
// Endurance : reprend le dernier mouvement, remet les morceaux et le rend.
|
||||
const before = stored(db, player.id, "normal").pos;
|
||||
const undone = use(chosen[1], "endurance");
|
||||
assert.equal(undone.swaps, free.swaps - 1);
|
||||
assert.deepEqual(undone.lastMove, [0, 5]);
|
||||
// Orientation : un bon échange, légal, qui ne dévoile rien d'autre.
|
||||
const hint = use(chosen[1], "orientation").hint;
|
||||
assert.ok(aligned(4, hint[0], hint[1]));
|
||||
assert.deepEqual(stored(db, player.id, "normal").pos, swapCells(before, 0, 5));
|
||||
|
||||
// Fortune : un morceau mal placé va à sa place, sans compter d'échange.
|
||||
// Orientation : la vraie case du morceau choisi ; Équilibré : le modèle pendant 5 secondes.
|
||||
force([["orientation"], ["balanced"]]);
|
||||
refuses("MIRROR_INVALID", () => use(chosen[0], "orientation"));
|
||||
const { pos } = stored(db, player.id, "normal");
|
||||
assert.deepEqual(use(chosen[0], "orientation", 6).hint, [6, pieceAt(pos)[6]]);
|
||||
assert.ok(use(chosen[1], "balanced").peekUntil > clock.now);
|
||||
assert.ok(mirror.image(player.id, "normal", { model: true }));
|
||||
clock.now += 10_000;
|
||||
refuses("MIRROR_MODEL_HIDDEN", () => mirror.image(player.id, "normal", { model: true }));
|
||||
|
||||
// Fortune : le Trésor double le gain d'une image reconstituée.
|
||||
force([["fortune"], ["endurance"]]);
|
||||
const placedBefore = placedCount(stored(db, player.id, "normal").pos);
|
||||
const lucky = use(chosen[0], "fortune");
|
||||
assert.ok(placedCount(stored(db, player.id, "normal").pos) > placedBefore);
|
||||
assert.equal(lucky.swaps, undone.swaps);
|
||||
assert.deepEqual(stored(db, player.id, "normal").used, { [chosen[0]]: "fortune" });
|
||||
assert.equal(use(chosen[0], "fortune").treasure, true);
|
||||
const before2 = service.getState(player.id).wallet.stardust;
|
||||
const won = play(context, "normal");
|
||||
assert.equal(won.status, "won");
|
||||
const { base, perSwap } = DEFAULT_MIRROR_SETTINGS.rewards.normal;
|
||||
assert.equal(won.reward, 2 * (base + perSwap * won.left));
|
||||
assert.equal(service.getState(player.id).wallet.stardust, before2 + won.reward);
|
||||
assert.equal(won.modelOpen, true);
|
||||
});
|
||||
|
||||
test("a closed daily team gives no helper, and a deleted account leaves no game", (t) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue