Route Advanced Emperor allied auction funding
Verify and publish checkpoint container / container (push) Canceled after 0s

This commit is contained in:
Quintine committed 2026-10-29 02:48:11 +11:00
1 parent 3ba9087405
commit 599af2475d
19 files changed
+883 -35

No files matched your search

+28 -1
View File
@@ -3,6 +3,7 @@ import type { FactionId } from './catalog';
import type { Game, ResponseWindow } from './engine';
import { requireRicheseDeclarationCache } from './richese-settlement';
import { quoteNormalAuctionRetirement } from './normal-auction-retirement';
import { routeAuctionPayment } from './auction-payment-routing';
export type AuctionContinuationSeat = {
id: string;
@@ -97,6 +98,8 @@ export function auctionEmperorIncomeAmount(
sale: NonNullable<Game['currentAuctionSale']>,
): number {
if (sale.free || sale.recipient === 'bank') return 0;
if (sale.paymentRouting) return sale.paymentRouting.filter(leg => leg.recipient === 'emperor')
.reduce((total, leg) => total + leg.amount, 0);
return sale.origin === 'normal' || sale.seller === sale.winner
? sale.amount
: sale.richeseContribution ?? 0;
@@ -322,6 +325,28 @@ function calculate(
);
const winner = seated(sale.winner)!;
requireAuction(winner, 'The auction winner is no longer seated.');
if (sale.paymentRouting !== undefined) {
const emperor = input.players.find(player => player.faction === 'emperor');
requireAuction(input.advanced && !sale.free && Array.isArray(sale.paymentRouting) &&
sale.paymentRouting.length > 0 && sale.paymentRouting.every(leg => seated(leg.payer)) &&
JSON.stringify(sale.paymentRouting) === JSON.stringify(routeAuctionPayment({
advanced: true, free: false, price: sale.amount, buyer: winner.id,
emperor: emperor?.id ?? null, seller: sale.seller, bankOnly: sale.recipient === 'bank',
contributions: sale.paymentRouting.map(({payer, amount}) => ({payer, amount})),
})) && sale.paymentRouting.some(leg => leg.payer === emperor?.id &&
leg.payer !== winner.id && leg.recipient === 'bank'),
'The paid auction lost its original Advanced Emperor bank contribution.');
if (sale.origin === 'normal') {
const a = input.auction!;
const donors = a.coalitionContributions ?? (a.allyPayment ? [{donor:winner.ally, amount:a.allyPayment}] : []);
const expected = donors.map(({donor,amount}) => ({payer:donor, amount}));
const own = sale.amount - expected.reduce((sum, leg) => sum + leg.amount, 0);
if (own > 0) expected.unshift({payer:winner.id, amount:own});
requireAuction(JSON.stringify(sale.paymentRouting.map(({payer,amount}) => ({payer,amount}))) === JSON.stringify(expected),
'The paid auction contributions no longer match the original bid.');
} else requireAuction(sale.paymentRouting.every(leg => leg.payer === winner.id || leg.payer === winner.ally),
'The paid Richese lot lost its original buyer or ally.');
}
let stage = operation.kind;
const steps: AuctionContinuationQuote['steps'] = [];
if (operation.kind === 'cancel') {
@@ -387,7 +412,9 @@ function calculate(
if (!sale.free && sale.origin !== 'normal' && sale.seller !== winner.id) {
if (sale.recipient !== 'bank') {
const seller = seated(sale.seller!)!;
const amount = sale.amount - (sale.richeseContribution ?? 0);
const amount = sale.paymentRouting
? sale.paymentRouting.filter(leg => leg.recipient === 'seller').reduce((sum, leg) => sum + leg.amount, 0)
: sale.amount - (sale.richeseContribution ?? 0);
requireAuction(
count(seller.spice) && count(seller.spice + amount),
'The seller credit would overflow its current balance.',