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
+19 -1
View File
@@ -4,7 +4,12 @@ import type { Play } from "../Go/Types";
import { Go } from "../Go/Go";
import { helpers } from "../Netscript/NetscriptHelpers";
import { simpleBoardFromBoard } from "../Go/boardAnalysis/boardAnalysis";
import {
addPointHighlight,
clearAllPointHighlights,
clearPointHighlight,
simpleBoardFromBoard,
} from "../Go/boardAnalysis/boardAnalysis";
import {
cheatDestroyNode,
cheatPlayTwoMoves,
@@ -125,6 +130,19 @@ export function NetscriptGo(): InternalAPI<NSGo> {
const komi: number | undefined = _komi !== undefined ? helpers.number(ctx, "komi", _komi) : undefined;
return setTestingBoardState(State.board, komi);
},
highlightPoint: (ctx) => (_x, _y, _color, _text) => {
const x = helpers.number(ctx, "x", _x);
const y = helpers.number(ctx, "y", _y);
const color = helpers.string(ctx, "color", _color ?? "");
const text = helpers.string(ctx, "text", _text ?? "");
addPointHighlight(Go.currentGame, x, y, color, text);
},
clearPointHighlight: (ctx) => (_x, _y) => {
const x = helpers.number(ctx, "x", _x);
const y = helpers.number(ctx, "y", _y);
clearPointHighlight(Go.currentGame, x, y);
},
clearAllPointHighlights: () => () => clearAllPointHighlights(Go.currentGame),
},
cheat: {
getCheatSuccessChance: (ctx: NetscriptContext) => (_cheatCount, _playAsWhite) => {