Skip to content

Commit

Permalink
Add Snake Egg
Browse files Browse the repository at this point in the history
  • Loading branch information
x-sheep authored Aug 12, 2024
1 parent 7352dcf commit b0454ab
Show file tree
Hide file tree
Showing 18 changed files with 684 additions and 15 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?snakeegg" target="_parent">Snake Egg</a></li>
<li><a href="/p?firewalk" target="_parent">Fire Walk</a></li>
<li><a href="/p?batten" target="_parent">Battenberg Painting</a></li>
<li><a href="/p?zabajaba" target="_parent">Zabajaba</a></li>
<li><a href="/p?curving" target="_parent">Curving Road カービングロード</a></li>
<li><a href="/p?sananko" target="_parent">San-Anko サンアンコー</a></li>
<li><a href="/p?bosnianroad" target="_parent">Bosnian Road</a></li>
<li><a href="/p?kuromenbun" target="_parent">Kuromenbun クロメンブン</a></li>
</ul>
</main>
</body>
Binary file added src-ui/img/snakeegg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src-ui/js/ui/KeyPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ ui.keypopup = {
sananko: [10, 113],
zabajaba: [80, 0],
batten: [10, 0],
firewalk: [10, 0]
firewalk: [10, 0],
snakeegg: [10, 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 @@ -190,6 +190,7 @@ function toBGimage(pid) {
"simpleloop",
"slashpack",
"snake",
"snakeegg",
"squarejam",
"starbattle",
"statuepark",
Expand Down
1 change: 1 addition & 0 deletions src-ui/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ <h2 id="title"><span lang="ja">パズルの種類のリスト</span><span lang="
<li data-pid="tetrochain"></li>
<li data-pid="mrtile"></li>
<li data-pid="batten"></li>
<li data-pid="snakeegg"></li>
</ul>
</div>
<div class="lists blocks">
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 @@ -76,6 +76,7 @@
"preset.fleet3": "Battleships (size 3)",
"preset.fleet4": "Battleships (size 4)",
"preset.fleet5": "Battleships (size 5)",
"preset.nine": "1~9",
"inputmode": "Input Mode",
"inputmode.auto": "Auto",
"inputmode.slide": "Slide",
Expand Down
5 changes: 4 additions & 1 deletion src/puzzle/Bank.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ pzpr.classmgr.makeCommon({
}

this.old = index < len ? this.board.bank.pieces[index].serialize() : null;
this.num = value || null;
this.num = value;
this.index = index;
},

Expand Down Expand Up @@ -268,6 +268,9 @@ pzpr.classmgr.makeCommon({
},

isNoop: function() {
if (this.num === null) {
return false;
}
return this.old === this.num;
},

Expand Down
1 change: 1 addition & 0 deletions src/puzzle/Graphic.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
// 枠外の一辺のmargin(セル数換算)
margin: 0.15,
bankratio: 0.5,
bankVerticalOffset: 0.5,

// canvasの大きさを保持する
canvasWidth: null,
Expand Down
5 changes: 3 additions & 2 deletions src/puzzle/KeyInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,9 @@ pzpr.classmgr.makeCommon({
else if (this.modesnum) {
this.targetdir = this.puzzle.playmode && this.disableAnum ? 5 : 0;
}
if (this.puzzle.playmode) {
this.bankpiece = null;
}
},
adjust_cell_to_excell: function() {
var bd = this.board;
Expand Down Expand Up @@ -569,8 +572,6 @@ pzpr.classmgr.makeCommon({
//---------------------------------------------------------------------------
movedir: function(dir, mv) {
if (this.bankpiece !== null) {
// TODO implement moving from board to bank
// TODO implement moving between bankpieces
return this;
}

Expand Down
1 change: 1 addition & 0 deletions src/pzpr/variety.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@
{ kanpen: "slitherlink" }
],
snake: [0, 0, "Snake", "Snake"],
snakeegg: [0, 0, "Snake Egg", "Snake Egg"],
snakepit: [0, 0, "Snake Pit", "Snake Pit", "fillomino"],
starbattle: [0, 0, "スターバトル", "Star Battle"],
squarejam: [0, 0, "Square Jam", "Square Jam"],
Expand Down
5 changes: 4 additions & 1 deletion src/res/failcode.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@
"asShadeNe.tilepaint": "The number of shaded cells underward or rightward is not correct.",
"baDir.lollipops": "A stick has the wrong orientation.",
"bankGt.battleship": "A ship appears too many times on the board.",
"bankGt.snakeegg": "A given size appears too many times on the board.",
"bankGt": "A piece appears too many times on the board.",
"bankInvalid": "The board contains an invalid piece.",
"bankInvalid.battleship": "The board contains an invalid ship.",
"bankInvalid.snakeegg": "The board contains an unshaded block of invalid size.",
"bankInvalid": "The board contains an invalid piece.",
"bankLt.battleship": "Some ships are not used on the board.",
"bankLt.snakeegg": "Some given sizes are not used on the board.",
"bankLt": "Some pieces are not used on the board.",
"bankNe.tachibk": "The left and right grids contain different pieces.",
"baParaGe3.juosan": "There are at least three vertical or horizontal bars in parallel.",
Expand Down
2 changes: 1 addition & 1 deletion src/variety-common/Answer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ pzpr.classmgr.makeCommon({

for (var key in pieces) {
var found = false;
for (var b = 0; b < this.board.bank.pieces.length; b++ && !found) {
for (var b = 0; b < this.board.bank.pieces.length && !found; b++) {
if (key === this.board.bank.pieces[b].canonize()) {
found = true;
}
Expand Down
10 changes: 7 additions & 3 deletions src/variety-common/Encode.js
Original file line number Diff line number Diff line change
Expand Up @@ -1008,9 +1008,13 @@ pzpr.classmgr.makeCommon({
this.outbstr += "/";
var bank = this.board.bank;

var pieces = bank.pieces.map(function(p) {
return p.serialize();
});
var pieces = bank.pieces
.map(function(p) {
return p.serialize();
})
.filter(function(p) {
return p;
});

for (var i = 0; i < bank.presets.length; i++) {
if (!bank.presets[i].constant) {
Expand Down
4 changes: 2 additions & 2 deletions src/variety-common/Graphic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2085,7 +2085,7 @@ pzpr.classmgr.makeCommon({

px = (piece.x + 0.25 + piece.w / 2) * this.cw * r;
py = (piece.y + 0.25 + piece.h / 2) * this.ch * r;
py += (this.board.rows + 0.5) * this.ch;
py += (this.board.rows + this.bankVerticalOffset) * this.ch;
w = (piece.w + 0.25) * this.cw * r * 0.5;
h = (piece.h + 0.25) * this.ch * r * 0.5;
} else {
Expand Down Expand Up @@ -2712,7 +2712,7 @@ pzpr.classmgr.makeCommon({
var r = this.bankratio;
var px = this.cw * r * (addButton.x + 0.25) + 1;
var py = this.ch * r * (addButton.y + 0.25) + 1;
py += (this.board.rows + 0.5) * this.ch;
py += (this.board.rows + this.bankVerticalOffset) * this.ch;
var px2 = px + this.cw * r * addButton.w - 1;
var py2 = py + this.ch * r * addButton.h - 1;
for (var i = 0; i < 4; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/variety/bosnianroad.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// bosnianroad.js
//
(function(pidlist, classbase) {
Expand Down
Loading

0 comments on commit b0454ab

Please sign in to comment.