Simplify accessability of player names
This commit is contained in:
parent
480a77ff86
commit
f36b60b2e4
|
@ -5,9 +5,11 @@ export class Constants
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The IDs of the players.
|
* The IDs of the players.
|
||||||
|
*
|
||||||
|
* @type {Partial<Record<CellOwner, string>>}
|
||||||
*/
|
*/
|
||||||
static PLAYER_NAMES = [
|
static PLAYER_NAMES = {
|
||||||
"red",
|
r: "red",
|
||||||
"blue"
|
b: "blue"
|
||||||
];
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { Constants } from "./Constants.js";
|
||||||
import { elt } from "./elt.js";
|
import { elt } from "./elt.js";
|
||||||
import { State } from "./State.js";
|
import { State } from "./State.js";
|
||||||
|
|
||||||
|
@ -10,6 +11,7 @@ import { State } from "./State.js";
|
||||||
export function initializeBoard(id)
|
export function initializeBoard(id)
|
||||||
{
|
{
|
||||||
let board = document.getElementById(id);
|
let board = document.getElementById(id);
|
||||||
|
board.innerHTML = "";
|
||||||
|
|
||||||
for (let i = 0; i < 6; i++)
|
for (let i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
|
@ -24,7 +26,7 @@ export function initializeBoard(id)
|
||||||
children.push(elt(
|
children.push(elt(
|
||||||
"div",
|
"div",
|
||||||
{
|
{
|
||||||
class: `piece ${playerId === "r" ? "red" : "blue"}`
|
class: `piece ${Constants.PLAYER_NAMES[playerId]}`
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue