Protect reserved Richese lot during Harkonnen exchange
Verify and publish checkpoint container / container (push) Canceled after 0s
Verify and publish checkpoint container / container (push) Canceled after 0s
This commit is contained in:
1 parent
88240e2cea
commit
2660b10af0
7 files changed
+274
-3
No files matched your search
@@ -6408,6 +6408,9 @@ export function GameTable({
|
||||
Once per game: take up to four unseen cards, inspect
|
||||
them, then return the same number.
|
||||
</p>
|
||||
{g.richeseAuction?.harkonnenExchangeBlocked && (
|
||||
<p className="muted">Finish the Black Market lot before exchanging its seller’s hand.</p>
|
||||
)}
|
||||
<label>
|
||||
Choose a player
|
||||
<select
|
||||
@@ -6418,7 +6421,8 @@ export function GameTable({
|
||||
{g.players
|
||||
.filter(
|
||||
(p) =>
|
||||
p.id !== me.id && (p.handCount ?? 0) > 0,
|
||||
p.id !== me.id && (p.handCount ?? 0) > 0 &&
|
||||
!(g.richeseAuction?.harkonnenExchangeBlocked && g.richeseAuction.owner === p.id),
|
||||
)
|
||||
.map((p) => (
|
||||
<option key={p.id} value={p.id}>
|
||||
@@ -6450,7 +6454,7 @@ export function GameTable({
|
||||
target,
|
||||
amount,
|
||||
},
|
||||
!target,
|
||||
!target || !!(g.richeseAuction?.harkonnenExchangeBlocked && g.richeseAuction.owner === target),
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -17,6 +17,19 @@ open mode gates.
|
||||
|
||||
## Current checkpoint and work
|
||||
|
||||
**Harkonnen special at a Richese Black Market lot — 16 November. Prototyped /
|
||||
Partial.** While the seller's physical card is reserved for an unsettled lot,
|
||||
Harkonnen waits until settlement before exchanging that hand. Other hands remain
|
||||
eligible; the table and bots use the public lot condition. Five focused files
|
||||
pass 23 cases, including all four bot levels; the production build passes.
|
||||
This is a provisional
|
||||
timing interpretation, and wider interactions and deployed acceptance remain
|
||||
open. The related test selection also exposed seven failures in
|
||||
`nexus-richese-engine.test.ts`; the same seven fail at the preceding commit
|
||||
`88240e2` (six Charity phase checks and one Homeworld income-ledger check).
|
||||
Whether they indicate stale fixtures or runtime defects remains uninvestigated.
|
||||
[Scope](HARKONNEN_EXCHANGE.md#reserved-black-market-lot--16-november-2026).
|
||||
|
||||
**Advanced Ecaz Duke revival with Harkonnen — 16 November. Prototyped /
|
||||
Partial.** At supported plain Advanced Ecaz/Harkonnen tables, Ecaz can revive
|
||||
a publicly dead Duke normally or with Ghola. A secret execution under another
|
||||
|
||||
@@ -35,6 +35,23 @@ repeat the return, spend a second Karama or consume the power twice.
|
||||
|
||||
## Authority and limits
|
||||
|
||||
### Reserved Black Market lot — 16 November 2026
|
||||
|
||||
During an unsettled Richese Black Market auction, the seller's offered card
|
||||
remains physically in their hand and is reserved for the lot. The Advanced
|
||||
Harkonnen special cannot target that seller until the lot is settled; it may
|
||||
still target another eligible hand. The table and bot use the same public
|
||||
auction condition, regardless of the concealed card's identity. This ordering
|
||||
is a provisional online priority for an otherwise unspecified interruption,
|
||||
not a claim that the publisher explicitly resolved the combination. Other
|
||||
auction interactions and full expansion acceptance remain open.
|
||||
|
||||
The focused `harkonnen-special-reserved-market` regression exercises all three
|
||||
auction methods, the initial response and bidding, and an unrelated exchange
|
||||
followed by a real sale. `duke-ambassador-advanced-harkonnen` separately
|
||||
exercises the Tleilaxu Ambassador's publicly dead Duke revival in a genuine
|
||||
Advanced setup with Harkonnen seated.
|
||||
|
||||
This composes the existing contract recorded under **Emperor and Harkonnen
|
||||
special Karama checkpoint** in [implementation history](IMPLEMENTATION_STATUS.md):
|
||||
GF9 base rules page 14; November 2020 FAQ page 3 (phase and once-per-game limit)
|
||||
|
||||
+2
-1
@@ -1717,7 +1717,8 @@ function policyActions(g: GameView): Action[] {
|
||||
}
|
||||
if (specialCard && me.faction === 'harkonnen' && g.phase === 3) {
|
||||
const victim = g.players
|
||||
.filter((p) => p.id !== me.id && (p.handCount ?? 0) > 0)
|
||||
.filter((p) => p.id !== me.id && (p.handCount ?? 0) > 0 &&
|
||||
!(g.richeseAuction?.harkonnenExchangeBlocked && g.richeseAuction.owner === p.id))
|
||||
.sort(
|
||||
(a, b) =>
|
||||
(b.ally === me.id ? -10 : 0) +
|
||||
|
||||
@@ -43238,6 +43238,11 @@ export function prepareSpecialKaramaIntent(
|
||||
g.pendingRicheseGift?.intent.owner !== target.id,
|
||||
'Resolve the reserved Richese gift before randomly exchanging that hand.',
|
||||
);
|
||||
requireRule(
|
||||
!(g.richeseAuction?.source === 'blackMarket' && !g.currentAuctionSale &&
|
||||
g.richeseAuction.owner === target.id),
|
||||
'Finish the Black Market lot before exchanging its seller’s hand.',
|
||||
);
|
||||
const count = integer(
|
||||
action.amount,
|
||||
1,
|
||||
@@ -50815,6 +50820,8 @@ export function viewGame(state: Game, id: string, now?: number) {
|
||||
richeseAuction: g.richeseAuction
|
||||
? {
|
||||
...projectRicheseAuction(g.richeseAuction, id),
|
||||
...(g.richeseAuction.source === 'blackMarket' && !g.currentAuctionSale
|
||||
? { harkonnenExchangeBlocked: true as const } : {}),
|
||||
card:
|
||||
g.richeseAuction.source === 'cache' ||
|
||||
g.richeseAuction.owner === id ||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createGame, joinGame, newPlayer, viewGame, type Game } from '../game/engine';
|
||||
import { ambassadorPlacementDestinations } from '../game/ecaz-ambassador-placement';
|
||||
import { validateAmbassadors } from '../game/ecaz-ambassadors';
|
||||
import { DUKE_VIDAL_ID } from '../game/duke-vidal';
|
||||
import { botActions } from '../game/bots';
|
||||
import { DIFFICULTIES } from '../game/bot-profiles';
|
||||
import { actDukeAmbassador as act, advanceDukeAmbassador as advance,
|
||||
dukeAmbassadorClean as clean, dukeAmbassadorPlayer as player } from './fixture-duke-ambassador';
|
||||
|
||||
const cards = (game: Game) => [...game.deck, ...game.discard, ...game.players.flatMap(p => p.hand)]
|
||||
.map(card => card.id).sort();
|
||||
const balances = (game: Game) => game.players.map(p => ({ id: p.id, spice: p.spice,
|
||||
reserves: p.reserves, tanks: p.tanks, forces: p.forces, hand: p.hand,
|
||||
revived: p.revived, freeForcesRevived: p.freeForcesRevived, leaderRevived: p.leaderRevived,
|
||||
ecazRevivalCohort: p.ecazRevivalCohort }));
|
||||
|
||||
/** Genuine Advanced setup and Ambassador placement/entry. The selected packet
|
||||
* token and public Duke death are explicitly staged for this focused path. */
|
||||
function nativeAdvancedGrant() {
|
||||
let game = createGame('ADVANCEDDUKEAMBASSADOR', newPlayer('ecaz', 'Ecaz', 'ecaz'), true, ['ecaz']);
|
||||
for (const faction of ['harkonnen', 'guild'] as const) joinGame(game, newPlayer(faction, faction, faction));
|
||||
for (const p of game.players) game = act(game, p.id, { type: 'ready' });
|
||||
game = act(game, 'ecaz', { type: 'start', advancedPreview: true });
|
||||
game = advance(game, state => state.status === 'playing');
|
||||
const originalCards = cards(game);
|
||||
for (const position of [0, 1]) {
|
||||
const index = game.spiceDeck.findIndex((card, i) => i >= position && 'territory' in card && !card.discovery);
|
||||
assert.ok(index >= position);
|
||||
[game.spiceDeck[position], game.spiceDeck[index]] = [game.spiceDeck[index], game.spiceDeck[position]];
|
||||
}
|
||||
game = advance(game, state => state.turn === 1 && state.phase === 4 && !state.response &&
|
||||
!state.phaseOpening && state.decision?.kind === 'ecazPlacement');
|
||||
const ambassadors = game.ecazAmbassadors!;
|
||||
const originalTokens = ambassadors.tokens.map(token => token.id).sort();
|
||||
const token = ambassadors.tokens.find(row => row.effect === 'tleilaxu'); assert.ok(token);
|
||||
// Select the actual Tleilaxu disc in the original five-token packet, swapping
|
||||
// custody with one unplaced selected disc rather than creating a marker.
|
||||
if (token.zone === 'pool') {
|
||||
const replaced = ambassadors.tokens.find(row => row.zone === 'supply' && row.effect !== 'ecaz');
|
||||
assert.ok(replaced);
|
||||
const index = ambassadors.cohort.indexOf(replaced.id); assert.ok(index >= 0);
|
||||
ambassadors.cohort[index] = token.id;
|
||||
replaced.zone = 'pool'; token.zone = 'supply';
|
||||
}
|
||||
validateAmbassadors(ambassadors);
|
||||
const destinations = ambassadorPlacementDestinations(game);
|
||||
const candidate = [
|
||||
{ territory: 'habbanya_ridge_sietch', sector: 17 },
|
||||
{ territory: 'sietch_tabr', sector: 14 },
|
||||
{ territory: 'arrakeen', sector: 10 },
|
||||
].find(row => destinations.some(destination => destination.id === row.territory));
|
||||
assert.ok(candidate);
|
||||
game = act(game, 'ecaz', { type: 'decision', token: token.id, territory: candidate.territory });
|
||||
game = advance(game, state => !state.response && state.decision?.kind === 'ecazPlacement');
|
||||
assert.equal(game.ecazAmbassadors!.tokens.find(row => row.id === token.id)!.zone, 'placed');
|
||||
game = act(game, 'ecaz', { type: 'decision', decline: true });
|
||||
game = advance(game, state => state.turn === 1 && state.phase === 5 && state.active === 'guild' && clean(state));
|
||||
assert.ok(game.dukeVidal); assert.equal(game.dukeVidal.controller, null);
|
||||
assert.equal(game.dukeVidal.leader.dead, false);
|
||||
// Stage a publicly dead shared disc, after ordinary Revival has concluded.
|
||||
game.dukeVidal.leader.dead = true;
|
||||
game.dukeVidal.leader.deaths = 1;
|
||||
game = act(game, 'guild', { type: 'ship', amount: 1, territory: candidate.territory, sector: candidate.sector });
|
||||
game = advance(game, state => !state.response && state.pendingAmbassador?.stage === 'offer');
|
||||
assert.equal(game.pendingAmbassador!.token, token.id);
|
||||
const event = game.pendingAmbassador!.event;
|
||||
game = act(game, 'ecaz', { type: 'decision', event, trigger: true, beneficiary: 'ecaz', choice: 'effect' });
|
||||
assert.equal(game.pendingAmbassador?.stage, 'revival');
|
||||
return { game, event, token: token.id, originalTokens, originalCards, candidate };
|
||||
}
|
||||
|
||||
void test('Advanced Tleilaxu entry returns the public Duke with Harkonnen seated and preserves custody and ordinary allowance', () => {
|
||||
const { game, event, token, originalTokens, originalCards, candidate } = nativeAdvancedGrant();
|
||||
assert.equal(game.advanced, true); assert.deepEqual(game.expansions, ['ecaz']);
|
||||
assert.equal(player(game, 'ecaz').tanks, 0);
|
||||
assert.ok(player(game, 'ecaz').leaders.every(leader => !leader.dead));
|
||||
assert.deepEqual(viewGame(game, 'ecaz').ambassadorEntry!.revival!.leaders.map(leader => leader.id), [DUKE_VIDAL_ID]);
|
||||
assert.equal(viewGame(game, 'guild').ambassadorEntry!.revival, null);
|
||||
const done = act(game, 'ecaz', { type: 'decision', event, leader: DUKE_VIDAL_ID });
|
||||
assert.deepEqual(balances(done), balances(game));
|
||||
assert.equal(done.dukeVidal!.leader.dead, false); assert.equal(done.dukeVidal!.leader.deaths, 1);
|
||||
assert.equal(done.dukeVidal!.controller, null);
|
||||
assert.ok(done.players.every(p => p.leaders.every(leader => leader.id !== DUKE_VIDAL_ID)));
|
||||
assert.deepEqual(done.ecazAmbassadors!.tokens.map(row => row.id).sort(), originalTokens);
|
||||
assert.equal(done.ecazAmbassadors!.tokens.find(row => row.id === token)!.zone, 'used');
|
||||
validateAmbassadors(done.ecazAmbassadors!);
|
||||
assert.deepEqual(cards(done), originalCards);
|
||||
assert.equal(done.pendingAmbassador, null); assert.equal(done.active, 'guild');
|
||||
assert.equal(player(done, 'guild').forces[`${candidate.territory}:${candidate.sector}`], 1);
|
||||
const ended = act(done, 'guild', { type: 'endMovement' });
|
||||
assert.equal(ended.movementRemaining?.includes('guild') ?? false, false);
|
||||
|
||||
for (const difficulty of DIFFICULTIES) {
|
||||
const view = viewGame(game, 'ecaz'); view.players.find(p => p.id === 'ecaz')!.bot = difficulty;
|
||||
const action = botActions(view)[0]; assert.equal(action.leader, DUKE_VIDAL_ID, difficulty);
|
||||
const resumed = act(game, 'ecaz', action);
|
||||
assert.equal(resumed.dukeVidal!.leader.dead, false); assert.equal(resumed.dukeVidal!.controller, null);
|
||||
assert.equal(resumed.pendingAmbassador, null); assert.equal(resumed.active, 'guild');
|
||||
assert.deepEqual(balances(resumed), balances(game));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,126 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
applyAction, createGame, newPlayer, viewGame, type Action, type Game,
|
||||
} from '../game/engine';
|
||||
import { baseDeck } from '../game/cards';
|
||||
import { richeseCards } from '../game/richese-cards';
|
||||
import type { RicheseAuctionMethod } from '../game/richese-auction';
|
||||
import { botActions } from '../game/bots';
|
||||
import { DIFFICULTIES } from '../game/bot-profiles';
|
||||
|
||||
const seat = (g: Game, id: string) => g.players.find(p => p.id === id)!;
|
||||
const physical = (g: Game) => [
|
||||
...g.deck, ...g.discard, ...g.players.flatMap(p => p.hand),
|
||||
...(g.richeseCache ?? []), ...(g.richeseRemoved ?? []),
|
||||
...(g.auction?.cards.slice(g.auction.index) ?? []),
|
||||
].map(c => c.id).sort();
|
||||
function act(g: Game, id: string, action: Action) {
|
||||
const before = structuredClone(g), inventory = physical(g);
|
||||
const next = applyAction(g, id, action);
|
||||
assert.deepEqual(g, before);
|
||||
assert.deepEqual(physical(next), inventory);
|
||||
assert.equal(new Set(inventory).size, inventory.length);
|
||||
return next;
|
||||
}
|
||||
function hold(g: Game, id: string, predicate: (card: Game['deck'][number]) => boolean) {
|
||||
const index = g.deck.findIndex(predicate);
|
||||
assert.ok(index >= 0);
|
||||
const card = g.deck.splice(index, 1)[0];
|
||||
seat(g, id).hand.push(card);
|
||||
return card.id;
|
||||
}
|
||||
/** Conserved staged Advanced Spice Blow position; all auction actions below are native. */
|
||||
function offered(method: RicheseAuctionMethod, extraSellerCard: boolean) {
|
||||
let g = createGame('RESERVED', newPlayer('r', 'Richese', 'richese'));
|
||||
g.players.push(newPlayer('h', 'Harkonnen', 'harkonnen'), newPlayer('e', 'Emperor', 'emperor'));
|
||||
Object.assign(g, { status: 'playing', phase: 2, turn: 2, advanced: true,
|
||||
order: ['e', 'h', 'r'], active: null, ready: [], deck: baseDeck(), richeseCache: richeseCards() });
|
||||
for (const p of g.players) Object.assign(p, { hand: [], spice: 20, forces: {}, traitors: [] });
|
||||
const reserved = hold(g, 'r', card => card.kind === 'shield');
|
||||
if (extraSellerCard) hold(g, 'r', card => card.kind === 'snooper');
|
||||
const karama = hold(g, 'h', card => card.effect === 'karama');
|
||||
const unrelated = hold(g, 'e', card => card.kind === 'projectile');
|
||||
for (const id of g.order) g = act(g, id, { type: 'ready' });
|
||||
assert.equal(g.decision?.kind, 'richeseBlackMarket');
|
||||
g = act(g, 'r', { type: 'decision', event: g.richeseBidding!.event,
|
||||
card: reserved, method, direction: 'clockwise', claim: 'A card' });
|
||||
assert.equal(g.richeseAuction?.source, 'blackMarket');
|
||||
assert.equal(g.richeseAuction?.cardId, reserved);
|
||||
return { g, reserved, karama, unrelated };
|
||||
}
|
||||
function special(card: string, target: string): Action {
|
||||
return { type: 'card', mode: 'special', card, target, amount: 1 };
|
||||
}
|
||||
function rejectSeller(g: Game, karama: string, reserved: string) {
|
||||
const before = structuredClone(g), inventory = physical(g);
|
||||
assert.throws(() => applyAction(g, 'h', special(karama, 'r')), /black market|reserved|lot/i);
|
||||
assert.deepEqual(g, before, 'Rejected special Karama leaves the complete original auction untouched.');
|
||||
assert.deepEqual(physical(g), inventory);
|
||||
assert.ok(seat(g, 'r').hand.some(card => card.id === reserved));
|
||||
assert.ok(seat(g, 'h').hand.some(card => card.id === karama));
|
||||
assert.notEqual(seat(g, 'h').specialKaramaUsed, true);
|
||||
}
|
||||
function passMarketResponse(g: Game) {
|
||||
for (const id of g.order)
|
||||
if (g.response?.kind === 'richeseBlackMarket' && !g.response.passed.includes(id))
|
||||
g = act(g, id, { type: 'passResponse' });
|
||||
assert.equal(g.response, null);
|
||||
return g;
|
||||
}
|
||||
|
||||
void test('Harkonnen cannot draw any card from a seller with a live reserved Black Market lot', () => {
|
||||
for (const method of ['normal', 'onceAround', 'silent'] as const) {
|
||||
for (const extraSellerCard of [false, true]) {
|
||||
const f = offered(method, extraSellerCard);
|
||||
rejectSeller(f.g, f.karama, f.reserved);
|
||||
const bidding = passMarketResponse(f.g);
|
||||
rejectSeller(bidding, f.karama, f.reserved);
|
||||
assert.deepEqual(bidding.richeseAuction, f.g.richeseAuction);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
void test('an unrelated exchange preserves the real Black Market auction and its reserved card through settlement', () => {
|
||||
const f = offered('silent', true);
|
||||
let g = passMarketResponse(f.g);
|
||||
const lot = structuredClone(g.richeseAuction);
|
||||
g = act(g, 'h', special(f.karama, 'e'));
|
||||
assert.equal(g.pendingExchange, null, 'The sole blind draw is automatically returned.');
|
||||
assert.deepEqual(g.richeseAuction, lot);
|
||||
assert.ok(seat(g, 'e').hand.some(card => card.id === f.unrelated));
|
||||
assert.ok(seat(g, 'r').hand.some(card => card.id === f.reserved));
|
||||
const event = g.richeseAuction!.event;
|
||||
const eligible = [...g.richeseAuction!.eligible];
|
||||
for (const id of eligible)
|
||||
g = act(g, id, { type: 'richeseBid', event, amount: id === 'e' ? 1 : 0, allyPayment: 0 });
|
||||
assert.equal(g.richeseAuction, null);
|
||||
assert.ok(seat(g, 'e').hand.some(card => card.id === f.reserved));
|
||||
assert.ok(!seat(g, 'r').hand.some(card => card.id === f.reserved));
|
||||
assert.equal(g.richeseBidding?.blackMarketSold, true);
|
||||
});
|
||||
|
||||
void test('the public lot flag guides all four Harkonnen bot levels to an eligible unrelated target', () => {
|
||||
const f = offered('silent', true);
|
||||
const g = passMarketResponse(f.g);
|
||||
const before = structuredClone(g);
|
||||
for (const viewer of ['r', 'h', 'e']) {
|
||||
const lot = viewGame(g, viewer).richeseAuction!;
|
||||
assert.equal(lot.owner, 'r');
|
||||
assert.equal(lot.harkonnenExchangeBlocked, true);
|
||||
if (viewer !== 'r') {
|
||||
assert.equal(lot.cardId, null);
|
||||
assert.equal(lot.card, null);
|
||||
}
|
||||
}
|
||||
for (const difficulty of DIFFICULTIES) {
|
||||
const view = viewGame(g, 'h');
|
||||
view.players.find(p => p.id === 'h')!.bot = difficulty;
|
||||
const actions = botActions(view);
|
||||
const exchange = actions.find(action => action.type === 'card' && action.mode === 'special');
|
||||
assert.ok(exchange, `${difficulty} should choose its available special exchange`);
|
||||
assert.equal(exchange.target, 'e', `${difficulty} must avoid the reserved seller`);
|
||||
assert.doesNotThrow(() => act(g, 'h', exchange));
|
||||
}
|
||||
assert.deepEqual(g, before);
|
||||
});
|
||||
Reference in new issue
Block a user