Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
x-sheep committed Sep 9, 2023
1 parent 777b2e1 commit 70ce5a7
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src-ui/js/ui/MenuConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
case "heyapin":
idname = "heyapin_overlap";
break;
case "battleship":
idname = "battleship_retro";
break;
case "bdwalk":
idname = "bdwalk_height";
break;
Expand Down
6 changes: 6 additions & 0 deletions src-ui/p.html
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,12 @@ <h2 id="title2">読み込み中です...</h2>
<span>__heyapin_overlap__</span>
</label>
</div>
<div class="config" data-config="battleship_retro">
<label>
<input type="checkbox">
<span>__battleship_retro__</span>
</label>
</div>
<div class="config" data-config="variant">
<label>
<input type="checkbox">
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 @@ -196,6 +196,7 @@
"akichi_maximum": "Maximum numbers may be reduced",
"magnets_anti": "Anti-Magnets (adjacent poles of different magnets must be equal)",
"heyapin_overlap": "Pins must overlap 2 or more regions",
"battleship_retro": "Retrograde Battleships",
"variant": "This puzzle uses variant rules",
"time": "Time:",
"timer.menu": "Show timer",
Expand Down
6 changes: 3 additions & 3 deletions src/puzzle/Board.js
Original file line number Diff line number Diff line change
Expand Up @@ -768,12 +768,12 @@ pzpr.classmgr.makeCommon({
// bd.modifyInfo() 黒マス・白マス・境界線や線が入力されたり消された時に情報を変更する
//--------------------------------------------------------------------------------
rebuildInfo: function() {
if (this.bank) {
this.bank.rebuildExtraData();
}
this.infolist.forEach(function(info) {
info.rebuild();
});
if (this.bank) {
this.bank.rebuildExtraData();
}
},
modifyInfo: function(obj, type) {
if (!this.isenableInfo()) {
Expand Down
12 changes: 12 additions & 0 deletions src/puzzle/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@
variant: true,
volatile: true
}); /* heyapin: Pins must overlap at least 2 regions */
this.add("battleship_retro", false, {
variant: true,
volatile: true
}); /* battleship: Retrograde variant */
/* generic variant */
this.add("variant", false, { variant: true, volatile: true });
this.add("variantid", "", { volatile: true });
Expand Down Expand Up @@ -467,6 +471,9 @@
case "heyapin_overlap":
exec = pid === "heyapin";
break;
case "battleship_retro":
exec = pid === "battleship";
break;
default:
exec = !!this.list[name];
}
Expand Down Expand Up @@ -501,6 +508,11 @@
puzzle.redraw();
break;

case "battleship_retro":
puzzle.board.rebuildInfo();
puzzle.redraw();
break;

case "font":
puzzle.painter.initFont();
puzzle.redraw();
Expand Down
64 changes: 55 additions & 9 deletions src/variety/statuepark.js
Original file line number Diff line number Diff line change
Expand Up @@ -737,13 +737,22 @@
},

allowShade: function() {
if (this.puzzle.getConfig("battleship_retro")) {
return this.qnum !== 0;
}

return this.qnum === -1;
},

isShade: function() {
if (this.puzzle.getConfig("battleship_retro")) {
return this.qans === 1;
}

var isClue = this.qnum !== -1 && this.qnum !== 0;
return !this.isnull && (isClue || this.qans === 1);
},

