|
| 1 | +(function(pidlist, classbase) { |
| 2 | + if (typeof module === "object" && module.exports) { |
| 3 | + module.exports = [pidlist, classbase]; |
| 4 | + } else { |
| 5 | + pzpr.classmgr.makeCustom(pidlist, classbase); |
| 6 | + } |
| 7 | +})(["bhaibahan"], { |
| 8 | + MouseEvent: { |
| 9 | + inputModes: { |
| 10 | + edit: ["number", "undef", "clear", "info-line"], |
| 11 | + play: ["line", "peke", "bgcolor", "bgcolor1", "bgcolor2", "info-line"] |
| 12 | + }, |
| 13 | + autoedit_func: "qnum", |
| 14 | + mouseinputAutoPlay: function() { |
| 15 | + if (this.btn === "left") { |
| 16 | + if (this.mousestart || this.mousemove) { |
| 17 | + this.inputLine(); |
| 18 | + } else if (this.mouseend && this.notInputted()) { |
| 19 | + if (!this.inputpeke_ifborder()) { |
| 20 | + this.inputMB(); |
| 21 | + } |
| 22 | + } |
| 23 | + } else if (this.btn === "right") { |
| 24 | + if (this.mousestart || this.mousemove) { |
| 25 | + this.inputpeke(); |
| 26 | + } else if (this.mouseend && this.notInputted()) { |
| 27 | + if (!this.inputpeke_ifborder()) { |
| 28 | + this.inputMB(); |
| 29 | + } |
| 30 | + } |
| 31 | + } |
| 32 | + } |
| 33 | + }, |
| 34 | + KeyEvent: { |
| 35 | + enablemake: true |
| 36 | + }, |
| 37 | + Border: { |
| 38 | + enableLineNG: true, |
| 39 | + isLineNG: function() { |
| 40 | + return !this.inside; |
| 41 | + }, |
| 42 | + posthook: { |
| 43 | + line: function(val) { |
| 44 | + this.board.roommgr.isStale = true; |
| 45 | + } |
| 46 | + } |
| 47 | + }, |
| 48 | + Cell: { |
| 49 | + l2cnt: 0, |
| 50 | + maxnum: function() { |
| 51 | + return this.board.cols * this.board.rows; |
| 52 | + } |
| 53 | + }, |
| 54 | + Board: { |
| 55 | + hasborder: 1 |
| 56 | + }, |
| 57 | + Graphic: { |
| 58 | + hideHatena: true, |
| 59 | + irowake: true, |
| 60 | + |
| 61 | + bgcellcolor_func: "qsub2", |
| 62 | + qsubcolor1: "rgb(224, 224, 255)", |
| 63 | + qsubcolor2: "rgb(255, 255, 144)", |
| 64 | + |
| 65 | + paint: function() { |
| 66 | + this.drawBGCells(); |
| 67 | + this.drawDashedGrid(false); |
| 68 | + |
| 69 | + this.drawLines(); |
| 70 | + |
| 71 | + this.drawPekes(); |
| 72 | + this.drawCircledNumbers(); |
| 73 | + |
| 74 | + this.drawChassis(); |
| 75 | + this.drawTarget(); |
| 76 | + } |
| 77 | + }, |
| 78 | + LineGraph: { |
| 79 | + enabled: true |
| 80 | + }, |
| 81 | + AreaRoomGraph: { |
| 82 | + countprop: "l2cnt", |
| 83 | + enabled: true, |
| 84 | + relation: { |
| 85 | + "cell.ques": "node", |
| 86 | + "border.line": "separator" |
| 87 | + }, |
| 88 | + isedgevalidbylinkobj: function(border) { |
| 89 | + if (!border.isLine()) { |
| 90 | + return false; |
| 91 | + } |
| 92 | + |
| 93 | + // TODO this in combination is isClosed isn't great |
| 94 | + if ( |
| 95 | + border.sidecell[0].lcnt !== 2 || |
| 96 | + border.sidecell[1].lcnt !== 2 || |
| 97 | + border.sidecell[0].isLineCurve() !== border.sidecell[1].isLineCurve() |
| 98 | + ) { |
| 99 | + return false; |
| 100 | + } |
| 101 | + |
| 102 | + return true; |
| 103 | + }, |
| 104 | + setExtraData: function(component) { |
| 105 | + this.common.setExtraData.call(this, component); |
| 106 | + component.isClosed = !component.clist.some(function(c) { |
| 107 | + return c.lcnt !== 2; |
| 108 | + }); |
| 109 | + } |
| 110 | + }, |
| 111 | + Encode: { |
| 112 | + decodePzpr: function() { |
| 113 | + this.decodeNumber16(); |
| 114 | + this.puzzle.setConfig("loop_full", this.checkpflag("f")); |
| 115 | + }, |
| 116 | + encodePzpr: function() { |
| 117 | + this.outpflag = this.puzzle.getConfig("loop_full") ? "f" : null; |
| 118 | + this.encodeNumber16(); |
| 119 | + } |
| 120 | + }, |
| 121 | + FileIO: { |
| 122 | + decodeData: function() { |
| 123 | + this.decodeConfigFlag("f", "loop_full"); |
| 124 | + this.decodeCellQnum(); |
| 125 | + this.decodeCellQanssub(); |
| 126 | + this.decodeBorderLine(); |
| 127 | + }, |
| 128 | + encodeData: function() { |
| 129 | + this.encodeConfigFlag("f", "loop_full"); |
| 130 | + this.encodeCellQnum(); |
| 131 | + this.encodeCellQanssub(); |
| 132 | + this.encodeBorderLine(); |
| 133 | + } |
| 134 | + }, |
| 135 | + AnsCheck: { |
| 136 | + checklist: [ |
| 137 | + "checkLineExist+", |
| 138 | + "checkBranchLine", |
| 139 | + "checkCrossLine", |
| 140 | + "checkAdjacentCircles", |
| 141 | + |
| 142 | + "checkLessWalk", |
| 143 | + "checkOverWalk", |
| 144 | + |
| 145 | + "checkOneLoop", |
| 146 | + "checkNoLineOnNum", |
| 147 | + "checkNoLineIfVariant", |
| 148 | + |
| 149 | + "checkDeadendLine+" |
| 150 | + ], |
| 151 | + |
| 152 | + checkAdjacentCircles: function() { |
| 153 | + this.checkSideCell(function(cell1, cell2) { |
| 154 | + return ( |
| 155 | + cell1.isNum() && |
| 156 | + cell2.isNum() && |
| 157 | + cell1.lcnt === 2 && |
| 158 | + cell2.lcnt === 2 && |
| 159 | + cell1.isLineCurve() === cell2.isLineCurve() |
| 160 | + ); |
| 161 | + }, "lnCurveEq"); |
| 162 | + }, |
| 163 | + |
| 164 | + checkLessWalk: function() { |
| 165 | + this.checkWalkLength(-1, "bkSizeLt"); |
| 166 | + }, |
| 167 | + checkOverWalk: function() { |
| 168 | + this.checkWalkLength(+1, "bkSizeGt"); |
| 169 | + }, |
| 170 | + |
| 171 | + checkWalkLength: function(flag, code) { |
| 172 | + if (this.board.roommgr.isStale) { |
| 173 | + this.board.roommgr.isStale = false; |
| 174 | + this.board.roommgr.rebuild(); |
| 175 | + } |
| 176 | + for (var i = 0; i < this.board.cell.length; i++) { |
| 177 | + var cell = this.board.cell[i]; |
| 178 | + var qnum = cell.qnum; |
| 179 | + if (qnum <= 0 || !cell.room) { |
| 180 | + continue; |
| 181 | + } |
| 182 | + |
| 183 | + if (flag < 0 && !cell.room.isClosed) { |
| 184 | + continue; |
| 185 | + } |
| 186 | + |
| 187 | + var d = cell.room.clist.length; |
| 188 | + |
| 189 | + if (flag > 0 ? d > qnum : d < qnum) { |
| 190 | + this.failcode.add(code); |
| 191 | + if (this.checkOnly) { |
| 192 | + return; |
| 193 | + } |
| 194 | + cell.room.clist.seterr(1); |
| 195 | + } |
| 196 | + } |
| 197 | + }, |
| 198 | + |
| 199 | + checkNoLineOnNum: function() { |
| 200 | + this.checkAllCell(function(cell) { |
| 201 | + return cell.qnum !== -1 && cell.lcnt === 0; |
| 202 | + }, "lnIsolate"); |
| 203 | + } |
| 204 | + }, |
| 205 | + FailCode: { |
| 206 | + lnIsolate: "lnIsolate.country" |
| 207 | + } |
| 208 | +}); |
0 commit comments