Skip to content

Commit 2c7f6bd

Browse files
authored
Adding "grey correct numbers" to Tasquare (#644)
1 parent a76f6df commit 2c7f6bd

1 file changed

Lines changed: 74 additions & 2 deletions

File tree

src/variety/tasquare.js

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,26 @@
1818
if (this.mousestart || this.mousemove) {
1919
this.inputcell();
2020
}
21+
if (this.mouseend && this.notInputted()) {
22+
this.inputqcmp();
23+
}
2124
} else if (this.puzzle.editmode) {
2225
if (this.mousestart) {
2326
this.inputqnum();
2427
}
2528
}
29+
},
30+
31+
inputqcmp: function() {
32+
var cell = this.getcell();
33+
if (cell.isnull || cell.noNum()) {
34+
return;
35+
}
36+
37+
cell.setQcmp(+!cell.qcmp);
38+
cell.draw();
39+
40+
this.mousereset();
2641
}
2742
},
2843

@@ -35,7 +50,44 @@
3550
//---------------------------------------------------------
3651
// 盤面管理系
3752
Cell: {
38-
numberRemainsUnshaded: true
53+
numberRemainsUnshaded: true,
54+
55+
isCmp: function() {
56+
if (!(this.qnum === -2 || this.isNum())) {
57+
return false;
58+
}
59+
if (this.qcmp === 1) {
60+
return true;
61+
}
62+
if (!this.puzzle.execConfig("autocmp")) {
63+
return false;
64+
}
65+
return this.checkComplete();
66+
},
67+
68+
checkComplete: function() {
69+
if (!this.isNum()) {
70+
return true;
71+
}
72+
73+
var cnt = 0,
74+
list = this.getdir4clist();
75+
for (var i = 0; i < list.length; i++) {
76+
var block = list[i][0].sblk;
77+
if (block !== null) {
78+
var shape = block.clist.getRectSize();
79+
if (
80+
shape.cnt !== shape.cols * shape.rows ||
81+
shape.cols !== shape.rows
82+
) {
83+
return false;
84+
}
85+
cnt += shape.cnt;
86+
}
87+
}
88+
89+
return this.isValidNum() ? this.qnum === cnt : cnt > 0;
90+
}
3991
},
4092

4193
AreaShadeGraph: {
@@ -48,13 +100,28 @@
48100
//---------------------------------------------------------
49101
// 画像表示系
50102
Graphic: {
103+
autocmp: "number",
104+
51105
hideHatena: true,
52106

53107
fontsizeratio: 0.65 /* 丸数字 */,
54108

55109
qanscolor: "black",
56110
numbercolor_func: "qnum",
57111

112+
setRange: function(x1, y1, x2, y2) {
113+
var puzzle = this.puzzle,
114+
bd = puzzle.board;
115+
if (puzzle.execConfig("autocmp")) {
116+
x1 = bd.minbx - 2;
117+
y1 = bd.minby - 2;
118+
x2 = bd.maxbx + 2;
119+
y2 = bd.maxby + 2;
120+
}
121+
122+
this.common.setRange.call(this, x1, y1, x2, y2);
123+
},
124+
58125
paint: function() {
59126
this.drawBGCells();
60127
this.drawShadedCells();
@@ -83,7 +150,12 @@
83150
var cell = clist[i];
84151
g.vid = "c_sq_" + cell.id;
85152
if (cell.qnum !== -1) {
86-
g.fillStyle = cell.error === 1 ? this.errbcolor1 : "white";
153+
g.fillStyle =
154+
cell.error === 1
155+
? this.errbcolor1
156+
: cell.isCmp()
157+
? this.qcmpcolor
158+
: "white";
87159
g.shapeRectCenter(cell.bx * this.bw, cell.by * this.bh, rw, rh);
88160
} else {
89161
g.vhide();

0 commit comments

Comments
 (0)