Allow Advanced Emperor gifts during Guild rate responses
Verify and publish checkpoint container / container (push) Successful in 11m3s
Verify and publish checkpoint container / container (push) Successful in 11m3s
This commit is contained in:
1 parent
b3843bf18e
commit
5e7f7b45e4
14 files changed
+475
-6
No files matched your search
@@ -4373,6 +4373,12 @@ function botAdvisorMatchingAllowed(g:GameView,action:Action) {
|
||||
} catch(error) { if(error instanceof AdvisorMatchingError) return false; throw error; }
|
||||
}
|
||||
export function botActions(g: GameView): Action[] {
|
||||
if (g.emperorGuildRatePriority) {
|
||||
const me = g.players.find(player => player.id === g.me);
|
||||
return (me?.bot || me?.autopilot) && g.emperorGuildRatePriority.canContinue &&
|
||||
g.status === 'playing' && !g.roomControl?.paused && !g.roomControl?.closed && !g.automaticContinuationPending
|
||||
? [{type:'emperorGuildRateContinue', event:g.emperorGuildRatePriority.event}] : [];
|
||||
}
|
||||
if (g.saphoStationPriority) {
|
||||
const own = g.players.find(player => player.id === g.me), priority = g.saphoStationPriority;
|
||||
return (own?.bot || own?.autopilot) && g.status === 'playing' && priority.canPass &&
|
||||
|
||||
+101
-2
@@ -1254,6 +1254,8 @@ type SpiceBankerIncomePayment = {
|
||||
};
|
||||
|
||||
export type ResponseWindow = {
|
||||
/** Original Guild-rate response parked while an allied gift is resolved. */
|
||||
emperorGuildRateGift?: { event: string; response: ResponseWindow; signature: string };
|
||||
/** The original public Guild timing decision remains live during this gift. */
|
||||
emperorGuildTimingGift?: { event: string; signature: string };
|
||||
/** The original Extortion payment decision remains live during this gift. */
|
||||
@@ -2396,6 +2398,7 @@ export type Game = {
|
||||
moritaniExtortion?: ExtortionState;
|
||||
/** Public release of the human Emperor's optional gift opportunity. */
|
||||
emperorExtortionGiftRelease?: { event: string; emperor: string; recipient: string };
|
||||
emperorGuildRateGiftRelease?: { event: string; emperor: string };
|
||||
grummanCollection?: GrummanCollection;
|
||||
pendingMoritaniPlacement?: {
|
||||
token: string;
|
||||
@@ -30836,6 +30839,59 @@ function emperorGuildTimingGiftIntegrity(g: Game) {
|
||||
if (g.pendingKarama?.use.kind === 'cancel')
|
||||
validateEmperorGuildTimingGift(g, g.pendingKarama.use.response);
|
||||
}
|
||||
function emperorGuildRateGiftPublicEligible(g: Game, p: Player): boolean {
|
||||
const response = g.response;
|
||||
const event = response?.guildRateEvent ?? response?.guildTransportEvent;
|
||||
return g.status === 'playing' && g.advanced && g.phase === 5 && g.expansions.length === 0 &&
|
||||
g.players.every(seat => ['atreides','beneGesserit','emperor','fremen','guild','harkonnen'].includes(seat.faction)) &&
|
||||
!g.techTokens && !g.strongholdCards && !g.leaderSkills && !g.homeworlds && !g.nexusCards &&
|
||||
!g.discoveryEnabled && !g.sandtrout && !g.coalitionPreview && !g.coalitionState && !g.phaseOpening && !g.decision &&
|
||||
!g.truthtrance && !g.pendingKarama && !g.pendingTreacheryDiscard && !g.pendingKull &&
|
||||
!g.pendingRicheseGift && !g.pendingNullentropy && !g.pendingEmperorAuctionGift &&
|
||||
!g.pendingArrivalOverlap && !g.pendingAmbassador &&
|
||||
response?.kind === 'guildRate' && typeof event === 'string' && !!event &&
|
||||
(!!g.pendingShipment !== !!g.pendingGuildTransport) && p.faction === 'emperor' && !!p.ally &&
|
||||
g.players.some(seat => seat.id === p.ally && seat.ally === p.id);
|
||||
}
|
||||
function emperorGuildRatePriority(g: Game): {event:string; emperor:string; recipient:string} | null {
|
||||
const emperor = byFaction(g, 'emperor');
|
||||
if (!emperor || !emperorGuildRateGiftPublicEligible(g, emperor) || !emperor.ally) return null;
|
||||
const event = g.response!.guildRateEvent ?? g.response!.guildTransportEvent!;
|
||||
if (g.emperorGuildRateGiftRelease?.event === event && g.emperorGuildRateGiftRelease.emperor === emperor.id) return null;
|
||||
return {event, emperor:emperor.id, recipient:emperor.ally};
|
||||
}
|
||||
function emperorGuildRateGiftMaximum(g: Game, p: Player): number {
|
||||
if (livePledgePromises(g.pledgePromises ?? [], p.id, g.turn, g.phase).length) return 0;
|
||||
const shipment = g.pendingShipment, transport = g.pendingGuildTransport;
|
||||
const pending = shipment?.player === p.id ? shipment.cost - shipment.allyPayment :
|
||||
transport?.player === p.id ? transport.cost - transport.allyPayment : 0;
|
||||
return Math.max(0, emperorAuctionGiftMaximum(g, p) - pending);
|
||||
}
|
||||
function emperorGuildRateGiftQuote(g: Game, p: Player): {recipient:string; maximum:number} | null {
|
||||
if (!emperorGuildRateGiftPublicEligible(g, p) || !p.ally) return null;
|
||||
const maximum = emperorGuildRateGiftMaximum(g, p);
|
||||
return maximum > 0 ? {recipient:p.ally, maximum} : null;
|
||||
}
|
||||
function emperorGuildRateGiftSignature(g: Game, parent: ResponseWindow, owner:string, recipient:string, amount:number): string {
|
||||
return JSON.stringify([g.turn,g.phase,g.active,g.order,g.pendingShipment,g.pendingGuildTransport,parent,owner,recipient,amount]);
|
||||
}
|
||||
function validateEmperorGuildRateGift(g: Game, response: ResponseWindow) {
|
||||
const parent = response.emperorGuildRateGift;
|
||||
if (!parent) return;
|
||||
const owner = g.players.find(player => player.id === response.owner);
|
||||
const recipient = g.players.find(player => player.id === response.recipient);
|
||||
requireRule(response.kind === 'emperorGift' && owner?.faction === 'emperor' && recipient &&
|
||||
owner.ally === recipient.id && recipient.ally === owner.id && parent.response.kind === 'guildRate' &&
|
||||
parent.event === (parent.response.guildRateEvent ?? parent.response.guildTransportEvent) && !!parent.event &&
|
||||
typeof response.amount === 'number' && Number.isSafeInteger(response.amount) && response.amount > 0 &&
|
||||
response.amount <= emperorGuildRateGiftMaximum(g, owner) &&
|
||||
parent.signature === emperorGuildRateGiftSignature(g,parent.response,owner.id,recipient.id,response.amount),
|
||||
'The Emperor gift lost its original Guild-rate response.');
|
||||
}
|
||||
function emperorGuildRateGiftIntegrity(g: Game) {
|
||||
if (g.response) validateEmperorGuildRateGift(g, g.response);
|
||||
if (g.pendingKarama?.use.kind === 'cancel') validateEmperorGuildRateGift(g, g.pendingKarama.use.response);
|
||||
}
|
||||
function emperorPhaseOpeningGiftSignature(g: Game, opening: {passed: string[]; initialize: boolean}, owner: string, recipient: string, amount: number): string {
|
||||
return JSON.stringify([g.turn, g.phase, g.active, g.order, g.ready, g.amalWindowOpen ?? false,
|
||||
opening, owner, recipient, amount]);
|
||||
@@ -38886,6 +38942,7 @@ function finishResponse(g: Game, canceled: boolean, settlement?: BureaucratSettl
|
||||
karamaConversionIntegrity(g);
|
||||
currentFactionPayment(g);
|
||||
const response = g.response!;
|
||||
validateEmperorGuildRateGift(g, response);
|
||||
validateEmperorGuildTimingGift(g, response);
|
||||
validateEmperorExtortionGift(g, response);
|
||||
validateEmperorPhaseOpeningGift(g, response);
|
||||
@@ -40066,6 +40123,7 @@ function finishResponse(g: Game, canceled: boolean, settlement?: BureaucratSettl
|
||||
);
|
||||
}
|
||||
if (response.emperorPhaseOpeningGift) g.phaseOpening = structuredClone(response.emperorPhaseOpeningGift.opening);
|
||||
if (response.emperorGuildRateGift) g.response = structuredClone(response.emperorGuildRateGift.response);
|
||||
if (response.emperorAuctionGiftEvent) {
|
||||
requireRule(g.pendingEmperorAuctionGift?.event === response.emperorAuctionGiftEvent,
|
||||
'The Emperor gift lost its original auction opportunity.');
|
||||
@@ -40798,10 +40856,12 @@ function savedNoFieldResponses(g: Game): ResponseWindow[] {
|
||||
continuation && 'resume' in continuation ? continuation.resume : null,
|
||||
g.pendingKull?.stage === 'counter' ? g.pendingKull.resume : null,
|
||||
continuation?.kind === 'kullCounterDiscard' ? continuation.frame.resume : null];
|
||||
return contexts.flatMap(context => {
|
||||
const responses = contexts.flatMap(context => {
|
||||
const karama = context && 'pendingKarama' in context ? context.pendingKarama as Game['pendingKarama'] : null;
|
||||
return [context?.response, karama?.use.kind === 'cancel' ? karama.use.response : null];
|
||||
}).filter((response): response is ResponseWindow => !!response);
|
||||
return responses.flatMap(response => response.emperorGuildRateGift
|
||||
? [response, response.emperorGuildRateGift.response] : [response]);
|
||||
}
|
||||
/** Bind both private stages, also while a card effect has saved their controls. */
|
||||
function leaderSkillNoFieldIntegrity(g: Game): boolean {
|
||||
@@ -43830,6 +43890,15 @@ function applyActionWithInitiator(state: Game, id: string, action: Action, initi
|
||||
emperorExtortionGiftIntegrity(state);
|
||||
emperorAuctionGiftIntegrity(state);
|
||||
emperorGuildTimingGiftIntegrity(state);
|
||||
emperorGuildRateGiftIntegrity(state);
|
||||
const rateGiftResponse = state.response?.emperorGuildRateGift ||
|
||||
(state.pendingKarama?.use.kind === 'cancel' && state.pendingKarama.use.response.emperorGuildRateGift);
|
||||
if (rateGiftResponse && action?.type !== 'advanceBots')
|
||||
requireRule(action?.type === 'passResponse' || action?.type === 'card' && action.mode === 'cancel',
|
||||
'Resolve the Emperor gift response before another action.');
|
||||
if (emperorGuildRatePriority(state) && action?.type !== 'advanceBots')
|
||||
requireRule(action?.type === 'emperorGift' || action?.type === 'emperorGuildRateContinue',
|
||||
'Wait for the Emperor to share spice or continue.');
|
||||
const phaseGiftResponse = state.response?.emperorPhaseOpeningGift ||
|
||||
(state.pendingKarama?.use.kind === 'cancel' && state.pendingKarama.use.response.emperorPhaseOpeningGift);
|
||||
if (phaseGiftResponse && action?.type !== 'advanceBots')
|
||||
@@ -44743,6 +44812,7 @@ function settleAutomaticContinuations(g: Game) {
|
||||
if (g.pendingHomeworldOccupiedPercentage || g.pendingHomeworldOccupiedBonus && !g.decision) return;
|
||||
if (response?.kind === 'ixAuction' && g.homeworldOccupationPreview &&
|
||||
quoteOccupiedBiddingAuthority(g, 'ixAuction').blocked) return;
|
||||
if (response && emperorGuildRatePriority(g)) return;
|
||||
if (response) {
|
||||
if (
|
||||
!(
|
||||
@@ -44800,6 +44870,7 @@ export function normalizeAutomaticGame(state: Game): Game {
|
||||
emperorExtortionGiftIntegrity(state);
|
||||
emperorAuctionGiftIntegrity(state);
|
||||
emperorGuildTimingGiftIntegrity(state);
|
||||
emperorGuildRateGiftIntegrity(state);
|
||||
twoPlayerControllersIntegrity(state);
|
||||
factionDraftIntegrity(state);
|
||||
factionSwapIntegrity(state);
|
||||
@@ -45661,8 +45732,29 @@ function applyActionInner(
|
||||
} };
|
||||
return g;
|
||||
}
|
||||
if (t === 'emperorGuildRateContinue') {
|
||||
const priority = emperorGuildRatePriority(g);
|
||||
requireRule(priority && priority.emperor === id && action.event === priority.event &&
|
||||
Object.keys(action).sort().join(',') === 'event,type',
|
||||
'Continue only your current Emperor Guild-rate opportunity.');
|
||||
g.emperorGuildRateGiftRelease = {event:priority.event, emperor:id};
|
||||
return g;
|
||||
}
|
||||
if (t === 'emperorGift' && g.response?.kind === 'guildRate') {
|
||||
const quote = emperorGuildRateGiftQuote(g, p);
|
||||
requireRule(quote && Object.keys(action).sort().join(',') === 'amount,type',
|
||||
'This Guild-rate gift is unavailable or no longer current.');
|
||||
const amount = integer(action.amount, 1, quote.maximum, 'Spice');
|
||||
const parent = structuredClone(g.response);
|
||||
const event = parent.guildRateEvent ?? parent.guildTransportEvent!;
|
||||
g.emperorGuildRateGiftRelease = {event, emperor:id};
|
||||
g.response = {kind:'emperorGift', owner:id, recipient:quote.recipient, amount, elite:0, passed:[],
|
||||
emperorGuildRateGift:{event,response:parent,signature:emperorGuildRateGiftSignature(g,parent,id,quote.recipient,amount)}};
|
||||
return g;
|
||||
}
|
||||
if (g.response) {
|
||||
const response = g.response;
|
||||
requireRule(!emperorGuildRatePriority(g), 'Wait for the Emperor to share spice or continue.');
|
||||
if (response.kind === 'fremenMovement') pendingFremenMovement(g, response);
|
||||
if (t === 'passResponse') {
|
||||
requireRule(
|
||||
@@ -49478,6 +49570,7 @@ export function viewGame(state: Game, id: string, now?: number) {
|
||||
emperorExtortionGiftIntegrity(state);
|
||||
emperorAuctionGiftIntegrity(state);
|
||||
emperorGuildTimingGiftIntegrity(state);
|
||||
emperorGuildRateGiftIntegrity(state);
|
||||
twoPlayerControllersIntegrity(state);
|
||||
factionDraftIntegrity(state);
|
||||
factionSwapIntegrity(state);
|
||||
@@ -50546,6 +50639,7 @@ export function viewGame(state: Game, id: string, now?: number) {
|
||||
? { amount: undefined }
|
||||
: {}),
|
||||
...(g.response.emperorGuildTimingGift ? { emperorGuildTimingGift: undefined } : {}),
|
||||
...(g.response.emperorGuildRateGift ? { emperorGuildRateGift: undefined } : {}),
|
||||
...(g.response.emperorExtortionGift ? { emperorExtortionGift: undefined } : {}),
|
||||
...(g.response.emperorPhaseOpeningGift ? { emperorPhaseOpeningGift: undefined } : {}),
|
||||
...(g.response.emperorAuctionGiftEvent ? { emperorAuctionGiftEvent: undefined } : {}),
|
||||
@@ -50554,7 +50648,7 @@ export function viewGame(state: Game, id: string, now?: number) {
|
||||
paymentIncome: currentFactionPayment(g),
|
||||
responseControls: g.pendingRicheseBetrayal || g.pendingKull?.stage === 'offer' ? undefined : g.response
|
||||
? {
|
||||
cancelCards: responseCancelCards(g, me, g.response),
|
||||
cancelCards: emperorGuildRatePriority(g) ? [] : responseCancelCards(g, me, g.response),
|
||||
hasPassed: g.response.passed.includes(id),
|
||||
}
|
||||
: undefined,
|
||||
@@ -50615,6 +50709,11 @@ export function viewGame(state: Game, id: string, now?: number) {
|
||||
: 0,
|
||||
},
|
||||
emperorGuildTimingGift: emperorGuildTimingGiftQuote(g, me),
|
||||
emperorGuildRateGift: emperorGuildRateGiftQuote(g, me),
|
||||
emperorGuildRatePriority: (() => {
|
||||
const priority = emperorGuildRatePriority(g);
|
||||
return priority ? {event:priority.event, recipient:priority.recipient, canContinue:priority.emperor === id} : null;
|
||||
})(),
|
||||
emperorExtortionGift: emperorExtortionGiftQuote(g, me),
|
||||
emperorExtortionPriority: (() => {
|
||||
const priority = emperorExtortionPriority(g);
|
||||
|
||||
@@ -298,6 +298,7 @@ export const RULE_TOPICS: RuleTopic[] = [
|
||||
'The recipient keeps paid spice separately until the next Mentat opening. A payment after the current opening waits for next turn’s opening. Your incoming bribes are shown separately from your spendable supply; they cannot fund bids, shipments or another bribe yet.',
|
||||
'A waiting Sandtrout does not prevent the supported Basic bribe interruption windows.',
|
||||
'During supported Basic phase openings, auction payments, Richese cache sales and Extortion decisions, a waiting Sandtrout does not prevent the Emperor gifting spice to an ally formed after the Sandtrout draw.',
|
||||
'In supported classic Advanced games, the Emperor may share spice before a pending Guild shipment-rate response continues. Allowing or canceling the gift returns to the same rate decision and shipment.',
|
||||
'You may pay out of turn when no decision or response is pending, including during Mentat after opening collection. In supported Basic games with classic or selected native expansion factions, direct bribes can also interrupt a normal auction-payment decision, Atreides auction inspection, Fremen allied-revival grant, ordinary Fremen or Ixian movement response, or CHOAM movement decision. Supported Basic Ix and Moritani games also allow payments during the Amal opening or an Extortion choice. The original parent and its passes remain pending. You cannot bribe yourself or your ally, or while Inflation shows Double. Emperor gifts to allies use their own power controls.',
|
||||
'Your payment limit excludes reserved spending and preserves binding Truthtrance answers. If an alliance, pending decision or available supply changes, recheck the recipient and amount. A rejected payment does not change the game.',
|
||||
'In the Basic group preview, group allies are excluded from ordinary bribes and nonallied deals. Existing agreements remain recorded and can be released; a deferred bribe to a newly allied recipient stays pending while it is unavailable, subject to its original deadline.',
|
||||
|
||||
Reference in new issue
Block a user