Skip to content

Commit 87a7d1e

Browse files
authored
scrabble: Add variant for given letters
1 parent 62ca69f commit 87a7d1e

7 files changed

Lines changed: 48 additions & 1 deletion

File tree

src-ui/js/ui/MenuConfig.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@
158158
case "trizone":
159159
idname = "trizone_ghost";
160160
break;
161+
case "scrabble":
162+
idname = "scrabble_given";
163+
break;
161164
case "slither":
162165
case "tslither":
163166
case "swslither":

src-ui/p.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,12 @@ <h2 id="title2">読み込み中です...</h2>
478478
<span>__lapaz_liar__</span>
479479
</label>
480480
</div>
481+
<div class="config" data-config="scrabble_given">
482+
<label>
483+
<input type="checkbox">
484+
<span>__scrabble_given__</span>
485+
</label>
486+
</div>
481487
<div class="config" data-config="slither_full">
482488
<label>
483489
<input type="checkbox">

src-ui/res/p.en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@
212212
"fillomino_tri": "Maximum block size is 3",
213213
"trizone_ghost": "Regions can have no clues",
214214
"lapaz_liar": "Liar (clues can be erased by shading)",
215+
"scrabble_given": "All letters of a certain type are given",
215216
"slither_full": "All points must be visited",
216217
"loop_full": "All cells must be visited",
217218
"variant": "This puzzle uses variant rules",

src/puzzle/Config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@
161161
variant: true,
162162
volatile: true
163163
}); /* Clues may be erased by shading over them */
164+
this.add("scrabble_given", false, {
165+
variant: true,
166+
volatile: true
167+
}); /* All letters of a certain type are given */
164168
this.add("slither_full", false, {
165169
variant: true,
166170
volatile: true

src/res/failcode.en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,7 @@
874874
"nmNotConseq.kouchoku": "Equal letters are not connected directly.",
875875
"nmNotConseq.trainstations": "A number doesn't connect to the next consecutive number.",
876876
"nmNotConseqFull.trainstations": "A number doesn't connect to the next consecutive number.",
877+
"nmNotGiven.scrabble": "There are too many instances of the given letter.",
877878
"nmNotLink.kazunori": "A number doesn't link to other cells in the room.",
878879
"nmNotSeq.numrope": "The numbers on a line are not consecutive.",
879880
"nmNumberEq.oyakodori": "Two identical birds are in the same nest.",

src/variety/scrabble.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,21 +362,25 @@
362362
decodePzpr: function(type) {
363363
this.decodeNumber16();
364364
this.decodePieceBank();
365+
this.puzzle.setConfig("scrabble_given", this.checkpflag("g"));
365366
},
366367
encodePzpr: function(type) {
368+
this.outpflag = this.puzzle.getConfig("scrabble_given") ? "g" : null;
367369
this.encodeNumber16();
368370
this.encodePieceBank();
369371
}
370372
},
371373

372374
FileIO: {
373375
decodeData: function() {
376+
this.decodeConfigFlag("g", "scrabble_given");
374377
this.decodeCellQnum();
375378
this.decodeCellAnumsub();
376379
this.decodePieceBank();
377380
this.decodePieceBankQcmp();
378381
},
379382
encodeData: function() {
383+
this.encodeConfigFlag("g", "scrabble_given");
380384
this.encodeCellQnum();
381385
this.encodeCellAnumsub();
382386
this.encodePieceBank();
@@ -388,8 +392,26 @@
388392
checklist: [
389393
"checkBankPiecesAvailable",
390394
"checkBankPiecesInvalid",
395+
"checkGivenLetters",
391396
"checkConnectNumber",
392397
"checkBankPiecesUsed"
393-
]
398+
],
399+
400+
checkGivenLetters: function() {
401+
if (!this.puzzle.getConfig("scrabble_given")) {
402+
return;
403+
}
404+
405+
var letters = new Set();
406+
this.board.cell.each(function(cell) {
407+
if (cell.qnum >= 0) {
408+
letters.add(cell.qnum);
409+
}
410+
});
411+
412+
this.checkAllCell(function(cell) {
413+
return cell.qnum === -1 && cell.anum >= 0 && letters.has(cell.anum);
414+
}, "nmNotGiven");
415+
}
394416
}
395417
});

test/script/scrabble.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ ui.debug.addDebugData("scrabble", {
1919
"bankLt",
2020
"pzprv3/scrabble/8/6/. . . . . . /. . . . . . /19 . . . . . /. . . 6 . . /. . . . . . /. . . . . . /. . . . . . /. . . . . . /. . . 19 . . /. . . 21 . . /. . . 18 . . /8 . . . . . /1 . 23 1 12 12 /16 . . 3 . . /5 4 7 5 . . /. . . . . . /5/EDGE/LINE/WALL/SHAPE/SURFACE/1 0 1 1 1 /"
2121
],
22+
[
23+
"nmNotGiven",
24+
"pzprv3/scrabble/3/4/g/. 1 . . /. 1 . . /. . . . /. . . . /. . . . /. 2 1 2 /2/AAB/BAB/0 0 /",
25+
{ skiprules: true }
26+
],
27+
[
28+
null,
29+
"pzprv3/scrabble/3/4/g/. 1 . . /. 1 . . /. . . . /2 . 2 . /. . . . /. 2 . . /2/AAB/BAB/0 0 /",
30+
{ skiprules: true }
31+
],
2232
[
2333
null,
2434
"pzprv3/scrabble/8/6/. . . . . . /. . . . . . /19 . . . . . /. . . 6 . . /. . . . . . /. . . . . . /. . . . . . /. . . . . . /. . . 19 . . /. . . 21 . . /. . . 18 . . /8 . . . . . /1 . 23 1 12 12 /16 . . 3 . 9 /5 4 7 5 . 14 /. . . . . 5 /5/EDGE/LINE/WALL/SHAPE/SURFACE/0 0 0 0 0 /"

0 commit comments

Comments
 (0)