Skip to content

Commit

Permalink
Add Tile City
Browse files Browse the repository at this point in the history
  • Loading branch information
x-sheep authored Feb 3, 2025
1 parent 3b023f8 commit 7d6e5b9
Show file tree
Hide file tree
Showing 9 changed files with 306 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src-ui/changes.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
<main>
<div style="margin-bottom: 5px;"><b>Latest types</b> (<em><a href="/list.html" target="_parent">all types</a></em>)</div>
<ul>
<li><a href="/p?tilecity" target="_parent">Tile City タイルシティー</a></li>
<li><a href="/p?turnrun" target="_parent">Turn and Run トツゲキループ</a></li>
<li><a href="/p?island" target="_parent">Inaba's Island アイランド</a></li>
<li><a href="/p?balloon" target="_parent">Balloon Box 風船箱</a></li>
<li><a href="/p?mintonette" target="_parent">Mintonette</a></li>
<li><a href="/p?nibunnogo" target="_parent">Nibun-nogo ニブンノゴ</a></li>
<li><a href="/p?timebomb" target="_parent">Time Bomb 時限爆弾</a></li>
<li><a href="/p?archipelago" target="_parent">Archipelago アーキペラゴ</a></li>
</ul>
</main>
</body>
Binary file added src-ui/img/tilecity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src-ui/js/ui/KeyPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ ui.keypopup = {
yajirushi2: [4, 0],
nibunnogo: [4, 0],
mintonette: [10, 0],
balloon: [10, 0]
balloon: [10, 0],
tilecity: [10, 0]
},

//---------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src-ui/js/ui/Misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ function toBGimage(pid) {
"teri",
"tetrochain",
"tetrominous",
"tilecity",
"timebomb",
"tontonbeya",
"trainstations",
Expand Down
1 change: 1 addition & 0 deletions src-ui/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ <h2 id="title"><span lang="ja">パズルの種類のリスト</span><span lang="
<li data-pid="patchwork"></li>
<li data-pid="mannequin"></li>
<li data-pid="kuromenbun"></li>
<li data-pid="tilecity"></li>
</ul>
</div>
<div class="lists blocks">
Expand Down
1 change: 1 addition & 0 deletions src/pzpr/variety.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,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"],
Expand Down
4 changes: 4 additions & 0 deletions src/res/failcode.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -811,6 +814,7 @@
"nqAroundSumNe.kakuru": "A sum of numbers around the pre-numbered cell is incorrect.",
"numNoLine": "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.",
Expand Down
244 changes: 244 additions & 0 deletions src/variety/tilecity.js
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
}
}
});
52 changes: 52 additions & 0 deletions test/script/tilecity.js
Original file line number Diff line number Diff line change
@@ -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 . /# . . /# + . /"
}
]
});

0 comments on commit 7d6e5b9

Please sign in to comment.