|
67 | 67 | mouseinput_clear: function() { |
68 | 68 | this.inputFixedNumber(-1); |
69 | 69 | }, |
| 70 | + initialize: function() { |
| 71 | + this.prevDiamond = new this.klass.Address(); |
| 72 | + this.common.initialize.call(this); |
| 73 | + }, |
| 74 | + mousereset: function() { |
| 75 | + this.prevDiamond.reset(); |
| 76 | + this.common.mousereset.call(this); |
| 77 | + }, |
70 | 78 |
|
71 | 79 | inputcross: function(fixed) { |
72 | 80 | if (this.inputData !== null && this.inputData < 8) { |
73 | 81 | return; |
74 | 82 | } |
| 83 | + |
| 84 | + var prev = this.prevDiamond.getx(); |
75 | 85 | var cross = this.getcross(); |
| 86 | + if (!prev.isnull) { |
| 87 | + var cell = this.getcell(); |
| 88 | + var candidate = null; |
| 89 | + |
| 90 | + // Prefer crosses that share a parity with the last placed diamond |
| 91 | + if (Math.abs(cell.bx - prev.bx) + Math.abs(cell.by - prev.by) === 4) { |
| 92 | + if (cell.bx > prev.bx + 1) { |
| 93 | + candidate = prev.relcross(4, 0); |
| 94 | + } else if (cell.bx < prev.bx - 1) { |
| 95 | + candidate = prev.relcross(-4, 0); |
| 96 | + } else if (cell.by > prev.by + 1) { |
| 97 | + candidate = prev.relcross(0, 4); |
| 98 | + } else if (cell.by < prev.by - 1) { |
| 99 | + candidate = prev.relcross(0, -4); |
| 100 | + } |
| 101 | + } |
| 102 | + if (candidate && !candidate.overlapsDiamond()) { |
| 103 | + cross = candidate; |
| 104 | + } |
| 105 | + } |
76 | 106 | if (this.prevPos.equals(cross)) { |
77 | 107 | return; |
78 | 108 | } |
|
96 | 126 | this.inputData |= 8; |
97 | 127 | } |
98 | 128 | cross.setDiamond(this.inputData & 7); |
| 129 | + if (cross.getDiamond() === 1) { |
| 130 | + this.prevDiamond.set(cross); |
| 131 | + } |
99 | 132 | cross.draw(); |
100 | 133 | } |
101 | 134 | }, |
|
0 commit comments