mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-22 01:03:01 +02:00
IPVGO: Support playing manually as white against your scripts using the No AI type board (#1296)
This commit is contained in:
committed by
GitHub
parent
f40d4f8e92
commit
a28bb4bd99
@@ -18,7 +18,7 @@ import { GoScoreModal } from "./GoScoreModal";
|
||||
import { GoGameboard } from "./GoGameboard";
|
||||
import { GoSubnetSearch } from "./GoSubnetSearch";
|
||||
import { CorruptableText } from "../../ui/React/CorruptableText";
|
||||
import { makeAIMove } from "../boardAnalysis/goAI";
|
||||
import { makeAIMove, resolveCurrentTurn } from "../boardAnalysis/goAI";
|
||||
|
||||
interface GoGameboardWrapperProps {
|
||||
showInstructions: () => void;
|
||||
@@ -85,7 +85,7 @@ export function GoGameboardWrapper({ showInstructions }: GoGameboardWrapperProps
|
||||
const didUpdateBoard = makeMove(boardState, x, y, currentPlayer);
|
||||
if (didUpdateBoard) {
|
||||
rerender();
|
||||
Go.currentGame.ai !== GoOpponent.none && takeAiTurn(boardState);
|
||||
takeAiTurn(boardState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,11 +104,17 @@ export function GoGameboardWrapper({ showInstructions }: GoGameboardWrapperProps
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
Go.currentGame.ai !== GoOpponent.none && takeAiTurn(boardState);
|
||||
takeAiTurn(boardState);
|
||||
}, 100);
|
||||
}
|
||||
|
||||
async function takeAiTurn(boardState: BoardState) {
|
||||
// If white is being played manually, halt and notify any scripts playing as black if present, instead of making an AI move
|
||||
if (Go.currentGame.ai === GoOpponent.none) {
|
||||
Go.currentGame.previousPlayer && resolveCurrentTurn();
|
||||
return;
|
||||
}
|
||||
|
||||
const move = await makeAIMove(boardState);
|
||||
|
||||
if (move.type === GoPlayType.pass) {
|
||||
@@ -137,6 +143,7 @@ export function GoGameboardWrapper({ showInstructions }: GoGameboardWrapperProps
|
||||
|
||||
Go.currentGame = getNewBoardState(newBoardSize, newOpponent, true);
|
||||
rerender();
|
||||
resolveCurrentTurn();
|
||||
}
|
||||
|
||||
function getPriorMove() {
|
||||
@@ -159,17 +166,19 @@ export function GoGameboardWrapper({ showInstructions }: GoGameboardWrapperProps
|
||||
rerender();
|
||||
}
|
||||
|
||||
const endGameAvailable = boardState.previousPlayer === GoColor.white && boardState.passCount;
|
||||
const noLegalMoves =
|
||||
boardState.previousPlayer === GoColor.white && !getAllValidMoves(boardState, GoColor.black).length;
|
||||
const ongoingNoAiGame = boardState.ai === GoOpponent.none && boardState.previousPlayer;
|
||||
const manualTurnAvailable = ongoingNoAiGame || boardState.previousPlayer === GoColor.white;
|
||||
const endGameAvailable = manualTurnAvailable && boardState.passCount;
|
||||
const noLegalMoves = manualTurnAvailable && !getAllValidMoves(boardState, currentPlayer).length;
|
||||
|
||||
const scoreBoxText = boardState.previousBoards.length
|
||||
? `Score: Black: ${score[GoColor.black].sum} White: ${score[GoColor.white].sum}`
|
||||
: "Place a router to begin!";
|
||||
|
||||
const getPassButtonLabel = () => {
|
||||
const playerString = boardState.ai === GoOpponent.none ? ` (${currentPlayer})` : "";
|
||||
if (endGameAvailable) {
|
||||
return "End Game";
|
||||
return `End Game${playerString}`;
|
||||
}
|
||||
if (boardState.previousPlayer === null) {
|
||||
return "View Final Score";
|
||||
@@ -177,8 +186,7 @@ export function GoGameboardWrapper({ showInstructions }: GoGameboardWrapperProps
|
||||
if (waitingOnAI) {
|
||||
return "Waiting for opponent";
|
||||
}
|
||||
const currentPlayer = boardState.previousPlayer === GoColor.black ? GoColor.white : GoColor.black;
|
||||
return `Pass Turn${boardState.ai === GoOpponent.none ? ` (${currentPlayer})` : ""}`;
|
||||
return `Pass Turn${playerString}`;
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user