Skip to content

Commit 61efdaa

Browse files
committed
Cifra: Fix race condition
1 parent 739d0be commit 61efdaa

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/games/cifra.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export class CifraGame extends GameBase {
152152
if (this.gameover) { return []; }
153153

154154
// side choosing
155-
if (this.stack.length === 1 || this.firstChoice === undefined) {
155+
if (this.firstChoice === undefined) {
156156
return ["light,top", "light,bottom", "dark,top", "dark,bottom","light,left", "light,right", "dark,left", "dark,right"];
157157
}
158158

@@ -200,7 +200,7 @@ export class CifraGame extends GameBase {
200200
}
201201

202202
public getButtons(): ICustomButton[] {
203-
if (this.stack.length === 1 || this.firstChoice === undefined) {
203+
if (this.firstChoice === undefined) {
204204
return [
205205
{ label: "cifra.lt", move: "light,top" },
206206
{ label: "cifra.lb", move: "light,bottom" },
@@ -216,7 +216,7 @@ export class CifraGame extends GameBase {
216216
}
217217

218218
public randomMove(): string {
219-
if (this.stack.length === 1 || this.firstChoice === undefined) {
219+
if (this.firstChoice === undefined) {
220220
const shuffled = shuffle(["light,top", "light,bottom", "dark,top", "dark,bottom","light,left", "light,right", "dark,left", "dark,right"]) as string[];
221221
return shuffled[0];
222222
} else if ( (this.variants.includes("sum") || this.variants.includes("king")) && this.stack.length <= 3) {
@@ -253,7 +253,7 @@ export class CifraGame extends GameBase {
253253
}
254254

255255
public getHomeRowCol(p: playerid): {col?: number; row?: number}|undefined {
256-
if (this.stack.length < 2 || this.firstChoice === undefined) {
256+
if (this.firstChoice === undefined) {
257257
return undefined;
258258
}
259259
const [, position] = this.firstChoice.split(",");
@@ -267,15 +267,15 @@ export class CifraGame extends GameBase {
267267
}
268268

269269
public get firstPos(): string|undefined {
270-
if (this.stack.length < 2 || this.firstChoice === undefined) {
270+
if (this.firstChoice === undefined) {
271271
return undefined;
272272
}
273273
const [, position] = this.firstChoice.split(",");
274274
return position;
275275
}
276276

277277
public getPlayerColour(p: playerid): number|string {
278-
if (this.stack.length === 1 || this.firstChoice === undefined) {
278+
if (this.firstChoice === undefined) {
279279
return "#808080";
280280
}
281281
const [shade,] = this.firstChoice.split(",");
@@ -285,7 +285,7 @@ export class CifraGame extends GameBase {
285285
}
286286

287287
public getPlayerShade(p: playerid): Shade|undefined {
288-
if (this.stack.length === 1 || this.firstChoice === undefined) {
288+
if (this.firstChoice === undefined) {
289289
return undefined
290290
}
291291
const [shade,] = this.firstChoice.split(",");
@@ -381,7 +381,7 @@ export class CifraGame extends GameBase {
381381

382382
if (m.length === 0) {
383383
let context = "play";
384-
if (this.stack.length === 1 || this.firstChoice === undefined) {
384+
if (this.firstChoice === undefined) {
385385
context = "choose";
386386
} else if ((this.variants.includes("king") || this.variants.includes("sum")) && this.stack.length <= 2) {
387387
context = "setup";
@@ -393,7 +393,7 @@ export class CifraGame extends GameBase {
393393
}
394394

395395
// setup scenarios first
396-
if (this.stack.length === 1 || this.firstChoice === undefined) {
396+
if (this.firstChoice === undefined) {
397397
const [shade, pos] = m.split(",")
398398
if ( (shade === "light" || shade === "dark") && (pos === "top" || pos === "bottom" || pos === "left" || pos === "right") ) {
399399
result.valid = true;
@@ -534,7 +534,7 @@ export class CifraGame extends GameBase {
534534
}
535535

536536
// choosing sides
537-
if (this.stack.length === 1 || this.firstChoice === undefined) {
537+
if (this.firstChoice === undefined) {
538538
this.firstChoice = m;
539539
this.results.push({type: "affiliate", which: m});
540540
// if in default Dash mode, populate the board

0 commit comments

Comments
 (0)