Skip to content

Commit

Permalink
Add Nuritwin
Browse files Browse the repository at this point in the history
  • Loading branch information
x-sheep committed Feb 28, 2025
1 parent 1bab081 commit 97ecb80
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src-ui/js/ui/KeyPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ ui.keypopup = {
balloon: [10, 0],
tilecity: [10, 0],
orbital: [124, 0],
outofsight: [132, 0]
outofsight: [132, 0],
nuritwin: [10, 0]
},

//---------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src-ui/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ <h2 id="title"><span lang="ja">パズルの種類のリスト</span><span lang="
<li data-pid="mannequin"></li>
<li data-pid="kuromenbun"></li>
<li data-pid="tilecity"></li>
<li data-pid="nuritwin"></li>
</ul>
</div>
<div class="lists blocks">
Expand Down
1 change: 1 addition & 0 deletions src/pzpr/variety.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@
nurikabe: [0, 1, "ぬりかべ", "Nurikabe", "nurikabe"],
nurimaze: [0, 0, "ぬりめいず", "Nuri-Maze", "nurimaze"],
nurimisaki: [0, 0, "ぬりみさき", "Nurimisaki", "kurodoko"],
nuritwin: [0, 0, "ぬりツイン", "Nuritwin", "shimaguni"],
nuriuzu: [0, 0, "ぬりうず", "Nuri-uzu", "tentaisho"],
ovotovata: [0, 0, "Ovotovata", "Ovotovata", "country"],
oneroom: [0, 0, "ワンルームワンドア", "One Room One Door", "heyawake"],
Expand Down
2 changes: 2 additions & 0 deletions src/res/failcode.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"bkDifferentShape.dbchoco": "The two shapes inside a block are different.",
"bkDifferentShape.kuroclone": "Two units in an area have different shapes.",
"bkDifferentShape.nikoji": "Two areas with equal letters have different shapes.",
"bkDifferentShape.nuritwin": "The two blocks inside an area have different sizes.",
"bkDivide": "The unused cells are divided.",
"bkDoubleBn.yosenabe": "There is two or more numbers in a crock.",
"bkDupNum.hakoiri": "A box has duplicate shapes.",
Expand Down Expand Up @@ -308,6 +309,7 @@
"bkSumNeBn.yosenabe": "Sum of filling is not equal to a crock.",
"bkUCGe2.dosufuwa": "An area has two or more balloons.",
"bkUnitNe2.kuroclone": "There is an area without exactly two units.",
"bkUnitNe2.nuritwin": "An area doesn't have exactly two blocks.",
"bkUnknown.lohkous": "A room has a segment of invalid length.",
"bkUnshade.lapaz": "A 1x1 region is unshaded.",
"bkUnshadeConsecGt3": "There is a line of consecutive unshaded cells that goes through 2 region borders.",
Expand Down
97 changes: 92 additions & 5 deletions src/variety/shimaguni.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//
// パズル固有スクリプト部 島国・チョコナ・ストストーン版 shimaguni.js
//
/* global Set:false */
(function(pidlist, classbase) {
if (typeof module === "object" && module.exports) {
module.exports = [pidlist, classbase];
Expand All @@ -15,7 +16,8 @@
"hinge",
"heyablock",
"cocktail",
"martini"
"martini",
"nuritwin"
],
{
//---------------------------------------------------------
Expand All @@ -35,7 +37,7 @@
play: ["shade", "unshade", "number"]
}
},
"MouseEvent@cocktail": {
"MouseEvent@cocktail,nuritwin": {
inputModes: {
edit: ["border", "number", "clear", "info-blk"],
play: ["shade", "unshade", "info-blk"]
Expand Down Expand Up @@ -111,6 +113,12 @@
return Math.min(999, this.room.clist.length);
}
},
"Cell@nuritwin": {
maxnum: function() {
var half = (this.room.clist.length - 1) >> 1;
return Math.max(1, Math.min(999, half));
}
},
"Cell@shimaguni": {
enableSubNumberArray: true,
disableAnum: true
Expand Down Expand Up @@ -174,7 +182,7 @@
Board: {
hasborder: 1
},
"Board@shimaguni,stostone,heyablock,cocktail,martini": {
"Board@shimaguni,stostone,heyablock,cocktail,martini,nuritwin": {
addExtraInfo: function() {
this.stonegraph = this.addInfoList(this.klass.AreaStoneGraph);
if (this.pid === "cocktail" || this.pid === "martini") {
Expand Down Expand Up @@ -296,7 +304,7 @@
}
},

"AreaShadeGraph@chocona": {
"AreaShadeGraph@chocona,nuritwin": {
enabled: true
},
"AreaShadeGraph@hinge": {
Expand All @@ -307,7 +315,7 @@
component.hinge = null;
}
},
"AreaStoneGraph:AreaShadeGraph@shimaguni,stostone,heyablock,cocktail,martini": {
"AreaStoneGraph:AreaShadeGraph@shimaguni,stostone,heyablock,cocktail,martini,nuritwin": {
// Same as LITS AreaTetrominoGraph
enabled: true,
relation: { "cell.qans": "node", "border.ques": "separator" },
Expand Down Expand Up @@ -618,6 +626,17 @@
"checkShadeCellCount"
]
},
"AnsCheck@nuritwin#1": {
checklist: [
"check2x2ShadeCell",
"checkShadeBlockSize",
"checkSizesEqual",
"checkTwoBlocks",
"checkConnectShade",
"checkNoShadeCellInArea",
"doneShadingDecided"
]
},
"AnsCheck@shimaguni,stostone,heyablock,cocktail,martini": {
checkSideAreaShadeCell: function() {
this.checkSideAreaCell(
Expand Down Expand Up @@ -926,6 +945,74 @@
this.checkOneArea(this.board.sblk8mgr, "csDivide");
}
},
"AnsCheck@nuritwin": {
checkShadeBlockSize: function() {
var blocks = this.board.stonegraph.components;
for (var id = 0; id < blocks.length; id++) {
var block = blocks[id];
var room = block.clist[0].room;
if (!room || !room.top.isValidNum()) {
continue;
}

if (block.clist.length !== room.top.getNum()) {
this.failcode.add("bkSizeNe");
if (this.checkOnly) {
break;
}
room.clist.seterr(1);
}
}
},
checkSizesEqual: function() {
var rooms = this.board.roommgr.components;
for (var r = 0; r < rooms.length; r++) {
var room = rooms[r];
if (room.top.isValidNum()) {
continue;
}

var units = this.getUnits(room);
if (units.length !== 2) {
continue;
}
if (units[0].clist.length === units[1].clist.length) {
continue;
}

this.failcode.add("bkDifferentShape");
if (this.checkOnly) {
break;
}
room.clist.seterr(1);
}
},
checkTwoBlocks: function() {
var rooms = this.board.roommgr.components;
for (var r = 0; r < rooms.length; r++) {
var room = rooms[r];
var units = this.getUnits(room);
if (units.length === 0 || units.length === 2) {
continue;
}

this.failcode.add("bkUnitNe2");
if (this.checkOnly) {
break;
}
room.clist.seterr(1);
}
},
getUnits: function(room) {
var set = new Set();
room.clist.each(function(cell) {
if (cell.isShade()) {
set.add(cell.stone);
}
});
return Array.from(set);
}
},

FailCode: {
bkShadeDivide: "bkShadeDivide",
Expand Down
28 changes: 28 additions & 0 deletions test/script/nuritwin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* nuritwin.js */

ui.debug.addDebugData("nuritwin", {
url: "5/5/08qi3u4632h",
failcheck: [
[
"bkSizeNe",
"pzprv3/nuritwin/5/5/4/0 0 0 0 0 /0 0 0 1 1 /2 2 2 3 1 /2 2 3 3 1 /2 2 2 1 1 /3 . . . . /. . . 2 . /. . . . . /. . . . . /. . . . . /# . # # . /# . . # # /# # # # . /. . # . . /# # # # # /"
],
[
"bkUnitNe2",
"pzprv3/nuritwin/5/5/4/0 0 0 0 0 /0 0 0 1 1 /2 2 2 3 1 /2 2 3 3 1 /2 2 2 1 1 /3 . . . . /. . . 2 . /. . . . . /. . . . . /. . . . . /# . # # # /# # . . # /. # # # # /. . . # . /. # # # # /"
],
[
"bkDifferentShape",
"pzprv3/nuritwin/5/5/4/0 0 0 0 0 /0 0 0 1 1 /2 2 2 3 1 /2 2 3 3 1 /2 2 2 1 1 /3 . . . . /. . . 2 . /. . . . . /. . . . . /. . . . . /# . # # # /# # . . # /. # # # # /# . # . . /# # # # # /"
],
[
"csDivide",
"pzprv3/nuritwin/5/5/4/0 0 0 0 0 /0 0 0 1 1 /2 2 2 3 1 /2 2 3 3 1 /2 2 2 1 1 /3 . . . . /. . . 2 . /. . . . . /. . . . . /. . . . . /# . # # # /# # . . # /# . . # # /# . # . . /. # # # # /"
],
[
null,
"pzprv3/nuritwin/5/5/4/0 0 0 0 0 /0 0 0 1 1 /2 2 2 3 1 /2 2 3 3 1 /2 2 2 1 1 /3 . . . . /. . . 2 . /. . . . . /. . . . . /. . . . . /# + # # # /# # + + # /+ # # # # /+ + # + + /+ # # # # /"
]
],
inputs: []
});

0 comments on commit 97ecb80

Please sign in to comment.