Use shared BGS preferred colourblind player symbols
This commit is contained in:
parent
d0c9537cca
commit
d21684430a
9 changed files with 56 additions and 13 deletions
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -39,7 +39,9 @@
|
|||
width="14"
|
||||
height="14"
|
||||
/>
|
||||
<span class="player-board-marker" aria-hidden="true">{{ preferences.colorBlind ? i + 1 : '' }}</span
|
||||
<span class="player-board-marker" aria-hidden="true">{{
|
||||
preferences.colorBlind ? ownerSymbol(i) : ''
|
||||
}}</span
|
||||
><span class="player-board-name" :data-bgs-player="i">{{ i === player ? 'You' : p.name }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
|
@ -158,7 +160,7 @@
|
|||
stroke="#203a45"
|
||||
/>
|
||||
<text x="872" :y="441 + i * 44" text-anchor="middle" font-size="11" fill="#172d34">
|
||||
{{ i + 1 }}
|
||||
{{ ownerSymbol(i) }}
|
||||
</text>
|
||||
</g>
|
||||
</template>
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
font-weight="600"
|
||||
:fill="playerTextColor(color)"
|
||||
:text-decoration="isCurrentPlayer ? 'underline' : ''"
|
||||
>{{ preferences.colorBlind ? owner + 1 + '. ' : '' }}{{ getPlayerName() }}</text
|
||||
>{{ preferences.colorBlind ? ownerSymbol + ' ' : '' }}{{ getPlayerName() }}</text
|
||||
>
|
||||
|
||||
<image
|
||||
|
|
@ -206,7 +206,7 @@
|
|||
</g>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { playerTextColor } from '../player-colors';
|
||||
import { playerTextColor, playerSymbol } from '../player-colors';
|
||||
import type { Preferences } from '../types/ui-data';
|
||||
import { Player } from 'container-engine';
|
||||
import { Vue, Component, Prop, InjectReactive } from 'vue-property-decorator';
|
||||
|
|
@ -218,6 +218,9 @@ import DropZone from './DropZone.vue';
|
|||
},
|
||||
})
|
||||
export default class PlayerBoard extends Vue {
|
||||
get ownerSymbol() {
|
||||
return playerSymbol(this.owner, this.preferences);
|
||||
}
|
||||
playerTextColor = playerTextColor;
|
||||
@InjectReactive() readonly preferences!: Preferences;
|
||||
get supporterBadge() {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<g v-if="preferences.colorBlind" class="player-number" pointer-events="none">
|
||||
<circle cx="15" cy="8" r="5.5" fill="white" stroke="#203a45" />
|
||||
<text x="15" y="8" text-anchor="middle" fill="#172d34" font-size="9" font-weight="bold">{{
|
||||
owner + 1
|
||||
ownerSymbol
|
||||
}}</text>
|
||||
</g>
|
||||
<DropZone :width="30" :height="80" :enabled="player == owner" :accepts="'container'" :data="{ type: 'ship' }" />
|
||||
|
|
@ -32,6 +32,7 @@
|
|||
</g>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { playerSymbol } from '../../player-colors';
|
||||
import { Preferences, PieceType } from '@/types/ui-data';
|
||||
import { ContainerPiece, ShipPosition } from 'container-engine/src/gamestate';
|
||||
import { Component, InjectReactive, Mixins, Prop } from 'vue-property-decorator';
|
||||
|
|
@ -49,6 +50,9 @@ import DropZone from '../DropZone.vue';
|
|||
},
|
||||
})
|
||||
export default class Ship extends Mixins(Piece) {
|
||||
get ownerSymbol() {
|
||||
return playerSymbol(this.owner, this.preferences);
|
||||
}
|
||||
@InjectReactive() readonly preferences!: Preferences;
|
||||
@InjectReactive()
|
||||
readonly player!: number;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { playerSymbolGlyph } from '@boardgamers/protocol/player-symbols';
|
||||
import { playerColors as defaults } from 'container-engine/src/engine';
|
||||
import type { Preferences } from './types/ui-data';
|
||||
|
||||
|
|
@ -16,3 +17,7 @@ export function playerTextColor(color = ''): string {
|
|||
});
|
||||
return luminance[0] * 0.2126 + luminance[1] * 0.7152 + luminance[2] * 0.0722 > 0.179 ? '#111' : '#fff';
|
||||
}
|
||||
|
||||
export function playerSymbol(index: number, preferences: { bgs?: { playerSymbols?: string[] } }): string {
|
||||
return playerSymbolGlyph(preferences.bgs?.playerSymbols?.[index], String(index + 1));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,12 @@ export interface UIData {
|
|||
}
|
||||
|
||||
export type Preferences = {
|
||||
bgs?: { playerColors?: string[]; players?: { pro: boolean }[]; supporterBadge?: { url: string; label: string } };
|
||||
bgs?: {
|
||||
playerSymbols?: string[];
|
||||
playerColors?: string[];
|
||||
players?: { pro: boolean }[];
|
||||
supporterBadge?: { url: string; label: string };
|
||||
};
|
||||
analysis?: boolean;
|
||||
sound: boolean;
|
||||
colorBlind?: boolean;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ module.exports = {
|
|||
}));
|
||||
}
|
||||
// Webpack 4 predates package exports; resolve the published ESM entry points.
|
||||
config.resolve.alias.set('@boardgamers/protocol/player-symbols$', join(protocolDist, 'player-symbols.js'));
|
||||
config.resolve.alias.set('@boardgamers/protocol/viewer', join(protocolDist, 'viewer.js'));
|
||||
config.resolve.alias.set('@boardgamers/protocol/chat/dom$', join(protocolDist, 'chat-dom.js'));
|
||||
config.resolve.alias.set('@boardgamers/protocol/chat$', join(protocolDist, 'chat.js'));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue