From 75738130f3a90dbc0352141d23cb6267d839d573 Mon Sep 17 00:00:00 2001 From: Lennard Sprong Date: Mon, 30 Dec 2024 12:33:10 +0100 Subject: [PATCH 1/3] Add Tile City --- src-ui/js/ui/KeyPopup.js | 3 +- src-ui/list.html | 1 + src/pzpr/variety.js | 1 + src/res/failcode.en.json | 4 + src/variety/tilecity.js | 244 +++++++++++++++++++++++++++++++++++++++ test/script/tilecity.js | 52 +++++++++ 6 files changed, 304 insertions(+), 1 deletion(-) create mode 100644 src/variety/tilecity.js create mode 100644 test/script/tilecity.js diff --git a/src-ui/js/ui/KeyPopup.js b/src-ui/js/ui/KeyPopup.js index 24fab562d..52a4873ca 100644 --- a/src-ui/js/ui/KeyPopup.js +++ b/src-ui/js/ui/KeyPopup.js @@ -215,7 +215,8 @@ ui.keypopup = { yajirushi2: [4, 0], nibunnogo: [4, 0], mintonette: [10, 0], - balloon: [10, 0] + balloon: [10, 0], + tilecity: [10, 0] }, //--------------------------------------------------------------------------- diff --git a/src-ui/list.html b/src-ui/list.html index 51e88b3f4..acfa87b01 100644 --- a/src-ui/list.html +++ b/src-ui/list.html @@ -90,6 +90,7 @@

