From 5a29f5cc0fd79c026136f2f9a527d58223643516 Mon Sep 17 00:00:00 2001 From: ReverM Date: Fri, 22 Aug 2025 14:44:15 -0400 Subject: [PATCH 1/4] First draft of adding greying to Tasquare --- src/variety/tasquare.js | 51 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/src/variety/tasquare.js b/src/variety/tasquare.js index 6af2e9c7e..abb2f19b4 100644 --- a/src/variety/tasquare.js +++ b/src/variety/tasquare.js @@ -35,7 +35,47 @@ //--------------------------------------------------------- // 盤面管理系 Cell: { - numberRemainsUnshaded: true + numberRemainsUnshaded: true, + + isCmp: function() { + if (!(this.qnum === -2 || this.isNum())) { + return false; + } + if (this.qcmp === 1) { + return true; + } + if (!this.puzzle.execConfig("autocmp")) { + return false; + } + return this.checkComplete(); + }, + + checkComplete: function() { + if (!this.isNum()) { + return true; + } + + var cnt = 0, + arealist = [], + list = this.getdir4clist(); + for (var i = 0; i < list.length; i++) { + var area = list[i][0].sblk; + if (area !== null) { + for (var j = 0; j < arealist.length; j++) { + if (arealist[j] === area) { + area = null; + break; + } + } + if (area !== null) { + cnt += area.clist.length; + arealist.push(area); + } + } + } + + return this.isValidNum() ? this.qnum === cnt : cnt > 0; + } }, AreaShadeGraph: { @@ -48,6 +88,8 @@ //--------------------------------------------------------- // 画像表示系 Graphic: { + autocmp: "number", + hideHatena: true, fontsizeratio: 0.65 /* 丸数字 */, @@ -83,7 +125,12 @@ var cell = clist[i]; g.vid = "c_sq_" + cell.id; if (cell.qnum !== -1) { - g.fillStyle = cell.error === 1 ? this.errbcolor1 : "white"; + g.fillStyle = + cell.error === 1 + ? this.errbcolor1 + : cell.isCmp() + ? this.qcmpcolor + : "white"; g.shapeRectCenter(cell.bx * this.bw, cell.by * this.bh, rw, rh); } else { g.vhide(); From 1b1f8907eaa78a765cd1f1205562517b118f95bb Mon Sep 17 00:00:00 2001 From: ReverM Date: Fri, 22 Aug 2025 14:50:37 -0400 Subject: [PATCH 2/4] And should be done --- src/variety/tasquare.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/variety/tasquare.js b/src/variety/tasquare.js index abb2f19b4..fb413ac6d 100644 --- a/src/variety/tasquare.js +++ b/src/variety/tasquare.js @@ -97,6 +97,19 @@ qanscolor: "black", numbercolor_func: "qnum", + setRange: function(x1, y1, x2, y2) { + var puzzle = this.puzzle, + bd = puzzle.board; + if (puzzle.execConfig("autocmp")) { + x1 = bd.minbx - 2; + y1 = bd.minby - 2; + x2 = bd.maxbx + 2; + y2 = bd.maxby + 2; + } + + this.common.setRange.call(this, x1, y1, x2, y2); + }, + paint: function() { this.drawBGCells(); this.drawShadedCells(); From bfb7d1684d7fe1651424a2504d85b2eb793b30c5 Mon Sep 17 00:00:00 2001 From: ReverM Date: Tue, 26 Aug 2025 14:04:06 -0400 Subject: [PATCH 3/4] Added requested behaviour to graying --- src/variety/tasquare.js | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/variety/tasquare.js b/src/variety/tasquare.js index fb413ac6d..f698ca89c 100644 --- a/src/variety/tasquare.js +++ b/src/variety/tasquare.js @@ -18,11 +18,26 @@ if (this.mousestart || this.mousemove) { this.inputcell(); } + if (this.mouseend && this.notInputted()) { + this.inputqcmp(); + } } else if (this.puzzle.editmode) { if (this.mousestart) { this.inputqnum(); } } + }, + + inputqcmp: function() { + var cell = this.getcell(); + if (cell.isnull || cell.noNum()) { + return; + } + + cell.setQcmp(+!cell.qcmp); + cell.draw(); + + this.mousereset(); } }, @@ -56,21 +71,16 @@ } var cnt = 0, - arealist = [], list = this.getdir4clist(); for (var i = 0; i < list.length; i++) { - var area = list[i][0].sblk; - if (area !== null) { - for (var j = 0; j < arealist.length; j++) { - if (arealist[j] === area) { - area = null; - break; - } - } - if (area !== null) { - cnt += area.clist.length; - arealist.push(area); + var block = list[i][0].sblk; + if (block !== null) { + var shape = block.clist.getRectSize(); + var area = block.clist.length; + if (area !== shape.cols * shape.rows || shape.cols !== shape.rows) { + return false; } + cnt += area; } } From 3b4b571d75fce6c3290181a854bf3b06d199420a Mon Sep 17 00:00:00 2001 From: ReverM Date: Thu, 28 Aug 2025 11:45:18 -0400 Subject: [PATCH 4/4] Switched to shape.cnt --- src/variety/tasquare.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/variety/tasquare.js b/src/variety/tasquare.js index f698ca89c..b4a297d26 100644 --- a/src/variety/tasquare.js +++ b/src/variety/tasquare.js @@ -76,11 +76,13 @@ var block = list[i][0].sblk; if (block !== null) { var shape = block.clist.getRectSize(); - var area = block.clist.length; - if (area !== shape.cols * shape.rows || shape.cols !== shape.rows) { + if ( + shape.cnt !== shape.cols * shape.rows || + shape.cols !== shape.rows + ) { return false; } - cnt += area; + cnt += shape.cnt; } }