mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 15:43:49 +01:00
IPvGO: Bugfix: ensure the 'No Ai' white player can still pass, and fix missing dead nodes (#1165)
This commit is contained in:
parent
c0662599b3
commit
edf8e24046
@ -3,14 +3,14 @@ import type { BoardState } from "../Types";
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Box, Button, Typography } from "@mui/material";
|
import { Box, Button, Typography } from "@mui/material";
|
||||||
|
|
||||||
import { GoOpponent, GoColor, GoPlayType, GoValidity, ToastVariant } from "@enums";
|
import { GoColor, GoOpponent, GoPlayType, GoValidity, ToastVariant } from "@enums";
|
||||||
import { Go, GoEvents } from "../Go";
|
import { Go, GoEvents } from "../Go";
|
||||||
import { SnackbarEvents } from "../../ui/React/Snackbar";
|
import { SnackbarEvents } from "../../ui/React/Snackbar";
|
||||||
import { getNewBoardState, getStateCopy, makeMove, passTurn, updateCaptures } from "../boardState/boardState";
|
import { getNewBoardState, getStateCopy, makeMove, passTurn, updateCaptures } from "../boardState/boardState";
|
||||||
import { getMove } from "../boardAnalysis/goAI";
|
import { getMove } from "../boardAnalysis/goAI";
|
||||||
import { bitverseArt, weiArt } from "../boardState/asciiArt";
|
import { bitverseArt, weiArt } from "../boardState/asciiArt";
|
||||||
import { getScore, resetWinstreak } from "../boardAnalysis/scoring";
|
import { getScore, resetWinstreak } from "../boardAnalysis/scoring";
|
||||||
import { evaluateIfMoveIsValid, getAllValidMoves, boardFromSimpleBoard } from "../boardAnalysis/boardAnalysis";
|
import { boardFromSimpleBoard, evaluateIfMoveIsValid, getAllValidMoves } from "../boardAnalysis/boardAnalysis";
|
||||||
import { useRerender } from "../../ui/React/hooks";
|
import { useRerender } from "../../ui/React/hooks";
|
||||||
import { OptionSwitch } from "../../ui/React/OptionSwitch";
|
import { OptionSwitch } from "../../ui/React/OptionSwitch";
|
||||||
import { boardStyles } from "../boardState/goStyles";
|
import { boardStyles } from "../boardState/goStyles";
|
||||||
@ -36,8 +36,7 @@ interface GoGameboardWrapperProps {
|
|||||||
export function GoGameboardWrapper({ showInstructions }: GoGameboardWrapperProps): React.ReactElement {
|
export function GoGameboardWrapper({ showInstructions }: GoGameboardWrapperProps): React.ReactElement {
|
||||||
const rerender = useRerender();
|
const rerender = useRerender();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const unsubscribe = GoEvents.subscribe(rerender);
|
return GoEvents.subscribe(rerender);
|
||||||
return unsubscribe;
|
|
||||||
}, [rerender]);
|
}, [rerender]);
|
||||||
|
|
||||||
const boardState = Go.currentGame;
|
const boardState = Go.currentGame;
|
||||||
@ -56,7 +55,7 @@ export function GoGameboardWrapper({ showInstructions }: GoGameboardWrapperProps
|
|||||||
|
|
||||||
// Only run this once on first component mount, to handle scenarios where the game was saved or closed while waiting on the AI to make a move
|
// Only run this once on first component mount, to handle scenarios where the game was saved or closed while waiting on the AI to make a move
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (boardState.previousPlayer === GoColor.black && !waitingOnAI) {
|
if (boardState.previousPlayer === GoColor.black && !waitingOnAI && boardState.ai !== GoOpponent.none) {
|
||||||
takeAiTurn(Go.currentGame);
|
takeAiTurn(Go.currentGame);
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
@ -104,6 +103,10 @@ export function GoGameboardWrapper({ showInstructions }: GoGameboardWrapperProps
|
|||||||
passTurn(boardState, GoColor.black);
|
passTurn(boardState, GoColor.black);
|
||||||
rerender();
|
rerender();
|
||||||
}
|
}
|
||||||
|
if (boardState.previousPlayer === GoColor.black && boardState.ai === GoOpponent.none) {
|
||||||
|
passTurn(boardState, GoColor.white);
|
||||||
|
rerender();
|
||||||
|
}
|
||||||
if (boardState.previousPlayer === null) {
|
if (boardState.previousPlayer === null) {
|
||||||
setScoreOpen(true);
|
setScoreOpen(true);
|
||||||
return;
|
return;
|
||||||
@ -150,7 +153,7 @@ export function GoGameboardWrapper({ showInstructions }: GoGameboardWrapperProps
|
|||||||
resetWinstreak(boardState.ai, false);
|
resetWinstreak(boardState.ai, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Go.currentGame = getNewBoardState(newBoardSize, newOpponent, false);
|
Go.currentGame = getNewBoardState(newBoardSize, newOpponent, true);
|
||||||
rerender();
|
rerender();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user