isUnshade: function() {
return !this.isnull && !this.isShade();
},
Expand Down Expand Up @@ -938,7 +947,6 @@
paint: function() {
this.drawBGCells();
this.drawShadedCells();
this.drawGrid();

if (this.pid === "pentatouch") {
this.drawCrossMarks();
Expand Down Expand Up @@ -1093,6 +1101,10 @@
},

"Graphic@battleship": {
MODE_SHARP: 0,
MODE_ROUNDED: 1,
MODE_OUTLINE: 2,

bcolor: "rgb(191, 191, 255)",
trialbcolor: "rgb(255, 191, 255)",
qanscolor: "rgb(0, 80, 0)",
Expand All @@ -1104,6 +1116,7 @@
this.drawBGCells();
this.drawBoardPieces();
this.drawWaterClues();

this.drawGrid();

this.drawNumbersExCell();
Expand Down Expand Up @@ -1199,6 +1212,13 @@
cell.isAdjacentDecided() ||
cell.qnum > 0);

var mode;
if (this.puzzle.getConfig("battleship_retro")) {
mode = cell.isShade() ? this.MODE_ROUNDED : this.MODE_OUTLINE;
} else {
mode = isCircled ? this.MODE_ROUNDED : this.MODE_SHARP;
}

var shape =
cell.qnum === -2
? this.board.CENTER
Expand All @@ -1208,13 +1228,19 @@

var vid = "c_piece_" + cell.id;

this.drawSinglePiece(g, vid, px, py, r, shape, color, isCircled);
this.drawSinglePiece(g, vid, px, py, r, shape, color, mode);
}
},

drawSinglePiece: function(g, vid, px, py, r, shape, color, isCircled) {
drawSinglePiece: function(g, vid, px, py, r, shape, color, mode) {
var isCircled = mode !== this.MODE_SHARP;
if (mode === this.MODE_OUTLINE) {
g.lineWidth = (1 + this.cw / 40) | 0;
r -= g.lineWidth;
}

g.vid = vid + "_circle";
if (color && isCircled) {
if (color && mode === this.MODE_ROUNDED) {
g.fillStyle = color;
g.fillCircle(px, py, r);
} else {
Expand All @@ -1223,8 +1249,6 @@

g.vid = vid;
if (!!color) {
g.fillStyle = color;

g.beginPath();
g.moveTo(px + r, py);

Expand Down Expand Up @@ -1283,7 +1307,13 @@
g.lineTo(px + r, py - r);
}
g.lineTo(px + r, py);
g.fill();
if (mode === this.MODE_OUTLINE) {
g.strokeStyle = color;
g.stroke();
} else {
g.fillStyle = color;
g.fill();
}
} else {
g.vhide();
}
Expand Down Expand Up @@ -1313,7 +1343,16 @@
var px = this.cw * br * (piece.x + 0.25 + x) + r;
var py = this.ch * br * (piece.y + 0.25 + y) + r;
py += (this.board.rows + 0.5) * this.ch + 1;
this.drawSinglePiece(g, vid, px, py, r, shape, color, true);
this.drawSinglePiece(
g,
vid,
px,
py,
r,
shape,
color,
this.MODE_ROUNDED
);
} else {
this.drawSinglePiece(g, vid, 0, 0, r, 0, null);
}
Expand Down Expand Up @@ -1356,8 +1395,10 @@
this.decodeNumber16();
}
this.decodePieceBank();
this.puzzle.setConfig("battleship_retro", this.checkpflag("r"));
},
encodePzpr: function(type) {
this.outpflag = this.puzzle.getConfig("battleship_retro") ? "r" : null;
this.encodeNumber16ExCell();
this.encodeNumber16();
this.encodePieceBank();
Expand Down Expand Up @@ -1391,6 +1432,7 @@

FileIO: {
decodeData: function() {
this.decodeConfigFlag("r", "battleship_retro");
this.decodePieceBank();
this.decodeConfig();
if (this.pid === "battleship") {
Expand All @@ -1415,6 +1457,7 @@
this.decodePieceBankQcmp();
},
encodeData: function() {
this.encodeConfigFlag("r", "battleship_retro");
this.encodePieceBank();
this.encodeConfig();
if (this.pid === "battleship") {
Expand Down Expand Up @@ -1688,6 +1731,9 @@
if (cell.qnum === 0) {
return cell.isShade();
}
if (!cell.isShade()) {
return false;
}

var shape = cell.getShape();

Expand All @@ -1704,7 +1750,7 @@
if (cell.qnum <= 0) {
return false;
}
return cell.qnum !== cell.getShape();
return cell.isShade() && cell.qnum !== cell.getShape();
}, "csMismatch");
},

Expand Down

0 comments on commit 70ce5a7

Please sign in to comment.