Offer Semuta on printed Emperor-share cancellation and repair stale unit tests

This commit is contained in:
Quintine committed 2026-10-12 14:46:09 +11:00
1 parent 63e5f22607
commit 308797567e
12 files changed
+319 -28

No files matched your search

+35 -8
View File
@@ -1344,7 +1344,7 @@ export type Game = {
stateSignature: string;
}
| {
kind: 'karamaCharityDiscard' | 'karamaInflationDiscard' | 'karamaBgCharityDiscard' | 'karamaBattleDiscard' | 'karamaChoamWorthlessDiscard';
kind: 'karamaCharityDiscard' | 'karamaInflationDiscard' | 'karamaBgCharityDiscard' | 'karamaBattleDiscard' | 'karamaChoamWorthlessDiscard' | 'karamaEmperorShareDiscard';
player: string;
card: string;
use: Extract<KaramaUse, { kind: 'cancel' }>;
@@ -5161,13 +5161,25 @@ function semutaChoamKaramaResponse(g: Game, response: ResponseWindow): boolean {
return !movement || (!movement.source && !movement.ornithopterEvent &&
!movement.ornithopterRange && !movement.discoveryFlight);
}
/** Emperor gift/revival cancellation is a clean public cost with no competing parent. */
function semutaEmperorShareKaramaResponse(g: Game, response: ResponseWindow): boolean {
if (response.kind !== 'emperorGift' && response.kind !== 'emperorRevival') return false;
const emperor = getPlayer(g, response.owner), recipient = response.recipient
? g.players.find(p => p.id === response.recipient) : null;
return !!emperor && !!recipient && emperor.faction === 'emperor' &&
emperor.id !== recipient.id && emperor.ally === recipient.id &&
recipient.ally === emperor.id && Number.isSafeInteger(response.amount) &&
response.amount! > 0 && (response.elite === undefined || response.elite === 0 || response.elite === 1) &&
!g.battle && !g.pendingShipment && !g.pendingGuildTransport;
}
type KaramaResponseDiscardContinuation = Extract<
NonNullable<Game['pendingTreacheryDiscard']>['continuation'],
{ kind: 'karamaCharityDiscard' | 'karamaInflationDiscard' | 'karamaBgCharityDiscard' | 'karamaBattleDiscard' | 'karamaChoamWorthlessDiscard' }
{ kind: 'karamaCharityDiscard' | 'karamaInflationDiscard' | 'karamaBgCharityDiscard' | 'karamaBattleDiscard' | 'karamaChoamWorthlessDiscard' | 'karamaEmperorShareDiscard' }
>;
function karamaResponseDiscardSignature(g: Game, c: KaramaResponseDiscardContinuation) {
const battle = c.kind === 'karamaBattleDiscard';
const worthless = c.kind === 'karamaChoamWorthlessDiscard';
const emperorShare = c.kind === 'karamaEmperorShareDiscard';
return JSON.stringify({
player: c.player, card: c.card, use: c.use,
parent: nullentropyParentSignature(g, c.resume,
@@ -5191,6 +5203,9 @@ function karamaResponseDiscardSignature(g: Game, c: KaramaResponseDiscardContinu
revival: g.pendingRevival, storm: g.stormResolution,
mentat: g.choamMentatPending, nexus: g.nexusChoamHistory?.at(-1),
} : undefined,
emperorShare: emperorShare ? {
response: g.response, emperorExtra: g.emperorExtra,
} : undefined,
order: g.order,
players: g.players.map(p => ({
id: p.id, faction: p.faction, ally: p.ally,
@@ -5959,7 +5974,8 @@ function treacheryDiscardIntegrity(g: Game) {
continuation?.kind === 'karamaInflationDiscard' ||
continuation?.kind === 'karamaBgCharityDiscard' ||
continuation?.kind === 'karamaBattleDiscard' ||
continuation?.kind === 'karamaChoamWorthlessDiscard') {
continuation?.kind === 'karamaChoamWorthlessDiscard' ||
continuation?.kind === 'karamaEmperorShareDiscard') {
const c = continuation, entry = batch.entries[0];
requireRule(
!g.response &&
@@ -5977,7 +5993,9 @@ function treacheryDiscardIntegrity(g: Game) {
(c.kind === 'karamaBattleDiscard' && g.phase === 6 && !g.battle &&
semutaBattleKaramaResponse(g, c.use.response)) ||
(c.kind === 'karamaChoamWorthlessDiscard' &&
semutaChoamKaramaResponse(g, c.use.response))) &&
semutaChoamKaramaResponse(g, c.use.response)) ||
(c.kind === 'karamaEmperorShareDiscard' &&
semutaEmperorShareKaramaResponse(g, c.use.response))) &&
c.use.response.owner !== c.player &&
c.resume.response?.kind === c.use.response.kind &&
JSON.stringify(c.resume.response) === JSON.stringify(c.use.response) &&
@@ -6802,6 +6820,7 @@ function semutaOfferSupported(
continuation.kind !== 'karamaBgCharityDiscard' &&
continuation.kind !== 'karamaBattleDiscard' &&
continuation.kind !== 'karamaChoamWorthlessDiscard' &&
continuation.kind !== 'karamaEmperorShareDiscard' &&
continuation.kind !== 'karamaPurchaseDiscard' &&
continuation.kind !== 'karamaPaymentDiscard' &&
continuation.kind !== 'thumperDiscard' &&
@@ -6882,12 +6901,15 @@ function semutaOfferSupported(
continuation.kind === 'karamaInflationDiscard' ||
continuation.kind === 'karamaBgCharityDiscard' ||
continuation.kind === 'karamaBattleDiscard' ||
continuation.kind === 'karamaChoamWorthlessDiscard'
continuation.kind === 'karamaChoamWorthlessDiscard' ||
continuation.kind === 'karamaEmperorShareDiscard'
? (continuation.kind === 'karamaBattleDiscard'
? semutaBattleKaramaResponse(g, continuation.use.response)
: continuation.kind === 'karamaChoamWorthlessDiscard'
? semutaChoamKaramaResponse(g, continuation.use.response)
: ['choamCharity', 'choamInflation', 'bgCharity'].includes(continuation.resume.response?.kind ?? '')) &&
: continuation.kind === 'karamaEmperorShareDiscard'
? semutaEmperorShareKaramaResponse(g, continuation.use.response)
: ['choamCharity', 'choamInflation', 'bgCharity'].includes(continuation.resume.response?.kind ?? '')) &&
!continuation.resume.decision && !continuation.resume.pendingKarama &&
!continuation.resume.phaseOpening && !g.pendingKarama &&
(!g.response || JSON.stringify(g.response) === JSON.stringify(continuation.resume.response))
@@ -6910,6 +6932,7 @@ function semutaOfferSupported(
continuation.kind === 'karamaBgCharityDiscard' ||
continuation.kind === 'karamaBattleDiscard' ||
continuation.kind === 'karamaChoamWorthlessDiscard' ||
continuation.kind === 'karamaEmperorShareDiscard' ||
(!continuation.resume.response && !continuation.resume.decision &&
!continuation.resume.pendingKarama &&
(continuation.kind === 'amalDiscard'
@@ -7175,6 +7198,7 @@ function finishTreacheryDiscard(g: Game, claim?: { player: string; card: string
next.kind === 'karamaBgCharityDiscard' ||
next.kind === 'karamaBattleDiscard' ||
next.kind === 'karamaChoamWorthlessDiscard' ||
next.kind === 'karamaEmperorShareDiscard' ||
next.kind === 'karamaPurchaseDiscard' ||
next.kind === 'karamaPaymentDiscard') {
g.response = next.resume.response;
@@ -13388,14 +13412,17 @@ function spendKarama(g: Game, p: Player, card: Card, use: KaramaUse, kullOffered
(use.response.kind === 'choamCharity' ||
use.response.kind === 'choamInflation' ||
use.response.kind === 'bgCharity' || semutaBattleKaramaResponse(g, use.response) ||
semutaChoamKaramaResponse(g, use.response))) {
semutaChoamKaramaResponse(g, use.response) ||
semutaEmperorShareKaramaResponse(g, use.response))) {
const continuation: KaramaResponseDiscardContinuation = {
kind: use.response.kind === 'choamCharity'
? 'karamaCharityDiscard'
: use.response.kind === 'choamInflation'
? 'karamaInflationDiscard'
: use.response.kind === 'bgCharity' ? 'karamaBgCharityDiscard'
: use.response.kind === 'choamWorthless' ? 'karamaChoamWorthlessDiscard' : 'karamaBattleDiscard',
: use.response.kind === 'choamWorthless' ? 'karamaChoamWorthlessDiscard'
: use.response.kind === 'emperorGift' || use.response.kind === 'emperorRevival'
? 'karamaEmperorShareDiscard' : 'karamaBattleDiscard',
player: p.id, card: used.id, use,
resume: { response: g.response, decision: g.decision,
pendingKarama: g.pendingKarama, phaseOpening: g.phaseOpening },
+2
View File
@@ -1184,6 +1184,7 @@ export const RULE_TOPICS: RuleTopic[] = [
'The fresh semuta --nexus-cards entry retains original native E1/E2 Nexus setup, optionally explicit Skills and original Tech/Advanced Strongholds. There is no starting Nexus hand: an actual qualifying closing draw follows a Nexus and settled alliance. CHOAM Secret Ally with CHOAM absent spends a Worthless and its Nexus for two bank spice before the public discard offer; CHOAM Betrayal with CHOAM seated commits one random actual hand-card discard without compensation before its private offer. Claim or Continue retires the original receipt once, without another payment or sample. Separate Nexus cards never become Treachery targets. Homeworlds, Discovery, E3, played-save conversion and public starts stay gated.',
'The same original native Nexus entry offers the actual CHOAM Cunning fuel discard for Kulon, Gamont, Baliset, La La La and Jubba. Any eligible held Treachery card keeps its printed identity and private face; there is no fabricated named Worthless. Original cancellation retains fuel and the spent Nexus. After allowance, Commit or Continue resumes the selected effect and parent once: one range bonus, one typed force return and original closing owner, stopped ordinary movement/free revival, or one threatened-territory storm protection. Jubba protects CHOAM forces, not spice; unprotected forces and covered spice still suffer the original storm. Kull retains its separate guard.',
'A distinct printed Karama canceling those five ordinary native CHOAM printed or Cunning powers also offers its public cost before the original denial completes. CHOAM retains the declared fuel; a Cunning Nexus remains spent. Claim or Continue restores the same saved response and one original movement, free-revival, storm or closing-Mentat suffix. Acquiring Karama cannot return the canceled force, grant range, stop the original request, protect the storm or restore Nexus. The retained CHOAM fuel is not a discard candidate; Kull and unsupported arrival/flight parents remain separate.',
'A printed Karama canceling the Emperor’s shared gift or extra allied revival also offers that exact public cost before the denial completes. The canceled share moves no spice, forces or revival; the Emperor’s ally and extra-revival ledger are unchanged. Claim or Continue restores the saved response and finishes the cancellation once. Only the actual Karama holder sees the private claimant choice; other seats see the neutral offer.',
'An ordinary Ghola played during battle also offers its consumed card after revival. Claim or Continue preserves the revived leader or forces and the opposing sealed plan, then normal planning resumes. It cannot revive again by resuming the receipt.',
'A completed paid Nullentropy Box search during battle offers only the used Box. Claim or Continue preserves the two-spice payment, private recovered card, already-shuffled pile and sealed opposing plan. The recovered card may be used in normal legal planning; the search is not repeated.',
'A clean Distrans transfer during battle also offers only the used Distrans. The private card has already reached its recipient; claim or Continue cannot repeat the gift or change a sealed plan. A recipient holding Semuta may claim the used Distrans and keep the already-transferred card.',
@@ -1251,6 +1252,7 @@ export const RULE_TOPICS: RuleTopic[] = [
'tests/semuta-nexus-cunning-proactive.test.ts',
'tests/semuta-nexus-cunning-reactive.test.ts',
'tests/semuta-choam-karama.test.ts',
'tests/semuta-emperor-share.test.ts',
],
},
],