diff --git a/docs/game/ENGINE_API.md b/docs/game/ENGINE_API.md index 19325b3..dfbbbe2 100644 --- a/docs/game/ENGINE_API.md +++ b/docs/game/ENGINE_API.md @@ -169,7 +169,7 @@ interface CardInPlay { card: GameCard; owner: 0 | 1; lane: number; turn: number; interface PlayerView { you: 0 | 1; ruleset; turn; phase; initiative; energy: number; energyLeft: number; hand: GameCard[]; queue: { cardId; lane }[]; committed; deckCount; - opponent: { handCount; deckCount; queuedCount; committed }; // never their cards or queue + opponent: { handCount; deckCount; committed }; // §5.3: nothing about their queue (cards, count or energy) until reveal lanes: { topic: TopicDef /* stat always; id/name/portal masked until portalRevealed */, portalRevealed, cards: [mine, theirs], cardPower: [number[], number[]], power: [mine, theirs], leader: 'you' | 'opponent' | null }[]; result: MatchResult | null; diff --git a/shared/game/engine.ts b/shared/game/engine.ts index 67d8616..2d0d7da 100644 --- a/shared/game/engine.ts +++ b/shared/game/engine.ts @@ -399,7 +399,7 @@ export function viewFor(state: MatchState, you: PlayerId): PlayerView { you, ruleset: state.ruleset, turn: state.turn, phase: state.phase, initiative: state.initiative, energy: me.energy, energyLeft: me.energy - queuedCost(me), hand: me.hand, queue: me.queue, committed: me.committed, deckCount: me.deck.length, - opponent: { handCount: opp.hand.length - opp.queue.length, deckCount: opp.deck.length, queuedCount: opp.queue.length, committed: opp.committed }, + opponent: { handCount: opp.hand.length, deckCount: opp.deck.length, committed: opp.committed }, lanes: state.lanes.map((lane, index) => { const power = lanePower(state, index); const mine = power[you], theirs = power[them]; diff --git a/shared/game/types.ts b/shared/game/types.ts index 1fe5994..ba67879 100644 --- a/shared/game/types.ts +++ b/shared/game/types.ts @@ -208,7 +208,11 @@ export interface PlayerView { queue: QueuedPlay[]; committed: boolean; deckCount: number; - opponent: { handCount: number; deckCount: number; queuedCount: number; committed: boolean }; + /** + * DESIGN §5.3: planning is hidden. handCount still counts queued cards and no + * opponent energy is exposed, so nothing changes while they queue; only `committed` does. + */ + opponent: { handCount: number; deckCount: number; committed: boolean }; lanes: { /** Always visible; `portal` is null until the Portal is revealed. */ topic: TopicDef; diff --git a/tests/game-core.test.ts b/tests/game-core.test.ts index 05a2c81..9e02239 100644 --- a/tests/game-core.test.ts +++ b/tests/game-core.test.ts @@ -88,7 +88,6 @@ test('queued plays are hidden until reveal; undo refunds; committed seats get no assert.ok(play, 'turn 1 should have a 1-cost play'); state = applyAction(state, play); assert.equal(viewFor(state, 0).energyLeft, 0); - assert.equal(viewFor(state, 1).opponent.queuedCount, 1); assert.equal(JSON.stringify(viewFor(state, 1)).includes(`"${play.cardId}"`), false); assert.equal(viewFor(applyAction(state, { type: 'undo', player: 0, cardId: play.cardId }), 0).energyLeft, 1); state = commit(state, 0); @@ -111,6 +110,30 @@ test('viewFor never leaks the opponent hand, deck order, queue, seed or RNG stat assert.deepEqual(view.hand.map(c => c.cardId), state.players[0].hand.map(c => c.cardId)); }); +test('planning is hidden: the opponent view is identical before and after queuing, until commit', () => { + for (let seed = 0; seed < 10; seed++) { + let state = createMatch(DEFAULT_RULESET, decks(`plan-${seed}`), seed); + for (let turn = 0; turn < 4 && !isOver(state); turn++) { + const before = JSON.stringify(viewFor(state, 1)); + let queued = 0; + for (;;) { + const play = legalActions(state, 0).find(a => a.type === 'play'); + if (!play) break; + state = applyAction(state, play); + queued++; + assert.equal(JSON.stringify(viewFor(state, 1)), before, `seed ${seed} turn ${state.turn}: view changed after ${queued} queued`); + } + if (queued) { + const undo = legalActions(state, 0).find(a => a.type === 'undo')!; + assert.equal(JSON.stringify(viewFor(applyAction(state, undo), 1)), before, 'undo must not show either'); + } + state = commit(state, 0); + assert.equal(viewFor(state, 1).opponent.committed, true); + state = commit(state, 1); + } + } +}); + test('energy: energyByTurn + carry (max 1) of unspent energy', () => { let state = createMatch(DEFAULT_RULESET, [flatDeck(1, 'a'), flatDeck(1, 'b')], 3); const first = state.players[0].hand[0].cardId;