Admit genuine Basic Tleilaxu/base setup with the full fourteen-skill deck, Ix card inventories and native three Face Dancers. Share public profile guards across existing skill effects while retaining public-start and Advanced gates. Record native own-leader skill offers at successful revival commitment so automatic Tleilaxu response chains preserve the optional private draw. Connect Rihani to unrevealed Face Dancer exchange with exact physical/status custody, private controls and existing legal AI choices. Release completed Rihani's live snapshot only after validated Face Dance admission; keep signed history and current census checks. Zoal Smuggler uses opposing printed disc value at reveal, excluding opposing skill bonuses and his separate revival value. Add genuine setup, response/cancellation, private choice, custody, Face Dance reset, Zoal, legal AI and authenticated concurrent recovery regressions. Add a reproducible two-through-six-player sample profile and saved continuation. Preserve unresolved skill effects, foreign-ghola boundaries and delayed AI tuning. Validation: types, lint, 5,058 offline tests and production build passed. Five full games completed with zero rejected actions and 74 JSON restores. Browser QA CRY4DD4J used genuine setup and an explicitly conserved staged battle; real Rihani draw/exchange and same-state refresh passed on mobile and desktop. Screenshot capture timed out; full visual acceptance remains open. No HTTP endpoint/auth/storage implementation changed; authenticated SQLite recovery was verified. All 1,581 prior rooms, 3,349 seats and auxiliary records were preserved. One new QA room/seat remains. No server restart, database reset or automation.
52 lines
2.5 KiB
TypeScript
52 lines
2.5 KiB
TypeScript
import type { Game, GameView } from './engine';
|
|
import { splitLocation, validGameLocation } from './board';
|
|
import { faction } from './catalog';
|
|
import { basicExpansionLeaderSkillsProfile } from './leader-skill-profile';
|
|
import { sandmasterLeader, sandmasterModeSupported } from './sandmaster-movement';
|
|
|
|
export type SandmasterWormCollection = {
|
|
leader: string;
|
|
key: string | null;
|
|
before: number;
|
|
blocked: string | null;
|
|
};
|
|
|
|
/** A worm ride names a destination, not a traversed ground route. */
|
|
export function sandmasterWormCollection(
|
|
game: Game | GameView,
|
|
player: string,
|
|
destination: string,
|
|
sector: number,
|
|
decision: Game['decision'] | GameView['decision'] = game.decision,
|
|
): SandmasterWormCollection | null {
|
|
const leader = sandmasterLeader(game, player);
|
|
if (!leader || game.phase !== 1 || decision?.kind !== 'wormRide' ||
|
|
decision.player !== player ||
|
|
game.players.find(p => p.id === player)?.faction !== 'fremen') return null;
|
|
const blocked = (reason: string): SandmasterWormCollection =>
|
|
({ leader, key: null, before: 0, blocked: reason });
|
|
if (!sandmasterModeSupported(game) || game.ecazTreachery ||
|
|
!(basicExpansionLeaderSkillsProfile(game) ||
|
|
game.players.every(p => faction(p.faction).expansion === 'base')))
|
|
return blocked('Sandmaster worm collection with other optional modules is still being integrated.');
|
|
if (destination === decision.territory ||
|
|
!validGameLocation(game, destination, sector) || sector === game.storm)
|
|
return blocked('Choose a different legal destination for the worm ride.');
|
|
const piles = Object.entries(game.spice)
|
|
.filter(([key]) => splitLocation(key).territory === destination);
|
|
if (piles.some(([key, amount]) => {
|
|
const at = splitLocation(key);
|
|
return !validGameLocation(game, at.territory, at.sector) ||
|
|
key !== `${at.territory}:${at.sector}` || !Number.isSafeInteger(amount) || amount < 0;
|
|
})) return blocked('Sandmaster needs a valid destination spice pile.');
|
|
const positive = piles.filter(([, amount]) => amount > 0);
|
|
if (positive.length > 1)
|
|
return blocked('Sandmaster collection among multiple spice piles awaits its allocation ruling.');
|
|
if (!positive.length) return blocked('There is no spice to collect at this destination.');
|
|
const [key, before] = positive[0];
|
|
const spice = game.players.find(p => p.id === player)?.spice;
|
|
if (!Number.isSafeInteger(spice) || !Number.isSafeInteger(spice! + 1))
|
|
return blocked('Sandmaster collection needs a valid spice balance.');
|
|
return { leader, key, before, blocked: null };
|
|
}
|