mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-29 04:17:05 +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
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user