Skip to content

Commit 9eaff0a

Browse files
authored
Add L-Ring
1 parent 317bee7 commit 9eaff0a

8 files changed

Lines changed: 227 additions & 37 deletions

File tree

src-ui/changes.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@
3333
<main>
3434
<div style="margin-bottom: 5px;"><b>Latest types</b> (<em><a href="/list.html" target="_parent">all types</a></em>)</div>
3535
<ul>
36+
<li><a href="/p?lring" target="_parent">L-Ring えるりんぐ</a></li>
3637
<li><a href="/p?gravel" target="_parent">Gravel</a></li>
3738
<li><a href="/p?scrabble" target="_parent">Scrabble</a></li>
3839
<li><a href="/p?vertigo" target="_parent">Vertigo</a></li>
3940
<li><a href="/p?mrokmrno" target="_parent">Mr. OK and Mr. NO</a></li>
4041
<li><a href="/p?slovak" target="_parent">Slovak Sums</a></li>
4142
<li><a href="/p?anymino" target="_parent">Anymino</a></li>
42-
<li><a href="/p?elasticlink" target="_parent">Elastic Link</a></li>
4343
</ul>
4444
</main>
4545
</body>

src-ui/js/ui/MenuConfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@
182182
case "wataridori":
183183
case "bhaibahan":
184184
case "bwloop":
185+
case "lring":
185186
idname = "loop_full";
186187
break;
187188
}

src-ui/list.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ <h2 id="title"><span lang="ja">パズルの種類のリスト</span><span lang="
176176
<li data-pid="roboticwalk"></li>
177177
<li data-pid="nuriloop"></li>
178178
<li data-pid="bwloop"></li>
179+
<li data-pid="lring"></li>
179180
</ul>
180181
</div>
181182
<div class="lists loops">

src/puzzle/Config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,8 @@
567567
"roboticwalk",
568568
"wataridori",
569569
"bhaibahan",
570-
"bwloop"
570+
"bwloop",
571+
"lring"
571572
].indexOf(pid) >= 0;
572573
break;
573574
default:

src/pzpr/variety.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@
287287
lookair: [0, 0, "るっくえあ", "Look-Air"],
288288
loopsp: [1, 0, "環状線スペシャル", "Loop Special", "pipelink"],
289289
loute: [0, 0, "エルート", "L-route"],
290+
lring: [0, 0, "えるりんぐ", "L-Ring", "balance"],
290291
magnets: [0, 0, "Magnets", "Magnets"],
291292
makaro: [0, 0, "マカロ", "Makaro"],
292293
mannequin: [0, 0, "マネキンゲート", "Mannequin Gate"],

src/res/failcode.en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
"arDistanceNe.myopia": "The lines pointed to by a clue are at different distances.",
3535
"arDistanceNe.pentopia": "The shaded cells pointed to by a clue are at different distances.",
3636
"arInvalid.evolmino": "The arrow is invalid.",
37+
"arHatenaNe.lring": "The line segments connected to a question mark don't have a length difference of 1.",
38+
"arLengthNe.lring": "An arrow does not point to a line segment that's 1 cell longer than the other line segment.",
39+
"arNoLine.lring": "A clue cell does not have a turn.",
3740
"arNoLine": "A line doesn't go through some arrows.",
3841
"arNoLineSeen": "There is no line in the direction of an arrow.",
3942
"arNoShade.distopia": "A number cannot see any shaded cells.",

src/variety/balance.js

Lines changed: 169 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,27 @@
44
} else {
55
pzpr.classmgr.makeCustom(pidlist, classbase);
66
}
7-
})(["balance"], {
7+
})(["balance", "lring"], {
88
MouseEvent: {
99
inputModes: {
1010
edit: ["number", "shade", "clear"],
1111
play: ["line", "peke", "info-line"]
1212
},
13-
mouseinput_auto: function() {
14-
if (this.puzzle.playmode) {
15-
if (this.mousestart || this.mousemove) {
16-
if (this.btn === "left") {
17-
this.inputLine();
18-
} else if (this.btn === "right") {
19-
this.inputpeke();
20-
}
21-
} else if (this.mouseend && this.notInputted()) {
22-
if (this.inputpeke_ifborder()) {
23-
return;
24-
}
13+
autoplay_func: "line",
14+
mouseinputAutoEdit: function() {
15+
if (this.mousestart) {
16+
var cell = this.getcell();
17+
if (cell.isnull) {
18+
return;
2519
}
26-
} else if (this.puzzle.editmode) {
27-
if (this.mousestart) {
28-
var cell = this.getcell();
29-
if (cell.isnull) {
20+
if (cell === this.cursor.getc() || this.btn === "left") {
21+
this.inputqnum();
22+
} else {
23+
if (cell.qnum === -1) {
3024
return;
3125
}
32-
if (cell === this.cursor.getc() || this.btn === "left") {
33-
this.inputqnum();
34-
} else {
35-
if (cell.qnum === -1) {
36-
return;
37-
}
38-
cell.ques = 1 - cell.ques;
39-
cell.draw();
40-
}
26+
cell.ques = 1 - cell.ques;
27+
cell.draw();
4128
}
4229
}
4330
},
@@ -58,6 +45,15 @@
5845
}
5946
}
6047
},
48+
"MouseEvent@lring": {
49+
mouseinputAutoEdit: function() {
50+
if (this.mousestart || this.mousemove) {
51+
this.inputarrow_cell();
52+
} else if (this.mouseend && this.notInputted()) {
53+
this.inputqnum();
54+
}
55+
}
56+
},
6157
KeyEvent: {
6258
enablemake: true,
6359

@@ -89,6 +85,34 @@
8985
}
9086
}
9187
},
88+
"KeyEvent@lring": {
89+
moveTarget: function(ca) {
90+
if (ca.match(/shift/)) {
91+
return false;
92+
}
93+
return this.moveTCell(ca);
94+
},
95+
96+
keyinput: function(ca) {
97+
this.key_toichika(ca);
98+
},
99+
key_toichika: function(ca) {
100+
if (ca === "1" || ca === "w" || ca === "shift+up") {
101+
ca = "1";
102+
} else if (ca === "2" || ca === "s" || ca === "shift+right") {
103+
ca = "4";
104+
} else if (ca === "3" || ca === "z" || ca === "shift+down") {
105+
ca = "2";
106+
} else if (ca === "4" || ca === "a" || ca === "shift+left") {
107+
ca = "3";
108+
} else if (ca === "5" || ca === "q" || ca === "-") {
109+
ca = "s1";
110+
} else if (ca === "6" || ca === "e" || ca === " ") {
111+
ca = " ";
112+
}
113+
this.key_inputqnum(ca);
114+
}
115+
},
92116

93117
Cell: {
94118
counted: false,
@@ -142,11 +166,18 @@
142166
}
143167

144168
var lengths = [];
169+
this.horizlength = 0;
170+
this.vertlength = 0;
145171
for (var dir = 1; dir <= 4; dir++) {
146172
var l = this.getSegmentDir(dir).length;
147173
if (l > 0) {
148174
lengths.push(l);
149175
}
176+
if (dir === this.UP || dir === this.DN) {
177+
this.vertlength += l;
178+
} else {
179+
this.horizlength += l;
180+
}
150181
}
151182
if (lengths[0] === lengths[1]) {
152183
this.equalsegments = true;
@@ -161,6 +192,10 @@
161192
this.counted = false;
162193
}
163194
},
195+
"Cell@lring": {
196+
numberAsObject: true,
197+
maxnum: 4
198+
},
164199
Border: {
165200
posthook: {
166201
line: function() {
@@ -181,6 +216,11 @@
181216
}
182217
}
183218
},
219+
"BoardExec@lring": {
220+
adjustBoardData: function(key, d) {
221+
this.adjustCellArrow(key, d);
222+
}
223+
},
184224
Board: {
185225
hasborder: 1,
186226

@@ -197,14 +237,16 @@
197237
enabled: true
198238
},
199239

240+
"Graphic@balance": {
241+
hideHatena: true,
242+
textoption: { ratio: 0.65 }
243+
},
200244
Graphic: {
201245
irowake: true,
202246

203247
numbercolor_func: "qnum",
204248
gridcolor_type: "LIGHT",
205249

206-
hideHatena: true,
207-
208250
circleratio: [0.4, 0.35],
209251

210252
getCircleFillColor: function(cell) {
@@ -224,17 +266,20 @@
224266
return cell.ques === 0 ? "black" : "white";
225267
},
226268

227-
textoption: { ratio: 0.65 },
228-
229269
minYdeg: 0.36,
230270
maxYdeg: 0.74,
231271

232272
paint: function() {
233273
this.drawBGCells();
234274
this.drawDashedGrid();
235275

236-
this.drawCircles();
237-
this.drawQuesNumbers();
276+
if (this.pid === "lring") {
277+
this.drawCellArrows(true);
278+
this.drawHatenas();
279+
} else {
280+
this.drawCircles();
281+
this.drawQuesNumbers();
282+
}
238283
this.drawLines();
239284

240285
this.drawPekes();
@@ -243,7 +288,7 @@
243288
}
244289
},
245290

246-
Encode: {
291+
"Encode@balance": {
247292
decodePzpr: function(type) {
248293
var c = 0,
249294
i = 0,
@@ -312,7 +357,17 @@
312357
this.outbstr += cm;
313358
}
314359
},
315-
FileIO: {
360+
"Encode@lring": {
361+
decodePzpr: function() {
362+
this.decode4Cell();
363+
this.puzzle.setConfig("loop_full", this.checkpflag("f"));
364+
},
365+
encodePzpr: function() {
366+
this.outpflag = this.puzzle.getConfig("loop_full") ? "f" : null;
367+
this.encode4Cell();
368+
}
369+
},
370+
"FileIO@balance": {
316371
decodeData: function() {
317372
this.decodeConfigFlag("f", "loop_full");
318373
this.decodeCell(function(cell, ca) {
@@ -337,8 +392,20 @@
337392
this.encodeBorderLine();
338393
}
339394
},
395+
"FileIO@lring": {
396+
decodeData: function() {
397+
this.decodeConfigFlag("f", "loop_full");
398+
this.decodeCellQnum();
399+
this.decodeBorderLine();
400+
},
401+
encodeData: function() {
402+
this.encodeConfigFlag("f", "loop_full");
403+
this.encodeCellQnum();
404+
this.encodeBorderLine();
405+
}
406+
},
340407

341-
AnsCheck: {
408+
"AnsCheck@balance": {
342409
checklist: [
343410
"checkBranchLine",
344411
"checkCrossLine",
@@ -417,5 +484,72 @@
417484
return cell.isNum() && cell.lcnt === 0;
418485
}, "circNoLine");
419486
}
487+
},
488+
489+
"AnsCheck@lring": {
490+
checklist: [
491+
"checkBranchLine",
492+
"checkCrossLine",
493+
"checkTurnOnArrow",
494+
"checkLengthInArrowDir",
495+
"checkLengthInHatena",
496+
"checkDeadendLine+",
497+
"checkOneLoop",
498+
"checkNoLineIfVariant"
499+
],
500+
501+
checkTurnOnArrow: function() {
502+
this.checkAllCell(function(cell) {
503+
return cell.isNum() && !cell.isLineCurve();
504+
}, "arNoLine");
505+
},
506+
507+
checkLengthInArrowDir: function() {
508+
var borders = this.board.border;
509+
510+
this.checkAllCell(function(cell) {
511+
if (!cell.isValidNum() || !cell.isLineCurve()) {
512+
return false;
513+
}
514+
515+
var addr = cell.getaddr();
516+
addr.movedir(cell.qnum, 1);
517+
var border = addr.getb();
518+
if (!border.isLine()) {
519+
return true;
520+
}
521+
522+
cell.recount();
523+
if (
524+
border.isVert()
525+
? cell.horizlength !== cell.vertlength + 1
526+
: cell.vertlength !== cell.horizlength + 1
527+
) {
528+
borders.setnoerr();
529+
cell.getAllSegments().seterr(1);
530+
return true;
531+
}
532+
533+
return false;
534+
}, "arLengthNe");
535+
},
536+
537+
checkLengthInHatena: function() {
538+
var borders = this.board.border;
539+
540+
this.checkAllCell(function(cell) {
541+
if (cell.qnum !== -2 || cell.lcnt !== 2) {
542+
return false;
543+
}
544+
545+
cell.recount();
546+
if (Math.abs(cell.horizlength - cell.vertlength) !== 1) {
547+
borders.setnoerr();
548+
cell.getAllSegments().seterr(1);
549+
return true;
550+
}
551+
return false;
552+
}, "arHatenaNe");
553+
}
420554
}
421555
});

0 commit comments

Comments
 (0)