Skip to content

Commit

Permalink
Add Archipelago
Browse files Browse the repository at this point in the history
  • Loading branch information
x-sheep authored Nov 18, 2024
1 parent 878d39d commit 6f28692
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 11 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?archipelago" target="_parent">Archipelago アーキペラゴ</a></li>
<li><a href="/p?yajirushi2" target="_parent">Yajirushi 2 見つめあう矢印2</a></li>
<li><a href="/p?swslither" target="_parent">Sheep Wolf Slitherlink</a></li>
<li><a href="/p?meidjuluk" target="_parent">Meidjuluk</a></li>
<li><a href="/p?smullyan" target="_parent">Smullyanic Dynasty</a></li>
<li><a href="/p?twinarea" target="_parent">Twin Area ツインエリア</a></li>
<li><a href="/p?turnaround" target="_parent">Turnaround</a></li>
<li><a href="/p?regional-poly" target="_parent">Regional Polyominoes</a></li>
</ul>
</main>
</body>
Binary file added src-ui/img/archipelago.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src-ui/js/ui/KeyPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ ui.keypopup = {
snakeegg: [10, 0],
smullyan: [10, 0],
meidjuluk: [10, 0],
archipelago: [10, 0],
yajirushi2: [4, 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 @@ -108,6 +108,7 @@ function toBGimage(pid) {
"akichi",
"alter",
"angleloop",
"archipelago",
"aquapelago",
"aquarium",
"araf",
Expand Down
1 change: 1 addition & 0 deletions src-ui/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ <h2 id="title"><span lang="ja">パズルの種類のリスト</span><span lang="
<li data-pid="mrtile"></li>
<li data-pid="batten"></li>
<li data-pid="snakeegg"></li>
<li data-pid="archipelago"></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 @@ -90,6 +90,7 @@
angleloop: [0, 0, "鋭直鈍ループ", "Angle Loop", "kouchoku"],
anglers: [0, 0, "フィッシング", "Anglers"],
antmill: [0, 0, "Ant Mill", "Ant Mill", "scrin"],
archipelago: [0, 0, "アーキペラゴ", "Archipelago", "chainedb"],
aqre: [0, 0, "Aqre", "Aqre", "aqre"],
aquapelago: [0, 0, "Aquapelago", "Aquapelago"],
aquarium: [0, 0, "アクアプレース", "Aquarium", "aquarium"],
Expand Down
3 changes: 3 additions & 0 deletions src/res/failcode.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@
"bkShadeNe.shimaguni": "The number of shaded cells is not equal to the number.",
"bkShadeNe": "The number of shaded cells in the room and the number written in the room is different.",
"bkSideNe.squarejam": "The side length of a room is not equal to a number inside of it.",
"bkSize1.archipelago": "There is an island not touching another island.",
"bkSize1.rectslider": "There is an isolated shaded cell.",
"bkSize1.yajitatami": "The length of the tatami is one.",
"bkSizeEq.fillmat": "The number is equal to the size of the tatami.",
Expand Down Expand Up @@ -328,7 +329,9 @@
"bsEqShade.mannequin": "The distance between the two shaded cells is the same in adjacent rooms.",
"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.",
"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.",
"bsSameShape.chainedb": "A chain contains two identical blocks.",
"bsSameShape.lits": "Some tetrominoes that have the same shape are adjacent.",
Expand Down
129 changes: 119 additions & 10 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", "mrtile"], {
})(["chainedb", "mrtile", "archipelago"], {
//---------------------------------------------------------
// マウス入力系
MouseEvent: {
Expand Down Expand Up @@ -52,7 +52,7 @@
relation: { "cell.qans": "node", "cell.qnum": "node" },
enabled: true
},
"AreaShade8Graph:AreaShadeGraph@chainedb": {
"AreaShade8Graph:AreaShadeGraph@chainedb,archipelago": {
enabled: true,
setComponentRefs: function(obj, component) {
obj.blk8 = component;
Expand All @@ -74,10 +74,19 @@
}
}
return cells;
},

setExtraData: function(component) {
this.common.setExtraData.call(this, component);
var set = new Set();
component.clist.each(function(cell) {
set.add(cell.sblk);
});
component.blockset = Array.from(set);
}
},

"Board@chainedb": {
"Board@chainedb,archipelago": {
addExtraInfo: function() {
this.sblk8mgr = this.addInfoList(this.klass.AreaShade8Graph);
}
Expand Down Expand Up @@ -114,6 +123,12 @@
return ((bd.cols * bd.rows) >> 1) - 1;
}
},
"Cell@archipelago": {
maxnum: function() {
var n = this.board.cols * this.board.rows;
return Math.ceil(Math.sqrt(n)) + 1;
}
},

//---------------------------------------------------------
// 画像表示系
Expand Down Expand Up @@ -155,7 +170,7 @@
return cell.qnum !== -1 ? this.shadecolor : this.qanscolor;
}
},
"Graphic@mrtile": {
"Graphic@mrtile,archipelago": {
hideHatena: true,
shadecolor: "#111111"
},
Expand Down Expand Up @@ -254,12 +269,7 @@

for (var r = 0; r < chains.length; r++) {
var chain = chains[r];

var set = new Set();
chain.clist.each(function(cell) {
set.add(cell.sblk);
});
var shapes = Array.from(set);
var shapes = chain.blockset;

for (var nna = 0; nna < shapes.length; nna++) {
for (var nnb = nna + 1; nnb < shapes.length; nnb++) {
Expand Down Expand Up @@ -360,5 +370,104 @@
}
}
}
},
"AnsCheck@archipelago": {
checklist: [
"checkNumberAndShadeSize",
"checkMaximumNumber",
"checkUniqueShapes",
"checkIsolated",
"doneShadingDecided"
],

checkMaximumNumber: function() {
var chains = this.board.sblk8mgr.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; actual >= 0 && i < chain.clist.length; i++) {
var cell = chain.clist[i];

if (cell.isValidNum() && cell.sblk.clist.length !== cell.getNum()) {
actual = -1;
} else {
actual = Math.max(actual, cell.sblk.clist.length);
}
}

if (actual === -1) {
continue;
}

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.sblk8mgr.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.getQnumCell().qnum;
if (size < 0) {
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;
}
}
}
},

checkIsolated: function() {
this.checkAllArea(
this.board.sblk8mgr,
function(w, h, a, n) {
return a !== 1 || n > 1;
},
"bkNoChain"
);
}
}
});
33 changes: 33 additions & 0 deletions test/script/archipelago.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* archipelago.js */

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

0 comments on commit 6f28692

Please sign in to comment.