パズルの種類のリスト
  • +
  • diff --git a/src/pzpr/variety.js b/src/pzpr/variety.js index 9eac5407e..5dc0eb7e7 100755 --- a/src/pzpr/variety.js +++ b/src/pzpr/variety.js @@ -424,6 +424,7 @@ teri: [0, 0, "テリトリー", "Territory", "kurodoko"], tetrochain: [0, 0, "テトロチェーン", "Tetrochain"], tetrominous: [0, 0, "Tetrominous", "Tetrominous", "fillomino"], + tilecity: [0, 0, "タイルシティー", "Tile City"], tilepaint: [1, 0, "タイルペイント", "Tilepaint"], timebomb: [0, 0, "時限爆弾", "Time Bomb", "bonsan"], toichika: [0, 0, "遠い誓い", "Toichika"], diff --git a/src/res/failcode.en.json b/src/res/failcode.en.json index 8f5af3e47..e08c9befc 100644 --- a/src/res/failcode.en.json +++ b/src/res/failcode.en.json @@ -124,6 +124,7 @@ "bkLineNe.nothing": "A country isn't fully visited.", "bkMajorBarGt.juosan": "The number of majority of vertical or horizontal bars is greater than the number of the area.", "bkMajorBarLt.juosan": "The number of majority of vertical or horizontal bars is less than the number of the area.", + "bkMaxSizeNe.tilecity": "The number is not equal to the amount of connected tiles.", "bkMirror.mirrorbk": "The two blocks divided by a mirror are not reflections of each other.", "bkMissingNum": "A block doesn't contain every number.", "bkMixed.sukoro": "A room includes both numbered and non-numbered cells.", @@ -335,9 +336,11 @@ "bsEqShade.shimaguni": "The sizes of countries that are in adjacent marine areas are the same.", "bsNoArrow.evolmino": "The block isn't placed on an arrow.", "bsNoSequence.archipelago": "A chain does not contain one island of every size from 1 to N.", + "bsNoSequence.tilecity": "A country does not contain one tile of every size from 1 to N.", "bsNotEvol.evolmino": "The block doesn't have the same shape as the previous block with one additional square.", "bsSameNum.archipelago": "A chain contains two islands of identical size.", "bsSameNum.fillomino": "Adjacent areas have the same number.", + "bsSameNum.tilecity": "A country contains two tiles of identical size.", "bsSameShape.chainedb": "A chain contains two identical blocks.", "bsSameShape.lits": "Some tetrominoes that have the same shape are adjacent.", "bsSameShape": "Two blocks that have the same shape are adjacent.", @@ -809,6 +812,7 @@ "numNoLine.geradeweg": "A number has no line.", "numNoLine.turnaround": "A number has no line.", "objShaded.nurimaze": "An object is shaded.", + "objShaded.tilecity": "A number is shaded.", "pairedLetterNe.kinkonkan": "Beam from a light doesn't reach its pair.", "pairedNumberNe.kinkonkan": "The number of reflections is wrong.", "pcMultipleTips.pencils": "A pencil has more than one tip.", diff --git a/src/variety/tilecity.js b/src/variety/tilecity.js new file mode 100644 index 000000000..6f6a4ac8d --- /dev/null +++ b/src/variety/tilecity.js @@ -0,0 +1,244 @@ +/* global Set:false */ +(function(pidlist, classbase) { + if (typeof module === "object" && module.exports) { + module.exports = [pidlist, classbase]; + } else { + pzpr.classmgr.makeCustom(pidlist, classbase); + } +})(["tilecity"], { + //--------------------------------------------------------- + // マウス入力系 + MouseEvent: { + use: true, + inputModes: { + edit: ["border", "number"], + play: ["shade", "unshade"] + }, + mouseinput: function() { + // オーバーライド + if (this.inputMode === "shade" || this.inputMode === "unshade") { + this.inputtile_tilecity(); + } else { + this.common.mouseinput.call(this); + } + }, + mouseinput_auto: function() { + if (this.puzzle.playmode) { + if (this.mousestart || this.mousemove) { + this.inputtile_tilecity(); + } + } else if (this.puzzle.editmode) { + if (this.mousestart || this.mousemove) { + this.inputborder(); + } else if (this.mouseend && this.notInputted()) { + this.inputqnum(); + } + } + }, + + inputtile_tilecity: function() { + var cell = this.getcell(); + if (cell.isnull || cell === this.mouseCell) { + return; + } + if (this.inputData === null) { + this.decIC(cell); + } + + var clist = cell.room.clist; + if (this.inputData === 1) { + for (var i = 0; i < clist.length; i++) { + if (clist[i].isNum()) { + if (this.mousestart) { + this.inputData = cell.qsub !== 1 ? 2 : 0; + break; + } else { + return; + } + } + } + } + + this.mouseCell = cell; + for (var i = 0; i < clist.length; i++) { + var cell2 = clist[i]; + (this.inputData === 1 ? cell2.setShade : cell2.clrShade).call(cell2); + cell2.setQsub(this.inputData === 2 ? 1 : 0); + } + clist.draw(); + } + }, + + KeyEvent: { + enablemake: true + }, + + Cell: { + maxnum: function() { + var n = this.board.cols * this.board.rows; + return Math.floor((Math.sqrt(8 * n + 1) - 1) / 2); + } + }, + Board: { + hasborder: 1 + }, + AreaUnshadeGraph: { + enabled: true, + + setExtraData: function(component) { + this.common.setExtraData.call(this, component); + var set = new Set(); + component.clist.each(function(cell) { + set.add(cell.room); + }); + component.blockset = Array.from(set); + } + }, + AreaRoomGraph: { + enabled: true + }, + + //--------------------------------------------------------- + // 画像表示系 + Graphic: { + enablebcolor: true, + bgcellcolor_func: "qsub1", + errbcolor2: "rgb(192, 192, 255)", + bbcolor: "rgb(96, 96, 96)", + + paint: function() { + this.drawBGCells(); + this.drawShadedCells(); + this.drawDashedGrid(); + + this.drawQuesNumbers(); + + this.drawBorders(); + + this.drawChassis(); + + this.drawBoxBorders(true); + + this.drawTarget(); + } + }, + + //--------------------------------------------------------- + // URLエンコード/デコード処理 + Encode: { + decodePzpr: function(type) { + this.decodeBorder(); + this.decodeNumber10(); + }, + encodePzpr: function(type) { + this.encodeBorder(); + this.encodeNumber10(); + } + }, + //--------------------------------------------------------- + FileIO: { + decodeData: function() { + this.decodeAreaRoom(); + this.decodeCellQnum(); + this.decodeCellAns(); + }, + encodeData: function() { + this.encodeAreaRoom(); + this.encodeCellQnum(); + this.encodeCellAns(); + } + }, + + //--------------------------------------------------------- + // 正解判定処理実行部 + AnsCheck: { + checklist: [ + "checkSameColorTile", + "checkShadedObject", + "check2x2ShadeCell", + + "checkSequence", + "checkNumberMatch", + "checkUniqueShapes", + + "doneShadingDecided" + ], + + checkShadedObject: function() { + this.checkAllCell(function(cell) { + return cell.qans === 1 && cell.qnum !== -1; + }, "objShaded"); + }, + + checkNumberMatch: function() { + this.checkAllCell(function(cell) { + return ( + cell.qnum > 0 && cell.ublk && cell.qnum !== cell.ublk.blockset.length + ); + }, "bkMaxSizeNe"); + }, + + checkSequence: function() { + var chains = this.board.ublkmgr.components; + + for (var r = 0; r < chains.length; r++) { + var chain = chains[r]; + var expected = chain.blockset.length; + var actual = 0; + + for (var i = 0; i < chain.blockset.length; i++) { + actual = Math.max(actual, chain.blockset[i].clist.length); + } + + if (actual > expected) { + this.failcode.add("bsNoSequence"); + if (this.checkOnly) { + return; + } + chain.clist.seterr(1); + } + } + }, + + checkUniqueShapes: function() { + var chains = this.board.ublkmgr.components; + var valid = true; + + for (var r = 0; r < chains.length; r++) { + var chain = chains[r]; + var shapes = chain.blockset; + + var sizemap = {}; + + for (var i = 0; i < shapes.length; i++) { + var clist = shapes[i].clist; + + var size = clist.length; + + if ("" + size in sizemap) { + this.failcode.add("bsSameNum"); + if (this.checkOnly) { + return; + } + + if (valid) { + this.board.cell.setnoerr(); + valid = false; + } + + chain.clist.each(function(cell) { + if (cell.error === -1) { + cell.seterr(0); + } + }); + + clist.seterr(1); + sizemap[size].seterr(1); + } else { + sizemap[size] = clist; + } + } + } + } + } +}); diff --git a/test/script/tilecity.js b/test/script/tilecity.js new file mode 100644 index 000000000..2f9338eeb --- /dev/null +++ b/test/script/tilecity.js @@ -0,0 +1,52 @@ +/* tilecity.js */ + +ui.debug.addDebugData("tilecity", { + url: "6/6/pdbvtjjv5vsua4i3l2i3a", + failcheck: [ + [ + "bkMixed", + "pzprv3/tilecity/6/6/19/0 1 2 2 2 3 /1 1 2 4 4 5 /6 6 7 7 4 5 /8 6 9 10 11 12 /13 14 15 16 16 12 /13 17 17 17 18 12 /. 4 . . . . /. . . . . 3 /. . . . . . /. . . . . . /2 . . . . . /. . . . 3 . /. . # . . . /. . # . . . /. . . . . . /. . . . . . /. . . . . . /. . . . . . /" + ], + [ + "objShaded", + "pzprv3/tilecity/6/6/19/0 1 2 2 2 3 /1 1 2 4 4 5 /6 6 7 7 4 5 /8 6 9 10 11 12 /13 14 15 16 16 12 /13 17 17 17 18 12 /. 4 . . . . /. . . . . 3 /. . . . . . /. . . . . . /2 . . . . . /. . . . 3 . /. . . . . . /. . . . . # /. . . . . # /. . . . . . /. . . . . . /. . . . . . /" + ], + [ + "cs2x2", + "pzprv3/tilecity/6/6/19/0 1 2 2 2 3 /1 1 2 4 4 5 /6 6 7 7 4 5 /8 6 9 10 11 12 /13 14 15 16 16 12 /13 17 17 17 18 12 /. 4 . . . . /. . . . . 3 /. . . . . . /. . . . . . /2 . . . . . /. . . . 3 . /. . . . . # /. . . # # . /# # . . # . /. # # # # . /. # . # # . /. # # # . . /" + ], + [ + "bkMaxSizeNe", + "pzprv3/tilecity/6/6/22/0 1 2 2 2 3 /1 1 2 4 4 5 /6 6 7 8 4 5 /9 6 10 11 12 13 /14 15 16 17 17 13 /14 18 19 20 21 13 /. 4 . . . . /. . . . . 3 /. . . . . . /. . . . . . /2 . . . . . /. . . . 3 . /# . . . . . /. . . # # . /# # # . # . /. # . # . # /. # # # # # /. # . # . # /" + ], + [ + "bsNoSequence", + "pzprv3/tilecity/6/6/19/0 1 2 2 2 3 /1 1 2 4 4 5 /6 6 7 7 4 5 /8 6 9 10 11 12 /13 14 15 16 16 12 /13 17 17 17 18 12 /. 4 . . . . /. . . . . 3 /. . . . . . /. . . . . . /2 . . . . . /. . . . 3 . /. . # # # # /. . # . . . /# # . . . . /. # # # # # /. # . . . # /. # # # . # /" + ], + [ + "bsSameNum", + "pzprv3/tilecity/6/6/19/0 1 2 2 2 3 /1 1 2 4 4 5 /6 6 7 7 4 5 /8 6 9 10 11 12 /13 14 15 16 16 12 /13 17 17 17 18 12 /. 4 . . . . /. . . . . 3 /. . . . . . /. . . . . . /. . . . . . /. . . . 3 . /# . . . . # /. . . # # . /# # . . # . /. # # . # . /. . . # # . /. # # # . . /" + ], + [ + null, + "pzprv3/tilecity/6/6/19/0 1 2 2 2 3 /1 1 2 4 4 5 /6 6 7 7 4 5 /8 6 9 10 11 12 /13 14 15 16 16 12 /13 17 17 17 18 12 /. 4 . . . . /. . . . . 3 /. . . . . . /. . . . . . /2 . . . . . /. . . . 3 . /# + + + + # /+ + + # # + /# # + + # + /+ # # + # + /+ # + # # + /+ # # # + + /" + ] + ], + inputs: [ + { + input: [ + "newboard,3,2", + "editmode", + "mouse,left,2,0,2,4", + "mouse,left,2,2,4,2,4,4", + "cursor,3,3", + "key,3" + ], + result: "pzprv3/tilecity/2/3/3/0 1 1 /0 2 1 /. . . /. 3 . /. . . /. . . /" + }, + { + input: ["playmode", "mouse,left,1,3", "mouse,left,3,3"], + result: "pzprv3/tilecity/2/3/3/0 1 1 /0 2 1 /. . . /. 3 . /# . . /# + . /" + } + ] +}); From 4a1b5122bf062e03a9ef4c297194c9b7280a4cef Mon Sep 17 00:00:00 2001 From: Lennard Sprong Date: Sun, 2 Feb 2025 12:16:47 +0100 Subject: [PATCH 2/3] Add changelog --- src-ui/changes.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-ui/changes.html b/src-ui/changes.html index 91032eec5..689b4dfc8 100644 --- a/src-ui/changes.html +++ b/src-ui/changes.html @@ -33,13 +33,13 @@
    Latest types (all types)
    From 054cb886e8c864f3fd1da8db98ed4224d432f2cf Mon Sep 17 00:00:00 2001 From: Lennard Sprong Date: Sun, 2 Feb 2025 13:12:03 +0100 Subject: [PATCH 3/3] Add background --- src-ui/img/tilecity.png | Bin 0 -> 233 bytes src-ui/js/ui/Misc.js | 1 + 2 files changed, 1 insertion(+) create mode 100644 src-ui/img/tilecity.png diff --git a/src-ui/img/tilecity.png b/src-ui/img/tilecity.png new file mode 100644 index 0000000000000000000000000000000000000000..0ed5d6877e9ae0b9b1b5e6f15a7d00e44f9ddd94 GIT binary patch literal 233 zcmeAS@N?(olHy`uVBq!ia0vp^20*O9!3-pmxw!R!6k~CayA#8@b22Z19L@lr5ZCil zr={uY9NM^H*~_I*fr5RWE{-7CMt`3@*>IRF3u!q;4^QE9^)3q7~XQJI}Co2CA~ zp02$$>1Fk@7HTy^hUfw_g&ZDtz`~>6gcjSGo4xLZW+;7%eRgB*0TlQU&o|!B=HHeSZ+6T fJX`5e@mF8=pCX$vUx`02&}9ssu6{1-oD!M