init
This commit is contained in:
No files matched your search
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
const assert = require("node:assert/strict");
|
||||
const E = require("../public/game.js");
|
||||
|
||||
const teams = [
|
||||
["radacovsky", "babis", "sutaj", "meciar"],
|
||||
["radacovsky", "lenart", "mhodza", "mihal"],
|
||||
["radacovsky", "kazimir", "kamenicky", "horvath"]
|
||||
];
|
||||
|
||||
for (const mode of ["fun", "balanced"]) {
|
||||
const G = E.newGame(teams, [1, 1, 1], {
|
||||
names: ["Test A", "Test B", "Test C"],
|
||||
ai: [false, false, false],
|
||||
mode
|
||||
});
|
||||
assert.equal(G.p.length, 3);
|
||||
assert.equal(G.mode, mode);
|
||||
for (const p of G.p) {
|
||||
assert.equal(p.table.length, 3);
|
||||
assert.equal(p.reserve.length, 1);
|
||||
}
|
||||
if (mode === "balanced") {
|
||||
const horvath = [...G.p[2].table, ...G.p[2].reserve].find(c => c.key === "horvath");
|
||||
assert.equal(horvath.hp, 250);
|
||||
assert.equal(horvath.atk, 60);
|
||||
}
|
||||
const attackerSeat = G.turn;
|
||||
const attacker = G.p[attackerSeat].table[0];
|
||||
const targetSeat = (attackerSeat + 2) % 3;
|
||||
const target = G.p[targetSeat].table[0];
|
||||
const before = target.hp;
|
||||
const err = E.applyAction(attackerSeat, { type: "attack", c: attacker.uid, t: target.uid });
|
||||
assert.equal(err, undefined);
|
||||
assert.ok(target.hp < before, `${mode}: attack should hit a non-adjacent opponent`);
|
||||
}
|
||||
|
||||
console.log("Smoke test OK: 3-player FFA, team setup, Balanced/Fun and cross-table attacks.");
|
||||
Reference in New Issue
Block a user