|
4 | 4 | } else { |
5 | 5 | pzpr.classmgr.makeCustom(pidlist, classbase); |
6 | 6 | } |
7 | | -})(["balance"], { |
| 7 | +})(["balance", "lring"], { |
8 | 8 | MouseEvent: { |
9 | 9 | inputModes: { |
10 | 10 | edit: ["number", "shade", "clear"], |
11 | 11 | play: ["line", "peke", "info-line"] |
12 | 12 | }, |
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; |
25 | 19 | } |
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) { |
30 | 24 | return; |
31 | 25 | } |
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(); |
41 | 28 | } |
42 | 29 | } |
43 | 30 | }, |
|
58 | 45 | } |
59 | 46 | } |
60 | 47 | }, |
| 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 | + }, |
61 | 57 | KeyEvent: { |
62 | 58 | enablemake: true, |
63 | 59 |
|
|
89 | 85 | } |
90 | 86 | } |
91 | 87 | }, |
| 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 | + }, |
92 | 116 |
|
93 | 117 | Cell: { |
94 | 118 | counted: false, |
|
142 | 166 | } |
143 | 167 |
|
144 | 168 | var lengths = []; |
| 169 | + this.horizlength = 0; |
| 170 | + this.vertlength = 0; |
145 | 171 | for (var dir = 1; dir <= 4; dir++) { |
146 | 172 | var l = this.getSegmentDir(dir).length; |
147 | 173 | if (l > 0) { |
148 | 174 | lengths.push(l); |
149 | 175 | } |
| 176 | + if (dir === this.UP || dir === this.DN) { |
| 177 | + this.vertlength += l; |
| 178 | + } else { |
| 179 | + this.horizlength += l; |
| 180 | + } |
150 | 181 | } |
151 | 182 | if (lengths[0] === lengths[1]) { |
152 | 183 | this.equalsegments = true; |
|
161 | 192 | this.counted = false; |
162 | 193 | } |
163 | 194 | }, |
| 195 | + "Cell@lring": { |
| 196 | + numberAsObject: true, |
| 197 | + maxnum: 4 |
| 198 | + }, |
164 | 199 | Border: { |
165 | 200 | posthook: { |
166 | 201 | line: function() { |
|
181 | 216 | } |
182 | 217 | } |
183 | 218 | }, |
| 219 | + "BoardExec@lring": { |
| 220 | + adjustBoardData: function(key, d) { |
| 221 | + this.adjustCellArrow(key, d); |
| 222 | + } |
| 223 | + }, |
184 | 224 | Board: { |
185 | 225 | hasborder: 1, |
186 | 226 |
|
|
197 | 237 | enabled: true |
198 | 238 | }, |
199 | 239 |
|
| 240 | + "Graphic@balance": { |
| 241 | + hideHatena: true, |
| 242 | + textoption: { ratio: 0.65 } |
| 243 | + }, |
200 | 244 | Graphic: { |
201 | 245 | irowake: true, |
202 | 246 |
|
203 | 247 | numbercolor_func: "qnum", |
204 | 248 | gridcolor_type: "LIGHT", |
205 | 249 |
|
206 | | - hideHatena: true, |
207 | | - |
208 | 250 | circleratio: [0.4, 0.35], |
209 | 251 |
|
210 | 252 | getCircleFillColor: function(cell) { |
|
224 | 266 | return cell.ques === 0 ? "black" : "white"; |
225 | 267 | }, |
226 | 268 |
|
227 | | - textoption: { ratio: 0.65 }, |
228 | | - |
229 | 269 | minYdeg: 0.36, |
230 | 270 | maxYdeg: 0.74, |
231 | 271 |
|
232 | 272 | paint: function() { |
233 | 273 | this.drawBGCells(); |
234 | 274 | this.drawDashedGrid(); |
235 | 275 |
|
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 | + } |
238 | 283 | this.drawLines(); |
239 | 284 |
|
240 | 285 | this.drawPekes(); |
|
243 | 288 | } |
244 | 289 | }, |
245 | 290 |
|
246 | | - Encode: { |
| 291 | + "Encode@balance": { |
247 | 292 | decodePzpr: function(type) { |
248 | 293 | var c = 0, |
249 | 294 | i = 0, |
|
312 | 357 | this.outbstr += cm; |
313 | 358 | } |
314 | 359 | }, |
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": { |
316 | 371 | decodeData: function() { |
317 | 372 | this.decodeConfigFlag("f", "loop_full"); |
318 | 373 | this.decodeCell(function(cell, ca) { |
|
337 | 392 | this.encodeBorderLine(); |
338 | 393 | } |
339 | 394 | }, |
| 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 | + }, |
340 | 407 |
|
341 | | - AnsCheck: { |
| 408 | + "AnsCheck@balance": { |
342 | 409 | checklist: [ |
343 | 410 | "checkBranchLine", |
344 | 411 | "checkCrossLine", |
|
417 | 484 | return cell.isNum() && cell.lcnt === 0; |
418 | 485 | }, "circNoLine"); |
419 | 486 | } |
| 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 | + } |
420 | 554 | } |
421 | 555 | }); |
0 commit comments