|
9 | 9 | use: true, |
10 | 10 | inputModes: { |
11 | 11 | edit: ["number", "clear", "info-blk"], |
12 | | - play: ["diamond", "peke", "unshade", "info-blk"] |
| 12 | + play: ["diamond", "peke", "unshade", "dot", "info-blk"] |
13 | 13 | }, |
14 | 14 |
|
15 | 15 | decIC: function(cell) { |
|
18 | 18 |
|
19 | 19 | mouseinput_auto: function() { |
20 | 20 | if (this.puzzle.playmode) { |
| 21 | + if (this.mousestart) { |
| 22 | + this.isInputtingDot = this.puzzle.key.isALT; |
| 23 | + } |
| 24 | + if (this.isInputtingDot) { |
| 25 | + this.inputdot(); |
| 26 | + return; |
| 27 | + } |
| 28 | + |
21 | 29 | if (this.mousestart && this.btn === "right") { |
22 | 30 | var cell = this.getcell(); |
23 | 31 | if (cell.isNum() || this.getpos(0.25).equals(cell)) { |
|
59 | 67 | mouseinput_other: function() { |
60 | 68 | if (this.inputMode === "diamond") { |
61 | 69 | this.inputcross(1); |
| 70 | + } else if (this.inputMode === "dot") { |
| 71 | + this.inputdot(); |
62 | 72 | } |
63 | 73 | }, |
| 74 | + inputdot: function() { |
| 75 | + if (!this.mousestart) { |
| 76 | + return; |
| 77 | + } |
| 78 | + |
| 79 | + var pos = this.getpos(0.15); |
| 80 | + if (this.prevPos.equals(pos)) { |
| 81 | + return; |
| 82 | + } |
| 83 | + |
| 84 | + var dot = pos.getDot(); |
| 85 | + if (!dot) { |
| 86 | + return; |
| 87 | + } |
| 88 | + if (this.inputData === null) { |
| 89 | + if (this.puzzle.getConfig("use") === 1) { |
| 90 | + var fixed = this.btn === "left" ? 2 : 3; |
| 91 | + this.inputData = dot.getDot() === fixed ? 0 : fixed; |
| 92 | + } else if (this.btn === "left") { |
| 93 | + this.inputData = { 2: 3, 3: -1 }[dot.getDot()] || 2; |
| 94 | + } else if (this.btn === "right") { |
| 95 | + this.inputData = { 3: 2, 2: -1 }[dot.getDot()] || 3; |
| 96 | + } |
| 97 | + } |
| 98 | + dot.setDot(Math.max(0, this.inputData)); |
| 99 | + dot.draw(); |
| 100 | + this.prevPos = pos; |
| 101 | + }, |
64 | 102 | inputpeke: function() { |
65 | 103 | this.inputcross(2); |
66 | 104 | }, |
|
145 | 183 | }, |
146 | 184 |
|
147 | 185 | getDiamond: function() { |
148 | | - return this.qans ? 1 : this.qsub ? 2 : 0; |
| 186 | + return this.qans ? 1 : this.qsub === 1 ? 2 : 0; |
149 | 187 | }, |
150 | 188 | overlapsDiamond: function(lenient) { |
151 | 189 | var self = this; |
|
189 | 227 |
|
190 | 228 | this.setQans(val === 1 ? 1 : 0); |
191 | 229 | this.setQsub(val === 2 ? 1 : 0); |
192 | | - |
193 | | - if (val === 1) { |
194 | | - this.dotCells().each(function(cell) { |
195 | | - cell.setQsub(0); |
196 | | - }); |
197 | | - } |
198 | 230 | }, |
199 | 231 | dotCells: function() { |
200 | 232 | var bx = this.bx, |
201 | 233 | by = this.by; |
202 | 234 | return this.board.cellinside(bx - 1, by - 1, bx + 1, by + 1); |
203 | 235 | } |
204 | 236 | }, |
205 | | - |
| 237 | + Border: { |
| 238 | + overlapsDiamond: function() { |
| 239 | + for (var i = 0; i < 2; i++) { |
| 240 | + if (this.sidecross[i].qans === 1) { |
| 241 | + return true; |
| 242 | + } |
| 243 | + } |
| 244 | + return false; |
| 245 | + } |
| 246 | + }, |
206 | 247 | Cell: { |
207 | 248 | minnum: 0, |
208 | 249 | maxnum: 4, |
|
237 | 278 | var bx = this.bx, |
238 | 279 | by = this.by; |
239 | 280 | return this.board.crossinside(bx - 1, by - 1, bx + 1, by + 1); |
| 281 | + }, |
| 282 | + /* Check if a regular qsub=1 should be drawn here */ |
| 283 | + isDot: function() { |
| 284 | + return this.qsub === 1 && this.allowUnshade(); |
240 | 285 | } |
241 | 286 | }, |
242 | 287 | Board: { |
| 288 | + hasborder: 1, |
243 | 289 | hascross: 1, |
| 290 | + hasdots: 1, |
244 | 291 | addExtraInfo: function() { |
245 | 292 | this.diamondgraph = this.addInfoList(this.klass.AreaDiamondGraph); |
246 | 293 | }, |
|
337 | 384 | } |
338 | 385 | }, |
339 | 386 |
|
| 387 | + Dot: { |
| 388 | + getTrial: function() { |
| 389 | + return this.piece.trial; |
| 390 | + }, |
| 391 | + getDot: function() { |
| 392 | + return this.piece.qsub; |
| 393 | + }, |
| 394 | + isHidden: function() { |
| 395 | + if (this.piece.allowUnshade && !this.piece.allowUnshade()) { |
| 396 | + return true; |
| 397 | + } |
| 398 | + if (this.piece.group === "border" && this.piece.overlapsDiamond()) { |
| 399 | + return true; |
| 400 | + } |
| 401 | + return this.piece.qans === 1; |
| 402 | + }, |
| 403 | + setDot: function(val) { |
| 404 | + if (val && this.isHidden()) { |
| 405 | + return; |
| 406 | + } |
| 407 | + |
| 408 | + this.puzzle.opemgr.disCombine = true; |
| 409 | + this.piece.setQsub(val); |
| 410 | + this.puzzle.opemgr.disCombine = false; |
| 411 | + } |
| 412 | + }, |
| 413 | + |
340 | 414 | Graphic: { |
341 | 415 | hideHatena: true, |
342 | 416 |
|
343 | 417 | fgcellcolor_func: "qnum", |
344 | 418 | fontShadecolor: "white", |
345 | 419 | pekecolor: "rgb(127,127,255)", |
| 420 | + altpekecolor: "rgb(80,80,127)", |
346 | 421 |
|
347 | 422 | paint: function() { |
348 | 423 | this.drawBGCells(); |
|
355 | 430 |
|
356 | 431 | this.drawDiamonds(); |
357 | 432 | this.drawDotCells(); |
| 433 | + this.drawDots(); |
358 | 434 |
|
359 | 435 | this.drawTarget(); |
360 | 436 | }, |
361 | 437 |
|
| 438 | + getDotFillColor: function(dot) { |
| 439 | + var value = dot.isHidden() ? 0 : dot.getDot(); |
| 440 | + if (value === 2) { |
| 441 | + return dot.getTrial() ? this.trialcolor : this.altpekecolor; |
| 442 | + } |
| 443 | + return value === 3 ? "white" : null; |
| 444 | + }, |
| 445 | + getDotOutlineColor: function(dot) { |
| 446 | + if (!dot.isHidden() && dot.getDot() === 3) { |
| 447 | + return dot.getTrial() ? this.trialcolor : this.altpekecolor; |
| 448 | + } |
| 449 | + return null; |
| 450 | + }, |
| 451 | + |
362 | 452 | drawBaseMarks: function() { |
363 | 453 | var bd = this.board; |
364 | 454 | var g = this.vinc("cross_mark", "auto", true); |
|
420 | 510 | return cell.qcmp === 1 ? this.qcmpcolor : this.fontShadecolor; |
421 | 511 | }, |
422 | 512 | drawDiamonds: function() { |
423 | | - var g = this.vinc("dot", "auto"); |
| 513 | + var g = this.vinc("diamond", "auto"); |
424 | 514 |
|
425 | 515 | var d = this.range; |
426 | 516 | var size = this.cw * 0.2; |
|
438 | 528 | px = bx * this.bw, |
439 | 529 | py = by * this.bh; |
440 | 530 |
|
441 | | - g.vid = "s_dot_" + dot.id; |
| 531 | + g.vid = "s_diamond_" + dot.id; |
442 | 532 | var outline = this.getDiamondColor(dot); |
443 | 533 | var value = dot.getDiamond(); |
444 | 534 | if (value === 1) { |
|
492 | 582 | this.decodeCross(function(cross, ca) { |
493 | 583 | cross.setDiamond(+ca, true); |
494 | 584 | }, true); |
| 585 | + this.decodeDotFile(); |
495 | 586 | }, |
496 | 587 | encodeData: function() { |
497 | 588 | this.encodeCellQnumAns(); |
498 | 589 | this.encodeCross(function(cross) { |
499 | 590 | return cross.getDiamond() + " "; |
500 | 591 | }, true); |
| 592 | + |
| 593 | + if ( |
| 594 | + this.board.dots.find(function(dot) { |
| 595 | + return dot.getDot() >= 2; |
| 596 | + }) |
| 597 | + ) { |
| 598 | + this.encodeDotFile(); |
| 599 | + } |
501 | 600 | } |
502 | 601 | }, |
503 | 602 | AnsCheck: { |
|
0 commit comments