import assert from 'node:assert/strict'; import test from 'node:test'; import { createGame, joinGame, newPlayer, type Game } from '../game/engine'; import { knowledgeFactAnswer, truthKnowledgeOf } from '../game/truthtrance-knowledge'; import { originalAuctionInspectionLot } from '../game/auction-inspection-source'; function fixture(): Game { const game = createGame('SHAREDPEEK', newPlayer('at', 'Atreides', 'atreides'), true, ['choam']); joinGame(game, newPlayer('occ', 'Occupier', 'guild')); joinGame(game, newPlayer('other', 'Other', 'emperor')); joinGame(game, newPlayer('seller', 'Richese', 'richese')); game.status = 'playing'; game.turn = 2; game.phase = 3; game.homeworldOccupationPreview = true; game.auction = { cards:[{id:'lot-card', name:'Shield', kind:'shield'}], index:0, occupiedEvent:'normal-event', bid:0, bidder:null, active:'occ', passed:[], opener:0, peekKnown:false }; game.homeworldAuctionInspection = {lot:originalAuctionInspectionLot(game)!, audience:['at','occ'], native:'at', occupation:'public-qualification', occupiedKnown:true}; return game; } function answer(game: Game, actor: string) { const seat = game.players.find(player => player.id === actor); assert.ok(seat); return knowledgeFactAnswer({kind:'auctionPeek', name:'Shield'}, truthKnowledgeOf(game, seat)); } void test('Caladan share binds the current ordinary lot and is independent of native denial', () => { const game = fixture(); assert.equal(answer(game,'occ'),'yes'); assert.equal(answer(game,'at'),'unknown'); assert.equal(answer(game,'other'),'unknown'); game.auction!.peekKnown = true; assert.equal(answer(game,'at'),'yes'); game.homeworldAuctionInspection!.occupiedKnown = false; assert.equal(answer(game,'occ'),'unknown'); assert.equal(answer(game,'at'),'yes'); }); void test('stale, foreign and expired ordinary lot receipts never grant knowledge', () => { const game = fixture(); game.homeworldAuctionInspection!.audience = ['at','other']; assert.equal(answer(game,'occ'),'unknown'); game.homeworldAuctionInspection!.audience = ['at','occ']; game.auction!.occupiedEvent = 'new-event'; assert.equal(answer(game,'occ'),'unknown'); game.auction!.occupiedEvent = 'normal-event'; game.phase = 4; assert.equal(answer(game,'occ'),'unknown'); game.phase = 3; delete game.homeworldOccupationPreview; assert.equal(answer(game,'occ'),'unknown'); }); void test('Black Market shared inspection binds its original event and current physical face', () => { const game = fixture(), card = game.auction!.cards[0]; game.auction = null; game.players.find(player => player.id === 'seller')!.hand.push(card); game.richeseAuction = {event:'black-one', cardId:card.id, source:'blackMarket', owner:'seller', method:'silent', eligible:['occ'], order:['occ'], tieOrder:['occ'], active:'occ', bid:0, bidder:null, passed:[], acted:[], sealed:{}, outcome:null}; game.richesePeekKnown = false; game.homeworldAuctionInspection!.lot = 'black-one'; assert.equal(answer(game,'occ'),'yes'); assert.equal(answer(game,'at'),'unknown'); assert.equal(answer(game,'other'),'unknown'); game.richeseAuction.event = 'black-two'; assert.equal(answer(game,'occ'),'unknown', 'the same card in a new lot does not reuse a receipt'); game.richeseAuction.event = 'black-one'; game.richeseAuction.outcome = {kind:'unbid'}; assert.equal(answer(game,'occ'),'unknown'); });