Skip to content

Commit

Permalink
Add Subomino
Browse files Browse the repository at this point in the history
  • Loading branch information
x-sheep authored Apr 1, 2024
1 parent 0b90b4b commit efb0241
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src-ui/changes.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
<main>
<div style="margin-bottom: 5px;"><b>Latest types</b> (<em><a href="/list.html" target="_parent">all types</a></em>)</div>
<ul>
<li><a href="/p?subomino" target="_parent">Subomino</a></li>
<li><a href="/p?retroships" target="_parent">Retrograde Battleships</a></li>
<li><a href="/p?pmemory" target="_parent">Persistence of Memory</a></li>
<li><a href="/p?mrtile" target="_parent">Mirroring Tile ミラーリングタイル</a></li>
<li><a href="/p?kissing" target="_parent">Kissing Polyominoes</a></li>
<li><a href="/p?lineofsight" target="_parent">Line of Sight サイトライン</a></li>
<li><a href="/p?tetrominous" target="_parent">Tetrominous</a></li>
<li><a href="/p?mannequin" target="_parent">Mannequin Gate マネキンゲート</a></li>
</ul>
</main>
</body>
Binary file added src-ui/img/subomino.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src-ui/js/ui/KeyPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ ui.keypopup = {
mannequin: [10, 0],
tetrominous: [128, 128],
lineofsight: [10, 0],
mrtile: [10, 0]
mrtile: [10, 0],
subomino: [10, 0]
},

