Skip to content

Commit

Permalink
Fix Bosnian Road shading input (#548)
Browse files Browse the repository at this point in the history
  • Loading branch information
Seren-35 authored Jul 3, 2024
1 parent 1443ef6 commit 4424dd2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/variety/bosnianroad.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
(this.mousestart || this.mousemove) &&
(!this.firstCell.isnull || this.notInputted())
) {
this.inputcell();
this.inputShade();
}
if (this.mouseend && this.notInputted()) {
this.inputqcmp();
Expand Down Expand Up @@ -59,6 +59,11 @@
},

inputShade: function() {
if (this.puzzle.playmode) {
this.inputcell();
return;
}

var cell = this.getcell();
if (cell.isnull || cell === this.mouseCell) {
return;
Expand All @@ -67,7 +72,7 @@
this.inputData = cell.qnum === -1 ? -2 : -1;
}
if ((this.inputData === -1) !== (cell.qnum === -1)) {
cell.setQnum(this.inputData);
cell.setNum(this.inputData);
cell.drawaround();
}
this.mouseCell = cell;
Expand Down
27 changes: 26 additions & 1 deletion test/script/bosnianroad.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,30 @@ ui.debug.addDebugData("bosnianroad", {
"pzprv3/bosnianroad/7/7/. . . . . . . /. 2 . . . 4 . /. . . . . . . /. . . . . . . /. . . . . . . /. - . . . 7 . /. . . . . . . /+ + + + + + + /+ . # # # . + /+ + # + # # # /+ + # + + + # /+ + # # # + # /+ . + + # . # /+ + + + # # # /"
]
],
inputs: []
inputs: [
{
label: "Gray cells",
input: ["newboard,3,3", "editmode,auto", "mouse,right, 1,1, 1,5"],
result:
"pzprv3/bosnianroad/3/3/- . . /- . . /- . . /. . . /. . . /. . . /"
},
{
label: "Shaded cells",
input: ["playmode,shade", "mouse,left, 1,1, 5,1"],
result:
"pzprv3/bosnianroad/3/3/- . . /- . . /- . . /. # # /. . . /. . . /"
},
{
label: "Unshaded cells",
input: ["playmode,unshade", "mouse,left, 1,5, 5,5"],
result:
"pzprv3/bosnianroad/3/3/- . . /- . . /- . . /. # # /. . . /. + + /"
},
{
label: "Gray cells on top of answer",
input: ["editmode,shade", "mouse,left, 5,1, 5,5"],
result:
"pzprv3/bosnianroad/3/3/- . - /- . - /- . - /. # . /. . . /. + . /"
}
]
});

0 comments on commit 4424dd2

Please sign in to comment.