Skip to content

Commit

Permalink
Better fix for puzzle move numbers showing up and analysis numbers di…
Browse files Browse the repository at this point in the history
…splaying after resuming a game
  • Loading branch information
anoek committed Aug 23, 2024
1 parent 4542b8a commit b1126dd
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "goban-engine",
"version": "8.3.23",
"version": "8.3.24",
"description": "",
"main": "build/goban-engine.js",
"types": "build/engine/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "goban",
"version": "8.3.23",
"version": "8.3.24",
"description": "",
"main": "build/goban.js",
"types": "build/src/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions src/Goban/CanvasRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ export class GobanCanvas extends Goban implements GobanCanvasInterface {
/* nor when in labeling mode */
this.analyze_tool !== "label"
) {
const m = this.engine.getMoveByLocation(x, y);
const m = this.engine.getMoveByLocation(x, y, true);
if (m) {
this.engine.jumpTo(m);
this.emit("update");
Expand Down Expand Up @@ -1940,7 +1940,7 @@ export class GobanCanvas extends Goban implements GobanCanvasInterface {
pos.square
)
) {
const m = this.engine.getMoveByLocation(i, j);
const m = this.engine.getMoveByLocation(i, j, false);
if (m && !m.trunk) {
if (m.edited) {
//letter = "triangle";
Expand Down Expand Up @@ -2602,7 +2602,7 @@ export class GobanCanvas extends Goban implements GobanCanvasInterface {
!letter &&
!(pos.circle || pos.triangle || pos.chat_triangle || pos.cross || pos.square)
) {
const m = this.engine.getMoveByLocation(i, j);
const m = this.engine.getMoveByLocation(i, j, false);
if (m && !m.trunk) {
if (m.edited) {
//letter = "triangle";
Expand Down
4 changes: 0 additions & 4 deletions src/Goban/InteractiveBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,6 @@ export abstract class GobanInteractive extends GobanBase {
}
*/
protected getShowVariationMoveNumbers(): boolean {
if (this.mode === "puzzle") {
return false;
}

if (callbacks.getShowVariationMoveNumbers) {
return callbacks.getShowVariationMoveNumbers();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Goban/SVGRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ export class SVGRenderer extends Goban implements GobanSVGInterface {
/* nor when in labeling mode */
this.analyze_tool !== "label"
) {
const m = this.engine.getMoveByLocation(x, y);
const m = this.engine.getMoveByLocation(x, y, true);
if (m) {
this.engine.jumpTo(m);
this.emit("update");
Expand Down Expand Up @@ -1933,7 +1933,7 @@ export class SVGRenderer extends Goban implements GobanSVGInterface {
pos.square
)
) {
const m = this.engine.getMoveByLocation(i, j);
const m = this.engine.getMoveByLocation(i, j, false);
if (m && !m.trunk) {
if (m.edited) {
//letter = "triangle";
Expand Down Expand Up @@ -2628,7 +2628,7 @@ export class SVGRenderer extends Goban implements GobanSVGInterface {
!letter &&
!(pos.circle || pos.triangle || pos.chat_triangle || pos.cross || pos.square)
) {
const m = this.engine.getMoveByLocation(i, j);
const m = this.engine.getMoveByLocation(i, j, false);
if (m && !m.trunk) {
if (m.edited) {
//letter = "triangle";
Expand Down
19 changes: 14 additions & 5 deletions src/engine/GobanEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2479,14 +2479,23 @@ export class GobanEngine extends BoardState {
);
return se.score();
}
public getMoveByLocation(x: number, y: number): MoveTree | null {
/* Returns the move by location if it exists within our current branch. If
* include_forward_search is true, we also search forward in the tree along
* the last selected branch. */
public getMoveByLocation(
x: number,
y: number,
include_forward_search: boolean,
): MoveTree | null {
let m: MoveTree | null = null;
let cur_move: MoveTree | null = this.cur_move;
while (!m && cur_move) {
if (cur_move.x === x && cur_move.y === y) {
m = cur_move;
if (include_forward_search) {
while (!m && cur_move) {
if (cur_move.x === x && cur_move.y === y) {
m = cur_move;
}
cur_move = cur_move.next();
}
cur_move = cur_move.next();
}
cur_move = this.cur_move.parent;
while (!m && cur_move) {
Expand Down

0 comments on commit b1126dd

Please sign in to comment.