Compose Planetologist movement with Ornithopter flights
This commit is contained in:
1 parent
90c50736f2
commit
4af90e547c
24 files changed
+1607
-50
No files matched your search
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user