|
| 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 | +})(["seiza"], { |
| 8 | + MouseEvent: { |
| 9 | + inputModes: { |
| 10 | + edit: ["empty", "border", "number"], |
| 11 | + play: ["star", "unshade", "peke", "line"] |
| 12 | + }, |
| 13 | + mouseinputAutoPlay: function() { |
| 14 | + if (this.mousestart || this.mousemove) { |
| 15 | + if (this.btn === "left") { |
| 16 | + this.inputLine(); |
| 17 | + } else if (this.btn === "right") { |
| 18 | + if (this.mousestart && this.inputpeke_ifborder()) { |
| 19 | + return; |
| 20 | + } |
| 21 | + if (!this.firstCell.isnull || this.notInputted()) { |
| 22 | + this.inputcell(); |
| 23 | + } |
| 24 | + } |
| 25 | + } else if (this.mouseend && this.notInputted()) { |
| 26 | + var cell = this.getcell(); |
| 27 | + if (!this.firstCell.isnull && cell !== this.firstCell) { |
| 28 | + return; |
| 29 | + } |
| 30 | + this.inputcell(); |
| 31 | + } |
| 32 | + }, |
| 33 | + mouseinputAutoEdit: function() { |
| 34 | + if (this.mousestart || this.mousemove) { |
| 35 | + this.inputborder(); |
| 36 | + } else if (this.mouseend && this.notInputted()) { |
| 37 | + this.inputqnum(); |
| 38 | + } |
| 39 | + } |
| 40 | + }, |
| 41 | + KeyEvent: { |
| 42 | + enablemake: true, |
| 43 | + keyinput: function(ca) { |
| 44 | + if (ca === "q") { |
| 45 | + var cell = this.cursor.getc(); |
| 46 | + if (!cell.isnull) { |
| 47 | + cell.setValid(cell.ques !== 7 ? 7 : 0); |
| 48 | + cell.draw(); |
| 49 | + } |
| 50 | + } else { |
| 51 | + this.key_inputqnum(ca); |
| 52 | + } |
| 53 | + } |
| 54 | + }, |
| 55 | + |
| 56 | + Cell: { |
| 57 | + maxnum: 4, |
| 58 | + isLineShapeEndpoint: function() { |
| 59 | + return this.qans === 1; |
| 60 | + }, |
| 61 | + noLP: function(dir) { |
| 62 | + return this.isEmpty(); |
| 63 | + }, |
| 64 | + prehook: { |
| 65 | + qans: function(num) { |
| 66 | + return num && this.isEmpty(); |
| 67 | + }, |
| 68 | + qsub: function(num) { |
| 69 | + return num && this.isEmpty(); |
| 70 | + } |
| 71 | + }, |
| 72 | + posthook: { |
| 73 | + ques: function() { |
| 74 | + if (!this.ques) { |
| 75 | + return; |
| 76 | + } |
| 77 | + this.setQans(0); |
| 78 | + this.setQsub(0); |
| 79 | + for (var dir in this.adjborder) { |
| 80 | + this.adjborder[dir].removeLine(); |
| 81 | + } |
| 82 | + } |
| 83 | + } |
| 84 | + }, |
| 85 | + Border: { |
| 86 | + enableLineNG: true, |
| 87 | + isBorder: function() { |
| 88 | + return ( |
| 89 | + this.isnull || |
| 90 | + this.ques || |
| 91 | + this.sidecell[0].isEmpty() || |
| 92 | + this.sidecell[1].isEmpty() |
| 93 | + ); |
| 94 | + } |
| 95 | + }, |
| 96 | + Board: { |
| 97 | + hasborder: 1 |
| 98 | + }, |
| 99 | + LineGraph: { |
| 100 | + enabled: true, |
| 101 | + makeClist: true |
| 102 | + }, |
| 103 | + AreaRoomGraph: { |
| 104 | + enabled: true, |
| 105 | + hastop: true |
| 106 | + }, |
| 107 | + |
| 108 | + //--------------------------------------------------------- |
| 109 | + // 画像表示系 |
| 110 | + Graphic: { |
| 111 | + irowake: true, |
| 112 | + gridcolor_type: "LIGHT", |
| 113 | + textoption: { ratio: 0.45, position: 5 } /* TOPLEFT */, |
| 114 | + numbercolor_func: "fixed", |
| 115 | + |
| 116 | + paint: function() { |
| 117 | + this.drawBGCells(); |
| 118 | + this.drawGrid(); |
| 119 | + this.drawQuesCells(); |
| 120 | + this.drawQuesNumbers(); |
| 121 | + |
| 122 | + this.drawDotCells(); |
| 123 | + this.drawLines(); |
| 124 | + this.drawStars(); |
| 125 | + this.drawPekes(); |
| 126 | + |
| 127 | + this.drawBorders(); |
| 128 | + |
| 129 | + this.drawChassis(); |
| 130 | + this.drawTarget(); |
| 131 | + }, |
| 132 | + getQuesCellColor: function(cell) { |
| 133 | + return cell.isEmpty() ? "black" : null; |
| 134 | + }, |
| 135 | + |
| 136 | + drawStars: function() { |
| 137 | + var g = this.vinc("cell_star", "auto", true); |
| 138 | + var clist = this.range.cells; |
| 139 | + for (var i = 0; i < clist.length; i++) { |
| 140 | + var cell = clist[i]; |
| 141 | + g.vid = "c_star_" + cell.id; |
| 142 | + if (cell.qans === 1) { |
| 143 | + g.fillStyle = !cell.trial ? this.qanscolor : this.trialcolor; |
| 144 | + this.fillStar( |
| 145 | + g, |
| 146 | + cell.bx * this.bw, |
| 147 | + cell.by * this.bh, |
| 148 | + this.bw * 0.8, |
| 149 | + this.bh * 0.8 |
| 150 | + ); |
| 151 | + } else { |
| 152 | + g.vhide(); |
| 153 | + } |
| 154 | + } |
| 155 | + } |
| 156 | + }, |
| 157 | + |
| 158 | + //--------------------------------------------------------- |
| 159 | + // URLエンコード/デコード処理 |
| 160 | + Encode: { |
| 161 | + decodePzpr: function(type) { |
| 162 | + this.decodeBorder(); |
| 163 | + this.decodeEmpty(); |
| 164 | + this.decodeRoomNumber16(); |
| 165 | + }, |
| 166 | + encodePzpr: function(type) { |
| 167 | + this.encodeBorder(); |
| 168 | + this.encodeEmpty(); |
| 169 | + this.encodeRoomNumber16(); |
| 170 | + }, |
| 171 | + encodeBorder_makaro: function() { |
| 172 | + /* 同じ見た目のパズルにおけるURLを同じにするため、 */ |
| 173 | + /* 一時的にborder.ques=1にしてURLを出力してから元に戻します */ |
| 174 | + var bd = this.board, |
| 175 | + sv_ques = []; |
| 176 | + for (var id = 0; id < bd.border.length; id++) { |
| 177 | + sv_ques[id] = bd.border[id].ques; |
| 178 | + bd.border[id].ques = bd.border[id].isBorder() ? 1 : 0; |
| 179 | + } |
| 180 | + |
| 181 | + this.encodeBorder(); |
| 182 | + |
| 183 | + for (var id = 0; id < bd.border.length; id++) { |
| 184 | + bd.border[id].ques = sv_ques[id]; |
| 185 | + } |
| 186 | + } |
| 187 | + }, |
| 188 | + FileIO: { |
| 189 | + decodeData: function() { |
| 190 | + this.decodeCell(function(cell, ca) { |
| 191 | + if (ca === "*") { |
| 192 | + cell.ques = 7; |
| 193 | + } else if (ca === "-") { |
| 194 | + cell.qnum = -2; |
| 195 | + } else if (ca !== ".") { |
| 196 | + cell.qnum = +ca; |
| 197 | + } |
| 198 | + }); |
| 199 | + this.decodeBorderQues(); |
| 200 | + this.decodeBorderLine(); |
| 201 | + this.decodeCellAns(); |
| 202 | + }, |
| 203 | + encodeData: function() { |
| 204 | + this.encodeCell(function(cell) { |
| 205 | + if (cell.ques) { |
| 206 | + return "* "; |
| 207 | + } else if (cell.qnum === -2) { |
| 208 | + return "- "; |
| 209 | + } else if (cell.qnum > 0) { |
| 210 | + return cell.qnum + " "; |
| 211 | + } else { |
| 212 | + return ". "; |
| 213 | + } |
| 214 | + }); |
| 215 | + this.encodeBorderQues(); |
| 216 | + this.encodeBorderLine(); |
| 217 | + this.encodeCellAns(); |
| 218 | + } |
| 219 | + }, |
| 220 | + AnsCheck: { |
| 221 | + checklist: [ |
| 222 | + "checkAroundStars", |
| 223 | + "checkCrossLine", |
| 224 | + "checkCurveLine", |
| 225 | + "checkOverSaturatedStars", |
| 226 | + "checkOutgoingLine", |
| 227 | + "checkLineShapeDeadend", |
| 228 | + "checkNoLineObject", |
| 229 | + "checkInsufficientStars", |
| 230 | + "checkConnectAllNumber" |
| 231 | + ], |
| 232 | + checkLineShapeDeadend: function() { |
| 233 | + this.checkAllCell(function(cell) { |
| 234 | + return !cell.qans && cell.lcnt === 1; |
| 235 | + }, "lcDeadEnd"); |
| 236 | + }, |
| 237 | + checkCrossLine: function() { |
| 238 | + this.checkAllCell(function(cell) { |
| 239 | + return !cell.qans && cell.lcnt > 2; |
| 240 | + }, "lnBranch"); |
| 241 | + }, |
| 242 | + checkCurveLine: function() { |
| 243 | + this.checkAllCell(function(cell) { |
| 244 | + return !cell.qans && cell.isLineCurve(); |
| 245 | + }, "laCurve"); |
| 246 | + }, |
| 247 | + checkAroundStars: function() { |
| 248 | + this.checkAroundCell(function(cell1, cell2) { |
| 249 | + return cell1.qans === 1 && cell2.qans === 1; |
| 250 | + }, "starAround"); |
| 251 | + }, |
| 252 | + checkOverSaturatedStars: function() { |
| 253 | + var bd = this.board; |
| 254 | + this.checkAllBlock( |
| 255 | + bd.roommgr, |
| 256 | + function(cell) { |
| 257 | + return cell.qans === 1; |
| 258 | + }, |
| 259 | + function(w, h, a, n) { |
| 260 | + return a <= 1; |
| 261 | + }, |
| 262 | + "bkStarGt" |
| 263 | + ); |
| 264 | + }, |
| 265 | + checkInsufficientStars: function() { |
| 266 | + var bd = this.board; |
| 267 | + this.checkAllBlock( |
| 268 | + bd.roommgr, |
| 269 | + function(cell) { |
| 270 | + return cell.qans === 1; |
| 271 | + }, |
| 272 | + function(w, h, a, n) { |
| 273 | + return a >= 1; |
| 274 | + }, |
| 275 | + "bkStarLt" |
| 276 | + ); |
| 277 | + }, |
| 278 | + checkNoLineObject: function() { |
| 279 | + this.checkAllCell(function(cell) { |
| 280 | + return cell.lcnt === 0 && cell.qans; |
| 281 | + }, "nmNoLine"); |
| 282 | + }, |
| 283 | + checkOutgoingLine: function() { |
| 284 | + this.checkAllCell(function(cell) { |
| 285 | + if (!cell.qans || !cell.room) { |
| 286 | + return false; |
| 287 | + } |
| 288 | + if (cell.room.top.isValidNum() && cell.room.top.qnum !== cell.lcnt) { |
| 289 | + cell.room.clist.seterr(1); |
| 290 | + return true; |
| 291 | + } |
| 292 | + return false; |
| 293 | + }, "nmLineNe"); |
| 294 | + } |
| 295 | + } |
| 296 | +}); |
0 commit comments