Compose Planetologist movement with Ornithopter flights

This commit is contained in:
Quintine committed 2026-10-26 09:53:21 +11:00
1 parent 90c50736f2
commit 4af90e547c
24 files changed
+1607 -50

No files matched your search

+2 -2
View File
@@ -5048,9 +5048,9 @@ export function GameTable({
destination={selected}
sector={sector}
unavailableReason={
!movementAvailable
!movementAvailable && !g.ornithopter?.active
? 'No ordinary movement is currently available.'
: (me.moved ?? 0) >= (me.movesAllowed ?? 1)
: !g.ornithopter?.active && (me.moved ?? 0) >= (me.movesAllowed ?? 1)
? 'No ordinary movement remains this turn.'
: selectedDestinationInStorm
? 'Choose a destination outside the storm.'
+36 -11
View File
@@ -13,6 +13,8 @@ import { isAdvisor } from '@/game/advisors';
import { quoteAdvisorGatherMatching, AdvisorGatherMatchingError } from '@/game/advisor-gather-matching';
import { location, splitLocation, validGameLocation } from '@/game/board';
import { nexusGuildMovementAvailable } from '@/game/nexus-guild-cunning-options';
import { planetologistFlightSelection, type PlanetologistFlight } from '@/game/planetologist-flight';
import { validateCohortSelection } from '@/game/ornithopter';
import { Button } from './ui/button';
type Counts = Record<string, number>;
@@ -49,6 +51,7 @@ export function planetologistMoveDraft(
forces: Counts,
elites: Counts,
includeNoField = false,
flight: PlanetologistFlight = 'ordinary',
): Draft {
const me = game.players.find((player) => player.id === game.me);
if (!me || !planetologistLeader(game, me.id))
@@ -58,6 +61,8 @@ export function planetologistMoveDraft(
action: null,
blocked: 'Planetologist movement with expansion factions awaits its movement audit.',
};
const transport = planetologistFlightSelection(game, flight);
if (transport.blocked) return { action: null, blocked: transport.blocked };
if (mode !== 'range' && mode !== 'gather')
return { action: null, blocked: 'Choose a Planetologist movement mode.' };
if (!Number.isSafeInteger(sector) || !validGameLocation(game, destination, sector))
@@ -103,13 +108,25 @@ export function planetologistMoveDraft(
const target = location(destination, sector);
const sources = [...selected.map(([from]) => from), ...(marker ? [location(marker.location.territory, marker.location.sector)] : [])];
if (sources.some(from => !botGroundMoveAllowed(game, me, from, target,
selectedOriginElites(selected, elites, splitLocation(from).territory), mode)))
selectedOriginElites(selected, elites, splitLocation(from).territory), mode, transport.rangeOverride)))
return {
action: null,
blocked: mode === 'range'
blocked: transport.rangeOverride
? 'The selected route is blocked or more than three territories away.'
: mode === 'range'
? 'The selected route is beyond the boosted range or is blocked.'
: 'Each selected source must reach the destination using its normal range.',
};
if (transport.cohort) {
try {
validateCohortSelection(transport.cohort, me.forces, me.elites?.forces ?? {},
Object.fromEntries(selected), Object.fromEntries(selected.map(([from]) => [from, elites[from] ?? 0])),
marker ? { tokenId: marker.tokenId, event: marker.event,
from: location(marker.location.territory, marker.location.sector) } : undefined);
} catch {
return { action: null, blocked: 'Choose original forces and any unmoved marker from the current Ornithopter cohort.' };
}
}
if (mode === 'gather') {
try {
quoteAdvisorGatherMatching(game, { owner: me.id, move: me.moved ?? 0, destination, sector,
@@ -126,25 +143,29 @@ export function planetologistMoveDraft(
forces: Object.fromEntries(selected),
...(me.elites ? { eliteForces: Object.fromEntries(selected.map(([from]) => [from, elites[from] ?? 0])) } : {}),
...(marker ? { noField: marker.tokenId, event: marker.event } : {}),
...transport.fields,
territory: destination, sector,
},
blocked: null,
};
}
export function planetologistMovementBlocked(game: GameView, draft: Draft, unavailableReason?: string | null): string | null {
export function planetologistMovementBlocked(game: GameView, draft: Draft, unavailableReason?: string | null,
flight: PlanetologistFlight = 'ordinary'): string | null {
const me = game.players.find(player => player.id === game.me);
const transport = planetologistFlightSelection(game, flight);
const currentCard = !transport.blocked && typeof transport.fields.ornithopterEvent === 'string';
return unavailableReason ||
(!me || game.status !== 'playing' || game.phase !== 5 || game.active !== me.id
? 'Planetologist movement is available only during your movement turn.'
: game.ornithopter?.active
? 'Finish the current Ornithopter movement first.'
: transport.blocked
? transport.blocked
: game.response || game.decision || game.phaseOpening || game.truthtrance ||
game.nexusTraitors?.pending || game.nexusCards?.waiting.length
? 'Resolve the current response or decision first.'
: me.autopilot || game.automaticContinuationPending
? 'Wait for the current automatic action to finish.'
: !nexusGuildMovementAvailable(game)
: !currentCard && !nexusGuildMovementAvailable(game)
? 'No ordinary movement remains this turn.'
: draft.blocked);
}
@@ -157,6 +178,7 @@ export interface PlanetologistMovementActionProps {
forces: Counts;
elites: Counts;
includeNoField?: boolean;
flight?: PlanetologistFlight;
busy: boolean;
unavailableReason?: string | null;
reasonId?: string;
@@ -165,9 +187,10 @@ export interface PlanetologistMovementActionProps {
/** Hook-free leaf owns the actual guarded submission callback. */
export function PlanetologistMovementAction({ game, mode, destination, sector, forces, elites,
includeNoField = false, busy, unavailableReason, reasonId, act }: PlanetologistMovementActionProps) {
const draft = planetologistMoveDraft(game, mode, destination, sector, forces, elites, includeNoField);
const blocked = planetologistMovementBlocked(game, draft, unavailableReason);
includeNoField = false, flight = 'ordinary', busy, unavailableReason, reasonId, act }: PlanetologistMovementActionProps) {
const draft = planetologistMoveDraft(game, mode, destination, sector, forces, elites, includeNoField, flight);
const blocked = planetologistMovementBlocked(game, draft, unavailableReason, flight);
const transport = planetologistFlightSelection(game, flight);
const marker = includeNoField ? planetologistNoFieldMarker(game) : null;
return <Button
className="min-h-11 whitespace-normal motion-reduce:transition-none"
@@ -176,8 +199,10 @@ export function PlanetologistMovementAction({ game, mode, destination, sector, f
aria-describedby={blocked ? reasonId : undefined}
onClick={() => {
if (busy || blocked || !draft.action) return;
const current = planetologistMoveDraft(game, mode, destination, sector, forces, elites, includeNoField);
if (planetologistMovementBlocked(game, current, unavailableReason) || !current.action) return;
const current = planetologistMoveDraft(game, mode, destination, sector, forces, elites, includeNoField, flight);
if (planetologistMovementBlocked(game, current, unavailableReason, flight) || !current.action) return;
const currentTransport = planetologistFlightSelection(game, flight);
if (JSON.stringify(currentTransport.fields) !== JSON.stringify(transport.fields)) return;
const currentMarker = includeNoField ? planetologistNoFieldMarker(game) : null;
if (includeNoField && (!marker || !currentMarker || marker.tokenId !== currentMarker.tokenId ||
marker.event !== currentMarker.event || marker.location.territory !== currentMarker.location.territory ||
+67 -10
View File
@@ -8,9 +8,11 @@ import {
} from '@/game/planetologist-movement';
import {
gameTerritories,
location,
splitLocation,
territory,
} from '@/game/board';
import { planetologistFlightSelection, type PlanetologistFlight } from '@/game/planetologist-flight';
import {
PlanetologistMovementAction,
planetologistMoveDraft,
@@ -36,7 +38,9 @@ export function PlanetologistMovement(props: Props) {
const marker = planetologistNoFieldMarker(props.game);
const me = props.game.players.find(player => player.id === props.game.me);
return <PlanetologistMovementDraft
key={JSON.stringify([props.game.me, props.game.turn, me?.moved, marker?.tokenId, marker?.event, marker?.location])}
key={JSON.stringify([props.game.me, props.game.turn, me?.moved, marker?.tokenId, marker?.event, marker?.location,
props.game.ornithopter?.card?.id, props.game.ornithopter?.active?.event,
props.game.ornithopter?.active?.completed, props.game.discoveryOrnithopter?.token])}
{...props}
/>;
}
@@ -54,11 +58,22 @@ function PlanetologistMovementDraft({
const [forces, setForces] = useState<Counts>({});
const [elites, setElites] = useState<Counts>({});
const [includeNoField, setIncludeNoField] = useState(false);
const [flight, setFlight] = useState<PlanetologistFlight>(game.ornithopter?.active?.mode ?? 'ordinary');
const me = game.players.find((player) => player.id === game.me);
const leader = me && planetologistLeader(game, me.id);
if (!me || !leader) return null;
const sources = Object.entries(me.forces).filter(([, count]) => count > 0);
const transport = planetologistFlightSelection(game, flight);
const sources = Object.entries(me.forces).map(([from, count]) => {
if (!transport.cohort) return [from, count] as const;
const currentElite = me.elites?.forces[from] ?? 0;
const cohortElite = transport.cohort.elites[from] ?? 0;
const normal = Math.min(count - currentElite, (transport.cohort.forces[from] ?? 0) - cohortElite);
return [from, normal + Math.min(currentElite, cohortElite)] as const;
}).filter(([, count]) => count > 0);
const marker = planetologistNoFieldMarker(game);
const markerAvailable = !transport.cohort || !!(marker && transport.cohort.noField &&
marker.tokenId === transport.cohort.noField.tokenId && marker.event === transport.cohort.noField.event &&
location(marker.location.territory, marker.location.sector) === transport.cohort.noField.from);
const draft = planetologistMoveDraft(
game,
mode,
@@ -67,8 +82,9 @@ function PlanetologistMovementDraft({
forces,
elites,
includeNoField,
flight,
);
const blocked = planetologistMovementBlocked(game, draft, unavailableReason);
const blocked = planetologistMovementBlocked(game, draft, unavailableReason, flight);
const leaderName =
game.allLeaders.find((candidate) => candidate.id === leader)?.name ??
leader;
@@ -96,6 +112,42 @@ function PlanetologistMovementDraft({
<option value="range">One territory farther, maximum three</option>
<option value="gather">Gather from two territories</option>
</select>
{(game.ornithopter || game.discoveryOrnithopter) && (
<>
<label htmlFor={`${id}-flight`}>Movement transport</label>
<select
id={`${id}-flight`}
value={flight}
disabled={busy || !!game.ornithopter?.active}
onChange={event => setFlight(event.target.value as PlanetologistFlight)}
>
{(['ordinary', 'range3', 'twoGroups', 'discovery'] as const).map(choice => {
const option = planetologistFlightSelection(game, choice);
const label = choice === 'ordinary' ? 'Ordinary movement' : choice === 'range3'
? 'Ornithopter card: fixed range three' : choice === 'twoGroups'
? 'Ornithopter card: two different movements' : 'Carried Discovery Ornithopter';
return <option key={choice} value={choice} disabled={!!option.blocked}>
{label}{option.blocked ? ' — unavailable' : ''}
</option>;
})}
</select>
<p className="fine" aria-label="Provisional Planetologist flight composition">
Provisional flight composition: fixed-range Ornithopter and Discovery
flight stay at three territories for either skill choice, including
each origin of a gather. Two-group card flight uses extra range up to
three, or gathers two origins using each origin’s normal range. A
gather counts as one card movement; the next movement must use
different original forces. Only one flight source is used per movement.
</p>
{game.ornithopter?.active && !transport.blocked && (
<p className="notice">
{game.ornithopter.active.completed} card movements completed ·{' '}
{game.ornithopter.active.remaining} remaining. Select original unmoved
forces below for the next movement.
</p>
)}
</>
)}
<p className="fine">
Destination: {territory(destination).name}, sector {sector}. Select the
physical forces to move below.
@@ -107,7 +159,7 @@ function PlanetologistMovementDraft({
id={`${id}-no-field`}
type="checkbox"
checked={includeNoField}
disabled={busy || !!game.homeworldMobility?.noFieldMovementBlocked}
disabled={busy || !markerAvailable || !!game.homeworldMobility?.noFieldMovementBlocked}
onChange={(event) => setIncludeNoField(event.target.checked)}
/>
Include your concealed No-Field from {territory(marker.location.territory).name}, sector {marker.location.sector}
@@ -121,9 +173,13 @@ function PlanetologistMovementDraft({
<p className="fine" aria-label="Provisional Planetologist No-Field gather">
Provisional gather composition: the concealed marker supplies one of
exactly two origin territories, alone or with physical forces there.
Select physical forces from one other territory. Every origin uses
its normal range; gather adds no extra range. Its value stays concealed.
Select physical forces from one other territory.{' '}
{transport.rangeOverride
? 'Every origin uses the selected flight’s fixed range of three.'
: 'Every origin uses its normal range; gather adds no extra range.'}{' '}
Its value stays concealed.
</p>
{!markerAvailable && <p className="fine">This marker is outside the original unmoved card cohort.</p>}
{game.homeworldMobility?.noFieldMovementBlocked && (
<p className="notice">{game.homeworldMobility.noFieldMovementBlocked}</p>
)}
@@ -151,7 +207,9 @@ function PlanetologistMovementDraft({
(candidate) => candidate.id === source.territory,
)?.name ?? source.territory;
const selected = forces[from] ?? 0;
const ownedElite = me.elites?.forces[from] ?? 0;
const ownedElite = transport.cohort
? Math.min(me.elites?.forces[from] ?? 0, transport.cohort.elites[from] ?? 0)
: me.elites?.forces[from] ?? 0;
const minimumElite = Math.max(0, selected - (owned - ownedElite));
return (
<div className="grid gap-2" key={from}>
@@ -201,12 +259,11 @@ function PlanetologistMovementDraft({
)}
<PlanetologistMovementAction
game={game} mode={mode} destination={destination} sector={sector}
forces={forces} elites={elites} includeNoField={includeNoField}
forces={forces} elites={elites} includeNoField={includeNoField} flight={flight}
busy={busy} unavailableReason={unavailableReason} reasonId={`${id}-reason`} act={act}
/>
<p className="fine">
Concealed No-Fields cannot join either Ornithopter card movement
or Discovery flight.
Only one flight source may be used for each movement.
Normal movement and arrival rules still apply.
</p>
</section>