Skip to content

Commit

Permalink
swslither: New puzzle type Sheep Wolf Slitherlink
Browse files Browse the repository at this point in the history
  • Loading branch information
despian committed Oct 6, 2024
1 parent 2f97e62 commit e4aa75a
Show file tree
Hide file tree
Showing 15 changed files with 303 additions and 5 deletions.
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 @@ -353,6 +354,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 @@ -991,6 +994,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 and wolves must be outside."
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
1 change: 1 addition & 0 deletions src-ui/res/rules.ja.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ shikaku: "1. 盤面の点線の上に線を引き、いくつかの長方形(
shwolf: "1. 点線の上にタテヨコに線を引いて、盤面をいくつかのブロックに分けましょう。\n2. すべてのブロックにはヤギかオオカミのどちらかを入れなければなりませんが、1つのブロックにヤギとオオカミの両方を入れてはいけません。\n 3. 線の両端は必ず盤面の外枠にしなければなりません。\n4. 線は、黒点でのみ直角に曲げることができます。なお、線を黒点で必ず曲げる必要はありませんし、線が通らない黒点があってもかまいません。\n 5. 線を交差させることはできますが、黒点では線を交差させてはいけません。"
simpleloop: 1. 盤面の黒マス以外の全てのマスに線を引いて全体で1つの輪っかを作りましょう
slither: "1. 盤面の点の間にタテヨコに線を引き、全体で1つの輪っかを作ります\n2. 輪っかを作る線は交差したり枝分かれしたり行き止まりがあったりしてはいけません\n 3. 数字は周りの点の間に引かれる線の数を表します。点のなかに数字の書かれていないところでは、線がいくつ引かれるかわかりません"
swslither: "1. 盤面の点の間にタテヨコに線を引き、全体で1つの輪っかを作ります\n2. 輪っかを作る線は交差したり枝分かれしたり行き止まりがあったりしてはいけません\n 3. 数字は周りの点の間に引かれる線の数を表します。点のなかに数字の書かれていないところでは、線がいくつ引かれるかわかりません\n4. 羊はループの内側に、オオカミはループの外側にいなければなりません"
toichika2: "1. 太線で区切られたところ(国)に数字を1つずつ入れましょう。 国の左上に数字が書いてある場合はその数字が入ります。\n2. どの数字にも自分とペアになる数字が1つだけあり、互いにタテかヨコかの同じ列に、その数字の個数の白マスをはさんで配置します。\n 3. 辺を共有する国に、ペアとなる数字を入れてはいけません。\n4. ペアとなる数字の間に、ほかの数字を入れてはいけません。\n5. ペアにならない同じ数字を、同じタテヨコの列に入れてはいけません。"
nikoji: "1. 点線上に線を引き、盤面をいくつかのブロックに分割します。\n2. 各ブロックには文字(アルファベット)が必ず1つずつ入ります。\n3. 同じ文字のブロックは、すべて同じ形になります。ブロックの向き、そしてブロック内での文字の入る位置も同じになります。\n 4. 異なる文字のブロックは、必ず形が異なります。裏返したり回転させたりすることで重なる形になってもいけません。"
nonogram: "1. 数字をヒントに盤面のいくつかのマスを黒く塗ります。\n2. タテとヨコの数字は、その列にある連続してつながっている黒マスの数を表します。\n 3. 複数の数字がある場合は、それぞれの間が一つ以上の白マスで分かれていることを表します。\n4. 複数の数字がある場合は、その順番通りに盤面を黒く塗ります。"
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
7 changes: 7 additions & 0 deletions src/pzpr/variety.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,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
1 change: 1 addition & 0 deletions src/res/failcode.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@
"shDiag.pentatouch": "A place where two pieces touch isn't marked with a point.",
"shDiag.snake": "The snake touches itself diagonally.",
"shDiag": "Two pieces are diagonally adjacent.",
"sheepOutsideOrWolfInside": "A sheep is outside the loop or a wolf is inside the loop.",
"shEndpoint.snake": "A black circle is not on an endpoint.",
"shIncorrect.curvedata": "A shape does not match the clue.",
"shInside.castle": "A shaded cell is inside of the loop.",
Expand Down
3 changes: 2 additions & 1 deletion src/res/failcode.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -838,5 +838,6 @@
"csAdjacent.fakearrow": "黒く塗られた矢印が隣り合っています。",
"lrFollowsFake.fakearrow": "間違っていない矢印が黒く塗られています。",
"bkShadeGe2.fakearrow": "間違っている矢印が部屋に2つ以上あります。",
"bkNoShade.fakearrow": "間違っている矢印が部屋にありません。"
"bkNoShade.fakearrow": "間違っている矢印が部屋にありません。",
"sheepOutsideOrWolfInside": "羊が囲われていないか、狼が囲われています。"
}
123 changes: 120 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,11 @@
}
},

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

Board: {
hasborder: 2,
borderAsLine: true,
Expand All @@ -115,6 +145,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 +194,14 @@
}
},

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

LineGraph: {
enabled: true
},
Expand All @@ -152,6 +221,9 @@
this.drawQuesNumbers();
this.drawPekes();
this.drawTarget();
if (this.pid === "swslither") {
this.drawSheepWolf();
}
},

repaintParts: function(blist) {
Expand All @@ -160,6 +232,25 @@
}
},

"Graphic@swslither": {
drawSheepWolf: function() {
this.vinc("cell_number_image", "auto");
var g = this.context;
var clist = this.range.cells;
for (var i = 0; i < clist.length; i++) {
var cell = clist[i];
if (cell.qnum >= 5) {
g.vid = "cell_text_" + cell.id;
g.vhide();
var text = cell.qnum === 5 ? "🐑" : "🐺";
var x = cell.bx * this.bw + this.getCellHorizontalOffset(cell);
var y = cell.by * this.bh + this.getNumberVerticalOffset(cell);
this.disptext(text, x, y);
}
}
}
},

//---------------------------------------------------------
// URLエンコード/デコード処理
Encode: {
Expand All @@ -177,6 +268,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 +393,31 @@
"checkdir4BorderLine",

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

"checkSheepInWolfOut@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");
},

checkSheepInWolfOut: function() {
var bd = this.board;
if (!bd.scanInside()) {
return;
}
this.checkAllCell(function(cell) {
return (
(cell.qnum === 5 && !cell.inside) || (cell.qnum === 6 && cell.inside)
);
}, "sheepOutsideOrWolfInside");
}
}
});
Loading

0 comments on commit e4aa75a

Please sign in to comment.