- commit
- 1a04d702cea64778065807e87bad5077f4deb07d
- parent
- 136662e7c14af7d6fe427071d4366c1037ae4422
- author
- Dami <dami.etoile@gmail.com>
| M | src/ | 15 | +++++++++------ |
| M | tests/ | 31 | ++++++++++++++++++++++++++++-- |
@@ -1,4 +1,5 @@
11 import { actionMatches, keycapPressFrame, stepRollFrame } from './motion.js';2+import { BOARD_COLORS } from './board/model.js';23 34 function keycapOptions(align, options) {45 if (align && typeof align === 'object') return { ...align, align: align.align || 'left' };@@ -348,11 +349,13 @@ export function drawMiniTile(
348349 ) {349350 const fills = {350351 noun: "#F2EEE6",351- YOU: "#FF4B3E",352- WIN: "#2EE6A8",353- PUSH: "#F2C14E",354- STOP: "#C6B7FF",355- TICK: "#C6F432",352+ YOU: BOARD_COLORS.YOU,353+ WIN: BOARD_COLORS.WIN,354+ PUSH: BOARD_COLORS.PUSH,355+ STOP: BOARD_COLORS.STOP,356+ TICK: BOARD_COLORS.TICK,357+ SINK: BOARD_COLORS.SINK,358+ DEFEAT: BOARD_COLORS.DEFEAT,356359 IS: "#F2EEE6",357360 AND: "#F2EEE6",358361 };@@ -396,7 +399,7 @@ export function drawSentenceTiles(
396399 let cursor = x;397400 for (const word of words) {398401 const value = word.toUpperCase();399- const role = ["YOU", "WIN", "PUSH", "STOP", "TICK", "IS", "AND"].includes(402+ const role = ["YOU", "WIN", "PUSH", "STOP", "TICK", "SINK", "DEFEAT", "IS", "AND"].includes(400403 value,401404 )402405 ? value@@ -1,10 +1,11 @@
11 import test from 'node:test';22 import assert from 'node:assert/strict';33 import { drawInlineActions, drawLedger, drawStepCounter } from '../src/render/stage-hud.js';4+import { BOARD_COLORS } from '../src/render/board/model.js';45 56 function context() {67 const calls = [];7- return {8+ const ctx = {89 calls,910 font: '',1011 save() { calls.push(['save']); },@@ -18,12 +19,38 @@ function context() {
1819 rect(...args) { calls.push(['rect', ...args]); },1920 clip() { calls.push(['clip']); },2021 stroke() { calls.push(['stroke']); },21- fillRect(...args) { calls.push(['fillRect', ...args]); },22+ fillRect(...args) { calls.push(['fillRect', ...args, this.fillStyle]); },2223 fillText(...args) { calls.push(['fillText', ...args]); },2324 measureText(text) { return { width: String(text).length * 6 }; },2425 };26+ Object.defineProperty(ctx, 'fillStyle', {27+ get() { return this._fillStyle; },28+ set(value) { this._fillStyle = value; },29+ });30+ return ctx;2531 }2632 33+test('drawLedger uses the board palette for every core property tile', () => {34+ const ctx = context();35+ const properties = ['YOU', 'PUSH', 'STOP', 'WIN', 'SINK', 'DEFEAT', 'TICK'];36+ const entries = properties.map((property) => ({ text: `MIAU IS ${property}` }));37+ drawLedger(38+ ctx,39+ entries,40+ 10,41+ 20,42+ 2000,43+ );44+ const tileFills = ctx.calls45+ .filter((call) => call[0] === 'fillRect' && call[5] !== '#000000')46+ .map((call) => call[5]);47+ const expected = properties.map((property) => BOARD_COLORS[property]);48+ const propertyFills = tileFills.filter((fill) => expected.includes(fill));49+ assert.equal(propertyFills.length, expected.length + 1, 'only the fallback PUSH tile adds a second core fill');50+ assert.deepEqual(propertyFills.slice(0, expected.length), expected);51+ assert.equal(propertyFills.at(-1), BOARD_COLORS.PUSH);52+});53+2754 test('drawLedger consumes physical frame entries with stamp, strike, and exit state', () => {2855 const ctx = context();2956 drawLedger(ctx, [{ text: 'MIAU IS YOU' }], 10, 20, 300, {