From e35c8d609fd93d550d868cd37008ded86a560490 Mon Sep 17 00:00:00 2001 From: Lennard Sprong Date: Wed, 24 Jun 2026 18:51:23 +0200 Subject: [PATCH] simpleloop: Move to separate file --- src/pzpr/variety.js | 2 +- src/variety/country.js | 109 ++++++++------------------------------ src/variety/simpleloop.js | 98 ++++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 89 deletions(-) create mode 100644 src/variety/simpleloop.js diff --git a/src/pzpr/variety.js b/src/pzpr/variety.js index 10c804b64..e7f3e88a6 100755 --- a/src/pzpr/variety.js +++ b/src/pzpr/variety.js @@ -422,7 +422,7 @@ shugaku: [1, 0, "修学旅行の夜", "School Trip"], shwolf: [0, 0, "ヤギとオオカミ", "Goats and Wolves", "kramma"], simplegako: [0, 0, "シンプルガコ", "Simple Gako"], - simpleloop: [0, 0, "シンプルループ", "Simple Loop", "country"], + simpleloop: [0, 0, "シンプルループ", "Simple Loop"], slalom: [1, 1, "スラローム", "Slalom", "", { alias: "suraromu" }], slashpack: [0, 0, "Slash Pack", "Slash Pack"], slither: [ diff --git a/src/variety/country.js b/src/variety/country.js index ce94f18de..25f1b6b53 100644 --- a/src/variety/country.js +++ b/src/variety/country.js @@ -8,7 +8,6 @@ "onsen", "doubleback", "maxi", - "simpleloop", "detour", "dotchi", "ovotovata", @@ -106,12 +105,6 @@ clist.draw(); } }, - "MouseEvent@simpleloop": { - inputModes: { - edit: ["clear", "info-line", "empty"], - play: ["line", "peke", "clear", "info-line"] - } - }, "MouseEvent@dotchi,dotchi2": { inputModes: { edit: ["border", "circle-shade", "circle-unshade", "clear", "info-line"], @@ -201,11 +194,7 @@ this.inputpeke(); } } - } else if ( - this.mouseend && - this.notInputted() && - this.pid !== "simpleloop" - ) { + } else if (this.mouseend && this.notInputted()) { if ( this.inputpeke_ifborder() || this.pid === "maxi" || @@ -220,10 +209,6 @@ } } } else if (this.puzzle.editmode) { - if (this.pid === "simpleloop") { - this.inputempty(); - return; - } if (this.mousestart || this.mousemove) { this.inputborder(); } else if (this.mouseend && this.notInputted()) { @@ -362,7 +347,7 @@ return this.qnum === 2; } }, - "Cell@doubleback,simpleloop,rassi,remlen": { + "Cell@doubleback,rassi,remlen": { noLP: function(dir) { return this.isEmpty(); } @@ -372,7 +357,7 @@ return Math.max(this.board.cols, this.board.rows) - 1; } }, - "Border@doubleback,simpleloop,dotchi,remlen": { + "Border@doubleback,dotchi,remlen": { enableLineNG: true }, "Border@moonsun,dotchi,dotchi2#1": { @@ -555,7 +540,7 @@ gridcolor_type: "SLIGHT", paint: function() { - if (this.pid !== "remlen" && this.pid !== "simpleloop") { + if (this.pid !== "remlen") { this.drawBGCells(); } @@ -567,7 +552,7 @@ if (this.pid === "remlen") { this.drawBorderDirBG(); } - if (this.pid === "remlen" || this.pid === "simpleloop") { + if (this.pid === "remlen") { this.drawBGCells(); } if ( @@ -607,8 +592,7 @@ if ( this.pid !== "rassi" && this.pid !== "doubleback" && - this.pid !== "nothing" && - this.pid !== "simpleloop" + this.pid !== "nothing" ) { this.drawTarget(); } @@ -683,26 +667,16 @@ } } }, - "Graphic@simpleloop": { - getBGCellColor: function(cell) { - return cell.ques === 7 ? "black" : this.getBGCellColor_error1(cell); - } - }, "Graphic@doubleback,rassi,remlen": { getBGCellColor: function(cell) { return cell.ques === 7 ? "darkgray" : this.getBGCellColor_error1(cell); - } - }, - "Graphic@simpleloop,doubleback,rassi,remlen": { + }, getBorderColor: function(border) { var cell1 = border.sidecell[0], cell2 = border.sidecell[1]; if (cell1.ques === 7 && cell2.ques === 7) { return null; } - if (this.pid === "simpleloop" && (cell1.ques === 7 || cell2.ques === 7)) { - return null; - } if ( border.inside && !cell1.isnull && @@ -769,9 +743,7 @@ if (this.pid === "ovotovata" || this.pid === "wataridori") { this.puzzle.setConfig("loop_full", this.checkpflag("f")); } - if (this.pid !== "simpleloop") { - this.decodeBorder(); - } + this.decodeBorder(); if (this.pid === "remlen") { if (this.outbstr[0] !== "/") { this.decodeEmpty(); @@ -795,11 +767,7 @@ this.decodeCircle(); } else if (this.pid === "onsen" || this.pid === "wataridori") { this.decodeNumber16(); - } else if ( - this.pid === "doubleback" || - this.pid === "simpleloop" || - this.pid === "rassi" - ) { + } else if (this.pid === "doubleback" || this.pid === "rassi") { this.decodeEmpty(); } }, @@ -810,9 +778,7 @@ if (this.pid === "ovotovata" || this.pid === "wataridori") { this.outpflag = this.puzzle.getConfig("loop_full") ? "f" : null; } - if (this.pid !== "simpleloop") { - this.encodeBorder(); - } + this.encodeBorder(); if (this.pid === "remlen" && !this.encodeEmpty()) { this.outbstr += "/"; } @@ -832,11 +798,7 @@ this.encodeCircle(); } else if (this.pid === "onsen" || this.pid === "wataridori") { this.encodeNumber16(); - } else if ( - this.pid === "doubleback" || - this.pid === "simpleloop" || - this.pid === "rassi" - ) { + } else if (this.pid === "doubleback" || this.pid === "rassi") { this.encodeEmpty(); } } @@ -884,18 +846,12 @@ if (this.pid === "ovotovata" || this.pid === "wataridori") { this.decodeConfigFlag("f", "loop_full"); } - if (this.pid !== "simpleloop") { - if (this.filever >= 2) { - this.decodeBorderQues(); - } else { - this.decodeAreaRoom(); - } + if (this.filever >= 2) { + this.decodeBorderQues(); + } else { + this.decodeAreaRoom(); } - if ( - this.pid === "doubleback" || - this.pid === "simpleloop" || - this.pid === "rassi" - ) { + if (this.pid === "doubleback" || this.pid === "rassi") { this.decodeEmpty(); } else { this.decodeCellQnum(); @@ -904,11 +860,7 @@ this.decodeBorderArrowAns(); } else { this.decodeBorderLine(); - if ( - this.pid !== "onsen" && - this.pid !== "simpleloop" && - this.pid !== "wataridori" - ) { + if (this.pid !== "onsen" && this.pid !== "wataridori") { this.decodeCellQsub(); } } @@ -920,15 +872,9 @@ if (this.pid === "ovotovata" || this.pid === "wataridori") { this.encodeConfigFlag("f", "loop_full"); } - if (this.pid !== "simpleloop") { - this.filever = 2; - this.encodeBorderQues(); - } - if ( - this.pid === "doubleback" || - this.pid === "simpleloop" || - this.pid === "rassi" - ) { + this.filever = 2; + this.encodeBorderQues(); + if (this.pid === "doubleback" || this.pid === "rassi") { this.encodeEmpty(); } else { this.encodeCellQnum(); @@ -937,11 +883,7 @@ this.encodeBorderArrowAns(); } else { this.encodeBorderLine(); - if ( - this.pid !== "onsen" && - this.pid !== "simpleloop" && - this.pid !== "wataridori" - ) { + if (this.pid !== "onsen" && this.pid !== "wataridori") { this.encodeCellQsub(); } } @@ -1052,15 +994,6 @@ "checkRoomPassTwice" ] }, - "AnsCheck@simpleloop#1": { - checklist: [ - "checkBranchLine", - "checkCrossLine", - "checkDeadendLine+", - "checkOneLoop", - "checkNoLine" - ] - }, "AnsCheck@moonsun#1": { checklist: [ "checkBranchLine", diff --git a/src/variety/simpleloop.js b/src/variety/simpleloop.js new file mode 100644 index 000000000..7269c0ff4 --- /dev/null +++ b/src/variety/simpleloop.js @@ -0,0 +1,98 @@ +(function(pidlist, classbase) { + if (typeof module === "object" && module.exports) { + module.exports = [pidlist, classbase]; + } else { + pzpr.classmgr.makeCustom(pidlist, classbase); + } +})(["simpleloop"], { + MouseEvent: { + inputModes: { + edit: ["clear", "info-line", "empty"], + play: ["line", "peke", "clear", "info-line"] + }, + mouseinputAutoEdit: function() { + this.inputempty(); + }, + + autoplay_func: "line" + }, + Cell: { + noLP: function(dir) { + return this.isEmpty(); + } + }, + Border: { + enableLineNG: true + }, + Board: { + hasborder: 1 + }, + LineGraph: { + enabled: true + }, + + Graphic: { + irowake: true, + + numbercolor_func: "qnum", + + gridcolor_type: "SLIGHT", + + paint: function() { + this.drawDashedGrid(); + this.drawBGCells(); + + this.drawBorders(); + + this.drawLines(); + this.drawPekes(); + + this.drawChassis(); + }, + + getBGCellColor: function(cell) { + return cell.ques === 7 ? "black" : this.getBGCellColor_error1(cell); + } + }, + + Encode: { + decodePzpr: function(type) { + this.decodeEmpty(); + }, + encodePzpr: function(type) { + this.encodeEmpty(); + } + }, + FileIO: { + decodeData: function() { + this.decodeEmpty(); + this.decodeBorderLine(); + }, + encodeData: function() { + this.encodeEmpty(); + this.encodeBorderLine(); + }, + decodeEmpty: function() { + this.decodeCell(function(cell, ca) { + if (ca === "*") { + cell.ques = 7; + } + }); + }, + encodeEmpty: function() { + this.encodeCell(function(cell) { + return cell.ques === 7 ? "* " : ". "; + }); + } + }, + + AnsCheck: { + checklist: [ + "checkBranchLine", + "checkCrossLine", + "checkDeadendLine+", + "checkOneLoop", + "checkNoLine" + ] + } +});