Fill Acquire viewer and show hand tiles on the board
This commit is contained in:
parent
8f2da86cb6
commit
73153fd0eb
33 changed files with 390 additions and 214 deletions
|
|
@ -1,12 +1,12 @@
|
|||
# Acquire private beta — 22 October 2026
|
||||
|
||||
Private BGS registration: `acquire`, version `1`. Engine `0.0.1`, viewer `0.0.4`.
|
||||
Private BGS registration: `acquire`, version `1`. Engine `0.0.1`, viewer `0.0.5`.
|
||||
Source: <https://github.com/boardgamers/mergers-game>. Keep `public: false`.
|
||||
|
||||
## Validation
|
||||
|
||||
- `pnpm check`: formatting, lint, TypeScript/Svelte checks, 198 engine tests,
|
||||
52 viewer/tutorial tests, and the production build. Two pre-existing lint warnings
|
||||
51 viewer/tutorial tests, and the production build. Two pre-existing lint warnings
|
||||
remain (an unused test import and Svelte's `bind:this` assignment).
|
||||
- Protocol diagnostics: all eight required engine methods; full core/chat/replay
|
||||
viewer coverage, preferences, avatars and theme handlers. Protocol `0.10.0` is the
|
||||
|
|
@ -25,6 +25,10 @@ Source: <https://github.com/boardgamers/mergers-game>. Keep `public: false`.
|
|||
- Screenshots and a machine-readable report are generated in `release/qa/`.
|
||||
The gallery uses three distinct views, each with light and dark variants. Height
|
||||
checks prevent oversized captures; desktop panels and the full-log toggle are checked.
|
||||
- Wide-screen checks cover the full-window background, outer margins, board sizing,
|
||||
permanently visible chat, player colors, and preservation of chat drafts when appearance changes.
|
||||
- Hand markers remain visible between turns, but only legal moves are clickable. Browser checks
|
||||
cover selecting and confirming from the board, spectator privacy, and hiding markers in replay.
|
||||
|
||||
## Fixes made for beta
|
||||
|
||||
|
|
@ -43,6 +47,9 @@ Source: <https://github.com/boardgamers/mergers-game>. Keep `public: false`.
|
|||
show eight recent log entries with the full history available on demand. Gallery
|
||||
captures frame the game instead of including an entire scrolling phone page.
|
||||
- Split the game description into two paragraphs.
|
||||
- Remove outer iframe margins and paint the full document with the game theme. Let the board
|
||||
fill its desktop column, keep chat open, and use consistent player colors in the table and chat.
|
||||
- Use chain letters in both color modes; reserve extra symbols for players.
|
||||
- Explain tile adjacency, chain price tiers (no special abilities), price bands,
|
||||
majority/minority bonuses and ties, safe chains, and final payouts alongside
|
||||
the tutorial actions in all 17 languages. Include an expandable price table
|
||||
|
|
@ -71,7 +78,6 @@ Source: <https://github.com/boardgamers/mergers-game>. Keep `public: false`.
|
|||
<https://boardgamegeek.com/boardgame/5/acquire>.
|
||||
- Upload the original transparent `pictogram.svg`, English rules as the CMS page
|
||||
`acquire:rules`, and `gameinfo.json` for the initial version/configuration.
|
||||
- Use the existing `economic` tag. Suggested additions to BGS's shared list:
|
||||
`tile placement` and `stock holding`.
|
||||
- Tags: `economic`, `tile-placement` and `stock-holding`.
|
||||
- Intended beta accounts: not2cool, Spock and AlphaZero. GitHub collaborator:
|
||||
MikeIsom, write permission (requires accepting GitHub's invitation).
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Acquire viewer - dev harness</title>
|
||||
</head>
|
||||
<body style="margin: 0; background: Canvas">
|
||||
<body>
|
||||
<div
|
||||
id="dev"
|
||||
style="
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "acquire-viewer",
|
||||
"version": "0.0.4",
|
||||
"version": "0.0.5",
|
||||
"private": true,
|
||||
"description": "Browser viewer for Acquire on boardgamers.space",
|
||||
"license": "AGPL-3.0-only",
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
<Board
|
||||
{state}
|
||||
selected={store.selected}
|
||||
onselect={(tile) => (store.selected = tile)}
|
||||
onconfirm={() =>
|
||||
store.selected !== undefined && store.send({ type: "place", tile: tileLabel(store.selected) })}
|
||||
/>
|
||||
|
|
@ -51,8 +52,7 @@
|
|||
</main>
|
||||
|
||||
<style>
|
||||
/* Narrow screens: one column, decision and board together so a selected square and its confirm
|
||||
button are both visible. No viewport-height units: BGS sizes the iframe to its content. */
|
||||
/* Keep the decision and board together on narrow screens. */
|
||||
.layout {
|
||||
display: grid;
|
||||
gap: 20px;
|
||||
|
|
@ -68,7 +68,6 @@
|
|||
}
|
||||
.board {
|
||||
grid-area: board;
|
||||
max-width: 660px;
|
||||
}
|
||||
.hand {
|
||||
grid-area: hand;
|
||||
|
|
|
|||
|
|
@ -1,17 +1,29 @@
|
|||
<script lang="ts">
|
||||
import { BOARD_COLUMNS, BOARD_ROWS, tileLabel, type GameState, type Tile } from "acquire-engine";
|
||||
import {
|
||||
BOARD_COLUMNS,
|
||||
BOARD_ROWS,
|
||||
HIDDEN,
|
||||
parseTile,
|
||||
tileLabel,
|
||||
tileLegality,
|
||||
type GameState,
|
||||
type Tile,
|
||||
} from "acquire-engine";
|
||||
import { ofType } from "./decisions";
|
||||
import { chainName } from "./format";
|
||||
import { CHAIN_STYLES, patternCss } from "./palette";
|
||||
import { CHAIN_STYLES } from "./palette";
|
||||
import { useStore } from "./store.svelte";
|
||||
|
||||
let {
|
||||
state,
|
||||
selected,
|
||||
onselect,
|
||||
onconfirm,
|
||||
}: {
|
||||
state: GameState;
|
||||
/** A tile selected in the hand: its square is highlighted and clicking it places the tile. */
|
||||
selected?: Tile;
|
||||
onselect?: (tile: Tile) => void;
|
||||
onconfirm?: () => void;
|
||||
} = $props();
|
||||
|
||||
|
|
@ -23,6 +35,14 @@
|
|||
const pendingTile = $derived(state.merger?.tile ?? state.pendingTile);
|
||||
const store = useStore();
|
||||
const t = $derived(store.lang.t);
|
||||
const playable = $derived(new Set(ofType(store.moves, "place").map((move) => parseTile(move.tile)!)));
|
||||
const held = $derived(
|
||||
new Set(
|
||||
store.replayAt === undefined && !store.readOnly
|
||||
? store.seats.flatMap((seat) => state.seats[seat]?.hand.filter((tile) => tile !== HIDDEN) ?? [])
|
||||
: []
|
||||
)
|
||||
);
|
||||
</script>
|
||||
|
||||
<div class="frame" dir="ltr">
|
||||
|
|
@ -39,17 +59,31 @@
|
|||
{@const tile = tileAt(row, column)}
|
||||
{@const cell = state.board[tile] ?? null}
|
||||
{@const label = tileLabel(tile)}
|
||||
{#if tile === selected && cell === null}
|
||||
{@const legality = held.has(tile) ? tileLegality(state.board, tile) : undefined}
|
||||
{#if playable.has(tile) && cell === null}
|
||||
<button
|
||||
type="button"
|
||||
class="square empty selected actionable"
|
||||
aria-label={t("board.place", { tile: label })}
|
||||
onclick={() => onconfirm?.()}
|
||||
class="square empty held playable actionable"
|
||||
class:selected={tile === selected}
|
||||
aria-label={tile === selected ? t("board.place", { tile: label }) : label}
|
||||
aria-pressed={tile === selected}
|
||||
disabled={store.sending}
|
||||
onclick={() => (tile === selected ? onconfirm?.() : onselect?.(tile))}
|
||||
>
|
||||
<span class="coord">{label}</span>
|
||||
</button>
|
||||
{:else if cell === null}
|
||||
<div class="square empty" aria-label={t("board.empty", { tile: label })}>
|
||||
<div
|
||||
class="square empty"
|
||||
class:held={held.has(tile)}
|
||||
class:unavailable={legality !== undefined && legality !== "playable"}
|
||||
aria-label={held.has(tile) ? `${label} — ${t("hand.yours")}` : t("board.empty", { tile: label })}
|
||||
title={legality === "permanentlyUnplayable"
|
||||
? t("hand.dead")
|
||||
: legality === "temporarilyUnplayable"
|
||||
? t("hand.eighth")
|
||||
: undefined}
|
||||
>
|
||||
<span class="coord">{label}</span>
|
||||
</div>
|
||||
{:else if cell === "loose"}
|
||||
|
|
@ -64,15 +98,8 @@
|
|||
style:color={style.text}
|
||||
aria-label={t("board.chain", { tile: label, chain: chainName(cell) })}
|
||||
>
|
||||
{#if store.colorBlind}
|
||||
<!-- Colour-blind mode: the chain's pattern, with the letter on a solid patch so its
|
||||
contrast never changes. Edge labels give the coordinate. -->
|
||||
<span class="pattern" style:background={patternCss(style.pattern, style.patternInk)}></span>
|
||||
<span class="letter patch" style:background={style.fill}>{style.letter}</span>
|
||||
{:else}
|
||||
<span class="corner-label">{label}</span>
|
||||
<span class="letter">{style.letter}</span>
|
||||
{/if}
|
||||
<span class="corner-label">{label}</span>
|
||||
<span class="letter">{style.letter}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
|
|
@ -86,7 +113,6 @@
|
|||
grid-template-columns: 16px minmax(0, 1fr);
|
||||
grid-template-rows: 18px auto;
|
||||
width: 100%;
|
||||
max-width: 660px;
|
||||
}
|
||||
/* Edge labels use the same 2px padding and gaps as the board so they line up with squares. */
|
||||
.numbers,
|
||||
|
|
@ -137,18 +163,31 @@
|
|||
font-size: 10px;
|
||||
color: var(--on-empty);
|
||||
}
|
||||
/* The selected tile's square: page colour plus an accent outline, since the accent is only
|
||||
2.92:1 against the grey. */
|
||||
.empty.held {
|
||||
background: var(--panel);
|
||||
border: 2px dashed var(--ink-muted);
|
||||
}
|
||||
.empty.held .coord {
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: var(--ink);
|
||||
}
|
||||
.empty.playable {
|
||||
border-color: transparent;
|
||||
}
|
||||
.empty.unavailable {
|
||||
background: var(--empty);
|
||||
border-color: var(--on-empty);
|
||||
}
|
||||
.empty.unavailable .coord {
|
||||
color: var(--on-empty);
|
||||
text-decoration: line-through;
|
||||
}
|
||||
.empty.selected {
|
||||
background: var(--page);
|
||||
outline: 4px solid var(--accent);
|
||||
outline-offset: -4px;
|
||||
}
|
||||
.empty.selected .coord {
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: var(--ink);
|
||||
}
|
||||
/* A loose tile is black with a light coordinate. */
|
||||
.loose {
|
||||
background: var(--loose);
|
||||
|
|
@ -183,18 +222,6 @@
|
|||
font-size: 10px;
|
||||
}
|
||||
}
|
||||
.chain .pattern {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
}
|
||||
.chain .patch {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 58%;
|
||||
height: 58%;
|
||||
}
|
||||
.chain .corner-label {
|
||||
position: absolute;
|
||||
top: 1px;
|
||||
|
|
|
|||
|
|
@ -1,27 +1,14 @@
|
|||
<script lang="ts">
|
||||
import type { ChainId } from "acquire-engine";
|
||||
import { chainName } from "./format";
|
||||
import { CHAIN_STYLES, patternCss } from "./palette";
|
||||
import { CHAIN_STYLES } from "./palette";
|
||||
|
||||
let {
|
||||
chain,
|
||||
withName = false,
|
||||
small = false,
|
||||
patterned = false,
|
||||
}: { chain: ChainId; withName?: boolean; small?: boolean; patterned?: boolean } = $props();
|
||||
let { chain, withName = false, small = false }: { chain: ChainId; withName?: boolean; small?: boolean } = $props();
|
||||
const style = $derived(CHAIN_STYLES[chain]);
|
||||
</script>
|
||||
|
||||
<span class="mark" class:small>
|
||||
{#if patterned}
|
||||
<!-- Colour-blind mode: the chain's pattern around a solid patch carrying the letter. -->
|
||||
<span class="swatch patterned" style:background={style.fill} aria-hidden="true">
|
||||
<span class="pattern" style:background={patternCss(style.pattern, style.patternInk)}></span>
|
||||
<span class="patch" style:background={style.fill} style:color={style.text}>{style.letter}</span>
|
||||
</span>
|
||||
{:else}
|
||||
<span class="swatch" style:background={style.fill} style:color={style.text} aria-hidden="true">{style.letter}</span>
|
||||
{/if}
|
||||
<span class="swatch" style:background={style.fill} style:color={style.text} aria-hidden="true">{style.letter}</span>
|
||||
{#if withName}<span class="name">{chainName(chain)}</span>{:else}<span class="sr-only">{chainName(chain)}</span>{/if}
|
||||
</span>
|
||||
|
||||
|
|
@ -41,32 +28,6 @@
|
|||
font-weight: 800;
|
||||
font-size: 14px;
|
||||
}
|
||||
.patterned {
|
||||
position: relative;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
}
|
||||
.pattern {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
}
|
||||
.patch {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
line-height: 1;
|
||||
}
|
||||
.small .patterned {
|
||||
width: 21px;
|
||||
height: 21px;
|
||||
}
|
||||
.small .patch {
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
}
|
||||
.small .swatch {
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
<tbody>
|
||||
{#each rows as row (row.chain)}
|
||||
<tr class:inactive={row.size === 0}>
|
||||
<td><ChainMark chain={row.chain} withName patterned={store.colorBlind} /></td>
|
||||
<td><ChainMark chain={row.chain} withName /></td>
|
||||
<td class="num">
|
||||
{#if row.size === 0}
|
||||
{t("chains.notOnBoard")}
|
||||
|
|
|
|||
|
|
@ -1,61 +1,103 @@
|
|||
<script lang="ts">
|
||||
import { untrack } from "svelte";
|
||||
import { mountChat } from "@boardgamers/protocol/chat/dom";
|
||||
import { PLAYER_SYMBOL_IDS, playerSymbolSvg } from "@boardgamers/protocol/player-symbols";
|
||||
import { playerColor, playerInk } from "./playerAppearance";
|
||||
import { useStore } from "./store.svelte";
|
||||
|
||||
const store = useStore();
|
||||
let host: HTMLDivElement;
|
||||
let panel: ReturnType<typeof mountChat> | undefined;
|
||||
|
||||
// The protocol library's chat panel, themed and labelled here. Labels are fixed at mount, so
|
||||
// it is remounted when the language changes.
|
||||
$effect(() => {
|
||||
const t = store.lang.t;
|
||||
// No openPlayer: authors stay plain text rather than a column of outlined buttons.
|
||||
const panel = mountChat(host, {
|
||||
chat: store.chat,
|
||||
labels: {
|
||||
title: t("chat.title"),
|
||||
message: t("chat.message"),
|
||||
placeholder: t("chat.placeholder"),
|
||||
send: t("chat.send"),
|
||||
sending: t("chat.sending"),
|
||||
empty: t("chat.empty"),
|
||||
edited: t("chat.edited"),
|
||||
suggestions: t("chat.suggestions"),
|
||||
game: t("chat.game"),
|
||||
unread: (count) => t("chat.unread", { count }),
|
||||
date: (date) => date.toLocaleDateString(store.locale, { dateStyle: "long" }),
|
||||
status: (state) => {
|
||||
if (state.disabled) {
|
||||
return t("chat.disabled");
|
||||
}
|
||||
if (!state.enabled) {
|
||||
return t("chat.connecting");
|
||||
}
|
||||
if (state.canSend) {
|
||||
return "";
|
||||
}
|
||||
switch (state.reason) {
|
||||
case "not-logged-in":
|
||||
return t("chat.signIn");
|
||||
case "not-confirmed":
|
||||
return t("chat.confirmAccount");
|
||||
case "not-a-player":
|
||||
return t("chat.playersOnly");
|
||||
case "chat-disabled":
|
||||
return t("chat.disabled");
|
||||
case "no-game":
|
||||
return t("chat.waiting");
|
||||
default:
|
||||
return t("chat.readOnly");
|
||||
untrack(() => {
|
||||
store.chat.setOpen(true);
|
||||
panel = mountChat(host, {
|
||||
chat: store.chat,
|
||||
renderAuthor: (message) => {
|
||||
const author = document.createElement("strong");
|
||||
author.className = "chat-author";
|
||||
const name = document.createElement("span");
|
||||
name.textContent = message.author ?? t("chat.game");
|
||||
if (message.playerIndex !== undefined) {
|
||||
const player = message.playerIndex;
|
||||
const color = playerColor(player, store.appearance?.playerColors);
|
||||
name.className = "player-name";
|
||||
name.style.setProperty("--player-ink-light", playerInk(color, "light"));
|
||||
name.style.setProperty("--player-ink-dark", playerInk(color, "dark"));
|
||||
const marker = document.createElement("span");
|
||||
marker.className = "player-color";
|
||||
marker.style.background = color;
|
||||
marker.setAttribute("aria-hidden", "true");
|
||||
author.append(marker);
|
||||
const symbol =
|
||||
store.appearance?.playerSymbols?.[player] ??
|
||||
(store.colorBlind ? PLAYER_SYMBOL_IDS[player % PLAYER_SYMBOL_IDS.length] : undefined);
|
||||
if (symbol) {
|
||||
const mark = document.createElement("span");
|
||||
mark.className = "player-symbol";
|
||||
mark.setAttribute("aria-hidden", "true");
|
||||
mark.innerHTML = playerSymbolSvg(symbol);
|
||||
author.append(mark);
|
||||
}
|
||||
}
|
||||
author.append(name);
|
||||
return author;
|
||||
},
|
||||
},
|
||||
labels: {
|
||||
title: t("chat.title"),
|
||||
message: t("chat.message"),
|
||||
placeholder: t("chat.placeholder"),
|
||||
send: t("chat.send"),
|
||||
sending: t("chat.sending"),
|
||||
empty: t("chat.empty"),
|
||||
edited: t("chat.edited"),
|
||||
suggestions: t("chat.suggestions"),
|
||||
game: t("chat.game"),
|
||||
unread: (count) => t("chat.unread", { count }),
|
||||
date: (date) => date.toLocaleDateString(store.locale, { dateStyle: "long" }),
|
||||
status: (state) => {
|
||||
if (state.disabled) {
|
||||
return t("chat.disabled");
|
||||
}
|
||||
if (!state.enabled) {
|
||||
return t("chat.connecting");
|
||||
}
|
||||
if (state.canSend) {
|
||||
return "";
|
||||
}
|
||||
switch (state.reason) {
|
||||
case "not-logged-in":
|
||||
return t("chat.signIn");
|
||||
case "not-confirmed":
|
||||
return t("chat.confirmAccount");
|
||||
case "not-a-player":
|
||||
return t("chat.playersOnly");
|
||||
case "chat-disabled":
|
||||
return t("chat.disabled");
|
||||
case "no-game":
|
||||
return t("chat.waiting");
|
||||
default:
|
||||
return t("chat.readOnly");
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
return () => panel.destroy();
|
||||
return () => panel?.destroy();
|
||||
});
|
||||
$effect(() => {
|
||||
void store.appearance;
|
||||
void store.colorBlind;
|
||||
untrack(() => panel?.refresh());
|
||||
});
|
||||
</script>
|
||||
|
||||
<section class="chat" aria-label={store.lang.t("chat.label")}>
|
||||
<h2>{store.lang.t("chat.title")}</h2>
|
||||
<div bind:this={host}></div>
|
||||
</section>
|
||||
|
||||
|
|
@ -71,7 +113,24 @@
|
|||
--chat-accent: var(--accent);
|
||||
--chat-height: 320px;
|
||||
}
|
||||
.chat :global(.bgs-game-chat summary),
|
||||
.chat :global(.bgs-game-chat summary) {
|
||||
display: none;
|
||||
}
|
||||
.chat :global(.chat-author) {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.chat :global(.player-color) {
|
||||
width: 4px;
|
||||
height: 16px;
|
||||
}
|
||||
.chat :global(.player-symbol),
|
||||
.chat :global(.player-symbol svg) {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
}
|
||||
.chat :global(.bgs-game-chat input),
|
||||
.chat :global(.bgs-game-chat button:not(:disabled)) {
|
||||
outline: 2.5px solid var(--ink);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
import { PLAYER_SYMBOL_IDS, playerSymbolSvg } from "@boardgamers/protocol/player-symbols";
|
||||
import type { GameState } from "acquire-engine";
|
||||
import { seatName } from "./format";
|
||||
import { playerColor, playerInk } from "./playerAppearance";
|
||||
import { useStore } from "./store.svelte";
|
||||
|
||||
/** `playerOnly` names the player without a seat number (fourHands results are per player). */
|
||||
|
|
@ -11,7 +12,7 @@
|
|||
// BGS appearance data is per real player; in fourHands two seats share one player.
|
||||
const player = $derived(game.seatOwner[seat] ?? seat);
|
||||
const avatar = $derived(store.avatars[player]);
|
||||
const color = $derived(store.appearance?.playerColors[player]);
|
||||
const color = $derived(playerColor(player, store.appearance?.playerColors));
|
||||
const symbol = $derived(
|
||||
store.appearance?.playerSymbols?.[player] ??
|
||||
(store.colorBlind ? PLAYER_SYMBOL_IDS[player % PLAYER_SYMBOL_IDS.length] : undefined)
|
||||
|
|
@ -21,11 +22,15 @@
|
|||
|
||||
<span class="player">
|
||||
{#if avatar}<img class="avatar" src={avatar} alt="" />{/if}
|
||||
<!-- The player colour is only ever this narrow bar, never a fill, so it can't pass for a chain. -->
|
||||
{#if color}<span class="color" style:background={color} aria-hidden="true"></span>{/if}
|
||||
<span class="color" style:background={color} aria-hidden="true"></span>
|
||||
<!-- Catalogued symbol SVGs only: an unknown value renders nothing. -->
|
||||
{#if symbol}<span class="symbol" aria-hidden="true">{@html playerSymbolSvg(symbol)}</span>{/if}
|
||||
<span class="name">{playerOnly ? game.seats[seat]!.name : seatName(game, seat, store.lang)}</span>
|
||||
<span
|
||||
class="player-name"
|
||||
style:--player-ink-light={playerInk(color, "light")}
|
||||
style:--player-ink-dark={playerInk(color, "dark")}
|
||||
>{playerOnly ? game.seats[seat]!.name : seatName(game, seat, store.lang)}</span
|
||||
>
|
||||
{#if badge}<img class="badge" src={badge.url} alt={badge.label} title={badge.label} />{/if}
|
||||
</span>
|
||||
|
||||
|
|
|
|||
|
|
@ -34,11 +34,7 @@
|
|||
<th class="tier" scope="col">
|
||||
<span class="sr-only">{t(TIER_KEYS[tier])}</span>
|
||||
<span class="heads">
|
||||
{#each chainsInTier(tier) as chain (chain)}<ChainMark
|
||||
{chain}
|
||||
small
|
||||
patterned={store.colorBlind}
|
||||
/>{/each}
|
||||
{#each chainsInTier(tier) as chain (chain)}<ChainMark {chain} small />{/each}
|
||||
</span>
|
||||
</th>
|
||||
{/each}
|
||||
|
|
@ -56,11 +52,7 @@
|
|||
<span class="size">{rangeLabel(row.sizes[tier])}</span>
|
||||
{#if here.length > 0}
|
||||
<span class="heads">
|
||||
{#each here as mark (mark.chain)}<ChainMark
|
||||
chain={mark.chain}
|
||||
small
|
||||
patterned={store.colorBlind}
|
||||
/>{/each}
|
||||
{#each here as mark (mark.chain)}<ChainMark chain={mark.chain} small />{/each}
|
||||
</span>
|
||||
{/if}
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export const da: Catalog = {
|
|||
"place.merges": "fusionerer {chains}",
|
||||
"place.button": "Læg {tile}",
|
||||
"place.another": "Vælg en anden",
|
||||
"place.choose": "Vælg en brik fra din hånd.",
|
||||
"place.choose": "Vælg et fremhævet felt eller en brik fra din hånd.",
|
||||
"place.none": "Ingen af dine brikker kan lægges.",
|
||||
"place.pass": "Fortsæt uden at lægge",
|
||||
"found.prompt": "Navngiv den nye kæde. Du får én gratis aktie.",
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export const de: Catalog = {
|
|||
"place.merges": "fusioniert {chains}",
|
||||
"place.button": "{tile} legen",
|
||||
"place.another": "Anderes wählen",
|
||||
"place.choose": "Wähle ein Plättchen von deiner Hand.",
|
||||
"place.choose": "Wähle ein hervorgehobenes Feld oder ein Plättchen aus deiner Hand.",
|
||||
"place.none": "Keines deiner Plättchen kann gelegt werden.",
|
||||
"place.pass": "Ohne Legen weiter",
|
||||
"found.prompt": "Benenne die neue Kette. Du erhältst eine Gratisaktie.",
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export const el: Catalog = {
|
|||
"place.merges": "συγχωνεύει {chains}",
|
||||
"place.button": "Τοποθέτηση {tile}",
|
||||
"place.another": "Άλλη επιλογή",
|
||||
"place.choose": "Διάλεξε ένα πλακίδιο από το χέρι σου.",
|
||||
"place.choose": "Επιλέξτε ένα επισημασμένο τετράγωνο ή ένα πλακίδιο από το χέρι σας.",
|
||||
"place.none": "Κανένα από τα πλακίδιά σου δεν μπορεί να τοποθετηθεί.",
|
||||
"place.pass": "Συνέχεια χωρίς τοποθέτηση",
|
||||
"found.prompt": "Ονόμασε τη νέα αλυσίδα. Παίρνεις μία δωρεάν μετοχή.",
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ export const en = {
|
|||
"place.merges": "merges {chains}",
|
||||
"place.button": "Place {tile}",
|
||||
"place.another": "Choose another",
|
||||
"place.choose": "Choose a tile from your hand.",
|
||||
"place.choose": "Choose a highlighted square or a tile from your hand.",
|
||||
"place.none": "None of your tiles can be placed.",
|
||||
"place.pass": "Continue without placing",
|
||||
"found.prompt": "Name the new chain. You receive one free share.",
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export const fa: Catalog = {
|
|||
"place.merges": "{chains} را ادغام میکند",
|
||||
"place.button": "گذاشتن {tile}",
|
||||
"place.another": "انتخاب کاشی دیگر",
|
||||
"place.choose": "یک کاشی از دستتان انتخاب کنید.",
|
||||
"place.choose": "یک خانهٔ مشخصشده یا کاشی از دست خود انتخاب کنید.",
|
||||
"place.none": "هیچکدام از کاشیهای شما قابل گذاشتن نیست.",
|
||||
"place.pass": "ادامه بدون گذاشتن",
|
||||
"found.prompt": "برای زنجیرهی جدید نام انتخاب کنید. یک سهم رایگان میگیرید.",
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export const fr: Catalog = {
|
|||
"place.merges": "fusionne {chains}",
|
||||
"place.button": "Poser {tile}",
|
||||
"place.another": "Choisir une autre",
|
||||
"place.choose": "Choisissez une tuile de votre main.",
|
||||
"place.choose": "Choisissez une case en surbrillance ou une tuile de votre main.",
|
||||
"place.none": "Aucune de vos tuiles ne peut être posée.",
|
||||
"place.pass": "Continuer sans poser",
|
||||
"found.prompt": "Nommez la nouvelle chaîne. Vous recevez une action gratuite.",
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export const hi: Catalog = {
|
|||
"place.merges": "{chains} का विलय करती है",
|
||||
"place.button": "{tile} रखें",
|
||||
"place.another": "दूसरी चुनें",
|
||||
"place.choose": "अपने हाथ से एक टाइल चुनें।",
|
||||
"place.choose": "कोई हाइलाइट किया हुआ खाना या अपने हाथ से एक टाइल चुनें।",
|
||||
"place.none": "आपकी कोई भी टाइल रखी नहीं जा सकती।",
|
||||
"place.pass": "बिना रखे आगे बढ़ें",
|
||||
"found.prompt": "नई श्रृंखला का नाम चुनें। आपको एक मुफ़्त शेयर मिलेगा।",
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export const it: Catalog = {
|
|||
"place.merges": "fonde {chains}",
|
||||
"place.button": "Piazza {tile}",
|
||||
"place.another": "Scegline un'altra",
|
||||
"place.choose": "Scegli una tessera dalla tua mano.",
|
||||
"place.choose": "Scegli una casella evidenziata o una tessera dalla tua mano.",
|
||||
"place.none": "Nessuna delle tue tessere può essere piazzata.",
|
||||
"place.pass": "Continua senza piazzare",
|
||||
"found.prompt": "Dai un nome alla nuova catena. Ricevi un'azione gratuita.",
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export const ko: Catalog = {
|
|||
"place.merges": "{chains}을(를) 합병합니다",
|
||||
"place.button": "{tile} 놓기",
|
||||
"place.another": "다른 타일 고르기",
|
||||
"place.choose": "손에서 타일 하나를 고르세요.",
|
||||
"place.choose": "강조된 칸이나 손에 있는 타일을 선택하세요.",
|
||||
"place.none": "놓을 수 있는 타일이 없습니다.",
|
||||
"place.pass": "놓지 않고 계속하기",
|
||||
"found.prompt": "새 체인의 이름을 고르세요. 무료 주식 1주를 받습니다.",
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export const nl: Catalog = {
|
|||
"place.merges": "fuseert {chains}",
|
||||
"place.button": "Leg {tile}",
|
||||
"place.another": "Kies een andere",
|
||||
"place.choose": "Kies een tegel uit je hand.",
|
||||
"place.choose": "Kies een gemarkeerd vak of een tegel uit je hand.",
|
||||
"place.none": "Geen van je tegels kan gelegd worden.",
|
||||
"place.pass": "Verder zonder te leggen",
|
||||
"found.prompt": "Geef de nieuwe keten een naam. Je krijgt één gratis aandeel.",
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export const pl: Catalog = {
|
|||
"place.merges": "łączy {chains}",
|
||||
"place.button": "Połóż {tile}",
|
||||
"place.another": "Wybierz inną",
|
||||
"place.choose": "Wybierz płytkę z ręki.",
|
||||
"place.choose": "Wybierz wyróżnione pole lub kafelek z ręki.",
|
||||
"place.none": "Żadnej z twoich płytek nie można położyć.",
|
||||
"place.pass": "Kontynuuj bez kładzenia",
|
||||
"found.prompt": "Nazwij nową sieć. Otrzymujesz jedną darmową akcję.",
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export const ptBR: Catalog = {
|
|||
"place.merges": "funde {chains}",
|
||||
"place.button": "Colocar {tile}",
|
||||
"place.another": "Escolher outra",
|
||||
"place.choose": "Escolha uma peça da sua mão.",
|
||||
"place.choose": "Escolha uma casa destacada ou uma peça da sua mão.",
|
||||
"place.none": "Nenhuma das suas peças pode ser colocada.",
|
||||
"place.pass": "Continuar sem colocar",
|
||||
"found.prompt": "Dê nome à nova rede. Você recebe uma ação grátis.",
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export const ro: Catalog = {
|
|||
"place.merges": "unește {chains}",
|
||||
"place.button": "Plasează {tile}",
|
||||
"place.another": "Alege alta",
|
||||
"place.choose": "Alege o piesă din mână.",
|
||||
"place.choose": "Alege o căsuță evidențiată sau o plăcuță din mână.",
|
||||
"place.none": "Niciuna dintre piesele tale nu poate fi plasată.",
|
||||
"place.pass": "Continuă fără să plasezi",
|
||||
"found.prompt": "Numește lanțul nou. Primești o acțiune gratuită.",
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export const ru: Catalog = {
|
|||
"place.merges": "сливает {chains}",
|
||||
"place.button": "Выложить {tile}",
|
||||
"place.another": "Выбрать другую",
|
||||
"place.choose": "Выберите фишку с руки.",
|
||||
"place.choose": "Выберите выделенную клетку или тайл из руки.",
|
||||
"place.none": "Ни одну из ваших фишек нельзя выложить.",
|
||||
"place.pass": "Продолжить без выкладки",
|
||||
"found.prompt": "Назовите новую сеть. Вы получаете одну бесплатную акцию.",
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export const vi: Catalog = {
|
|||
"place.merges": "sáp nhập {chains}",
|
||||
"place.button": "Đặt {tile}",
|
||||
"place.another": "Chọn ô khác",
|
||||
"place.choose": "Chọn một ô trên tay.",
|
||||
"place.choose": "Chọn một ô được đánh dấu hoặc một ô trên tay bạn.",
|
||||
"place.none": "Không ô nào của bạn đặt được.",
|
||||
"place.pass": "Tiếp tục mà không đặt",
|
||||
"found.prompt": "Đặt tên cho chuỗi mới. Bạn nhận một cổ phiếu miễn phí.",
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export const zhCN: Catalog = {
|
|||
"place.merges": "合并 {chains}",
|
||||
"place.button": "放置 {tile}",
|
||||
"place.another": "换一块",
|
||||
"place.choose": "从手中选择一块板块。",
|
||||
"place.choose": "选择一个高亮方格或手中的板块。",
|
||||
"place.none": "你没有可以放置的板块。",
|
||||
"place.pass": "不放置,继续",
|
||||
"found.prompt": "为新连锁命名。你将获得一股免费股票。",
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export const zhTW: Catalog = {
|
|||
"place.merges": "合併 {chains}",
|
||||
"place.button": "放置 {tile}",
|
||||
"place.another": "換一塊",
|
||||
"place.choose": "從手中選擇一塊板塊。",
|
||||
"place.choose": "選擇一個醒目方格或手中的板塊。",
|
||||
"place.none": "你沒有可以放置的板塊。",
|
||||
"place.pass": "不放置,繼續",
|
||||
"found.prompt": "為新連鎖命名。你將獲得一股免費股票。",
|
||||
|
|
|
|||
|
|
@ -148,18 +148,8 @@ test("dark theme: the rack is the lightest grey that keeps the accent at 3:1, ma
|
|||
);
|
||||
});
|
||||
|
||||
for (const [themeName] of themes) {
|
||||
// Patterns are non-text marks (3:1); letters sit on solid patches, so the 4.5:1 check holds.
|
||||
test(`${themeName} theme: each chain pattern has at least 3:1 contrast against its chain colour`, () => {
|
||||
for (const [chain, style] of chains) {
|
||||
const ratio = contrastRatio(style.patternInk, style.fill);
|
||||
assert.ok(ratio >= 3, `${chain} pattern: ${ratio.toFixed(2)}:1`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
test("colour-blind mode gives every chain a different pattern", () => {
|
||||
assert.equal(new Set(chains.map(([, style]) => style.pattern)).size, chains.length);
|
||||
test("chain letters identify every chain without relying on colour", () => {
|
||||
assert.equal(new Set(chains.map(([, style]) => style.letter)).size, chains.length);
|
||||
});
|
||||
|
||||
test("the palette stays close to its Okabe-Ito origins", () => {
|
||||
|
|
|
|||
|
|
@ -99,9 +99,9 @@ export function themeCss(): string {
|
|||
const light = `${vars(THEMES.light)} color-scheme: light;`;
|
||||
const dark = `${vars(THEMES.dark)} color-scheme: dark;`;
|
||||
return [
|
||||
`.acquire, .acquire[data-theme="light"] { ${light} }`,
|
||||
`.acquire[data-theme="dark"] { ${dark} }`,
|
||||
`@media (prefers-color-scheme: dark) { .acquire:not([data-theme]) { ${dark} } }`,
|
||||
`.acquire, html:has(.acquire) { ${light} }`,
|
||||
`.acquire[data-theme="dark"], html:has(.acquire[data-theme="dark"]) { ${dark} }`,
|
||||
`@media (prefers-color-scheme: dark) { .acquire:not([data-theme]), html:has(.acquire:not([data-theme])) { ${dark} } }`,
|
||||
].join(" ");
|
||||
}
|
||||
|
||||
|
|
@ -122,51 +122,18 @@ export interface ChainStyle {
|
|||
text: string;
|
||||
/** Shown on every chain tile and marker, so colour is never the only signal. */
|
||||
letter: string;
|
||||
/** Colour-blind mode: a pattern structurally different from every other chain's. */
|
||||
pattern: Pattern;
|
||||
/** The pattern's ink: the label colour blended into the fill, softened to just over 3:1. */
|
||||
patternInk: string;
|
||||
}
|
||||
|
||||
export type Pattern = "stripes" | "bars" | "diagonalUp" | "diagonalDown" | "dots" | "checker" | "crosshatch";
|
||||
|
||||
/**
|
||||
* CSS background for a chain pattern. Sizes are percentages of the tile, so the same pattern
|
||||
* reads the same on a 26px phone square and a 44px desktop square.
|
||||
*/
|
||||
export function patternCss(pattern: Pattern | "grid", ink: string): string {
|
||||
const lines = (angle: number, width = 9) =>
|
||||
`repeating-linear-gradient(${angle}deg, ${ink} 0 ${width}%, transparent ${width}% 25%)`;
|
||||
switch (pattern) {
|
||||
case "stripes":
|
||||
return lines(0);
|
||||
case "bars":
|
||||
return lines(90);
|
||||
case "diagonalUp":
|
||||
return lines(45);
|
||||
case "diagonalDown":
|
||||
return lines(135);
|
||||
case "dots":
|
||||
return `radial-gradient(circle, ${ink} 0 30%, transparent 33%) 0 0 / 25% 25%`;
|
||||
case "checker":
|
||||
return `conic-gradient(${ink} 0 25%, transparent 0 50%, ${ink} 0 75%, transparent 0) 0 0 / 50% 50%`;
|
||||
case "crosshatch":
|
||||
return `${lines(45, 6)}, ${lines(135, 6)}`;
|
||||
case "grid":
|
||||
return `${lines(0, 7)}, ${lines(90, 7)}`;
|
||||
}
|
||||
}
|
||||
|
||||
// Okabe-Ito without its black and yellow (they clash with the board), nudged and with a violet
|
||||
// added so every pair stays apart under each colour-vision deficiency. See palette.spec.ts.
|
||||
export const CHAIN_STYLES: Record<ChainId, ChainStyle> = {
|
||||
tower: { fill: "#b44906", text: "#ffffff", letter: "T", pattern: "stripes", patternInk: "#e6c1aa" },
|
||||
luxor: { fill: "#d08200", text: "#000000", letter: "L", pattern: "bars", patternInk: "#603c00" },
|
||||
worldwide: { fill: "#a16494", text: "#000000", letter: "W", pattern: "diagonalUp", patternInk: "#3a2435" },
|
||||
american: { fill: "#5285e0", text: "#000000", letter: "A", pattern: "diagonalDown", patternInk: "#22385e" },
|
||||
festival: { fill: "#0b7d59", text: "#ffffff", letter: "F", pattern: "dots", patternInk: "#b1d5ca" },
|
||||
imperial: { fill: "#7a2ac4", text: "#ffffff", letter: "I", pattern: "checker", patternInk: "#c4a1e5" },
|
||||
continental: { fill: "#21c5e2", text: "#000000", letter: "C", pattern: "crosshatch", patternInk: "#116473" },
|
||||
tower: { fill: "#b44906", text: "#ffffff", letter: "T" },
|
||||
luxor: { fill: "#d08200", text: "#000000", letter: "L" },
|
||||
worldwide: { fill: "#a16494", text: "#000000", letter: "W" },
|
||||
american: { fill: "#5285e0", text: "#000000", letter: "A" },
|
||||
festival: { fill: "#0b7d59", text: "#ffffff", letter: "F" },
|
||||
imperial: { fill: "#7a2ac4", text: "#ffffff", letter: "I" },
|
||||
continental: { fill: "#21c5e2", text: "#000000", letter: "C" },
|
||||
};
|
||||
|
||||
/** The Okabe-Ito colour each chain colour started from (the violet is new). */
|
||||
|
|
|
|||
16
packages/viewer/src/lib/playerAppearance.spec.ts
Normal file
16
packages/viewer/src/lib/playerAppearance.spec.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import { contrastRatio } from "./color.ts";
|
||||
import { THEMES } from "./palette.ts";
|
||||
import { PLAYER_COLORS, playerInk } from "./playerAppearance.ts";
|
||||
|
||||
test("default and custom player names remain readable on every light and dark surface", () => {
|
||||
for (const mode of ["light", "dark"] as const) {
|
||||
for (const color of [...PLAYER_COLORS, "#000000", "#ffffff", "#ffff00", "#13b7c8"]) {
|
||||
const ink = playerInk(color, mode);
|
||||
for (const surface of ["page", "panel", "panelAlt"] as const) {
|
||||
assert.ok(contrastRatio(ink, THEMES[mode][surface]) >= 4.5, `${color} on ${mode} ${surface}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
29
packages/viewer/src/lib/playerAppearance.ts
Normal file
29
packages/viewer/src/lib/playerAppearance.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import { contrastRatio, hexToRgb } from "./color.ts";
|
||||
import { THEMES } from "./palette.ts";
|
||||
|
||||
export const PLAYER_COLORS = ["#4595d1", "#e68b32", "#8a5cc2", "#3aa35b", "#d14545", "#d45c9e"];
|
||||
|
||||
export function playerColor(player: number, colors?: string[]): string {
|
||||
const preferred = colors?.[player];
|
||||
return preferred && /^#[\da-f]{6}$/i.test(preferred) ? preferred : PLAYER_COLORS[player % PLAYER_COLORS.length]!;
|
||||
}
|
||||
|
||||
export function playerInk(color: string, mode: "light" | "dark"): string {
|
||||
const theme = THEMES[mode];
|
||||
const rgb = hexToRgb(color);
|
||||
const ink = hexToRgb(theme.ink);
|
||||
for (let step = 0; step <= 20; step++) {
|
||||
const mix = step / 20;
|
||||
const candidate = `#${rgb
|
||||
.map((value, i) =>
|
||||
Math.round((value * (1 - mix) + ink[i]! * mix) * 255)
|
||||
.toString(16)
|
||||
.padStart(2, "0")
|
||||
)
|
||||
.join("")}`;
|
||||
if ([theme.page, theme.panel, theme.panelAlt].every((background) => contrastRatio(candidate, background) >= 4.5)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return theme.ink;
|
||||
}
|
||||
|
|
@ -1,3 +1,9 @@
|
|||
html:has(.acquire),
|
||||
body:has(.acquire) {
|
||||
margin: 0;
|
||||
background: var(--page);
|
||||
}
|
||||
|
||||
/* Square corners everywhere; outlines only on things the player can act on. */
|
||||
.acquire,
|
||||
.acquire * {
|
||||
|
|
@ -20,6 +26,18 @@
|
|||
padding: 12px;
|
||||
}
|
||||
|
||||
.acquire .player-name {
|
||||
color: var(--player-ink-light);
|
||||
}
|
||||
.acquire[data-theme="dark"] .player-name {
|
||||
color: var(--player-ink-dark);
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.acquire:not([data-theme]) .player-name {
|
||||
color: var(--player-ink-dark);
|
||||
}
|
||||
}
|
||||
|
||||
.acquire h2 {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
|
|
|
|||
|
|
@ -79,6 +79,113 @@ try {
|
|||
assert.equal(report.diagnostics.compatible, true);
|
||||
assert.equal(report.diagnostics.recommended.percent, 100);
|
||||
|
||||
for (const theme of ["light", "dark"]) {
|
||||
await page.setViewportSize({ width: 1920, height: 1280 });
|
||||
await open(`players=4&moves=95&publicHoldings=1&theme=${theme}`);
|
||||
const geometry = await page.evaluate(() => {
|
||||
const main = document.querySelector("main");
|
||||
const column = document.querySelector(".layout > .board");
|
||||
const frame = column.querySelector(".frame");
|
||||
return {
|
||||
margin: getComputedStyle(document.body).margin,
|
||||
page: getComputedStyle(main).backgroundColor,
|
||||
canvas: getComputedStyle(document.documentElement).backgroundColor,
|
||||
body: getComputedStyle(document.body).backgroundColor,
|
||||
left: main.getBoundingClientRect().left,
|
||||
right: main.getBoundingClientRect().right,
|
||||
board: frame.getBoundingClientRect().width,
|
||||
column: column.getBoundingClientRect().width,
|
||||
};
|
||||
});
|
||||
assert.equal(geometry.margin, "0px");
|
||||
assert.equal(geometry.canvas, geometry.page);
|
||||
assert.equal(geometry.body, geometry.page);
|
||||
assert.equal(geometry.left, 0);
|
||||
assert.equal(geometry.right, 1920);
|
||||
assert.ok(geometry.board > 750, "board uses the wide desktop column");
|
||||
assert.ok(Math.abs(geometry.board - geometry.column) < 1);
|
||||
assert.equal(await page.locator(".chat summary").isVisible(), false);
|
||||
assert.equal(await page.locator(".chat-composer").isVisible(), true);
|
||||
await page.screenshot({ path: new URL(`fullscreen-${theme}.png`, output).pathname });
|
||||
}
|
||||
report.scenarios.push("full-window theme background, no outer gutters, wider board and permanently visible chat");
|
||||
|
||||
await open("players=4&hotseat=0&view=0&theme=dark");
|
||||
const inspectHand = async (view) => {
|
||||
const expected = await page.evaluate((view) => {
|
||||
const dev = window.acquireDev;
|
||||
const player =
|
||||
view === "acting"
|
||||
? dev.engine.currentPlayer(dev.state)
|
||||
: view === "waiting"
|
||||
? (dev.engine.currentPlayer(dev.state) + 1) % 4
|
||||
: undefined;
|
||||
const state = dev.engine.stripSecret(structuredClone(dev.state), player);
|
||||
dev.emitter.emit("player", { index: player });
|
||||
dev.emitter.emit("state", state);
|
||||
return player === undefined
|
||||
? []
|
||||
: state.seats
|
||||
.flatMap((seat, index) =>
|
||||
state.seatOwner[index] === player
|
||||
? seat.hand.filter((tile) => tile !== dev.rules.HIDDEN).map(dev.rules.tileLabel)
|
||||
: []
|
||||
)
|
||||
.sort();
|
||||
}, view);
|
||||
await settle();
|
||||
assert.deepEqual((await page.locator(".square.held .coord").allTextContents()).sort(), expected);
|
||||
};
|
||||
await inspectHand("waiting");
|
||||
assert.equal(await page.locator(".square.playable").count(), 0, "waiting players cannot submit a tile");
|
||||
await inspectHand("spectator");
|
||||
await inspectHand("acting");
|
||||
await open("players=4&theme=dark");
|
||||
const beforeBoardMove = await page.evaluate(() => window.acquireDev.state.log.length);
|
||||
await page.locator(".square.playable").first().click();
|
||||
assert.equal(
|
||||
await page.evaluate(() => window.acquireDev.state.log.length),
|
||||
beforeBoardMove,
|
||||
"first click previews the move"
|
||||
);
|
||||
assert.equal(await page.locator(".square.selected").count(), 1);
|
||||
await page.locator(".square.selected").click();
|
||||
await page.waitForFunction((length) => window.acquireDev.state.log.length > length, beforeBoardMove);
|
||||
await page.evaluate(() => window.acquireDev.emitter.emit("replay:start"));
|
||||
await settle();
|
||||
assert.equal(
|
||||
await page.locator(".square.held").count(),
|
||||
0,
|
||||
"replay does not project the current hand onto old boards"
|
||||
);
|
||||
report.scenarios.push(
|
||||
"own hand visible while waiting, spectator privacy, board selection/confirmation and replay isolation"
|
||||
);
|
||||
|
||||
await open("players=4&moves=95&theme=light&colorBlind=1");
|
||||
assert.equal(await page.locator(".chain .letter").count(), await page.locator(".square.chain").count());
|
||||
assert.equal(await page.locator(".pattern, .patterned").count(), 0);
|
||||
assert.ok((await page.locator(".chat .player-symbol").count()) > 0);
|
||||
const authorColors = await page
|
||||
.locator(".chat .player-name")
|
||||
.evaluateAll((names) => names.map((name) => getComputedStyle(name).color));
|
||||
assert.equal(new Set(authorColors).size, 2, "chat authors have distinct player colors");
|
||||
await page.locator(".chat-composer input").fill("Unsent draft");
|
||||
await preferences({
|
||||
locale: "en",
|
||||
colorBlind: true,
|
||||
bgs: { players: [{}, {}, {}, {}], playerColors: ["#13b7c8", "#111111", "#ffffff", "#3aa35b"] },
|
||||
});
|
||||
assert.equal(
|
||||
await page.locator(".chat-composer input").inputValue(),
|
||||
"Unsent draft",
|
||||
"appearance updates preserve chat drafts"
|
||||
);
|
||||
await page.locator(".chat-composer input").fill("");
|
||||
report.scenarios.push(
|
||||
"chain letters without redundant patterns; player colors/symbols in chat and live appearance updates"
|
||||
);
|
||||
|
||||
for (const [width, height] of [
|
||||
[1280, 900],
|
||||
[390, 844],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue