- Kollár s Poliačikom sa delil donekonečna a Fun hra zamrzla: limit kópií platí v oboch režimoch (Fun 128, Balanced 16) - Nové pravidlá zápasu: Poliačikovo liečenie (Fun 15, Balanced 100 HP) a prednosť majiteľa pri Clementisovi (Balanced) - Balanced štatistiky doladené pre všetkých 91 kariet (sd 1,7 p. b. v 1v1) - docs/CARDS.md a docs/BALANCE.md pregenerované, výklad nejasných schopností - tools/crop.py + tools/map.tsv: výrezy podľa tváre s odstránením pozadia, 23 nových obrázkov kariet, 15 kandidátov orezaných nanovo - TODO.md so zvyšnou prácou Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
200 lines
9.1 KiB
JavaScript
200 lines
9.1 KiB
JavaScript
"use strict";
|
|
// Mechaniky nových kariet a nastavenia zápasu.
|
|
const assert = require("node:assert/strict");
|
|
const E = require("../public/game.js");
|
|
|
|
// hra s pevne daným začínajúcim hráčom, bez rezerv (všetky 4 karty na stole), ak nie je povedané inak
|
|
function game(teams, { mode = "fun", cfg, first = 0, res = [0, 0] } = {}) {
|
|
let G;
|
|
do G = E.newGame(teams, res, { mode, cfg }); while (G.first !== first);
|
|
return G;
|
|
}
|
|
const card = (G, p, k) => [...G.p[p].table, ...G.p[p].reserve].find(c => c.key === k);
|
|
const act = (G, a) => { const e = E.applyAction(G.turn, a); assert.equal(e, undefined, e); };
|
|
const end = G => act(G, { type: "end" });
|
|
const ability = (G, c, a, b) => act(G, { type: "ability", c: c.uid, a: a && (a.uid ?? a), b: b && b.uid });
|
|
const filler = ["remisova", "budaj", "mihal"];
|
|
|
|
// --- nastavenia ---
|
|
{
|
|
const bal = E.presetCfg("balanced"), fun = E.presetCfg("fun");
|
|
assert.equal(bal.uses.sutaj, 3);
|
|
assert.equal(fun.uses.sutaj, undefined);
|
|
const c = E.cleanCfg("fun", { kazimirDmg: "70", shieldPct: 500, sakovaKolar: "áno", bogus: 1, uses: { babis: 7, nope: 3, sutaj: "x" } });
|
|
assert.equal(c.kazimirDmg, 70);
|
|
assert.equal(c.shieldPct, 100, "clamped to max");
|
|
assert.equal(c.sakovaKolar, true, "invalid value falls back to preset");
|
|
assert.equal(c.bogus, undefined);
|
|
assert.deepEqual(c.uses, { babis: 7 });
|
|
assert.ok(E.sameCfg(E.cleanCfg("balanced", null), bal));
|
|
const G = game([["sutaj", ...filler], ["remisova", "budaj", "mihal", "korcok"]], { mode: "balanced", cfg: { ...bal, uses: { sutaj: 1 } } });
|
|
assert.equal(card(G, 0, "sutaj").uses, 1);
|
|
assert.ok(G.custom);
|
|
}
|
|
|
|
// --- Kollár: limit kópií v Balanced ---
|
|
{
|
|
const G = game([["kolar", "heger", "remisova", "budaj"], ["korcok", "gaspar", "remisova", "gal"]], { mode: "balanced" });
|
|
for (let i = 0; i < 30 && !G.over; i++) end(G);
|
|
assert.ok(G.p[0].table.filter(c => c.key === "kolar").length <= 16);
|
|
}
|
|
|
|
// --- Mikloš vymení kartu so súperom ---
|
|
{
|
|
const G = game([["miklos", ...filler], ["meciar", "babis", "korcok", "gal"]]);
|
|
const mine = card(G, 0, "remisova"), theirs = card(G, 1, "meciar");
|
|
ability(G, card(G, 0, "miklos"), mine, theirs);
|
|
assert.equal(theirs.owner, 0); assert.ok(G.p[0].table.includes(theirs));
|
|
assert.equal(mine.owner, 1); assert.ok(G.p[1].table.includes(mine));
|
|
}
|
|
|
|
// --- Fígeľ vstane z mŕtvych raz ---
|
|
{
|
|
const G = game([["figel", ...filler], ["remisova", "budaj", "mihal", "korcok"]]);
|
|
const f = card(G, 0, "figel"), hp0 = f.hp;
|
|
f.hp = 0; end(G);
|
|
assert.ok(!f.dead); assert.equal(f.hp, hp0); assert.equal(f.atk, 1);
|
|
f.hp = 0; end(G);
|
|
assert.ok(f.dead);
|
|
}
|
|
|
|
// --- Kováč: po smrti Tiso s 0 ATK, Mečiar ho nemôže vyhodiť do vzduchu ---
|
|
{
|
|
const G = game([["meciar", ...filler], ["kovac", "budaj", "mihal", "korcok"]]);
|
|
const k = card(G, 1, "kovac");
|
|
const e = E.applyAction(0, { type: "ability", c: card(G, 0, "meciar").uid, a: k.uid });
|
|
assert.equal(e, "Neplatný cieľ schopnosti.");
|
|
k.hp = 0; end(G);
|
|
const t = card(G, 1, "tiso");
|
|
assert.ok(t && t.atk === 0, "Kováč is replaced by Tiso with 0 ATK");
|
|
}
|
|
|
|
// --- Ódor blokuje striedanie a Válka ---
|
|
{
|
|
const G = game([["remisova", "budaj", "mihal", "valek"], ["odor", "korcok", "gal", "babis"]], { res: [1, 0] });
|
|
assert.equal(E.applyAction(0, { type: "swap", c: card(G, 0, "remisova").uid, t: card(G, 0, "valek").uid }), "Ódor blokuje striedanie.");
|
|
assert.match(E.applyAction(0, { type: "valek", c: card(G, 0, "valek").uid }), /Ódor/);
|
|
}
|
|
|
|
// --- Clementis: prvý, kto vetu povie, dostane komunistu ---
|
|
{
|
|
const G = game([["remisova", "budaj", "mihal", "korcok"], ["clementis", "babis", "gal", "meciar"]]);
|
|
const before = G.p[0].table.length;
|
|
act(G, { type: "clementis" });
|
|
assert.equal(G.p[0].table.length, before + 1);
|
|
assert.equal(G.p[0].table.at(-1).fk, "komunista");
|
|
assert.ok(!card(G, 1, "clementis"), "Clementis leaves the game");
|
|
assert.equal(G.turn, 0, "saying the line does not end the turn");
|
|
}
|
|
|
|
// --- Clementis v Balanced: súper musí počkať, kým mal majiteľ jeden ťah ---
|
|
{
|
|
const G = game([["remisova", "budaj", "mihal", "korcok"], ["clementis", "babis", "gal", "meciar"]], { mode: "balanced" });
|
|
assert.equal(E.applyAction(0, { type: "clementis" }), "Clementis tu nie je, alebo ti Ódor blokuje stôl.");
|
|
end(G); end(G); // ťah majiteľa prešiel, teraz už môže aj súper
|
|
act(G, { type: "clementis" });
|
|
assert.equal(G.p[0].table.at(-1).fk, "komunista");
|
|
}
|
|
{
|
|
const G = game([["remisova", "budaj", "mihal", "korcok"], ["clementis", "babis", "gal", "meciar"]], { mode: "balanced", first: 1 });
|
|
act(G, { type: "clementis" });
|
|
assert.equal(G.p[1].table.at(-1).fk, "komunista", "owner can say it right away");
|
|
}
|
|
|
|
// --- Kollár s Poliačikom: kópie nikdy neumrú, limit drží hru konečnú aj vo Fun ---
|
|
{
|
|
const G = game([["kolar", "poliacik", "remisova", "budaj"], ["korcok", "gal", "meciar", "mihal"]], { cfg: { kolarMax: 8 } });
|
|
for (let i = 0; i < 40 && !G.over; i++) end(G);
|
|
assert.ok(G.p[0].table.filter(c => c.key === "kolar").length <= 8);
|
|
}
|
|
|
|
// --- Poliačik: liečenie je nastaviteľné ---
|
|
{
|
|
const G = game([["poliacik", "remisova", "budaj", "mihal"], ["korcok", "gal", "meciar", "babis"]], { cfg: { poliacikHp: 100 } });
|
|
const b = card(G, 0, "budaj"), hp = b.hp;
|
|
end(G); end(G); // druhý ťah majiteľa spustí efekty kola
|
|
assert.ok(b.hp === hp + 100 || card(G, 0, "poliacik").hp <= 0, "ally healed by poliacikHp");
|
|
}
|
|
|
|
// --- Lexa ukradne schopnosť; keď vzor umrie, stratí ju ---
|
|
{
|
|
const G = game([["lexa", ...filler], ["babis", "korcok", "gal", "meciar"]]);
|
|
const lexa = card(G, 0, "lexa"), babis = card(G, 1, "babis");
|
|
ability(G, lexa, babis);
|
|
assert.equal(G.turn, 1);
|
|
assert.equal(E.applyAction(1, { type: "ability", c: babis.uid, a: card(G, 0, "remisova").uid }), "Schopnosť sa teraz nedá použiť.", "Babiš lost his ability");
|
|
end(G);
|
|
const target = card(G, 1, "korcok"), hp = target.hp;
|
|
ability(G, lexa, target);
|
|
assert.equal(target.hp, hp - 300, "Lexa throws Babiš's stork");
|
|
babis.hp = 0; end(G);
|
|
assert.ok(babis.dead); assert.equal(G.turn, 0);
|
|
assert.equal(E.applyAction(0, { type: "ability", c: lexa.uid, a: target.uid }), "Schopnosť sa teraz nedá použiť.");
|
|
}
|
|
|
|
// --- Čepelka zvarí dve karty ---
|
|
{
|
|
const G = game([["cepelka", ...filler], ["meciar", "babis", "korcok", "gal"]]);
|
|
const a = card(G, 1, "meciar"), b = card(G, 1, "babis");
|
|
ability(G, card(G, 0, "cepelka"), a, b);
|
|
a.hp = 0; end(G);
|
|
assert.ok(a.dead && b.dead);
|
|
}
|
|
|
|
// --- Poliačik sa nedá napadnúť, Ľupták a HZDS na seba neútočia ---
|
|
{
|
|
const G = game([["luptak", "remisova", "budaj", "mihal"], ["poliacik", "meciar", "korcok", "harabin"]]);
|
|
const lup = card(G, 0, "luptak");
|
|
assert.equal(E.applyAction(0, { type: "attack", c: card(G, 0, "budaj").uid, t: card(G, 1, "poliacik").uid }), "Neplatný cieľ útoku.");
|
|
assert.equal(E.applyAction(0, { type: "attack", c: lup.uid, t: card(G, 1, "meciar").uid }), "Neplatný cieľ útoku.");
|
|
act(G, { type: "attack", c: lup.uid, t: card(G, 1, "korcok").uid });
|
|
assert.equal(E.applyAction(1, { type: "attack", c: card(G, 1, "meciar").uid, t: lup.uid }), "Neplatný cieľ útoku.");
|
|
}
|
|
|
|
// --- Kňažko: Lenárt naňho nemôže ---
|
|
{
|
|
const G = game([["lenart", ...filler], ["knazko", "korcok", "gal", "meciar"]]);
|
|
assert.equal(E.applyAction(0, { type: "ability", c: card(G, 0, "lenart").uid, a: card(G, 1, "knazko").uid }), "Neplatný cieľ schopnosti.");
|
|
}
|
|
|
|
// --- Balanced: Hlinkov Tiso prevezme HP, štít chráni pred zabitím ---
|
|
{
|
|
const G = game([["hlinka", "uhrik", "remisova", "budaj"], ["korcok", "gal", "remisova", "mihal"]], { mode: "balanced" });
|
|
const u = card(G, 0, "uhrik"); u.hp = 25;
|
|
ability(G, card(G, 0, "hlinka"), u);
|
|
assert.equal(card(G, 0, "tiso").hp, 25);
|
|
}
|
|
{
|
|
const G = game([["lenart", ...filler], ["hlavaj", "korcok", "gal", "mihal"]], { mode: "balanced", first: 1 });
|
|
ability(G, card(G, 1, "hlavaj"));
|
|
const t = card(G, 1, "korcok"); t.hp = 300;
|
|
ability(G, card(G, 0, "lenart"), t);
|
|
assert.ok(t.hp > 0, "shield blocks Lenárt in Balanced");
|
|
}
|
|
|
|
// --- Fico ide do rezervy bez ťahu, Kiska po 3 kolách pridá HP ---
|
|
{
|
|
const G = game([["fico", "kiska", "remisova", "budaj"], ["korcok", "gal", "remisova", "mihal"]], { res: [1, 0] });
|
|
const fico = card(G, 0, "fico");
|
|
ability(G, fico);
|
|
assert.ok(G.p[0].reserve.includes(fico)); assert.equal(G.turn, 0);
|
|
const kiska = card(G, 0, "kiska"), hp = kiska.hp;
|
|
ability(G, kiska);
|
|
for (let i = 0; i < 6; i++) end(G);
|
|
assert.equal(kiska.hp, hp + 300);
|
|
}
|
|
|
|
// --- Štúr zmätie nepriateľa aj spojenca, Radičová dá balónik ---
|
|
{
|
|
const G = game([["stur", "radicova", "remisova", "budaj"], ["meciar", "korcok", "gal", "mihal"]]);
|
|
const m = card(G, 1, "meciar"), ally = card(G, 0, "remisova");
|
|
ability(G, card(G, 0, "stur"), m, ally);
|
|
// súper je hneď na ťahu, takže prvé z 5 zmätených kôl už beží
|
|
assert.ok(m.confusedNow); assert.equal(m.confused, 4); assert.equal(ally.confused, 5);
|
|
end(G);
|
|
ability(G, card(G, 0, "radicova"), card(G, 1, "korcok"));
|
|
assert.ok(card(G, 1, "korcok").balloon);
|
|
}
|
|
|
|
console.log("Cards test OK: settings, Kollár cap, Kollár+Poliačik, Clementis priority, Mikloš, Fígeľ, Kováč, Ódor, Clementis, Lexa, Čepelka, Poliačik, Ľupták, Kňažko, Balanced caps, Fico, Kiska, Štúr, Radičová.");
|