From d21684430a4619e65ac57be5e9cdf3c55efdad49 Mon Sep 17 00:00:00 2001 From: coyotte508 Date: Fri, 2 Oct 2026 11:20:54 +0200 Subject: [PATCH] Use shared BGS preferred colourblind player symbols --- pnpm-lock.yaml | 10 +++++----- viewer/package.json | 2 +- viewer/scripts/protocol-smoke.mjs | 19 +++++++++++++++++++ viewer/src/components/Game.vue | 12 +++++++++--- viewer/src/components/PlayerBoard.vue | 7 +++++-- viewer/src/components/pieces/Ship.vue | 6 +++++- viewer/src/player-colors.ts | 5 +++++ viewer/src/types/ui-data.ts | 7 ++++++- viewer/vue.config.js | 1 + 9 files changed, 56 insertions(+), 13 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e9dfb0b..e1ca33c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -86,8 +86,8 @@ importers: viewer: dependencies: '@boardgamers/protocol': - specifier: 0.8.1 - version: 0.8.1 + specifier: 0.9.0 + version: 0.9.0 container-engine: specifier: workspace:../engine version: link:../engine @@ -1042,10 +1042,10 @@ packages: } engines: { node: '>=6.9.0' } - '@boardgamers/protocol@0.8.1': + '@boardgamers/protocol@0.9.0': resolution: { - integrity: sha512-BZNj+wof1aR1nSybRMqmQ+yAVNR3ZZy+mczIz2KbXSLXMLL3Jv21yi50CRbJ2ipdkPiPatcSP0nJj+xJbFgIfQ==, + integrity: sha512-xDQMui0xqqRF/ERIJ7Rm79JonMA2+6zn1CrgxpM6Oy3SpFKF6i0Wo6oAyYYqMveqiWJCkC0WvHlePclVfbH/IQ==, } '@cspotcode/source-map-support@0.8.1': @@ -11587,7 +11587,7 @@ snapshots: '@babel/helper-string-parser': 7.29.7 '@babel/helper-validator-identifier': 7.29.7 - '@boardgamers/protocol@0.8.1': + '@boardgamers/protocol@0.9.0': dependencies: zod: 4.6.2 diff --git a/viewer/package.json b/viewer/package.json index cae63c7..c42b36e 100644 --- a/viewer/package.json +++ b/viewer/package.json @@ -19,7 +19,7 @@ "preview:tutorial": "node scripts/tutorial-preview.mjs" }, "dependencies": { - "@boardgamers/protocol": "0.8.1", + "@boardgamers/protocol": "0.9.0", "container-engine": "workspace:../engine", "core-js": "^3.6.5", "lodash": "^4.17.19", diff --git a/viewer/scripts/protocol-smoke.mjs b/viewer/scripts/protocol-smoke.mjs index b209ea1..08e83ed 100644 --- a/viewer/scripts/protocol-smoke.mjs +++ b/viewer/scripts/protocol-smoke.mjs @@ -118,6 +118,25 @@ try { 'journal uses the same colour symbols' ); assert.equal(await page.locator('.player-number').count(), 6, 'ships and island rows identify all players'); + await page.evaluate(() => + host.emit('preferences', { + colorBlind: true, + bgs: { players: [], playerColors: [], playerSymbols: ['star', 'hexagon', 'cross'] }, + }) + ); + await page.waitForFunction(() => document.querySelector('.player-number')?.textContent.includes('★')); + assert.equal( + await page.locator('.point-card .color-mark').count(), + 5, + 'resource symbols keep their own meaning' + ); + await page.evaluate(() => + host.emit('preferences', { + colorBlind: true, + bgs: { players: [], playerColors: [], playerSymbols: ['diamond', 'hexagon', 'cross'] }, + }) + ); + await page.waitForFunction(() => document.querySelector('.player-number')?.textContent.includes('◆')); await page.screenshot({ path: `/tmp/container-color-blind-${width}.png`, fullPage: true }); await page.locator('.color-blind-toggle').scrollIntoViewIfNeeded(); await page.locator('.color-blind-toggle').click(); diff --git a/viewer/src/components/Game.vue b/viewer/src/components/Game.vue index 8c255bf..f75a995 100644 --- a/viewer/src/components/Game.vue +++ b/viewer/src/components/Game.vue @@ -39,7 +39,9 @@ width="14" height="14" /> - {{ + preferences.colorBlind ? ownerSymbol(i) : '' + }}{{ i === player ? 'You' : p.name }} @@ -158,7 +160,7 @@ stroke="#203a45" /> - {{ i + 1 }} + {{ ownerSymbol(i) }} @@ -704,7 +706,7 @@ import InlineLog from './InlineLog.vue'; import { islandValue } from '../island-value'; import ColorBlindButton from './buttons/ColorBlindButton.vue'; import { colorBadgeHtml } from '../color-blind'; -import { playerColors, playerTextColor } from '../player-colors'; +import { playerColors, playerTextColor, playerSymbol } from '../player-colors'; import { journalPieces } from '../journal-pieces'; import { Vue, Component, Prop, Watch, Provide, ProvideReactive } from 'vue-property-decorator'; import { MoveName, ended, isLoanReversal, move as engineMove } from 'container-engine'; @@ -793,6 +795,10 @@ export default class Game extends Vue { loanCards: Piece[] = []; ships: ShipType[] = []; + ownerSymbol(index: number) { + return playerSymbol(index, this.preferences); + } + get playerColors() { return playerColors(this.preferences); } diff --git a/viewer/src/components/PlayerBoard.vue b/viewer/src/components/PlayerBoard.vue index 14e16c8..f8f6070 100644 --- a/viewer/src/components/PlayerBoard.vue +++ b/viewer/src/components/PlayerBoard.vue @@ -10,7 +10,7 @@ font-weight="600" :fill="playerTextColor(color)" :text-decoration="isCurrentPlayer ? 'underline' : ''" - >{{ preferences.colorBlind ? owner + 1 + '. ' : '' }}{{ getPlayerName() }}{{ preferences.colorBlind ? ownerSymbol + ' ' : '' }}{{ getPlayerName() }}