|
18 | 18 | if (this.mousestart || this.mousemove) { |
19 | 19 | this.inputcell(); |
20 | 20 | } |
| 21 | + if (this.mouseend && this.notInputted()) { |
| 22 | + this.inputqcmp(); |
| 23 | + } |
21 | 24 | } else if (this.puzzle.editmode) { |
22 | 25 | if (this.mousestart) { |
23 | 26 | this.inputqnum(); |
24 | 27 | } |
25 | 28 | } |
| 29 | + }, |
| 30 | + |
| 31 | + inputqcmp: function() { |
| 32 | + var cell = this.getcell(); |
| 33 | + if (cell.isnull || cell.noNum()) { |
| 34 | + return; |
| 35 | + } |
| 36 | + |
| 37 | + cell.setQcmp(+!cell.qcmp); |
| 38 | + cell.draw(); |
| 39 | + |
| 40 | + this.mousereset(); |
26 | 41 | } |
27 | 42 | }, |
28 | 43 |
|
|
35 | 50 | //--------------------------------------------------------- |
36 | 51 | // 盤面管理系 |
37 | 52 | Cell: { |
38 | | - numberRemainsUnshaded: true |
| 53 | + numberRemainsUnshaded: true, |
| 54 | + |
| 55 | + isCmp: function() { |
| 56 | + if (!(this.qnum === -2 || this.isNum())) { |
| 57 | + return false; |
| 58 | + } |
| 59 | + if (this.qcmp === 1) { |
| 60 | + return true; |
| 61 | + } |
| 62 | + if (!this.puzzle.execConfig("autocmp")) { |
| 63 | + return false; |
| 64 | + } |
| 65 | + return this.checkComplete(); |
| 66 | + }, |
| 67 | + |
| 68 | + checkComplete: function() { |
| 69 | + if (!this.isNum()) { |
| 70 | + return true; |
| 71 | + } |
| 72 | + |
| 73 | + var cnt = 0, |
| 74 | + list = this.getdir4clist(); |
| 75 | + for (var i = 0; i < list.length; i++) { |
| 76 | + var block = list[i][0].sblk; |
| 77 | + if (block !== null) { |
| 78 | + var shape = block.clist.getRectSize(); |
| 79 | + if ( |
| 80 | + shape.cnt !== shape.cols * shape.rows || |
| 81 | + shape.cols !== shape.rows |
| 82 | + ) { |
| 83 | + return false; |
| 84 | + } |
| 85 | + cnt += shape.cnt; |
| 86 | + } |
| 87 | + } |
| 88 | + |
| 89 | + return this.isValidNum() ? this.qnum === cnt : cnt > 0; |
| 90 | + } |
39 | 91 | }, |
40 | 92 |
|
41 | 93 | AreaShadeGraph: { |
|
48 | 100 | //--------------------------------------------------------- |
49 | 101 | // 画像表示系 |
50 | 102 | Graphic: { |
| 103 | + autocmp: "number", |
| 104 | + |
51 | 105 | hideHatena: true, |
52 | 106 |
|
53 | 107 | fontsizeratio: 0.65 /* 丸数字 */, |
54 | 108 |
|
55 | 109 | qanscolor: "black", |
56 | 110 | numbercolor_func: "qnum", |
57 | 111 |
|
| 112 | + setRange: function(x1, y1, x2, y2) { |
| 113 | + var puzzle = this.puzzle, |
| 114 | + bd = puzzle.board; |
| 115 | + if (puzzle.execConfig("autocmp")) { |
| 116 | + x1 = bd.minbx - 2; |
| 117 | + y1 = bd.minby - 2; |
| 118 | + x2 = bd.maxbx + 2; |
| 119 | + y2 = bd.maxby + 2; |
| 120 | + } |
| 121 | + |
| 122 | + this.common.setRange.call(this, x1, y1, x2, y2); |
| 123 | + }, |
| 124 | + |
58 | 125 | paint: function() { |
59 | 126 | this.drawBGCells(); |
60 | 127 | this.drawShadedCells(); |
|
83 | 150 | var cell = clist[i]; |
84 | 151 | g.vid = "c_sq_" + cell.id; |
85 | 152 | if (cell.qnum !== -1) { |
86 | | - g.fillStyle = cell.error === 1 ? this.errbcolor1 : "white"; |
| 153 | + g.fillStyle = |
| 154 | + cell.error === 1 |
| 155 | + ? this.errbcolor1 |
| 156 | + : cell.isCmp() |
| 157 | + ? this.qcmpcolor |
| 158 | + : "white"; |
87 | 159 | g.shapeRectCenter(cell.bx * this.bw, cell.by * this.bh, rw, rh); |
88 | 160 | } else { |
89 | 161 | g.vhide(); |
|
0 commit comments