Skip to content

Commit ecb0f99

Browse files
authored
Add Suguru
1 parent c845798 commit ecb0f99

5 files changed

Lines changed: 93 additions & 6 deletions

File tree

src-ui/js/ui/KeyPopup.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ ui.keypopup = {
248248
bhaibahan: [10, 0],
249249
edamame: [4, 0],
250250
heavydots: [10, 0],
251+
suguru: [10, 10],
251252
marutaring: [10, 0],
252253
tetroctb: [10, 0],
253254
hasunomura: [10, 0],

src-ui/list.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ <h2 id="title"><span lang="ja">パズルの種類のリスト</span><span lang="
376376
<li data-pid="twinarea"></li>
377377
<li data-pid="numcity"></li>
378378
<li data-pid="topo"></li>
379+
<li data-pid="suguru"></li>
379380
</ul>
380381
</div>
381382
<div class="lists others">

src/pzpr/variety.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@
433433
stostone: [0, 0, "ストストーン", "Stostone", "shimaguni"],
434434
subomino: [0, 0, "Subomino", "Subomino", "nawabari"],
435435
sudoku: [0, 1, "数独", "Sudoku"],
436+
suguru: [0, 0, "ナンバーブロック", "Suguru (Capsules)", "ripple"],
436437
sukoro: [1, 0, "数コロ", "Sukoro", "sukoro"],
437438
sukororoom: [0, 0, "数コロ部屋", "Sukoro-room", "sukoro"],
438439
sumiwake: [0, 0, "すみわけ", "Sumiwake", "heyawake"],

src/variety/ripple.js

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77
} else {
88
pzpr.classmgr.makeCustom(pidlist, classbase);
99
}
10-
})(["ripple", "cojun", "meander"], {
10+
})(["ripple", "cojun", "meander", "suguru"], {
1111
//---------------------------------------------------------
1212
// マウス入力系
1313
MouseEvent: {
1414
inputModes: {
15-
edit: ["border", "number", "clear"],
15+
edit: ["border", "empty", "number", "clear"],
1616
play: ["number", "clear"]
1717
},
1818
autoedit_func: "areanum",
1919
autoplay_func: "qnum"
2020
},
2121
"MouseEvent@meander": {
2222
inputModes: {
23-
edit: ["border", "number", "clear"],
23+
edit: ["border", "empty", "number", "clear"],
2424
play: ["number", "dragnum+", "dragnum-", "clear"]
2525
},
2626
mouseinput: function() {
@@ -106,7 +106,18 @@
106106
// キーボード入力系
107107
KeyEvent: {
108108
enablemake: true,
109-
enableplay: true
109+
enableplay: true,
110+
111+
keyinput: function(ca) {
112+
if ((ca === "q" || ca === "w") && this.puzzle.editmode) {
113+
var cell = this.cursor.getc();
114+
if (!cell.isnull) {
115+
cell.setValid(cell.ques !== 7 ? 7 : 0);
116+
}
117+
} else {
118+
this.key_inputqnum(ca);
119+
}
120+
}
110121
},
111122

112123
//---------------------------------------------------------
@@ -117,10 +128,17 @@
117128
return this.room.clist.length;
118129
}
119130
},
131+
Border: {
132+
isQuesBorder: function() {
133+
return (
134+
this.ques || this.sidecell[0].isEmpty() || this.sidecell[1].isEmpty()
135+
);
136+
}
137+
},
120138
Board: {
121139
hasborder: 1
122140
},
123-
"Board@cojun": {
141+
"Board@cojun,suguru": {
124142
cols: 8,
125143
rows: 8
126144
},
@@ -139,6 +157,13 @@
139157
Graphic: {
140158
gridcolor_type: "DLIGHT",
141159

160+
getBGCellColor: function(cell) {
161+
if (!cell.isValid()) {
162+
return "black";
163+
}
164+
return this.getBGCellColor_error1(cell);
165+
},
166+
142167
paint: function() {
143168
this.drawBGCells();
144169
this.drawTargetSubNumber();
@@ -153,6 +178,14 @@
153178
this.drawChassis();
154179

155180
this.drawCursor();
181+
},
182+
183+
getBorderColor: function(border) {
184+
if (border.isQuesBorder()) {
185+
return border.error === 1 ? this.errcolor1 : "black";
186+
}
187+
188+
return this.getBorderColor_qans(border);
156189
}
157190
},
158191

@@ -162,10 +195,12 @@
162195
decodePzpr: function(type) {
163196
this.decodeBorder();
164197
this.decodeNumber16();
198+
this.decodeEmpty();
165199
},
166200
encodePzpr: function(type) {
167201
this.encodeBorder();
168202
this.encodeNumber16();
203+
this.encodeEmpty();
169204
},
170205

171206
decodeKanpen: function() {
@@ -212,6 +247,31 @@
212247
this.encodeCellAnum_XMLAnswer();
213248
},
214249

250+
decodeCellQnum: function() {
251+
this.decodeCell(function(cell, ca) {
252+
if (ca === "#") {
253+
cell.ques = 7;
254+
} else if (ca === "-") {
255+
cell.qnum = -2;
256+
} else if (ca !== ".") {
257+
cell.qnum = +ca;
258+
}
259+
});
260+
},
261+
encodeCellQnum: function() {
262+
this.encodeCell(function(cell) {
263+
if (cell.ques === 7) {
264+
return "# ";
265+
} else if (cell.qnum >= 0) {
266+
return cell.qnum + " ";
267+
} else if (cell.qnum === -2) {
268+
return "- ";
269+
} else {
270+
return ". ";
271+
}
272+
});
273+
},
274+
215275
UNDECIDED_NUM_XML: 0
216276
},
217277

@@ -223,7 +283,7 @@
223283
"checkRippleNumber@ripple",
224284
"checkAdjacentDiffNumber@cojun",
225285
"checkUpperNumber@cojun",
226-
"checkAdjacentNumbers@meander",
286+
"checkAdjacentNumbers@meander,suguru",
227287
"checkConsecutiveNeighbors@meander",
228288
"checkNoNumCell+"
229289
],

test/script/suguru.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* suguru.js */
2+
3+
ui.debug.addDebugData("suguru", {
4+
url: "5/5/cih47bs73m3g5p1g2g",
5+
failcheck: [
6+
[
7+
"bkDupNum",
8+
"pzprv3/suguru/5/5/0 1 1 0 /0 1 0 0 /1 0 1 0 /0 0 1 0 /0 1 0 0 /0 0 1 1 1 /0 1 0 1 1 /1 1 1 0 0 /0 0 1 1 1 /3 . . . . /. . . 3 . /5 . . . . /. . . . . /. 1 . 2 . /. . . . . /. . 1 . 4 /. 3 2 . . /2 4 5 . . /3 . 3 . 1 /"
9+
],
10+
[
11+
"nmAround",
12+
"pzprv3/suguru/5/5/0 1 1 0 /0 1 0 0 /1 0 1 0 /0 0 1 0 /0 1 0 0 /0 0 1 1 1 /0 1 0 1 1 /1 1 1 0 0 /0 0 1 1 1 /3 . . . . /. . . 3 . /5 . . . . /. . . . . /. 1 . 2 . /. . 1 . . /. 1 . . 1 /. . . . . /. . . . . /. . . . . /"
13+
],
14+
[
15+
"ceNoNum",
16+
"pzprv3/suguru/5/5/0 1 1 0 /0 1 0 0 /1 0 1 0 /0 0 1 0 /0 1 0 0 /0 0 1 1 1 /0 1 0 1 1 /1 1 1 0 0 /0 0 1 1 1 /3 . . . . /. . . 3 . /5 . . . . /. . . . . /. 1 . 2 . /. . 1 2 1 /1 . . . . /. 2 1 2 1 /. . . 4 3 /. . 3 . 1 /"
17+
],
18+
[
19+
null,
20+
"pzprv3/suguru/5/5/0 1 1 0 /0 1 0 0 /1 0 1 0 /0 0 1 0 /0 1 0 0 /0 0 1 1 1 /0 1 0 1 1 /1 1 1 0 0 /0 0 1 1 1 /3 . . . . /. . . 3 . /5 . . . . /. . . . . /. 1 . 2 . /. 2 1 2 1 /1 4 5 . 4 /. 2 1 2 1 /3 4 5 4 3 /2 . 3 . 1 /"
21+
]
22+
],
23+
inputs: []
24+
});

0 commit comments

Comments
 (0)