Skip to content

Commit

Permalink
Add Mirroring Tile
Browse files Browse the repository at this point in the history
  • Loading branch information
x-sheep authored Dec 25, 2023
1 parent 1538c85 commit 5fb2c31
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 31 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?mrtile" target="_parent">Mirroring Tile ミラーリングタイル</a></li>
<li><a href="/p?kissing" target="_parent">Kissing Polyominoes</a></li>
<li><a href="/p?lineofsight" target="_parent">Line of Sight サイトライン</a></li>
<li><a href="/p?tetrominous" target="_parent">Tetrominous</a></li>
<li><a href="/p?mannequin" target="_parent">Mannequin Gate マネキンゲート</a></li>
<li><a href="/p?nothing" target="_parent">All or Nothing オールorナッシング</a></li>
<li><a href="/p?alter" target="_parent">Alternation オルタネーション</a></li>
<li><a href="/p?tachibk" target="_parent">Tachiawase Block たちあわせブロック</a></li>
</ul>
</main>
</body>
Binary file added src-ui/img/mrtile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions src-ui/js/ui/KeyPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ ui.keypopup = {
alter: [113, 113],
mannequin: [10, 0],
tetrominous: [128, 128],
lineofsight: [10, 0]
lineofsight: [10, 0],
mrtile: [10, 0]
},

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -409,7 +410,11 @@ ui.keypopup = {
) {
} else if (pid === "tasquare") {
cap = "□";
} else if (pid === "rectslider" || pid === "aquapelago") {
} else if (
pid === "rectslider" ||
pid === "aquapelago" ||
pid === "mrtile"
) {
cap = "■";
} else if (pid === "patchwork") {
cap = {
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 @@ -153,6 +153,7 @@ function toBGimage(pid) {
"midloop",
"mirrorbk",
"moonsun",
"mrtile",
"mukkonn",
"nanameguri",
"nondango",
Expand Down
1 change: 1 addition & 0 deletions src-ui/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ <h2 id="title"><span lang="ja">パズルの種類のリスト</span><span lang="
<li data-pid="norinuri"></li>
<li data-pid="circlesquare"></li>
<li data-pid="tetrochain"></li>
<li data-pid="mrtile"></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 @@ -264,6 +264,7 @@
mochikoro: [1, 0, "モチコロ", "Mochikoro", "nurikabe"],
mochinyoro: [1, 0, "モチにょろ", "Mochinyoro", "nurikabe"],
moonsun: [0, 0, "月か太陽", "Moon or Sun", "country"],
mrtile: [0, 0, "ミラーリングタイル", "Mirroring Tile", "chainedb"],
mukkonn: [0, 0, "Mukkonn Enn", "Mukkonn Enn", "compass"],
myopia: [0, 0, "Myopia", "Myopia"],
nagare: [0, 0, "流れるループ", "Nagareru-Loop"],
Expand Down
1 change: 1 addition & 0 deletions src/res/failcode.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
"bkMSPassedGt2.moonsun": "A line passes the marks of the moon for two rooms in a row.",
"bkMUPassedGt2.moonsun": "A line passes the marks of the sun for two rooms in a row.",
"bkNoChain.chainedb": "A block is not diagonally adjacent to another block.",
"bkNoChain.mrtile": "A block is not diagonally adjacent to another identical block.",
"bkNoColor.interbd": "A country has no color.",
"bkNoLevel.aquarium": "A region has different water surface levels.",
"bkNoLine.country": "A line doesn't pass a country.",
Expand Down
135 changes: 107 additions & 28 deletions src/variety/chainedb.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
} else {
pzpr.classmgr.makeCustom(pidlist, classbase);
}
})(["chainedb"], {
})(["chainedb", "mrtile"], {
//---------------------------------------------------------
// マウス入力系
MouseEvent: {
Expand All @@ -35,6 +35,12 @@
this.inputFixedNumber(-1);
}
},
"MouseEvent@mrtile": {
inputModes: {
edit: ["number", "undef", "clear"],
play: ["shade", "unshade"]
}
},

//---------------------------------------------------------
// キーボード入力系
Expand All @@ -43,9 +49,10 @@
},

AreaShadeGraph: {
relation: { "cell.qans": "node", "cell.qnum": "node" },
enabled: true
},
"AreaShade8Graph:AreaShadeGraph": {
"AreaShade8Graph:AreaShadeGraph@chainedb": {
enabled: true,
setComponentRefs: function(obj, component) {
obj.blk8 = component;
Expand All @@ -70,22 +77,9 @@
}
},

Board: {
"Board@chainedb": {
addExtraInfo: function() {
this.sblk8mgr = this.addInfoList(this.klass.AreaShade8Graph);
},

reapplyShades: function() {
this.cell.each(function(cell) {
if (cell.qnum !== -1) {
cell.setQans(1);
}
});
},

ansclear: function() {
this.common.ansclear.call(this);
this.reapplyShades();
}
},

Expand Down Expand Up @@ -114,11 +108,17 @@
}
}
},
"Cell@mrtile": {
maxnum: function() {
var bd = this.board;
return ((bd.cols * bd.rows) >> 1) - 1;
}
},

