feedback7 dober: 教鞭 is the official personal choice of three 战术特训 cards again, not a random one (PR #353 by @Sukvii, the owner's decision of 2026-10-08); golden: coop2-NORMAL-8-serverrun and coop2-ABYSS-10-boosted move
Seen: the Art 教鞭 (杜宾's strategy) drew three 战术特训 cards and added a random one — a documented simplification (docs/META.md §2.5: a personal choice would need its own phase, protocol message, timer and AI takeover). Official: act2autochess choice_event hunter_band_1 is a PERSONAL_CHOOSE; PRTS 下半 记录 §法术 教鞭 "使用后销毁,于3个战术特训的悬赏任务中选择一项". The owner decided on 2026-10-08 to follow it. Taken from PR #353 (code and tests by @Sukvii), ported to the split 0.2.2 modules. Now: ctx.offerBountyChoice -> Match.offerBountyChoice keeps up to three different mode-eligible cards (15 of 20 in 标准 / 险境, 20 in 绝境 / 终极; one meta-rng shuffle) in PlayerState.personalChoice, m.private only (same cards after a reconnect); g.choice { idx, choiceId } confirms it (Match.pickPersonalChoice: owner, id, round, index; a request without a choiceId is still the public draft, a stale id never falls through to it). No new phase or timer: Ready is refused while it is open, the prep's deadline picks at random before the temp pieces and Ready, a bot or a 托管 seat picks with the bounty scorer (botPickCard, the bots' seeded rng; at the prep's start, after the cast, before Ready; the scheduler's fallback picks at random if a step fails). The client reuses ChoiceOverlay (personal: no order, no turns, the prep's countdown) over a locked prep, the Ready reasons, the mock harness; six UI strings in en / ja / ko / zh-TW. An eliminated player's offer goes with it; invariants.js flags an offer outside its owner's own open prep. Not taken from the PR: its §25.24 in the released docs/history/0.2.0.md (the 0.2.2 section is the integrator's), its edits of the Ready toggle beyond the personal-choice case, its tail placement of the i18n keys. Golden: coop2-NORMAL-8-serverrun (ai_0 杜宾 casts 教鞭 from R2 on and now scores the three cards: teamLp 39 -> 34, virtualMs 121400 -> 118400, rng shop 511 -> 483 / bots 18063 -> 18070 / meta 112 -> 103) and coop2-ABYSS-10-boosted (ai_1 杜宾: virtualMs 121650 -> 124650, shop 590 -> 589 / bots 22075 -> 22096 / meta 141 -> 154); both first differ in round 2, every other scenario and family is unchanged; node tools/golden.mjs --twice is identical. Tests: items.test.js (three distinct cards, the tapped one applied once, nothing before the confirm, a refused cast keeps the Art / count / rng / uid, an eliminated player's offer), economy.test.js (Ready refused, the deadline picks before endPrep, solo prep untimed), connection.test.js (two players' offers, reconnect, foreign / duplicate / old ids, an offline player's pick at the deadline), bot.test.js (托管 takeover incl. the failing-step fallback), bot-smarter.test.js (the scorer's pick, deterministic per seed, no rng draw when nothing is pending), followups.test.js (R14 / R15), draft.test.js, unitStats.test.js (protocol), hardening.test.js (invariant), gameLogic / playtest3 / playtest4 (view model, Ready reason, ChoiceView, actions), mock.e2e.test.js and playtest2.real.e2e.test.js (browser, SP_E2E=1).
This commit is contained in:
1 parent
05eb2b807f
commit
56a7b918a9
48 files changed
+901
-159
No files matched your search
@@ -38,9 +38,45 @@ test('bounty pick: the card the own board can beat, never one it cannot (even wh
|
||||
assert.equal(botPickCard(m, ps, [hard, easy, huge].map((c, idx) => ({ ...c, idx })), [0, 1, 2]), 1);
|
||||
ps.lp = 2;
|
||||
assert.equal(botPickCard(m, ps, [hard, huge, easy].map((c, idx) => ({ ...c, idx })), [0, 1, 2]), 2, 'low LP: still the beatable one');
|
||||
const raw = [hard, easy].map((c) => DATA.choices.cards.bounty.find((x) => x.effectId === c.id));
|
||||
assert.deepEqual(m.offerBountyChoice(ps, raw, 'chess_item_6_03_m'), { ok: true });
|
||||
assert.deepEqual(m.autoPickPersonalChoice(ps, 'bot'), { ok: true });
|
||||
assert.equal(ps.personalChoice, null);
|
||||
assert.equal(ps.bounties.at(-1).card.enemyKey, easy.enemyKey, 'personal cards use bounty scoring too');
|
||||
const metaState = m.rngMeta.state(), botState = m.rngBots.state();
|
||||
m.autoPickPersonalChoice(ps, 'bot');
|
||||
m.autoPickPersonalChoice(ps, 'random');
|
||||
assert.equal(m.rngMeta.state(), metaState);
|
||||
assert.equal(m.rngBots.state(), botState, 'nothing pending: no RNG draws');
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('a bot\'s 教鞭 pick is deterministic: one seed offers the same three cards and picks the same one, drawing only on the bots\' rng', () => {
|
||||
const runs = [];
|
||||
for (let k = 0; k < 2; k++) {
|
||||
const h = soloBot({ seed: 5, difficulty: 'HARD' }).start();
|
||||
const m = h.m;
|
||||
const ps = m.order[0];
|
||||
h.run(() => m.phase === PHASE.PREP && m.round === 1);
|
||||
ps.lp = 999;
|
||||
h.run(() => m.phase === PHASE.PREP && m.round === 5);
|
||||
const art = giveItem(m, ps, 'chess_item_6_03_m');
|
||||
assert.deepEqual(ps.useArt(art.uid, 10, 5), { ok: true });
|
||||
const offered = ps.personalChoice.cards.map((c) => c.effectId);
|
||||
assert.equal(offered.length, 3);
|
||||
assert.equal(new Set(offered).size, 3, 'three different cards');
|
||||
const meta = m.rngMeta.state(), bots = m.rngBots.state();
|
||||
assert.deepEqual(m.autoPickPersonalChoice(ps, 'bot'), { ok: true });
|
||||
assert.equal(m.rngMeta.state(), meta, 'the pick leaves the meta rng alone');
|
||||
assert.notEqual(m.rngBots.state(), bots, 'one scoring draw per card from the bots\' rng');
|
||||
assert.equal(ps.personalChoice, null);
|
||||
runs.push({ offered, picked: ps.bounties.at(-1).card.effectId, bots: m.rngBots.state() });
|
||||
assert.ok(offered.includes(runs[k].picked));
|
||||
m.dispose();
|
||||
}
|
||||
assert.deepEqual(runs[0], runs[1]);
|
||||
});
|
||||
|
||||
test('bounty pick in real drafts (绝境 R3 悬赏决策): a card the board likely beats (p ≥ 0.5) whenever a near-sure one (p ≥ 0.9) is offered', () => {
|
||||
let drafts = 0;
|
||||
for (const seed of [1, 2, 3, 4]) {
|
||||
@@ -138,9 +174,12 @@ test('bounty Arts (教鞭): kept after a battle with leaks, used after a perfect
|
||||
assert.ok(owns(ps, WHIP), 'kept after a battle with leaks (not destroyed)');
|
||||
h.run(() => m.phase === PHASE.PREP && m.round === 4);
|
||||
m.lastResults.set(ps.playerId, clean);
|
||||
giveItem(m, ps, WHIP);
|
||||
const bounties = ps.bounties.length;
|
||||
h.run(() => m.phase === PHASE.COMBAT && m.round === 4);
|
||||
assert.ok(!owns(ps, WHIP) && ps.bounties.length > bounties, 'used after a perfect battle');
|
||||
assert.ok(!owns(ps, WHIP) && ps.bounties.length === bounties + 2, 'both Arts used and picked after a perfect battle');
|
||||
assert.equal(ps.personalChoice, null);
|
||||
assert.equal(ps.round.arts, 2);
|
||||
assert.equal(m.errorCount, 0);
|
||||
m.dispose();
|
||||
}
|
||||
|
||||
+27
-1
@@ -4,7 +4,7 @@ import assert from 'node:assert/strict';
|
||||
import { PHASE } from '../../shared/constants.js';
|
||||
import { fieldModel, planLayout, rehearse, rangeTiles, REHEARSAL_VARIANTS, LAYOUT_PARAMS, botPickCard, botPickBand } from '../../server/match/bot.js';
|
||||
import { FIELD, canPlace, placeClass, parseKey } from '../../server/match/board.js';
|
||||
import { makeMatch, checkInvariants, give, DATA } from './harness.js';
|
||||
import { makeMatch, checkInvariants, give, giveItem, DATA } from './harness.js';
|
||||
|
||||
const soloBot = (o = {}) => makeMatch({ mode: 'solo', difficulty: 'NORMAL', seats: [{ seat: 0, playerId: 'ai_0', name: 'AI', isBot: true, connected: true }], ...o });
|
||||
|
||||
@@ -222,6 +222,32 @@ test('a sliced rehearsal is dropped when the prep ends first; the default layout
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('AI takeover resolves a personal choice in untimed PREP, including generator-error Ready cleanup', () => {
|
||||
for (const broken of [false, true]) {
|
||||
const h = makeMatch({ mode: 'coop', humans: 1, seed: 6, fake: true, botSliceMs: 0 }).start();
|
||||
h.toPrep(1);
|
||||
const m = h.m, ps = h.ps('p_0');
|
||||
assert.equal(m.deadline, 0, 'single-human co-op is untimed');
|
||||
const art = giveItem(m, ps, 'chess_item_6_03_m');
|
||||
assert.deepEqual(ps.useArt(art.uid, 10, 5), { ok: true });
|
||||
const pick = m.autoPickPersonalChoice.bind(m), modes = [];
|
||||
m.autoPickPersonalChoice = (p, mode) => {
|
||||
if (p.personalChoice) modes.push(mode);
|
||||
if (broken && mode === 'bot') throw new Error('scripted choice scoring failure');
|
||||
return pick(p, mode);
|
||||
};
|
||||
assert.deepEqual(m.handle(ps.playerId, { t: 'g.autoplay', on: true }), { ok: true });
|
||||
assert.ok(h.run(() => m.phase !== PHASE.PREP));
|
||||
assert.equal(ps.personalChoice, null);
|
||||
assert.equal(ps.bounties.length, 1);
|
||||
assert.equal(ps.round.arts, 1);
|
||||
assert.ok(ps.ready);
|
||||
assert.ok(modes.includes(broken ? 'random' : 'bot'));
|
||||
assert.equal(m.errorCount > 0, broken);
|
||||
m.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
test('economy: the bot fills the board first (8 units by round 4), levels on its curve and keeps a hand slot free', () => {
|
||||
for (const seed of [5, 8]) {
|
||||
const h = soloBot({ seed }).start();
|
||||
|
||||
@@ -4,7 +4,7 @@ import assert from 'node:assert/strict';
|
||||
import { PHASE, ERR } from '../../shared/constants.js';
|
||||
import { Match } from '../../server/match/Match.js';
|
||||
import { StubMatch } from '../../server/match/StubMatch.js';
|
||||
import { DATA, makeMatch, checkInvariants, give, chessOfTier } from './harness.js';
|
||||
import { DATA, makeMatch, checkInvariants, give, giveItem, chessOfTier } from './harness.js';
|
||||
import { bossPoolHp } from '../../server/match/finalAssault.js';
|
||||
|
||||
const STATUSES = ['acting', 'ready', 'deciding', 'combat', 'done', 'helping', 'left', 'dead'];
|
||||
@@ -51,6 +51,7 @@ test('m.private shape in PREP matches DESIGN §8.3 (pieces, slots, bonds, effect
|
||||
assert.ok(s.kind === 'chess' || s.kind === 'item');
|
||||
}
|
||||
assert.equal(priv.shop.rewardOffer, null);
|
||||
assert.equal(priv.personalChoice, null);
|
||||
assert.equal(priv.deployCap, 8);
|
||||
assert.ok(priv.effects.some((e) => e.iconKind === 'band' && e.name));
|
||||
assert.ok(priv.nextEnemies.length > 0);
|
||||
@@ -109,6 +110,45 @@ test('disconnect: the seat keeps playing; draft turns / prep auto-resolve at dea
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('教鞭: simultaneous private choices survive reconnect; foreign, duplicate and old IDs cannot add bounties', () => {
|
||||
const h = makeMatch({ mode: 'coop', humans: 2, spectators: ['watcher'], seed: 63, fake: true }).start();
|
||||
h.toPrep(1);
|
||||
const m = h.m, a = h.ps('p_0'), b = h.ps('p_1');
|
||||
for (const ps of [a, b]) {
|
||||
const art = giveItem(m, ps, 'chess_item_6_03_m');
|
||||
assert.deepEqual(ps.useArt(art.uid, 10, 5), { ok: true });
|
||||
}
|
||||
const aChoice = a.privateView().personalChoice, bChoice = b.privateView().personalChoice;
|
||||
assert.notEqual(aChoice.id, bChoice.id);
|
||||
assert.equal(m.handle('p_0', { t: 'g.choice', idx: 0, choiceId: bChoice.id }).error, ERR.BAD_TARGET);
|
||||
assert.equal(a.bounties.length + b.bounties.length, 0);
|
||||
m.onDisconnect('p_0');
|
||||
m.onReconnect('p_0');
|
||||
assert.deepEqual(h.lastTo('p_0', 'm.private').personalChoice, aChoice);
|
||||
m.flush(true);
|
||||
assert.deepEqual(h.lastTo('p_1', 'm.private').personalChoice, bChoice);
|
||||
assert.ok(!h.allTo('watcher', 'm.private').length);
|
||||
assert.ok(!JSON.stringify(m.publicView()).includes(aChoice.id));
|
||||
assert.ok(!JSON.stringify(m.prepFieldMeta(a)).includes(aChoice.id));
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.choice', idx: 1, choiceId: aChoice.id }), { ok: true });
|
||||
m.flush(true);
|
||||
assert.equal(h.lastTo('p_0', 'm.private').personalChoice, null);
|
||||
assert.equal(m.handle('p_0', { t: 'g.choice', idx: 1, choiceId: aChoice.id }).error, ERR.BAD_TARGET);
|
||||
const next = giveItem(m, a, 'chess_item_6_03_m');
|
||||
assert.deepEqual(a.useArt(next.uid, 10, 5), { ok: true });
|
||||
const nextId = a.personalChoice.id;
|
||||
assert.notEqual(nextId, aChoice.id);
|
||||
assert.equal(m.handle('p_0', { t: 'g.choice', idx: 0, choiceId: aChoice.id }).error, ERR.BAD_TARGET);
|
||||
assert.equal(a.personalChoice.id, nextId);
|
||||
assert.equal(a.bounties.length, 1);
|
||||
m.onDisconnect('p_1');
|
||||
h.sched.advance(m.deadline - h.sched.now() + 1);
|
||||
m.onReconnect('p_1');
|
||||
assert.equal(h.lastTo('p_1', 'm.private').personalChoice, null);
|
||||
assert.equal(b.bounties.length, 1, 'offline choice picked at the existing PREP deadline');
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('g.autoplay lets the bot play a human seat (buys, places, readies); turning it off returns control', () => {
|
||||
const h = makeMatch({ mode: 'solo', seed: 64, fake: true }).start();
|
||||
const m = h.m;
|
||||
|
||||
@@ -150,6 +150,8 @@ test('机变 (co-op): 6 shared cards, random order, 30 s first / 16 s others, ti
|
||||
assert.deepEqual(sp.order.slice().sort(), ['p_0', 'p_1', 'p_2']);
|
||||
assert.equal(Math.round((m2.deadline - h2.sched.now()) / 1000), 30, 'first picker 30 s');
|
||||
const [a, b, c] = sp.order;
|
||||
assert.equal(m2.handle(a, { t: 'g.choice', idx: 2, choiceId: 'old.choice.1' }).error, ERR.WRONG_PHASE);
|
||||
assert.deepEqual(m2.sp.picks, {}, 'personal IDs never fall through to the global draft');
|
||||
assert.equal(m2.handle(b, { t: 'g.choice', idx: 0 }).error, ERR.NOT_YOUR_TURN);
|
||||
assert.deepEqual(m2.handle(a, { t: 'g.choice', idx: 2 }), { ok: true });
|
||||
assert.equal(m2.handle(a, { t: 'g.choice', idx: 3 }).error, ERR.ALREADY);
|
||||
|
||||
@@ -214,6 +214,15 @@ test('ready gating: temp must be empty (a freed hand slot pulls the temp piece i
|
||||
assert.equal(a.hand[3], t);
|
||||
assert.ok(a.tempEmpty);
|
||||
assert.equal(a.privateView().canReady, true);
|
||||
const art = giveItem(m, a, 'chess_item_6_03_m', 'temp');
|
||||
assert.deepEqual(a.useArt(art.uid, 10, 5), { ok: true });
|
||||
assert.ok(a.tempEmpty);
|
||||
assert.equal(a.privateView().canReady, false);
|
||||
assert.deepEqual(a.setReady(true), { error: ERR.BAD_TARGET, detail: '请先完成教鞭选择' });
|
||||
assert.deepEqual(a.setReady(false), { ok: true });
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.choice', idx: 0, choiceId: a.personalChoice.id }), { ok: true });
|
||||
assert.equal(a.privateView().canReady, true);
|
||||
assert.equal(a.round.arts, 1);
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.ready', ready: true }), { ok: true });
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.refresh' }), { error: ERR.WRONG_PHASE, detail: 'ready' });
|
||||
assert.deepEqual(m.handle('p_0', { t: 'g.ready', ready: false }), { ok: true });
|
||||
@@ -235,13 +244,26 @@ test('prep deadline (co-op): unready players are auto-readied and their temp is
|
||||
const a = h.ps('p_0');
|
||||
const id = chessOfTier(1).find((x) => m.pool.has(x));
|
||||
const left = m.pool.left(id);
|
||||
const art = giveItem(m, a, 'chess_item_6_03_m');
|
||||
assert.deepEqual(a.useArt(art.uid, 10, 5), { ok: true });
|
||||
fillHand(a);
|
||||
give(m, a, id, 'temp');
|
||||
assert.ok(!a.tempEmpty, 'a full hand: it waits in temp');
|
||||
const endPrep = m.endPrep.bind(m);
|
||||
let checked = false;
|
||||
m.endPrep = () => {
|
||||
assert.equal(a.personalChoice, null, 'deadline picks before endPrep builds the battle');
|
||||
assert.equal(a.bounties.length, 1);
|
||||
assert.equal(a.round.arts, 1);
|
||||
assert.ok(a.ready && a.tempEmpty);
|
||||
checked = true;
|
||||
endPrep();
|
||||
};
|
||||
assert.ok(m.deadline > h.sched.now(), 'co-op prep is timed');
|
||||
assert.equal(Math.round((m.deadline - h.sched.now()) / 1000), m.gd.prepTime(1));
|
||||
h.sched.advance(m.deadline - h.sched.now() + 1);
|
||||
assert.notEqual(m.phase, PHASE.PREP);
|
||||
assert.ok(checked);
|
||||
assert.ok(a.tempEmpty);
|
||||
assert.equal(m.pool.left(id), left, 'temp chess sold back to the pool');
|
||||
checkInvariants(m);
|
||||
@@ -252,7 +274,12 @@ test('solo prep and 机变 are untimed', () => {
|
||||
const h = makeMatch({ mode: 'solo', difficulty: 'NORMAL', seed: 13 }).start();
|
||||
h.toPrep(1);
|
||||
assert.equal(h.m.deadline, 0);
|
||||
const ps = h.ps('p_0');
|
||||
const art = giveItem(h.m, ps, 'chess_item_6_03_m');
|
||||
assert.deepEqual(ps.useArt(art.uid, 10, 5), { ok: true });
|
||||
const id = ps.personalChoice.id;
|
||||
h.sched.advance(10 * 60 * 1000);
|
||||
assert.equal(h.m.phase, PHASE.PREP);
|
||||
assert.equal(ps.personalChoice.id, id, 'no separate personal-choice timer');
|
||||
h.m.dispose();
|
||||
});
|
||||
@@ -11,7 +11,7 @@ import { fieldModel } from '../../server/match/bot.js';
|
||||
import { FIELD, parseKey } from '../../server/match/board.js';
|
||||
import { createRng } from '../../server/sim/rng.js';
|
||||
import { FakeBattle } from './fakeBattle.js';
|
||||
import { DATA, makeMatch, checkInvariants } from './harness.js';
|
||||
import { DATA, makeMatch, checkInvariants, giveItem } from './harness.js';
|
||||
|
||||
const bossFields = () => FakeBattle.instances.filter((b) => b.kind === 'boss' || b.kind === 'hidden');
|
||||
|
||||
@@ -90,6 +90,40 @@ test('perfect-payout bounties in the boss rounds: a 战术特训 card\'s coins j
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('教鞭 in the boss rounds (R14, R15): the card the owner chose spawns in the boss battle and pays at the next income, the Hidden Core takes another choice', () => {
|
||||
const h = makeMatch({ mode: 'coop', difficulty: 'NORMAL', humans: 2, seed: 61, fake: true,
|
||||
script: (b) => (b.kind === 'boss' || b.kind === 'hidden' ? { bossDps: 1e9, coins: { p_0: 3 } } : {}) }).start();
|
||||
const m = h.m;
|
||||
h.toPrep(14);
|
||||
const ps = h.ps('p_0');
|
||||
const art = giveItem(m, ps, 'chess_item_6_03_m');
|
||||
assert.deepEqual(ps.useArt(art.uid, 10, 5), { ok: true });
|
||||
assert.equal(ps.bounties.length, 0, 'nothing is applied before the owner confirms');
|
||||
assert.equal(ps.setReady(true).error, 'BAD_TARGET', 'Ready waits for the choice');
|
||||
const card = ps.personalChoice.cards[2];
|
||||
assert.deepEqual(m.handle(ps.playerId, { t: 'g.choice', idx: 2, choiceId: ps.personalChoice.id }), { ok: true });
|
||||
assert.equal(ps.bounties[0].card.effectId, card.effectId, 'the card of the tapped slot');
|
||||
const pending = ps.pendingFunds;
|
||||
h.drive(() => m.phase === PHASE.FINAL_ASSAULT);
|
||||
m.hiddenLayerSum = 1e6;
|
||||
assert.ok(bossFields()[0].opts.spawns.some((s) => s.tag === 'bounty' && s.enemyKey === card.enemyKey && s.ownerPlayerId === ps.playerId), 'the chosen card\'s enemies come in the boss battle');
|
||||
h.run(() => m.runner === null);
|
||||
assert.equal(ps.pendingFunds, pending + 3 + card.coin, 'kill coins + the chosen card\'s coins');
|
||||
h.toPrep(15);
|
||||
assert.equal(ps.funds, m.gd.income(15) + pending + 3 + card.coin, 'paid at the R15 income, apart from the base income');
|
||||
const hiddenArt = giveItem(m, ps, 'chess_item_6_03_m');
|
||||
assert.deepEqual(ps.useArt(hiddenArt.uid, 10, 5), { ok: true });
|
||||
const hiddenCard = ps.personalChoice.cards[0];
|
||||
assert.deepEqual(m.handle(ps.playerId, { t: 'g.choice', idx: 0, choiceId: ps.personalChoice.id }), { ok: true });
|
||||
const owed = ps.bounties.filter((b) => b.card.payout === 'perfect').reduce((n, b) => n + b.card.coin, 0);
|
||||
h.drive(() => m.phase === PHASE.HIDDEN_CORE);
|
||||
assert.ok(bossFields().at(-1).opts.spawns.some((s) => s.tag === 'bounty' && s.enemyKey === hiddenCard.enemyKey));
|
||||
h.runToEnd();
|
||||
assert.equal(ps.pendingFunds, 3 + owed, 'the Hidden Core pays by the same rule');
|
||||
checkInvariants(m);
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('boss victory without a perfect own result keeps the kill coins but gives no perfect-card funds', () => {
|
||||
const h = makeMatch({ mode: 'coop', humans: 2, seed: 61, fake: true,
|
||||
script: (b) => (b.kind === 'boss' ? { bossDps: 1e9, leaks: { p_0: 1 }, coins: { p_0: 3 } } : {}) }).start();
|
||||
|
||||
@@ -397,6 +397,22 @@ test('collectViolations reports corrupted state (funds, pool accounting, duplica
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('collectViolations: a 教鞭 choice belongs to its owner\'s open prep only', () => {
|
||||
const { m, ps } = prepSolo({ seed: 922 });
|
||||
const art = giveItem(m, ps, 'chess_item_6_03_m');
|
||||
assert.deepEqual(ps.useArt(art.uid, 10, 5), { ok: true });
|
||||
assert.deepEqual(collectViolations(m), [], 'an open choice in its own prep is fine');
|
||||
const pc = ps.personalChoice;
|
||||
pc.round = m.round - 1;
|
||||
assert.match(collectViolations(m).join('\n'), /personal choice outside its own prep/, 'a choice left from an earlier round');
|
||||
pc.round = m.round;
|
||||
pc.cards = [pc.cards[0], pc.cards[0]];
|
||||
assert.match(collectViolations(m).join('\n'), /personal choice of 2 cards/, 'the same card twice');
|
||||
ps.personalChoice = null;
|
||||
assert.deepEqual(collectViolations(m), []);
|
||||
m.dispose();
|
||||
});
|
||||
|
||||
test('the rule auditor flags an LP loss that does not match the leaks (engine regression guard)', () => {
|
||||
const h = makeMatch({ mode: 'coop', humans: 2, seed: 921, fake: true, script: (b) => (b.kind === 'normal' ? { leaks: Object.fromEntries(b.players.map((p) => [p, 2])) } : {}) }).start();
|
||||
const m = h.m;
|
||||
|
||||
@@ -122,6 +122,7 @@ export function makeMatch(o = {}) {
|
||||
if (idx != null) m.handle(ps.playerId, { t: 'g.choice', idx });
|
||||
}
|
||||
if (ready && m.phase === 'PREP' && ps.alive && !ps.ready) {
|
||||
if (ps.personalChoice) m.handle(ps.playerId, { t: 'g.choice', idx: 0, choiceId: ps.personalChoice.id });
|
||||
if (!ps.tempEmpty) ps.resolveTemp();
|
||||
m.handle(ps.playerId, { t: 'g.ready', ready: true });
|
||||
}
|
||||
|
||||
@@ -42,6 +42,11 @@ test('protocol: g.unitStats { seq? } and g.bandFocus { bandId? } validate; m.uni
|
||||
assert.equal(validateC2S({ t: 'g.bandFocus', bandId: 'band_bldsk' }), null);
|
||||
assert.notEqual(validateC2S({ t: 'g.bandFocus', bandId: 'a b' }), null);
|
||||
assert.ok(S2C.includes('m.unitStats'));
|
||||
assert.equal(validateC2S({ t: 'g.choice', idx: 0 }), null);
|
||||
assert.equal(validateC2S({ t: 'g.choice', idx: 2, choiceId: 'seed-2.choice.12' }), null);
|
||||
for (const choiceId of [null, '', 'a b', 12, 'a'.repeat(65)]) {
|
||||
assert.notEqual(validateC2S({ t: 'g.choice', idx: 0, choiceId }), null);
|
||||
}
|
||||
});
|
||||
|
||||
test('unitStatsEntry: effective stats next to the base, rounded for display; the interval from bat / aspd when absent', () => {
|
||||
|
||||
Reference in new issue
Block a user