Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Alternation #471

Merged
merged 6 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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?alter" target="_parent">Alternation オルタネーション</a></li>
<li><a href="/p?tachibk" target="_parent">Tachiawase Block たちあわせブロック</a></li>
<li><a href="/p?mukkonn" target="_parent">Mukkonn Enn</a></li>
<li><a href="/p?aquapelago" target="_parent">Aquapelago</a></li>
<li><a href="/p?wittgen" target="_parent">Wittgenstein Briquet</a></li>
<li><a href="/p?kaisu" target="_parent">Kaisu</a></li>
<li><a href="/p?pentatouch" target="_parent">Penta Touch</a></li>
<li><a href="/p?waterwalk" target="_parent">Water Walk ウォーターウォーク</a></li>
</ul>
</main>
</body>
Binary file added src-ui/img/alter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions src-ui/js/ui/KeyPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ ui.keypopup = {
aquapelago: [10, 0],
compass: [10, 0],
mukkonn: [10, 0],
tachibk: [10, 0]
tachibk: [10, 0],
alter: [113, 113]
},

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -632,7 +633,7 @@ ui.keypopup = {
itemlist = [];

itemlist.push(["1", "○"], ["2", "△"], ["3", "□"]);
if (pid === "hakoiri") {
if (pid === "hakoiri" || pid === "alter") {
itemlist.push([
"4",
{
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 @@ -106,6 +106,7 @@ ui.misc = {
function toBGimage(pid) {
var imgs = [
"akichi",
"alter",
"angleloop",
"aquapelago",
"aquarium",
Expand Down
1 change: 1 addition & 0 deletions src-ui/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ <h2 id="title"><span lang="ja">パズルの種類のリスト</span><span lang="
<li data-pid="evolmino"></li>
<li data-pid="tontonbeya"></li>
<li data-pid="pentatouch"></li>
<li data-pid="alter"></li>
</ul>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/pzpr/variety.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
{
aho: [0, 0, "アホになり切れ", "Aho-ni-Narikire", "shikaku"],
akichi: [0, 0, "Akichiwake", "Akichiwake", "heyawake"],
alter: [0, 0, "オルタネーション", "Alternation", "hakoiri"],
amibo: [0, 0, "あみぼー", "Amibo", "amibo"],
angleloop: [0, 0, "鋭直鈍ループ", "Angle Loop", "kouchoku"],
anglers: [0, 0, "フィッシング", "Anglers"],
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 @@ -632,6 +632,7 @@
"nmDivide.tontonbeya": "Identical symbols are divided in a room.",
"nmDivide": "Numbers are divided.",
"nmDivNe2.kropki": "The number is not double the other between two adjacent cells with shaded circle.",
"nmDupRow.alter": "A row or column does not have alternating symbols.",
"nmDupRow.easyasabc": "There are equal letters in a row or column.",
"nmDupRow.lollipops": "Two identical symbols can see each other.",
"nmDupRow.takoyaki": "Two circles in the same row or column belong to the same line.",
Expand All @@ -658,6 +659,7 @@
"nmMidpoint.snakepit": "A grey cell is not a middle part of a snake.",
"nmMinesNe.mines": "The number of mines in the surrounding cells is not equal to the number.",
"nmMissing.lohkous": "There is no segment of the given length in the room.",
"nmMissRow.alter": "A row or column has less than two symbols.",
"nmMissRow.easyasabc": "There are missing letters in a row or column.",
"nmMixed.aquapelago": "A group contains different numbers.",
"nmMoveNe.tren": "A block cannot move in the correct number of spaces.",
Expand Down Expand Up @@ -735,6 +737,7 @@
"nmTreeNone.tents": "A tent is not next to a tree.",
"nmTriangleGt.shakashaka": "There are too many triangles adjacent to a number.",
"nmTriangleLt.shakashaka": "There are not enough triangles adjacent to a number.",
"nmTripRow.alter": "A row or column has three different symbols.",
"nmTripRow.toichika2": "A number appears more than twice in the same row or column.",
"nmUnpass.icebarn": "The line doesn't pass all of the number.",
"nmUnshadeAdjNe.context": "The number of shaded cells orthogonally adjacent to an unshaded number is not correct.",
Expand Down
80 changes: 73 additions & 7 deletions src/variety/hakoiri.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
} else {
pzpr.classmgr.makeCustom(pidlist, classbase);
}
})(["hakoiri", "tontonbeya"], {
})(["hakoiri", "tontonbeya", "alter"], {
//---------------------------------------------------------
// マウス入力系
MouseEvent: {
Expand Down Expand Up @@ -176,7 +176,7 @@
} else if (ca === "3" || ca === "e" || ca === "d" || ca === "c") {
ca = "3";
} else if (ca === "4" || ca === "r" || ca === "f" || ca === "v") {
ca = this.pid !== "hakoiri" ? " " : "s1";
ca = this.pid === "tontonbeya" ? " " : "s1";
} else if (ca === "5" || ca === "t" || ca === "g" || ca === "b") {
ca = " ";
}
Expand All @@ -198,10 +198,10 @@
hasborder: 1
},

AreaNumberGraph: {
"AreaNumberGraph@hakoiri,tontonbeya": {
enabled: true
},
"AreaNumberGraph@tontonbeya": {
"AreaNumberGraph@tontonbeya#1": {
relation: {
"cell.qnum": "node",
"cell.anum": "node",
Expand Down Expand Up @@ -334,11 +334,14 @@
// 正解判定処理実行部
AnsCheck: {
checklist: [
"checkAroundMarks",
"checkAroundMarks@hakoiri",
"checkThreeTypesInLine@alter",
"checkOverFourMarksInBox",
"checkDifferentNumberInRoom",
"checkConnectNumber",
"checkAllMarkInBox"
"checkAlternatingLines@alter",
"checkConnectNumber@hakoiri",
"checkAllMarkInBox",
"checkNoTypesInLine@alter"
],

checkOverFourMarksInBox: function() {
Expand Down Expand Up @@ -370,6 +373,69 @@
this.checkAroundCell(function(cell1, cell2) {
return cell1.getNum() >= 0 && cell1.getNum() === cell2.getNum();
}, "nmAround");
},

checkAlternatingLines: function() {
var bd = this.board;
var hasError = false;
this.checkRowsCols(function(clist) {
var found = null;

for (var idx = 0; idx < clist.length; idx++) {
var cell = clist[idx];
if (!cell.isNum()) {
continue;
}

if (found && found.getNum() === cell.getNum()) {
if (this.checkOnly) {
return false;
}
hasError = true;
bd.cellinside(found.bx, found.by, cell.bx, cell.by).seterr(1);
}
found = cell;
}

return true;
}, "nmDupRow");

if (hasError) {
this.failcode.add("nmDupRow");
}
},

checkThreeTypesInLine: function() {
this.checkRowsCols(function(clist) {
var found = [false, false, false];

clist.each(function(cell) {
var num = cell.getNum();
if (num >= 1 && num <= 3) {
found[num - 1] = true;
}
});

if (found[0] && found[1] && found[2]) {
clist.seterr(1);
return false;
}
return true;
}, "nmTripRow");
},

checkNoTypesInLine: function() {
this.checkRowsCols(function(clist) {
var found = clist.filter(function(cell) {
return cell.isNum();
});

if (found.length < 2) {
clist.seterr(1);
return false;
}
return true;
}, "nmMissRow");
}
},

Expand Down
36 changes: 36 additions & 0 deletions test/script/alter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* alter.js */

ui.debug.addDebugData("alter", {
url: "4/4/aqgk1gc1a3b1a1a2c",
failcheck: [
[
"bkNumLt3",
"pzprv3/alter/4/4/3/0 0 1 1 /2 0 0 1 /2 0 0 1 /2 2 1 1 /. . . 1 /. 3 . . /1 . 1 . /2 . . . /. . . . /. . . . /. 2 . . /. . . . /"
],
[
"bkDupNum",
"pzprv3/alter/4/4/3/0 0 1 1 /2 0 0 1 /2 0 0 1 /2 2 1 1 /. . . 1 /. 3 . . /1 . 1 . /2 . . . /. . . . /2 . . . /. . . . /. . . . /"
],
[
"bkNumGt3",
"pzprv3/alter/4/4/3/0 0 1 1 /2 0 0 1 /2 0 0 1 /2 2 1 1 /. . . 1 /. 3 . . /1 . 1 . /2 . . . /. . 3 . /. . . . /. 2 . 2 /. . 3 . /"
],
[
"nmTripRow",
"pzprv3/alter/4/4/3/0 0 1 1 /2 0 0 1 /2 0 0 1 /2 2 1 1 /. . . 1 /. 3 . . /1 . 1 . /2 . . . /. . . . /. . . . /. 2 . 3 /. . . . /"
],
[
"nmMissRow",
"pzprv3/alter/4/4/3/0 0 1 1 /2 0 0 1 /2 0 0 1 /2 2 1 1 /. . . 1 /. 3 . . /1 . 1 . /2 . . . /. . 3 . /. . . . /. 2 . 2 /. 3 . . /"
],
[
"nmDupRow",
"pzprv3/alter/4/4/3/0 0 1 1 /2 0 0 1 /2 0 0 1 /2 2 1 1 /. . . 1 /. 3 . . /1 . 1 . /2 . . . /2 . . . /. . . 2 /. . . . /. . . . /"
],
[
null,
"pzprv3/alter/4/4/3/0 0 1 1 /2 0 0 1 /2 0 0 1 /2 2 1 1 /. . . 1 /. 3 . . /1 . 1 . /2 . . . /. . 3 . /. . . 2 /. 2 . . /. 3 . . /"
]
],
inputs: []
});
Loading