Skip to content

Commit

Permalink
Add Territory
Browse files Browse the repository at this point in the history
  • Loading branch information
x-sheep authored Apr 29, 2024
1 parent 3260a2e commit ff6e270
Show file tree
Hide file tree
Showing 12 changed files with 272 additions and 42 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?teri" target="_parent">Territory テリトリー</a></li>
<li><a href="/p?lixloop" target="_parent">LIX Loop</a></li>
<li><a href="/p?subomino" target="_parent">Subomino</a></li>
<li><a href="/p?retroships" target="_parent">Retrograde Battleships</a></li>
<li><a href="/p?pmemory" target="_parent">Persistence of Memory</a></li>
<li><a href="/p?mrtile" target="_parent">Mirroring Tile ミラーリングタイル</a></li>
<li><a href="/p?kissing" target="_parent">Kissing Polyominoes</a></li>
<li><a href="/p?lineofsight" target="_parent">Line of Sight サイトライン</a></li>
</ul>
</main>
</body>
Binary file added src-ui/img/teri.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 @@ -196,7 +196,8 @@ ui.keypopup = {
lineofsight: [10, 0],
mrtile: [10, 0],
subomino: [10, 0],
lixloop: [130, 0]
lixloop: [130, 0],
teri: [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 @@ -194,6 +194,7 @@ function toBGimage(pid) {
"takoyaki",
"tapaloop",
"tents",
"teri",
"tetrochain",
"tetrominous",
"tontonbeya",
Expand Down
1 change: 1 addition & 0 deletions src-ui/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ <h2 id="title"><span lang="ja">パズルの種類のリスト</span><span lang="
<li data-pid="akichi"></li>
<li data-pid="guidearrow"></li>
<li data-pid="aquapelago"></li>
<li data-pid="teri"></li>
</ul>
</div>
<div class="lists loops">
Expand Down
11 changes: 9 additions & 2 deletions src/puzzle/MouseInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,18 @@ pzpr.classmgr.makeCommon({
mouseinput: function() {
var mode = this.inputMode;
if (this.puzzle.key.isZ && this.inputMode.indexOf(/info\-/) === -1) {
var hasUblk = this.inputModes.play.indexOf("info-ublk") >= 0;

if (this.inputModes.play.indexOf("info-line") >= 0) {
mode = "info-line";
} else if (this.inputModes.play.indexOf("info-blk") >= 0) {
mode = "info-blk";
} else if (this.inputModes.play.indexOf("info-ublk") >= 0) {
var cell = this.getcell();
if (hasUblk && cell.isUnshade()) {
mode = "info-ublk";
} else {
mode = "info-blk";
}
} else if (hasUblk) {
mode = "info-ublk";
} else if (this.inputModes.play.indexOf("info-room") >= 0) {
mode = "info-room";
Expand Down
1 change: 1 addition & 0 deletions src/pzpr/variety.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@
tawa: [0, 0, "たわむれんが", "Tawamurenga"],
tentaisho: [0, 0, "天体ショー", "Tentaisho"],
tents: [0, 0, "Tents", "Tents", "tents"],
teri: [0, 0, "テリトリー", "Territory", "kurodoko"],
tetrochain: [0, 0, "テトロチェーン", "Tetrochain"],
tetrominous: [0, 0, "Tetrominous", "Tetrominous", "fillomino"],
tilepaint: [1, 0, "タイルペイント", "Tilepaint"],
Expand Down
3 changes: 1 addition & 2 deletions src/res/failcode.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -741,8 +741,7 @@
"nmSumRowShadeNe.box": "A number is not equal to the sum of the number of shaded cells.",
"nmSumSizeNe.kurotto": "The number is not equal to sum of adjacent masses of shaded cells.",
"nmSumSizeNe.tasquare": "Sum of the adjacent masses of shaded cells is not equal to the number.",
"nmSumViewNe.sukoro": "Sum of four-way gaps to another number is not equal to the number.",
"nmSumViewNe.sukororoom": "Sum of four-way gaps to another number is not equal to the number.",
"nmSumViewNe.teri": "The size of the largest possible rectangle is not equal to the number.",
"nmSumViewNe.view": "Sum of four-way gaps to another number is not equal to the number.",
"nmSumViewNe": "A cell containing a clue number sees a different number of cells in the four orthogonal directions.",
"nmTentGt.tents": "There are too many tents around a tree.",
Expand Down
2 changes: 0 additions & 2 deletions src/res/failcode.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,6 @@
"nmSumRowShadeNe.box": "数字と黒マスになった数字の合計が正しくありません。",
"nmSumSizeNe.kurotto": "隣り合う黒マスの個数の合計が数字と違います。",
"nmSumSizeNe.tasquare": "数字とそれに接する黒マスの大きさの合計が一致しません。",
"nmSumViewNe.sukoro": "数字と、他のマスにたどり着くまでのマスの数の合計が一致していません。",
"nmSumViewNe.sukororoom": "数字と、他のマスにたどり着くまでのマスの数の合計が一致していません。",
"nmSumViewNe.view": "数字と、他のマスにたどり着くまでのマスの数の合計が一致していません。",
"nmSumViewNe": "数字と黒マスにぶつかるまでの4方向のマスの合計が違います。",
"nmTentGt.tents": "木の数よりもテントの数が多い部分があります。",
Expand Down
224 changes: 193 additions & 31 deletions src/variety/kurodoko.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
} else {
pzpr.classmgr.makeCustom(pidlist, classbase);
}
})(["kurodoko", "nurimisaki", "cave"], {
})(["kurodoko", "nurimisaki", "cave", "teri"], {
//---------------------------------------------------------
// マウス入力系
MouseEvent: {
Expand All @@ -23,6 +23,36 @@
},
RBShadeCell: true
},
"MouseEvent@teri": {
inputModes: {
edit: ["number", "clear", "info-blk", "info-ublk"],
play: ["shade", "unshade", "subline", "info-blk", "info-ublk"]
},
RBShadeCell: true,

mouseinputAutoPlay: function() {
if (this.mousestart) {
this.isDraggingLine = this.puzzle.key.isALT;
}

if (this.isDraggingLine) {
this.inputQsubLine();
} else {
this.inputcell();
}
},

dispInfoUblk: function() {
var cell = this.getcell();
this.mousereset();
if (cell.isnull || !cell.isUnshade()) {
return;
}
cell.getVisibleCells().setinfo(2);
this.board.hasinfo = true;
this.puzzle.redraw();
}
},
"MouseEvent@nurimisaki": {
inputModes: {
edit: ["number", "clear", "info-ublk"],
Expand Down Expand Up @@ -50,13 +80,142 @@
maxnum: function() {
return this.board.cols + this.board.rows - 1;
},
minnum: 2
minnum: 2,

seterr: function(num) {
if (this.board.isenableSetError()) {
if (this.error <= 0) {
this.error = num;
} else {
this.error = Math.min(this.error, num);
}
}
},

getVisibleDirections: function() {
var outer = {};
for (var dir in this.adjacent) {
var target = this;
do {
outer[dir] =
dir === "left" || dir === "right" ? target.bx : target.by;
target = target.adjacent[dir];
} while (target.isUnshade() && !target.isnull);
}
return outer;
},

getVisibleCells: function() {
var outer = this.getVisibleDirections();
var clist = this.board.cellinside(
outer.left,
this.by,
outer.right,
this.by
);
clist.extend(
this.board.cellinside(this.bx, outer.top, this.bx, this.by - 2)
);
clist.extend(
this.board.cellinside(this.bx, this.by + 2, this.bx, outer.bottom)
);
return clist;
}
},
"Cell@teri": {
maxnum: function() {
return this.board.cols * this.board.rows;
},

getVisibleCells: function() {
var outer = this.getVisibleDirections();

/* Build list of distances in every column */
var topdist = {},
botdist = {};
topdist[this.bx] = outer.top;
botdist[this.bx] = outer.bottom;
for (var delta = -2; delta <= 2; delta += 4) {
var maxtop = outer.top;
var maxbot = outer.bottom;
var end = delta < 0 ? outer.left : outer.right;
for (var x = this.bx + delta; x !== end + delta; x += delta) {
var start = this.board.getc(x, this.by);

var target = start;
while (target.by > maxtop) {
var newtarget = target.adjacent.top;

if (newtarget.isShade()) {
break;
}
target = newtarget;
}
maxtop = target.by;
topdist[x] = maxtop;

target = start;
while (target.by < maxbot) {
var newtarget = target.adjacent.bottom;
if (newtarget.isShade()) {
break;
}
target = newtarget;
}
maxbot = target.by;
botdist[x] = maxbot;
}
}

/* Find combination of left/right values that leads to optimal size */
var maxrect = {
left: this.bx,
right: this.bx,
top: this.by,
bottom: this.by,
count: 1
};

for (var left = outer.left; left <= this.bx; left += 2) {
for (var right = this.bx; right <= outer.right; right += 2) {
var top = Math.max(topdist[left], topdist[right]);
var bottom = Math.min(botdist[left], botdist[right]);

var rows = ((right - left) >> 1) + 1,
cols = ((bottom - top) >> 1) + 1;

if (rows * cols > maxrect.count) {
maxrect = {
left: left,
right: right,
top: top,
bottom: bottom,
count: rows * cols
};
}
}
}

return this.board.cellinside(
maxrect.left,
maxrect.top,
maxrect.right,
maxrect.bottom
);
}
},
CellList: {
seterr: function(num) {
for (var i = 0; i < this.length; i++) {
this[i].seterr(num);
}
}
},
Board: {
cols: 9,
rows: 9
},
"Board@cave": {
"Board@cave,teri": {
hasborder: 1 // for pekes
},

Expand Down Expand Up @@ -87,11 +246,22 @@
this.drawShadedCells();
this.drawDotCells();

if (this.pid === "teri") {
this.drawBorderQsubs();
}

this.drawCircledNumbers();

this.drawChassis();

this.drawTarget();
},

getBGCellColor: function(cell) {
if (cell.error > 0 || cell.qinfo > 0) {
return this.errbcolor1;
}
return null;
}
},

Expand All @@ -100,7 +270,10 @@

gridcolor_type: "DLIGHT",
enablebcolor: true,
bgcellcolor_func: "qsub1",

getBGCellColor: function(cell) {
return this.getBGCellColor_qsub1(cell);
},

qanscolor: "black",

Expand Down Expand Up @@ -156,10 +329,21 @@
decodeData: function() {
this.decodeCellQnum();
this.decodeCellAns();
if (this.pid === "teri") {
this.decodeBorderAns();
}
},
encodeData: function() {
this.encodeCellQnum();
this.encodeCellAns();
if (
this.pid === "teri" &&
this.board.border.some(function(border) {
return border.qsub;
})
) {
this.encodeBorderAns();
}
},

kanpenOpen: function() {
Expand Down Expand Up @@ -200,8 +384,8 @@
checklist: [
"checkShadeCellExist",
"check2x2ShadeCell@nurimisaki",
"checkAdjacentShadeCell@kurodoko",
"checkConnectUnshadeRB@kurodoko",
"checkAdjacentShadeCell@kurodoko,teri",
"checkConnectUnshadeRB@kurodoko,teri",
"checkConnectUnshade@nurimisaki,cave",
"checkConnectShadeOutside@cave",
"checkViewOfNumber",
Expand All @@ -219,30 +403,7 @@
continue;
}

var clist = new this.klass.CellList(),
adc = cell.adjacent,
target;
clist.add(cell);
target = adc.left;
while (target.isUnshade()) {
clist.add(target);
target = target.adjacent.left;
}
target = adc.right;
while (target.isUnshade()) {
clist.add(target);
target = target.adjacent.right;
}
target = adc.top;
while (target.isUnshade()) {
clist.add(target);
target = target.adjacent.top;
}
target = adc.bottom;
while (target.isUnshade()) {
clist.add(target);
target = target.adjacent.bottom;
}
var clist = cell.getVisibleCells();
if (cell.qnum === clist.length) {
continue;
}
Expand All @@ -251,7 +412,8 @@
if (this.checkOnly) {
break;
}
clist.seterr(1);
cell.seterr(1);
clist.seterr(2);
}
}
},
Expand Down
Loading

0 comments on commit ff6e270

Please sign in to comment.