Release viewer 2.3.8 preserving custom BGS colours after colour selection
This commit is contained in:
parent
ef972c74fc
commit
287343f11c
3 changed files with 6 additions and 5 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "powergrid-viewer",
|
||||
"version": "2.3.7",
|
||||
"version": "2.3.8",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/boardgamers/powergrid.git",
|
||||
|
|
|
|||
|
|
@ -1145,8 +1145,7 @@ export default class Game extends Vue {
|
|||
|
||||
defaultPlayerColors = ['limegreen', 'mediumorchid', 'red', 'dodgerblue', 'yellow', 'brown'];
|
||||
|
||||
// Colors indexed by player id. Falls back to the default palette, but any color
|
||||
// a player drafted via the chooseColors option overrides their default entry.
|
||||
// Colors indexed by player id: BGS preferences, then drafted colors, then defaults.
|
||||
get playerColors() {
|
||||
return resolvePlayerColors(this.defaultPlayerColors, this.G?.players ?? [], this.preferences);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,13 +6,15 @@ export function resolvePlayerColors(
|
|||
preferences?: ColorPreferences
|
||||
): string[] {
|
||||
const colors = [...defaults];
|
||||
for (const player of players) if (player.color) colors[player.id] = player.color;
|
||||
|
||||
// The game's chosen colors are fallbacks for the viewer's BGS preferences.
|
||||
const preferred = preferences?.bgs?.playerColors;
|
||||
if (!preferences?.colorBlind && !players.some((p) => p.color) && Array.isArray(preferred)) {
|
||||
if (!preferences?.colorBlind && Array.isArray(preferred)) {
|
||||
preferred.slice(0, colors.length).forEach((color, i) => {
|
||||
if (typeof color === 'string' && /^#[a-f0-9]{6}$/i.test(color)) colors[i] = color;
|
||||
});
|
||||
}
|
||||
for (const player of players) if (player.color) colors[player.id] = player.color;
|
||||
return colors;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue