Support concealed No-Field Guild transport

This commit is contained in:
Quintine committed 2026-10-27 12:44:34 +11:00
1 parent e41abdaf2e
commit 933a9c1379
24 files changed
+1138 -74

No files matched your search

+32 -11
View File
@@ -1,6 +1,7 @@
import type { Action, GameView } from './engine';
import { gameTerritories, MOBILE_STRONGHOLD } from './board';
import { gameTerritories, MOBILE_STRONGHOLD, splitLocation, validGameLocation } from './board';
import { quoteNexusGuildSecretShipment } from './nexus-guild-secret-ally';
import { guildNoFieldSelection } from './guild-no-field-selection';
/** Consume only the current actor's private offer and public faction roster. */
export function nexusGuildSecretAllyCanAct(g: GameView): boolean {
@@ -36,29 +37,31 @@ export function nexusGuildSecretAllyQuote(
g: GameView,
destination: string,
amount: number,
noField = false,
) {
if (
!nexusGuildSecretAllyCanAct(g) ||
typeof noField !== 'boolean' ||
!Number.isSafeInteger(amount) ||
amount < 1 ||
amount > 20
amount > (noField ? 21 : 20)
)
return null;
const me = g.players.find((p) => p.id === g.me)!;
if (destination === 'reserves') {
// User ruling 7 October 2026: the Secret Ally return grant overrides the
// Arrakis-to-native-Homeworld restriction for the holder's own reserves.
return quoteNexusGuildSecretShipment('reserves', amount);
return quoteNexusGuildSecretShipment('reserves', amount, noField);
}
const world = g.homeworlds?.worlds?.find((w) => w.id === destination);
if (world) {
if (world.native === me.id || world.native === me.ally) return null;
return quoteNexusGuildSecretShipment('homeworld', amount);
if (noField || world.native === me.id || world.native === me.ally) return null;
return quoteNexusGuildSecretShipment('homeworld', amount, noField);
}
const to = gameTerritories(g).find((t) => t.id === destination);
if (!to || (destination === MOBILE_STRONGHOLD && me.faction !== 'ixians'))
return null;
return quoteNexusGuildSecretShipment(to.type, amount);
return quoteNexusGuildSecretShipment(to.type, amount, noField);
}
/** Add a selected source, never infer card use just from possession. */
@@ -72,12 +75,31 @@ export function nexusGuildSecretAllyAction(
event !== g.nexusGuildSecretAlly!.event ||
!['ship', 'guildShip', 'homeworldShip'].includes(action.type) ||
action.nexus !== undefined ||
action.noField !== undefined ||
(action.noField !== undefined && action.type !== 'guildShip') ||
(action.type === 'guildShip' && action.from === 'reserves')
)
return null;
const amount =
action.type === 'homeworldShip'
const me = g.players.find((p) => p.id === g.me)!;
const noField = action.noField !== undefined;
let amount: number;
if (noField) {
const marker = guildNoFieldSelection(g, action);
if (!marker || !action.forces || typeof action.forces !== 'object' || Array.isArray(action.forces) ||
!validGameLocation(g, marker.location.territory, marker.location.sector) || marker.location.sector === g.storm)
return null;
let physical = 0;
for (const [key, count] of Object.entries(action.forces)) {
const source = splitLocation(key);
if (!validGameLocation(g, source.territory, source.sector) ||
typeof count !== 'number' || !Number.isSafeInteger(count) || count < 0 ||
count > (me.forces[key] ?? 0)) return null;
if (!count) continue;
if (source.territory !== marker.location.territory || source.sector === g.storm) return null;
physical += count;
}
if (physical > 20) return null;
amount = physical + 1;
} else amount = action.type === 'homeworldShip'
? Object.values(
(action.sources ?? {}) as Record<
string,
@@ -93,8 +115,7 @@ export function nexusGuildSecretAllyAction(
const destination = String(
action.type === 'homeworldShip' ? action.destination : action.territory,
);
if (!nexusGuildSecretAllyQuote(g, destination, amount)) return null;
const me = g.players.find((p) => p.id === g.me)!;
if (!nexusGuildSecretAllyQuote(g, destination, amount, noField)) return null;
if (
action.type === 'ship' &&
(amount > me.reserves ||