v0.4.8 — the Limits bound the whole district, the nine spots really are nine, and an action points at its square
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YQAJ4dND7enLj54eLyiF2C
This commit is contained in:
+49
-4
@@ -87,9 +87,36 @@ export type ActionGroup = {
|
||||
* from the browser, which needs the whole `GameState`. A remote client has no state, so the menu
|
||||
* carries it. See `docs/architecture/multiplayer.md` §5.
|
||||
*/
|
||||
actions: { index: number; label: string; tip?: string }[];
|
||||
/**
|
||||
* `coord` is the square the action HAPPENS ON, when it happens on one.
|
||||
*
|
||||
* Carried as data rather than left inside the label. Half these buttons are near-identical
|
||||
* sentences distinguished only by a coordinate — "(1,3)" against "(-1,3)" — and picking the wrong
|
||||
* one is recoverable in solitaire, where Undo is a click, and a disaster in a multiplayer game
|
||||
* where it is not. The page hovers the matching square on the board instead of asking the player
|
||||
* to read the row and column off the button. Reported by Jesse.
|
||||
*
|
||||
* Resolved HERE for the same reason `tip` is: a remote client holds no `GameState` and cannot look
|
||||
* up where a tray is standing. See `docs/architecture/multiplayer.md` §5.
|
||||
*/
|
||||
actions: { index: number; label: string; tip?: string; coord?: { row: number; col: number } }[];
|
||||
};
|
||||
|
||||
/**
|
||||
* The square an intent acts on, or null when it acts on none.
|
||||
*
|
||||
* Only squares the intent NAMES. A card played out on the Mainline (`node`) is not a district
|
||||
* coordinate and must not be treated as one — that confusion is exactly why `placement` and `node`
|
||||
* are separate fields on the intent (see `intents.ts`) — and an action like ending a turn has no
|
||||
* square at all.
|
||||
*/
|
||||
export function coordOf(i: Intent): { row: number; col: number } | null {
|
||||
if ('at' in i) return i.at;
|
||||
if ('to' in i) return i.to;
|
||||
if (i.type === 'card.play' && i.placement) return i.placement;
|
||||
return null;
|
||||
}
|
||||
|
||||
export type Game = {
|
||||
state: GameState;
|
||||
seed: number;
|
||||
@@ -212,7 +239,13 @@ export function actionGroups(game: Game): { options: Intent[]; groups: ActionGro
|
||||
* to survive every edit to a line nobody would think to check. One stray byte and every crew's
|
||||
* moves silently collapsed back into a single group. The tray is data; it travels as data.
|
||||
*/
|
||||
type Entry = { index: number; label: string; tip?: string; trayId?: string };
|
||||
type Entry = {
|
||||
index: number;
|
||||
label: string;
|
||||
tip?: string;
|
||||
trayId?: string;
|
||||
coord?: { row: number; col: number };
|
||||
};
|
||||
const byKind = new Map<string, Entry[]>();
|
||||
options.forEach((intent, index) => {
|
||||
const label = describeIntent(game.state, intent);
|
||||
@@ -227,14 +260,26 @@ export function actionGroups(game: Game): { options: Intent[]; groups: ActionGro
|
||||
* on the crew as well makes the de-duplication per crew, which is what it always meant.
|
||||
*/
|
||||
if (!list.some((a) => a.label === label && a.trayId === trayId)) {
|
||||
list.push({ index, label, ...(tip ? { tip } : {}), ...(trayId ? { trayId } : {}) });
|
||||
const coord = coordOf(intent);
|
||||
list.push({
|
||||
index,
|
||||
label,
|
||||
...(tip ? { tip } : {}),
|
||||
...(trayId ? { trayId } : {}),
|
||||
...(coord ? { coord } : {}),
|
||||
});
|
||||
}
|
||||
byKind.set(intent.type, list);
|
||||
});
|
||||
|
||||
/** Groups take the plain shape; the crew was only ever needed to split them. */
|
||||
const plain = (entries: Entry[]): ActionGroup['actions'] =>
|
||||
entries.map(({ index, label, tip }) => ({ index, label, ...(tip ? { tip } : {}) }));
|
||||
entries.map(({ index, label, tip, coord }) => ({
|
||||
index,
|
||||
label,
|
||||
...(tip ? { tip } : {}),
|
||||
...(coord ? { coord } : {}),
|
||||
}));
|
||||
|
||||
const groups: ActionGroup[] = [];
|
||||
const used = new Set<string>();
|
||||
|
||||
Reference in New Issue
Block a user