IPVGO: Add support for highlighting nodes and adding small text (#1996)

This commit is contained in:
Michael Ficocelli
2025-03-31 16:36:30 -04:00
committed by GitHub
parent 5d486e3914
commit f6e7ef082c
17 changed files with 251 additions and 28 deletions
+16 -1
View File
@@ -1,7 +1,7 @@
import type { Board, BoardState, Neighbor, Play, PointState, SimpleBoard } from "../Types";
import { GoValidity, GoOpponent, GoColor, GoPlayType } from "@enums";
import { Go } from "../Go";
import { getEmptyHighlightedPoints, Go, GoEvents } from "../Go";
import {
findAdjacentPointsInChain,
findNeighbors,
@@ -730,3 +730,18 @@ export function getPreviousMoveDetails(): Play {
y: null,
};
}
export function addPointHighlight(board: BoardState, x: number, y: number, color: string, text: string) {
board.highlightedPoints[x][y] = { color, text };
GoEvents.emit();
}
export function clearPointHighlight(board: BoardState, x: number, y: number) {
board.highlightedPoints[x][y] = null;
GoEvents.emit();
}
export function clearAllPointHighlights(board: BoardState) {
board.highlightedPoints = getEmptyHighlightedPoints(Go.currentGame.board.length);
GoEvents.emit();
}