Skip to content

Commit

Permalink
Add Sheep Wolf Slitherlink (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
despian authored Oct 28, 2024
1 parent 2efa04b commit 388b9fa
Show file tree
Hide file tree
Showing 16 changed files with 288 additions and 6 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,8 @@ peke: cross mark
[puzz.link]: https://puzz.link/list.html
[sudoku]: https://en.wikipedia.org/wiki/Sudoku
[yajilin]: https://en.wikipedia.org/wiki/Yajilin


## OpenSource Licenses

Emojis used in some puzzles are sourced from [noto-emoji](https://github.com/googlefonts/noto-emoji) and licensed under the [SIL Open Font License](https://scripts.sil.org/OFL), Version 1.1.
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?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>
<li><a href="/p?fakearrow" target="_parent">Fake Arrow フェイクアロー</a></li>
<li><a href="/p?snakeegg" target="_parent">Snake Egg</a></li>
</ul>
</main>
</body>
Binary file added src-ui/img/swslither.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src-ui/js/ui/KeyPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ ui.keypopup = {
/* どの文字配置を作成するかのテーブル */
type: {
slither: [3, 0],
swslither: [5339, 0],
nawabari: [4, 0],
fourcells: [4, 0],
fivecells: [4, 0],
Expand Down Expand Up @@ -354,6 +355,8 @@ ui.keypopup = {
this.generate_lix(mode);
} else if (type === 131) {
this.generate_infinity(mode);
} else if (type === 5339) {
this.generate_swslither();
}
},
gentable4: function(mode) {
Expand Down Expand Up @@ -992,6 +995,13 @@ ui.keypopup = {
);
},

generate_swslither: function() {
this.generate_main(
[["5", "🐑"], ["6", "🐺"], null, "1", "2", "3", "0", " ", ["-", "?"]],
3
);
},

generate_main: function(list, split) {
for (var i = 0; i < list.length; i++) {
this.inputcol(list[i]);
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 @@ -199,6 +199,7 @@ function toBGimage(pid) {
"statuepark",
"subomino",
"wafusuma",
"swslither",
"symmarea",
"tachibk",
"tajmahal",
Expand Down
1 change: 1 addition & 0 deletions src-ui/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ <h2 id="title"><span lang="ja">パズルの種類のリスト</span><span lang="
<li data-pid="slither"></li>
<li data-pid="vslither"></li>
<li data-pid="tslither"></li>
<li data-pid="swslither"></li>
<li data-pid="mashu"></li>
<li data-pid="yajilin"></li>
<li data-pid="slalom"></li>
Expand Down
2 changes: 2 additions & 0 deletions src-ui/p.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ <h2 id="title2">読み込み中です...</h2>
<div class="child" data-value="circle-shade">__inputmode.circle-shade__</div>
<div class="child" data-value="circle-gray">__inputmode.circle-gray__</div>
<div class="child" data-value="goat">__inputmode.goat__</div>
<div class="child" data-value="sheep">__inputmode.sheep__</div>
<div class="child" data-value="wolf">__inputmode.wolf__</div>
<div class="child" data-value="moon">__inputmode.moon__</div>
<div class="child" data-value="sun">__inputmode.sun__</div>
Expand Down Expand Up @@ -470,6 +471,7 @@ <h2 id="title2">読み込み中です...</h2>
<button type="button" class="btn" id="btnpresets" data-button-exec="applypreset">__applypreset__</button>
<button type="button" class="btn" data-disp-pid="stostone" data-press-exec="dropblocks,resetblocks">__dropblocks__</button>
<button type="button" class="btn" data-disp-pid="slither" data-button-exec="outlineshaded">__outlineshaded__</button>
<button type="button" class="btn" data-disp-pid="swslither" data-button-exec="outlineshaded">__outlineshaded__</button>
<button type="button" class="btn" data-disp-pid="myopia" data-button-exec="outlineshaded">__outlineshaded__</button>
<button type="button" class="btn" id="btntrial" data-button-exec="enterTrial">__enterTrial__</button>
<div id="btntrialarea" style="display:none;">
Expand Down
1 change: 1 addition & 0 deletions src-ui/res/p.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"inputmode.circle-shade": "Shaded circles",
"inputmode.circle-gray": "Gray circles",
"inputmode.goat": "Goats",
"inputmode.sheep": "Sheep",
"inputmode.wolf": "Wolves",
"inputmode.moon": "Marks of moon",
"inputmode.sun": "Marks of sun",
Expand Down
1 change: 1 addition & 0 deletions src-ui/res/p.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"inputmode.circle-shade": "黒まる",
"inputmode.circle-gray": "灰まる",
"inputmode.goat": "ヤギ",
"inputmode.sheep": "",
"inputmode.wolf": "オオカミ",
"inputmode.moon": "",
"inputmode.sun": "太陽",
Expand Down
1 change: 1 addition & 0 deletions src-ui/res/rules.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ shwolf: "Draw lines over the dotted lines to divide the board into cages.\n1. Ea
simpleloop: "Draw a loop that goes through every unshaded cell.\n1. The loop cannot branch off or cross itself.\n2. The loop cannot go through shaded cells."
slalom: "Draw lines through orthogonally adjacent cells to form a directional loop, starting at the circle.\n1. The loop cannot branch off or cross itself.\n2. The loop cannot go through shaded cells.\n3. The loop must visit every gate in the order denoted by the numbers. Some gates have an unknown number.\n4. The loop cannot turn while traveling through a gate.\n5. A gate cannot be visited more than once."
slither: "Draw lines along the edges of some cells to form a loop.\n1. The loop cannot branch off or cross itself.\n2. A number indicates the amount of edges surrounding the cell that are visited by the loop."
swslither: "Draw lines along the edges of some cells to form a loop.\n1. The loop cannot branch off or cross itself.\n2. A number indicates the amount of edges surrounding the cell that are visited by the loop.\n3. Sheep must be inside the loop.\n4. Wolves must be outside the loop."
snake: "Shade some cells into the grid to form a snake.\n1. The snake cannot loop back on itself and visit a cell that's orthogonally or diagonally adjacent to a cell it has visited before.\n2. Black circles must lie on one end of the path.\n 3. White circles must lie somewhere along the path, but not at an end.\n4. A number outside the grid represents how many cells in the corresponding row or column are shaded."
starbattle: "Place a star into some of the cells.\n1. Stars cannot be horizontally, vertically or diagonally adjacent.\n2. The number at the top of the grid indicates how many stars are in each row, column and outlined region."
stostone: "Shade some cells on the board to form blocks.\n1. All regions contain exactly one block, which is an orthogonally connected group of shaded cells.\n2. A number indicates the size of the block in the region.\n3. Shaded cells cannot be adjacent across region borders.\n4. If all of the blocks were to fall straight down without changing shape, they must completely fill the bottom half of the grid."
Expand Down
2 changes: 1 addition & 1 deletion src/puzzle/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
exec = pid === "interbd";
break;
case "bgcolor":
exec = pid === "slither" || pid === "myopia";
exec = pid === "slither" || pid === "myopia" || pid === "swslither";
break;
case "irowake":
exec = puzzle.painter.irowake;
Expand Down
2 changes: 1 addition & 1 deletion src/puzzle/Puzzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@
if ("bgcolor" in imageopt) {
pc2.bgcolor = imageopt.bgcolor;
}
if (puzzle.pid === "kramma") {
if (puzzle.pid === "kramma" || puzzle.pid === "swslither") {
pc2.imgtile = puzzle.painter.imgtile;
}
if ("bank" in imageopt) {
Expand Down
7 changes: 7 additions & 0 deletions src/pzpr/variety.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,13 @@
sudoku: [0, 1, "数独", "Sudoku"],
sukoro: [1, 0, "数コロ", "Sukoro", "sukoro"],
sukororoom: [0, 0, "数コロ部屋", "Sukoro-room", "sukoro"],
swslither: [
0,
0,
"Sheep Wolf Slitherlink",
"Sheep Wolf Slitherlink",
"slither"
],
symmarea: [0, 0, "シンメトリーエリア", "Symmetry Area", "fillomino"],
tachibk: [0, 0, "たちあわせブロック", "Tachiawase Block"],
tajmahal: [0, 0, "タージ・マハル", "Taj Mahal", "kouchoku"],
Expand Down
2 changes: 2 additions & 0 deletions src/res/failcode.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@
"nmHatenaNe.crossstitch": "A circled question mark does not have any corners used by a loop.",
"nmIgnored.herugolf": "There is a Hole without a ball.",
"nmIneqNe.minarism": "A inequality sign is not correct.",
"nmInside": "A wolf is inside the loop.",
"nmLineGt.hashikake": "The number of connecting bridges to a number is not correct.",
"nmLineGt.kaidan": "The number of blocks adjacent to a number is not correct.",
"nmLineGt1.amibo": "Multiple lines connect to a white circle.",
Expand Down Expand Up @@ -724,6 +725,7 @@
"nmOutOfBk.oyakodori": "A bird is outside a nest.",
"nmOutOfBk.yosenabe": "A filling isn't in a crock.",
"nmOutOfHole.herugolf": "A ball doesn't cup in.",
"nmOutside": "A sheep is outside the loop.",
"nmOutsidePencil.pencils": "A number is not inside a pencil.",
"nmOutsideTren.tren": "A number is not contained inside a 1x2 or 1x3 block.",
"nmPillowGt.shugaku": "The number of pillows around the number is wrong.",
Expand Down
146 changes: 143 additions & 3 deletions src/variety/slither.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
} else {
pzpr.classmgr.makeCustom(pidlist, classbase);
}
})(["slither"], {
})(["slither", "swslither"], {
//---------------------------------------------------------
// マウス入力系
MouseEvent: {
Expand Down Expand Up @@ -62,6 +62,31 @@
}
},

"MouseEvent@swslither": {
inputModes: {
edit: ["sheep", "wolf", "number", "clear", "info-line"],
play: [
"line",
"peke",
"bgcolor",
"bgcolor1",
"bgcolor2",
"clear",
"info-line"
]
},
mouseinput_other: function() {
switch (this.inputMode) {
case "sheep":
this.inputFixedNumber(5);
break;
case "wolf":
this.inputFixedNumber(6);
break;
}
}
},

//---------------------------------------------------------
// キーボード入力系
KeyEvent: {
Expand Down Expand Up @@ -93,6 +118,10 @@
}
},

"Cell@swslither": {
maxnum: 6
},

Board: {
hasborder: 2,
borderAsLine: true,
Expand All @@ -115,6 +144,37 @@
}
},

"Board@swslither": {
scanResult: null,
scanInside: function() {
if (this.scanResult !== null) {
return this.scanResult;
}

var inside = false;
this.cell.each(function(cell) {
if (cell.adjborder.left.isLine()) {
inside = !inside;
}
cell.inside = inside;
if (
(cell.id + 1) % cell.board.cols === 0 &&
cell.adjborder.right.isLine()
) {
inside = !inside;
}
});

this.scanResult = true;
return true;
},

rebuildInfo: function() {
this.scanResult = null;
this.common.rebuildInfo.call(this);
}
},

Border: {
updateShaded: function() {
var c0 = this.sidecell[0],
Expand All @@ -133,6 +193,14 @@
}
},

"Border@swslither": {
posthook: {
line: function() {
this.board.scanResult = null;
}
}
},

LineGraph: {
enabled: true
},
Expand All @@ -149,6 +217,9 @@
this.drawBGCells();
this.drawLines();
this.drawBaseMarks();
if (this.pid === "swslither") {
this.drawSheepWolf();
}
this.drawQuesNumbers();
this.drawPekes();
this.drawTarget();
Expand All @@ -160,6 +231,31 @@
}
},

"Graphic@swslither": {
initialize: function() {
this.imgtile = new this.klass.ImageTile();
this.common.initialize.call(this);
},
drawSheepWolf: function() {
var g = this.vinc("cell_number_image", "auto");
var clist = this.range.cells;
for (var i = 0; i < clist.length; i++) {
var cell = clist[i];
var keyimg = ["cell", cell.id, "quesimg"].join("_");
var x = (cell.bx - 1) * this.bw;
var y = (cell.by - 1) * this.bh;
var tile = cell.qnum >= 5 ? cell.qnum - 5 : null;
this.imgtile.putImage(g, keyimg, tile, x, y, this.cw, this.ch);
}
},
getQuesNumberText: function(cell) {
if (cell.qnum >= 5) {
return "";
}
return this.common.getQuesNumberText.call(this, cell);
}
},

//---------------------------------------------------------
// URLエンコード/デコード処理
Encode: {
Expand All @@ -177,6 +273,14 @@
this.fio.encodeCellQnum_kanpen();
}
},
"Encode@swslither": {
decodePzpr: function(type) {
this.decodeNumber10();
},
encodePzpr: function(type) {
this.encodeNumber10();
}
},
//---------------------------------------------------------
FileIO: {
decodeData: function() {
Expand Down Expand Up @@ -294,13 +398,49 @@
"checkdir4BorderLine",

"checkOneLoop",
"checkDeadendLine+"
"checkDeadendLine+",

"checkSheepIn@swslither",
"checkWolvesOut@swslither"
],

checkdir4BorderLine: function() {
this.checkAllCell(function(cell) {
return cell.qnum >= 0 && cell.getdir4BorderLine1() !== cell.qnum;
return (
cell.qnum >= 0 &&
cell.qnum <= 4 &&
cell.getdir4BorderLine1() !== cell.qnum
);
}, "nmLineNe");
},

checkSheepIn: function() {
var bd = this.board;
if (!bd.scanInside()) {
return;
}
this.checkAllCell(function(cell) {
return cell.qnum === 5 && !cell.inside;
}, "nmOutside");
},

checkWolvesOut: function() {
var bd = this.board;
if (!bd.scanInside()) {
return;
}
this.checkAllCell(function(cell) {
return cell.qnum === 6 && cell.inside;
}, "nmInside");
}
},

"ImageTile@swslither": {
imgsrc_dataurl:
"data:image/webp;base64,UklGRiYHAABXRUJQVlA4WAoAAAAQAAAA/wAAfwAAQUxQSPECAAABkBSAbSRJgiZogrJMtAwWwkAYCHp0dR22K3luREwA/qeUkkjumnLS5H4pV829Uu40N0q5mduk3K5NUh7kFjGPbpGf0d6QBJSHl4hN5Hw67yY5sU02oZRDsxydqpTIuZSTNstJOetqTHFzKOaiWUq5ymKulmgmX0nMKlKuq5bTUO+QmCWUO2sxLfkSifmYcm8t9xAgxbY5XBLxiJLzaZs8Uu6ulabKd3O6xKScyxaV+0uxy3kOoQc68mWydhpBM3AUvE1ASWQzTOL3+WqxlV+KoyRxJw3CUpgmZh+8laZJ1MdjGMXnidpoDFbTPFEXTGEUpkRC86SNhmAhZWx1wQzGCkRdNAIrcT0wgVBac6WNBkBxzcUu6Kdq0Fh/2qibUV9TpQ3UjAvhNuhl1FfmVhu1Yj1mcnVBJ6O+R4tWKNPrbVSP4yViPXZKPb1AXM+tuCLhq6icV4TprQ1Ic68IiqtbVEzr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h2UHyw0M7/ni4fX3EHxf/93eoeolK+0m1MGn6cizzgIWhvu63WvYR2TgxzazGP1TGgAErS+Mo6vREgFDMoTwnPxjUEcqsKrB9+W062tn90VX72KWCbzQkTDh0pSeREgpn4YjHW13Hfjw+BdmbVPlAzTJk4miALyCNA0yYZp6D6VrwPObym3Vj0aa55Hfq9qsit16PXGehx5MW9WCsLELzPwLuPrBh4Uls+Qju+em5UyZrMZ6OgTVUpNaZvIxN7v/vTuoN56Y4hgNw496ABgSHYIX1TlH7xoRQ734V7GO4W4RIy/D2yQ6otgin6pVuSM+JLulVfq+i/HjIT//3liX6/KaZHZraypzKVERqT1eVhVOLTF06UrSy+o7wt4fhPFKSs+f4PjtE7xOhx/tGtVIASafOFJtUIFWGDDQXpXxy/C9bm22rYV2La2tAOnU5Bmwc9a/XhqiqRh2P0dOzTAkQTu1KcgZ1Jwkc4YmMz/1zaX+mKAym+DOozDOZYS5sjlGYzYKke6FJgREtB4QkQZ+v0YnZkjMuR7C82JWQ7+dS5aiALxv7S1CsTyXZPVWQqY8s9fopsjAeJ0B2BDgSzLI4hksg9Du6/nn8MwI0BlelA2tsxn6IqvrPQz6BbUwbmfIxRQvEBZQWooSvoeLk5zIfWf2B1JBvvwliA4mIhUJ8PydD3Uxlksa5bXyEyXMMP9tnmwn1LDIuNkf8CIF+0IdeIZceOzU1xH1/XaAGeWN81ayt+WLXaZo0d4d53SKtvLZf8Nyv76TCZ5KWoOzaEnPx4C+4iIrr8wAl6BlMt5RsBxueHYR4s+2hH1Kq36LDfNQ5O+vXAAAAA=",
cols: 2,
rows: 1,
width: 256,
height: 128
}
});
Loading

0 comments on commit 388b9fa

Please sign in to comment.