mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-26 03:00:56 +02:00
IPVGO: Add support to netscript API for game state, current player, and alternate ways to check/wait on AI turn (#1142)
This commit is contained in:
committed by
GitHub
parent
6aaeb6b59e
commit
d81358c80f
@@ -7,7 +7,6 @@ import { GoColor, GoOpponent, GoPlayType, GoValidity, ToastVariant } from "@enum
|
||||
import { Go, GoEvents } from "../Go";
|
||||
import { SnackbarEvents } from "../../ui/React/Snackbar";
|
||||
import { getNewBoardState, getStateCopy, makeMove, passTurn, updateCaptures } from "../boardState/boardState";
|
||||
import { getMove } from "../boardAnalysis/goAI";
|
||||
import { bitverseArt, weiArt } from "../boardState/asciiArt";
|
||||
import { getScore, resetWinstreak } from "../boardAnalysis/scoring";
|
||||
import { boardFromSimpleBoard, evaluateIfMoveIsValid, getAllValidMoves } from "../boardAnalysis/boardAnalysis";
|
||||
@@ -19,6 +18,7 @@ import { GoScoreModal } from "./GoScoreModal";
|
||||
import { GoGameboard } from "./GoGameboard";
|
||||
import { GoSubnetSearch } from "./GoSubnetSearch";
|
||||
import { CorruptableText } from "../../ui/React/CorruptableText";
|
||||
import { getAIMove } from "../effects/netscriptGoImplementation";
|
||||
|
||||
interface GoGameboardWrapperProps {
|
||||
showInstructions: () => void;
|
||||
@@ -119,10 +119,7 @@ export function GoGameboardWrapper({ showInstructions }: GoGameboardWrapperProps
|
||||
|
||||
async function takeAiTurn(boardState: BoardState) {
|
||||
setWaitingOnAI(true);
|
||||
const move = await getMove(boardState, GoColor.white, opponent);
|
||||
|
||||
// If a new game has started while this async code ran, just drop it
|
||||
if (boardState !== Go.currentGame) return;
|
||||
const move = await getAIMove(boardState);
|
||||
|
||||
if (move.type === GoPlayType.pass) {
|
||||
SnackbarEvents.emit(`The opponent passes their turn; It is now your turn to move.`, ToastVariant.WARNING, 4000);
|
||||
@@ -134,10 +131,7 @@ export function GoGameboardWrapper({ showInstructions }: GoGameboardWrapperProps
|
||||
setScoreOpen(true);
|
||||
return;
|
||||
}
|
||||
|
||||
const didUpdateBoard = makeMove(boardState, move.x, move.y, GoColor.white);
|
||||
|
||||
if (didUpdateBoard) setWaitingOnAI(false);
|
||||
setWaitingOnAI(false);
|
||||
}
|
||||
|
||||
function newSubnet() {
|
||||
|
||||
Reference in New Issue
Block a user