//---------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src-ui/js/ui/Misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ function toBGimage(pid) {
"squarejam",
"starbattle",
"statuepark",
"subomino",
"wafusuma",
"symmarea",
"tachibk",
Expand Down
1 change: 1 addition & 0 deletions src-ui/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ <h2 id="title"><span lang="ja">パズルの種類のリスト</span><span lang="
<li data-pid="fracdiv"></li>
<li data-pid="sashikazune"></li>
<li data-pid="tachibk"></li>
<li data-pid="subomino"></li>
</ul>
</div>
<div class="lists divides">
Expand Down
1 change: 1 addition & 0 deletions src/pzpr/variety.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@
statuepark: [0, 0, "Statue Park", "Statue Park"],
"statuepark-aux": [0, 0, "図形の編集", "Edit shape"],
stostone: [0, 0, "ストストーン", "Stostone", "shimaguni"],
subomino: [0, 0, "Subomino", "Subomino", "nawabari"],
sudoku: [0, 1, "数独", "Sudoku"],
sukoro: [1, 0, "数コロ", "Sukoro", "sukoro"],
sukororoom: [0, 0, "数コロ部屋", "Sukoro-room", "sukoro"],
Expand Down
1 change: 1 addition & 0 deletions src/res/failcode.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@
"bkObjGe2.kinkonkan": "A room has more than one mirror.",
"bkObjNotSym.bonsan": "Position of circles in the room is not point symmetric.",
"bkOddSize.kazunori": "The size of the room is not even.",
"bkOverlap.subomino": "A block fits entirely in an adjacent block.",
"bkOverNum": "A block contains too many numbers.",
"bkPassTwice.country": "A line passes a country twice or more.",
"bkPassTwice.moonsun": "A line passes a room twice or more.",
Expand Down
148 changes: 139 additions & 9 deletions src/variety/nawabari.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
} else {
pzpr.classmgr.makeCustom(pidlist, classbase);
}
})(["nawabari", "fourcells", "fivecells", "heteromino"], {
})(["nawabari", "fourcells", "fivecells", "heteromino", "subomino"], {
//---------------------------------------------------------
// マウス入力系
MouseEvent: {
Expand All @@ -29,10 +29,13 @@
this.inputempty();
}
},
"MouseEvent@fourcells,fivecells,heteromino": {
"MouseEvent@fourcells,fivecells,subomino": {
inputModes: {
edit: ["empty", "number", "clear"],
play: ["border", "subline"]
},
mouseinput_clear: function() {
this.inputFixedNumber(-1);
}
},

Expand All @@ -42,7 +45,7 @@
enablemake: true
},

"KeyEvent@fourcells,fivecells,heteromino": {
"KeyEvent@fourcells,fivecells,subomino,heteromino": {
keyinput: function(ca) {
if (ca === "w") {
this.key_inputvalid(ca);
Expand Down Expand Up @@ -87,6 +90,19 @@
maxnum: 3,
minnum: 0
},
"Cell@subomino": {
maxnum: function() {
return this.board.cols * this.board.rows;
},
minnum: 2,
posthook: {
qnum: function(num) {
if (this.room) {
this.board.roommgr.setExtraData(this.room);
}
}
}
},
"CellList@heteromino": {
triminoShape: function() {
if (this.length !== 3) {
Expand All @@ -106,6 +122,15 @@
return id;
}
},
"CellList@subomino": {
seterr: function(err) {
this.each(function(cell) {
if (err > cell.error) {
cell.error = err;
}
});
}
},

Border: {
isGrid: function() {
Expand Down Expand Up @@ -154,6 +179,14 @@
AreaRoomGraph: {
enabled: true
},
"AreaRoomGraph@subomino": {
setExtraData: function(component) {
component.clist = new this.klass.CellList(component.getnodeobjs());
component.valid = !component.clist.some(function(cell) {
return cell.qnum > 0 && cell.qnum !== component.clist.length;
});
}
},

//---------------------------------------------------------
// 画像表示系
Expand All @@ -169,13 +202,14 @@
this.drawQansBorders();
this.drawQuesBorders();

this.drawQuesNumbers();
this.drawBorderQsubs();

if (this.pid === "heteromino") {
if (this.pid === "heteromino" || this.pid === "subomino") {
this.drawCircles();
this.drawChassis();
}

this.drawQuesNumbers();
this.drawBorderQsubs();

this.drawTarget();
},

Expand Down Expand Up @@ -210,12 +244,24 @@
}
},

"Graphic@heteromino": {
"Graphic@heteromino,subomino": {
errbcolor2: "rgb(255, 216, 216)",
circlestrokecolor_func: "null",
circleratio: [0.35, 0.35],
getBGCellColor: function(cell) {
if (!cell.isValid()) {
return "black";
}
return this.getBGCellColor_error1(cell);
var info = cell.error || cell.qinfo;
if (info === 1 || info === 3) {
return this.errbcolor1;
} else if (info === 2) {
return this.errbcolor2;
}
return null;
},
getCircleFillColor: function(cell) {
return cell.error === 3 ? this.errbcolor2 : null;
}
},

Expand Down Expand Up @@ -295,6 +341,16 @@
this.outbstr += cm;
}
},
"Encode@subomino": {
decodePzpr: function(type) {
this.decodeNumber16();
this.decodeEmpty();
},
encodePzpr: function(type) {
this.encodeNumber16();
this.encodeEmpty();
}
},
//---------------------------------------------------------
FileIO: {
decodeData: function() {
Expand Down Expand Up @@ -440,5 +496,79 @@
l2.seterr(1);
}
}
},
"AnsCheck@subomino": {
checklist: ["checkAreaOverlap", "checkNumberValid", "checkBorderDeadend+"],

checkAreaOverlap: function() {
var sides = this.board.roommgr.getSideAreaInfo();
for (var i = 0; i < sides.length; i++) {
var small = sides[i][0],
large = sides[i][1];

if (!small.valid || !large.valid) {
continue;
}
if (small.clist.length > large.clist.length) {
large = sides[i][0];
small = sides[i][1];
}

var ss = small.clist.getRectSize();
var ls = large.clist.getRectSize();
var clist = new this.klass.CellList();
var found = false;

for (var ox = 0; !found && ox <= ls.cols - ss.cols; ox++) {
for (var oy = 0; !found && oy <= ls.rows - ss.rows; oy++) {
var c;
for (c = 0; c < small.clist.length; c++) {
var oldcell = small.clist[c];
var newcell = this.board.getc(
ox * 2 + ls.x1 + oldcell.bx - ss.x1,
oy * 2 + ls.y1 + oldcell.by - ss.y1
);
if (newcell.isnull || newcell.room !== large) {
break;
}
clist.add(newcell);
}

if (c === small.clist.length) {
found = true;
} else {
clist = new this.klass.CellList();
}
}
}
if (!found) {
continue;
}

this.failcode.add("bkOverlap");
if (this.checkOnly) {
break;
}
clist.seterr(3);
small.clist.seterr(2);
large.clist.seterr(1);
}
},

checkNumberValid: function() {
var bd = this.board;
for (var r = 0; r < bd.roommgr.components.length; r++) {
var area = bd.roommgr.components[r];
if (area.valid) {
continue;
}

this.failcode.add("bkSizeNe");
if (this.checkOnly) {
break;
}
area.clist.seterr(1);
}
}
}
});
31 changes: 31 additions & 0 deletions test/script/subomino.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* subomino.js */

ui.debug.addDebugData("subomino", {
url: "5/5/3j6j3i4o410000",
failcheck: [
[
"bkSizeNe",
"pzprv3/subomino/5/5/3 . . . * /6 . . . . /3 . . . 4 /. . . . . /. . . . 4 /0 0 0 1 0 0 /0 0 1 0 1 0 /0 1 0 1 1 0 /0 1 1 1 1 0 /0 1 0 0 1 0 /0 0 0 0 0 /1 1 1 0 0 /1 0 1 0 0 /0 1 0 1 0 /0 0 1 0 0 /0 0 0 0 0 /"
],
[
"bkOverlap",
"pzprv3/subomino/5/5/3 . . . * /6 . . . . /3 . . . 4 /. . . . . /. . . . 4 /0 0 0 1 0 0 /0 0 0 0 1 0 /0 1 1 1 0 0 /0 1 0 0 1 0 /0 1 0 0 0 0 /0 0 0 0 0 /1 1 1 0 0 /1 1 0 1 0 /0 0 1 1 0 /0 1 1 1 1 /0 0 0 0 0 /"
],
[
null,
"pzprv3/subomino/5/5/3 . . . * /6 . . . . /3 . . . 4 /. . . . . /. . . . 4 /0 0 0 1 0 0 /0 0 1 0 1 0 /0 1 0 1 1 0 /0 1 1 0 1 0 /0 1 0 0 1 0 /0 0 0 0 0 /1 1 1 0 0 /1 0 1 0 0 /0 1 0 1 0 /0 0 1 1 0 /0 0 0 0 0 /"
]
],
inputs: [
{
input: ["newboard,3,3", "editmode", "cursor,3,3", "mouse,right,3,3"],
result:
"pzprv3/subomino/3/3/. . . /. 9 . /. . . /0 0 0 0 /0 0 0 0 /0 0 0 0 /0 0 0 /0 0 0 /0 0 0 /0 0 0 /"
},
{
input: ["editmode,clear", "mouse,left,3,3"],
result:
"pzprv3/subomino/3/3/. . . /. . . /. . . /0 0 0 0 /0 0 0 0 /0 0 0 0 /0 0 0 /0 0 0 /0 0 0 /0 0 0 /"
}
]
});

0 comments on commit efb0241

Please sign in to comment.