Skip to content

Commit c1ef44a

Browse files
Fix Fillomino [?] region size validation (fixes #462)
1 parent f59e7cd commit c1ef44a

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/variety/fillomino.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,8 +720,17 @@
720720
--numkind;
721721
}
722722
component.numkind = numkind;
723-
component.number =
724-
numkind === 1 ? filled : numkind === 0 ? clist.length : -1;
723+
if (numkind === 1) {
724+
if (filled === -2) {
725+
component.number = clist.length;
726+
} else {
727+
component.number = filled;
728+
}
729+
} else if (numkind === 0) {
730+
component.number = clist.length;
731+
} else {
732+
component.number = -1;
733+
}
725734
component.complete = clist.length === component.number;
726735
component.looseborders = null;
727736
},

test/variety/fillomino_test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,20 @@ describe("Variety:fillomino", function() {
4646
center.adjacent.left.setNum(-1);
4747
assert.equal(center.adjborder.top.qcmp, 0);
4848
});
49+
50+
it("detects same size regions with ? properly", function() {
51+
var p = new pzpr.Puzzle();
52+
p.open("fillomino/5/1");
53+
p.board.getc(1, 1).setNum(-2);
54+
p.board.getc(3, 1).setNum(-2);
55+
p.board.getb(2, 1).setQans(0);
56+
p.board.getb(4, 1).setQans(1);
57+
p.board.getc(5, 1).setNum(-2);
58+
p.board.getc(7, 1).setNum(-2);
59+
p.board.getb(6, 1).setQans(0);
60+
p.board.getb(8, 1).setQans(1);
61+
p.board.getc(9, 1).setNum(1);
62+
var check = p.check(true);
63+
assert.equal(check[0], "bsSameNum");
64+
});
4965
});

0 commit comments

Comments
 (0)