mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 06:18:42 +02:00
BUGFIX: Ensure that IPvGO promises are initialized correctly on a new save and on fluming (#2032)
This commit is contained in:
committed by
GitHub
parent
88fef7d8a3
commit
47b34c8563
@@ -2,7 +2,7 @@ import type { BoardState, OpponentStats } from "./Types";
|
||||
|
||||
import type { GoOpponent } from "@enums";
|
||||
import { getRecordKeys, PartialRecord } from "../Types/Record";
|
||||
import { resetAI } from "./boardAnalysis/goAI";
|
||||
import { resetGoPromises } from "./boardAnalysis/goAI";
|
||||
import { getNewBoardState } from "./boardState/boardState";
|
||||
import { EventEmitter } from "../utils/EventEmitter";
|
||||
import { newOpponentStats } from "./Constants";
|
||||
@@ -20,10 +20,10 @@ export class GoObject {
|
||||
}
|
||||
}
|
||||
prestigeSourceFile() {
|
||||
resetAI();
|
||||
this.previousGame = null;
|
||||
this.currentGame = getNewBoardState(7);
|
||||
this.stats = {};
|
||||
resetGoPromises();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,7 +27,7 @@ type PlayerPromise = {
|
||||
resolver: ((play?: Play) => void) | null;
|
||||
};
|
||||
|
||||
const gameOver = { type: GoPlayType.gameOver, x: null, y: null } as const;
|
||||
const gameOver: Play = { type: GoPlayType.gameOver, x: null, y: null } as const;
|
||||
const playerPromises: Record<GoColor.black | GoColor.white, PlayerPromise> = {
|
||||
[GoColor.black]: { nextTurn: Promise.resolve(gameOver), resolver: null },
|
||||
[GoColor.white]: { nextTurn: Promise.resolve(gameOver), resolver: null },
|
||||
@@ -40,6 +40,11 @@ export function getNextTurn(color: GoColor.black | GoColor.white): Promise<Play>
|
||||
return playerPromises[color].nextTurn;
|
||||
}
|
||||
|
||||
export function resetGoPromises(): void {
|
||||
resetAI();
|
||||
handleNextTurn().catch((error) => exceptionAlert(error, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Does common processing in response to a move being made.
|
||||
*
|
||||
@@ -51,7 +56,7 @@ export function getNextTurn(color: GoColor.black | GoColor.white): Promise<Play>
|
||||
* handling and dispatches common events.
|
||||
* @returns the nextTurn promise for the player who just moved
|
||||
*/
|
||||
export function handleNextTurn(boardState: BoardState, useOfflineCycles = true): Promise<Play> {
|
||||
export function handleNextTurn(boardState: BoardState = Go.currentGame, useOfflineCycles = true): Promise<Play> {
|
||||
const previousColor = boardState.previousPlayer;
|
||||
if (previousColor === null) {
|
||||
// The game is over. We shouldn't get here in most circumstances,
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
passTurn,
|
||||
updateCaptures,
|
||||
} from "../boardState/boardState";
|
||||
import { getNextTurn, handleNextTurn, resetAI } from "../boardAnalysis/goAI";
|
||||
import { getNextTurn, handleNextTurn, resetGoPromises } from "../boardAnalysis/goAI";
|
||||
import {
|
||||
evaluateIfMoveIsValid,
|
||||
getControlledSpace,
|
||||
@@ -22,7 +22,6 @@ import { endGoGame, getOpponentStats, getScore, resetWinstreak } from "../boardA
|
||||
import { WHRNG } from "../../Casino/RNG";
|
||||
import { getRecordKeys } from "../../Types/Record";
|
||||
import { CalculateEffect, getEffectTypeForFaction } from "./effect";
|
||||
import { exceptionAlert } from "../../utils/helpers/exceptionAlert";
|
||||
import { newOpponentStats } from "../Constants";
|
||||
|
||||
/**
|
||||
@@ -342,9 +341,8 @@ export function resetBoardState(
|
||||
resetWinstreak(oldBoardState.ai, false);
|
||||
}
|
||||
|
||||
resetAI();
|
||||
Go.currentGame = getNewBoardState(boardSize, opponent, true);
|
||||
handleNextTurn(Go.currentGame).catch((error) => exceptionAlert(error));
|
||||
resetGoPromises();
|
||||
logger(`New game started: ${opponent}, ${boardSize}x${boardSize}`);
|
||||
return simpleBoardFromBoard(Go.currentGame.board);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import { GoScoreModal } from "./GoScoreModal";
|
||||
import { GoGameboard } from "./GoGameboard";
|
||||
import { GoSubnetSearch } from "./GoSubnetSearch";
|
||||
import { CorruptableText } from "../../ui/React/CorruptableText";
|
||||
import { handleNextTurn, resetAI } from "../boardAnalysis/goAI";
|
||||
import { handleNextTurn, resetGoPromises } from "../boardAnalysis/goAI";
|
||||
import { GoScoreExplanation } from "./GoScoreExplanation";
|
||||
import { exceptionAlert } from "../../utils/helpers/exceptionAlert";
|
||||
|
||||
@@ -133,9 +133,8 @@ export function GoGameboardWrapper({ showInstructions }: GoGameboardWrapperProps
|
||||
resetWinstreak(boardState.ai, false);
|
||||
}
|
||||
|
||||
resetAI();
|
||||
Go.currentGame = getNewBoardState(newBoardSize, newOpponent, true);
|
||||
handleNextTurn(Go.currentGame).catch((error) => exceptionAlert(error));
|
||||
resetGoPromises();
|
||||
}
|
||||
|
||||
function getPriorMove() {
|
||||
|
||||
@@ -47,6 +47,7 @@ import { SaveData } from "./types";
|
||||
import { Go } from "./Go/Go";
|
||||
import { EventEmitter } from "./utils/EventEmitter";
|
||||
import { Companies } from "./Company/Companies";
|
||||
import { resetGoPromises } from "./Go/boardAnalysis/goAI";
|
||||
|
||||
declare global {
|
||||
// This property is only available in the dev build
|
||||
@@ -391,6 +392,7 @@ const Engine: {
|
||||
Player.init();
|
||||
initForeignServers(Player.getHomeComputer());
|
||||
Player.reapplyAllAugmentations();
|
||||
resetGoPromises();
|
||||
|
||||
// Start interactive tutorial
|
||||
iTutorialStart();
|
||||
|
||||
Reference in New Issue
Block a user