1
0

Robber is always on the Desert

Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
James Ketrenos 2022-01-31 17:08:33 -08:00
parent c3e15b986b
commit be6fc22534
2 changed files with 16 additions and 16 deletions

View File

@ -1252,17 +1252,13 @@ class Board extends React.Component {
let angle, let angle,
radius = this.radius, radius = this.radius,
index = 1, pip; //, roll = dice[0].pips + dice[1].pips; index = 0, pip; //, roll = dice[0].pips + dice[1].pips;
/* Outer row */ /* Outer row */
angle = 0; angle = 0;
for (let i = 0; i < 12; i++) { for (let i = 0; i < 12; i++) {
angle -= Math.PI * 2. / 12.; angle -= Math.PI * 2. / 12.;
if (this.tiles[i].type === "robber") { pip = this.pips.pips[index++];
pip = this.pips.pips[0]
} else {
pip = this.pips.pips[index++];
}
this.tiles[i].pip = pip; this.tiles[i].pip = pip;
drawTile(this.tiles[i], angle, radius - (i % 2) * 0.04); drawTile(this.tiles[i], angle, radius - (i % 2) * 0.04);
drawPip(pip, angle, radius - (i % 2) * 0.04, this.tiles[i].jitter); drawPip(pip, angle, radius - (i % 2) * 0.04, this.tiles[i].jitter);
@ -1273,11 +1269,7 @@ class Board extends React.Component {
radius = this.radius * 0.5; radius = this.radius * 0.5;
for (let i = 12; i < 18; i++) { for (let i = 12; i < 18; i++) {
angle -= Math.PI * 2. / 6.; angle -= Math.PI * 2. / 6.;
if (this.tiles[i].type === "robber") { pip = this.pips.pips[index++];
pip = this.pips.pips[0]
} else {
pip = this.pips.pips[index++];
}
this.tiles[i].pip = pip; this.tiles[i].pip = pip;
drawTile(this.tiles[i], angle, radius); drawTile(this.tiles[i], angle, radius);
drawPip(pip, angle, radius, this.tiles[i].jitter); drawPip(pip, angle, radius, this.tiles[i].jitter);
@ -1285,11 +1277,7 @@ class Board extends React.Component {
/* Center */ /* Center */
let i = 18; let i = 18;
if (this.tiles[i].type === "robber") { pip = this.pips.pips[index++];
pip = this.pips.pips[0]
} else {
pip = this.pips.pips[index++];
}
this.tiles[i].pip = pip; this.tiles[i].pip = pip;
drawTile(this.tiles[i], 0, 0); drawTile(this.tiles[i], 0, 0);
drawPip(pip, 0, 0, this.tiles[i].jitter); drawPip(pip, 0, 0, this.tiles[i].jitter);

View File

@ -646,6 +646,18 @@ const shuffleBoard = (game) => {
} }
}); });
/* Walk through the board looking for the robber and
* if it isn't on the desert, swap with the desert to
* be under the robber */
const robberIndex = game.pips.findIndex((pip) => pip.roll === 7),
desertIndex = game.tiles.findIndex((tile) => tile.type === 'robber');
if (robberIndex !== desertIndex) {
let tmp = game.tiles[desertIndex];
game.tiles[desertIndex] = game.tiles[robberIndex];
game.tiles[robberIndex] = tmp;
}
shuffle(game.developmentCards) shuffle(game.developmentCards)
} }