//---------------------------------------------------------
// 画像表示系
Graphic: {
qanscolor: "black",
qanscolor: "#222222",
shadecolor: "#222222",
numbercolor_func: "fixed_shaded",
fontShadecolor: "white",
Expand All @@ -139,19 +139,32 @@
},

getShadedCellColor: function(cell) {
if (cell.qans === 1 && !cell.trial && cell.error === -1) {
if (!cell.isShade()) {
return null;
}

var info = cell.error || cell.qinfo;

if (info === 1) {
return this.errcolor1;
} else if (cell.trial) {
return this.trialcolor;
} else if (info === -1) {
return this.noerrcolor;
}
return this.common.getShadedCellColor.call(this, cell);
return cell.qnum !== -1 ? this.shadecolor : this.qanscolor;
}
},
"Graphic@mrtile": {
hideHatena: true,
shadecolor: "#111111"
},

//---------------------------------------------------------
// URLエンコード/デコード処理
Encode: {
decodePzpr: function(type) {
this.decodeNumber16();
this.board.reapplyShades();
},
encodePzpr: function(type) {
this.encodeNumber16();
Expand All @@ -161,7 +174,6 @@
FileIO: {
decodeData: function() {
this.decodeCellQnumAns();
this.board.reapplyShades();
},
encodeData: function() {
this.encodeCellQnumAns();
Expand Down Expand Up @@ -204,13 +216,23 @@
);
},
checkNumberAndShadeSize: function() {
this.checkAllArea(
this.board.sblkmgr,
function(w, h, a, n) {
return n <= 0 || n === a;
},
"bkSizeNe"
);
for (var c = 0; c < this.board.cell.length; c++) {
var cell = this.board.cell[c];
if (!cell.isShade() || cell.qnum < 0) {
continue;
}

var clist = cell.sblk.clist;
if (clist.length === cell.qnum) {
continue;
}

this.failcode.add("bkSizeNe");
if (this.checkOnly) {
break;
}
cell.sblk.clist.seterr(1);
}
},
checkNoChain: function() {
var shapes = this.board.sblkmgr.components;
Expand Down Expand Up @@ -281,5 +303,62 @@
}
}
}
},
"AnsCheck@mrtile": {
checklist: [
"checkNumberAndShadeSize",
"checkAdjacentExist",
"doneShadingDecided"
],

checkAdjacentExist: function() {
var bd = this.board;

var blocks = bd.sblkmgr.components;
for (var r = 0; r < blocks.length; r++) {
blocks[r].valid = false;
}

for (var c = 0; c < bd.cell.length; c++) {
var cell = bd.cell[c];
if (cell.bx >= bd.maxbx - 1 || cell.by >= bd.maxby - 1) {
continue;
}

var bx = cell.bx,
by = cell.by;
var clist = bd.cellinside(bx, by, bx + 2, by + 2).filter(function(cc) {
return cc.isShade();
});
if (clist.length !== 2) {
continue;
}

var ca = clist[0],
cb = clist[1];

if (ca.bx === cb.bx || ca.by === cb.by) {
continue;
}

if (
ca.sblk !== cb.sblk &&
!this.isDifferentShapeBlock(ca.sblk, cb.sblk)
) {
ca.sblk.valid = true;
cb.sblk.valid = true;
}
}

for (var r = 0; r < blocks.length; r++) {
if (!blocks[r].valid) {
this.failcode.add("bkNoChain");
if (this.checkOnly) {
break;
}
blocks[r].clist.seterr(1);
}
}
}
}
});
25 changes: 25 additions & 0 deletions test/script/mrtile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* mrtile.js */

ui.debug.addDebugData("mrtile", {
url: "5/5/1h3k32g..q",
failcheck: [
[
"bkSizeNe",
"pzprv3/mrtile/5/5/1 . . 3 . /. # . . 3 /2 . - - . /# . . . # /. # # . # /"
],
[
"bkNoChain",
"pzprv3/mrtile/5/5/1 . . 3 # /. # . . 3 /2 . - - . /# . . . # /. # # . # /"
],
[
null,
"pzprv3/mrtile/5/5/1 + + 3 # /+ # + + 3 /2 + - - + /# + + # + /+ # # + + /"
]
],
inputs: [
{
input: ["newboard,6,2", "cursor,5,3", "mouse,right,5,3"],
result: "pzprv3/mrtile/2/6/. . . . . . /. . 5 . . . /"
}
]
});

1 comment on commit 5fb2c31

@vercel
Copy link

@vercel vercel bot commented on 5fb2c31 Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

pzprjs – ./

pzprjs-git-main-robx.vercel.app
pzprjs.vercel.app
pzprjs-robx.vercel.app

Please sign in to comment.