mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-17 06:48:42 +02:00
CODEBASE: Fix lint errors 4 (#1773)
Co-authored-by: Michael Ficocelli <ficocemt@gmail.com>
This commit is contained in:
@@ -53,7 +53,7 @@ describe("Netscript Go API unit tests", () => {
|
||||
throw new Error("Invalid");
|
||||
});
|
||||
|
||||
await makePlayerMove(mockLogger, mockError, 0, 0).catch((_) => _);
|
||||
await makePlayerMove(mockLogger, mockError, 0, 0).catch(() => {});
|
||||
|
||||
expect(mockError).toHaveBeenCalledWith("Invalid move: 0 0. That node is already occupied by a piece.");
|
||||
});
|
||||
@@ -95,7 +95,7 @@ describe("Netscript Go API unit tests", () => {
|
||||
});
|
||||
|
||||
describe("getGameState() tests", () => {
|
||||
it("should correctly retrieve the current game state", async () => {
|
||||
it("should correctly retrieve the current game state", () => {
|
||||
const board = ["OXX..", ".....", "..#..", "...XX", "...X."];
|
||||
const boardState = boardStateFromSimpleBoard(board, GoOpponent.Daedalus, GoColor.black);
|
||||
boardState.previousBoards = ["OX.........#.....XX...X."];
|
||||
@@ -240,7 +240,7 @@ describe("Netscript Go API unit tests", () => {
|
||||
});
|
||||
});
|
||||
describe("cheatPlayTwoMoves() tests", () => {
|
||||
it("should handle invalid moves", async () => {
|
||||
it("should handle invalid moves", () => {
|
||||
const board = ["XOO..", ".....", ".....", ".....", "....."];
|
||||
Go.currentGame = boardStateFromSimpleBoard(board, GoOpponent.Daedalus, GoColor.white);
|
||||
const mockError = jest.fn();
|
||||
@@ -289,7 +289,7 @@ describe("Netscript Go API unit tests", () => {
|
||||
});
|
||||
});
|
||||
describe("cheatRemoveRouter() tests", () => {
|
||||
it("should handle invalid moves", async () => {
|
||||
it("should handle invalid moves", () => {
|
||||
const board = ["XOO..", ".....", ".....", ".....", "....."];
|
||||
Go.currentGame = boardStateFromSimpleBoard(board, GoOpponent.Daedalus, GoColor.white);
|
||||
const mockError = jest.fn();
|
||||
@@ -327,7 +327,7 @@ describe("Netscript Go API unit tests", () => {
|
||||
});
|
||||
});
|
||||
describe("cheatRepairOfflineNode() tests", () => {
|
||||
it("should handle invalid moves", async () => {
|
||||
it("should handle invalid moves", () => {
|
||||
const board = ["XOO..", ".....", ".....", ".....", "....#"];
|
||||
Go.currentGame = boardStateFromSimpleBoard(board, GoOpponent.Daedalus, GoColor.white);
|
||||
const mockError = jest.fn();
|
||||
|
||||
@@ -6,13 +6,15 @@ import {
|
||||
getAllValidMoves,
|
||||
boardStateFromSimpleBoard,
|
||||
evaluateIfMoveIsValid,
|
||||
getPreviousMove,
|
||||
} from "../../../src/Go/boardAnalysis/boardAnalysis";
|
||||
import { findAnyMatchedPatterns } from "../../../src/Go/boardAnalysis/patternMatching";
|
||||
import { Go } from "../../../src/Go/Go";
|
||||
|
||||
setPlayer(new PlayerObject());
|
||||
|
||||
describe("Go board analysis tests", () => {
|
||||
it("identifies chains and liberties", async () => {
|
||||
it("identifies chains and liberties", () => {
|
||||
const board = ["XOO..", ".....", ".....", ".....", "....."];
|
||||
const boardState = boardStateFromSimpleBoard(board);
|
||||
|
||||
@@ -20,7 +22,7 @@ describe("Go board analysis tests", () => {
|
||||
expect(boardState.board[0]?.[1]?.liberties?.length).toEqual(3);
|
||||
});
|
||||
|
||||
it("identifies all points that are part of 'eyes' on the board", async () => {
|
||||
it("identifies all points that are part of 'eyes' on the board", () => {
|
||||
const board = ["..O..", "OOOOO", "..XXX", "..XX.", "..X.X"];
|
||||
const boardState = boardStateFromSimpleBoard(board);
|
||||
|
||||
@@ -46,7 +48,7 @@ describe("Go board analysis tests", () => {
|
||||
expect(point?.y).toEqual(2);
|
||||
});
|
||||
|
||||
it("identifies invalid moves from self-capture", async () => {
|
||||
it("identifies invalid moves from self-capture", () => {
|
||||
const board = [".X...", "X....", ".....", ".....", "....."];
|
||||
const boardState = boardStateFromSimpleBoard(board);
|
||||
const validity = evaluateIfMoveIsValid(boardState, 0, 0, GoColor.white, false);
|
||||
@@ -54,7 +56,7 @@ describe("Go board analysis tests", () => {
|
||||
expect(validity).toEqual(GoValidity.noSuicide);
|
||||
});
|
||||
|
||||
it("identifies invalid moves from repeat", async () => {
|
||||
it("identifies invalid moves from repeat", () => {
|
||||
const board = [".X...", ".....", ".....", ".....", "....."];
|
||||
const boardState = boardStateFromSimpleBoard(board);
|
||||
boardState.previousBoards.push(".X.......................");
|
||||
@@ -65,4 +67,12 @@ describe("Go board analysis tests", () => {
|
||||
|
||||
expect(validity).toEqual(GoValidity.boardRepeated);
|
||||
});
|
||||
|
||||
it("identifies the previous move made, based on the board history", () => {
|
||||
const board = [".XXO.", ".....", ".....", ".....", "....."];
|
||||
Go.currentGame = boardStateFromSimpleBoard(board);
|
||||
Go.currentGame.previousBoards.push("..XO.....................");
|
||||
|
||||
expect(getPreviousMove()).toEqual([0, 1]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,13 +13,14 @@ describe("Board analysis utility tests", () => {
|
||||
.filter((p) => p === "O").length;
|
||||
expect(whitePieceCount).toEqual(1);
|
||||
expect(result).toEqual({
|
||||
board: expect.any(Object),
|
||||
board: result.board, // This board state is different every run, due to random offline nodes and handicap placement
|
||||
previousPlayer: GoColor.white,
|
||||
previousBoards: [],
|
||||
ai: GoOpponent.Illuminati,
|
||||
passCount: 0,
|
||||
cheatCount: 0,
|
||||
});
|
||||
expect(result.board?.length).toEqual(5);
|
||||
});
|
||||
|
||||
it("Correctly applies the board size and handicap for the special opponent", () => {
|
||||
|
||||
Reference in New Issue
Block a user