Color objects based on player color
Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
parent
51a60d0837
commit
30c7979871
@ -844,6 +844,36 @@ class Board extends React.Component {
|
|||||||
}, 250);
|
}, 250);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPlayerColors() {
|
||||||
|
switch (this.game.color) {
|
||||||
|
case "O":
|
||||||
|
return {
|
||||||
|
strokeStyle: "rgb(128, 64, 32)",
|
||||||
|
fillStyle: "rgb(255, 64, 0)"
|
||||||
|
}
|
||||||
|
case "R":
|
||||||
|
return {
|
||||||
|
strokeStyle: "rgb(255, 64, 64)",
|
||||||
|
fillStyle: "rgb(255, 0, 0)"
|
||||||
|
}
|
||||||
|
case "W":
|
||||||
|
return {
|
||||||
|
strokeStyle: "rgb(64, 64, 64)",
|
||||||
|
fillStyle: "rgb(255, 255, 255)"
|
||||||
|
}
|
||||||
|
case "B":
|
||||||
|
return {
|
||||||
|
strokeStyle: "rgb(64, 64, 255)",
|
||||||
|
fillStyle: "rgb(0, 0, 255)"
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return {
|
||||||
|
strokeStyle: "rgb(16, 16, 16)",
|
||||||
|
fillStyle: "rgb(64, 64, 64)"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
drawFrame() {
|
drawFrame() {
|
||||||
if (!this.canvas || !this.table) {
|
if (!this.canvas || !this.table) {
|
||||||
return;
|
return;
|
||||||
@ -959,16 +989,18 @@ class Board extends React.Component {
|
|||||||
|
|
||||||
if (this.closest.tile) {
|
if (this.closest.tile) {
|
||||||
ctx.save();
|
ctx.save();
|
||||||
|
|
||||||
|
Object.assign(ctx, this.getPlayerColors());
|
||||||
|
|
||||||
ctx.translate(this.closest.tile.pos.x, this.closest.tile.pos.y);
|
ctx.translate(this.closest.tile.pos.x, this.closest.tile.pos.y);
|
||||||
ctx.strokeStyle = "red";
|
/* draw circle hovered current tile
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.arc(0, 0, tileHeight * 0.5, 0, Math.PI * 2.);
|
ctx.arc(0, 0, tileHeight * 0.5, 0, Math.PI * 2.);
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
|
*/
|
||||||
|
|
||||||
/* road */
|
/* road */
|
||||||
let angle = Math.round(this.closest.info.angle / (Math.PI / 3.)) * (Math.PI / 3.);
|
let angle = Math.round(this.closest.info.angle / (Math.PI / 3.)) * (Math.PI / 3.);
|
||||||
ctx.strokeStyle = "rgb(64, 64, 255)";
|
|
||||||
ctx.fillStyle = "rgb(0, 0, 255)";
|
|
||||||
ctx.rotate(angle);
|
ctx.rotate(angle);
|
||||||
ctx.translate(-tileHeight * 0.5, 0);
|
ctx.translate(-tileHeight * 0.5, 0);
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
@ -982,8 +1014,6 @@ class Board extends React.Component {
|
|||||||
angle = (this.closest.info.angle - Math.PI / 6.);
|
angle = (this.closest.info.angle - Math.PI / 6.);
|
||||||
angle = Math.round(angle / (Math.PI / 3.)) * (Math.PI / 3.);
|
angle = Math.round(angle / (Math.PI / 3.)) * (Math.PI / 3.);
|
||||||
angle += Math.PI / 6.;
|
angle += Math.PI / 6.;
|
||||||
ctx.strokeStyle = "rgb(64, 64, 255)";
|
|
||||||
ctx.fillStyle = "rgb(0, 0, 255)";
|
|
||||||
ctx.rotate(angle);
|
ctx.rotate(angle);
|
||||||
ctx.translate(-tileWidth * 0.5, 0);
|
ctx.translate(-tileWidth * 0.5, 0);
|
||||||
ctx.rotate(-angle);
|
ctx.rotate(-angle);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user