Prototype named Ghola leader Truthtrance promises
Verify and publish checkpoint container / container (push) Successful in 10m45s
Verify and publish checkpoint container / container (push) Successful in 10m45s
This commit is contained in:
1 parent
f8078ed5e2
commit
c1ffa1c28a
16 files changed
+689
-9
No files matched your search
@@ -0,0 +1,46 @@
|
||||
'use client';
|
||||
|
||||
import { parseGholaLeaderClaim, type GholaLeaderClaim } from '@/game/ghola-leader-promises';
|
||||
|
||||
type LeaderChoice = { id: string; name: string };
|
||||
|
||||
export function gholaLeaderClaimInputError(value: unknown, leaders?: readonly LeaderChoice[]): string | null {
|
||||
try {
|
||||
const claim = parseGholaLeaderClaim(value);
|
||||
return leaders && !leaders.some(leader => leader.id === claim.leader)
|
||||
? 'Choose one of the current named leaders.' : null;
|
||||
} catch (error) {
|
||||
return error instanceof Error ? error.message : 'Choose the current turn and a named leader.';
|
||||
}
|
||||
}
|
||||
|
||||
/** The parent supplies the current turn and public leader names. Server rules
|
||||
* decide whether the named return is possible and whether a response is legal. */
|
||||
export function GholaLeaderClaimFields(props: {
|
||||
value: GholaLeaderClaim;
|
||||
onChange: (claim: GholaLeaderClaim) => void;
|
||||
leaders: readonly LeaderChoice[];
|
||||
disabled?: boolean;
|
||||
}) {
|
||||
const error = gholaLeaderClaimInputError(props.value, props.leaders);
|
||||
return <fieldset className="grid gap-2" disabled={props.disabled} aria-label="Named Ghola leader return condition">
|
||||
<legend>Future Ghola leader return</legend>
|
||||
<p>Turn {props.value.turn}</p>
|
||||
<label htmlFor="truth-ghola-leader">Named leader</label>
|
||||
<select id="truth-ghola-leader" disabled={props.disabled}
|
||||
value={props.leaders.some(leader => leader.id === props.value.leader) ? props.value.leader : ''}
|
||||
onChange={event => {
|
||||
const next = { ...props.value, leader: event.currentTarget.value };
|
||||
if (!props.disabled && !gholaLeaderClaimInputError(next, props.leaders)) props.onChange(parseGholaLeaderClaim(next));
|
||||
}}>
|
||||
<option value="">Choose a named leader</option>
|
||||
{props.leaders.map(leader => <option key={leader.id} value={leader.id}>{leader.name}</option>)}
|
||||
</select>
|
||||
{error && <p role="alert">{error}</p>}
|
||||
<p className="fine">
|
||||
Ask whether this named leader will actually return using Tleilaxu Ghola after the answer this turn.
|
||||
Playing Ghola to return forces, ordinary revival, or a return before the answer does not count.
|
||||
The card and its normal eligibility rules still apply.
|
||||
</p>
|
||||
</fieldset>;
|
||||
}
|
||||
Reference in new issue
Block a user