mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-18 07:18:38 +02:00
IPVGO: Add support to netscript API for game state, current player, and alternate ways to check/wait on AI turn (#1142)
This commit is contained in:
committed by
GitHub
parent
6aaeb6b59e
commit
d81358c80f
166
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
166
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@@ -1058,9 +1058,6 @@ export type SleeveTask =
|
||||
| SleeveSupportTask
|
||||
| SleeveSynchroTask;
|
||||
|
||||
/** @public */
|
||||
type GoOpponent = "Netburners" | "Slum Snakes" | "The Black Hand" | "Tetrads" | "Daedalus" | "Illuminati";
|
||||
|
||||
/** Object representing a port. A port is a serialized queue.
|
||||
* @public */
|
||||
export interface NetscriptPort {
|
||||
@@ -3923,6 +3920,9 @@ export interface Gang {
|
||||
nextUpdate(): Promise<number>;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
type GoOpponent = "Netburners" | "Slum Snakes" | "The Black Hand" | "Tetrads" | "Daedalus" | "Illuminati";
|
||||
|
||||
/**
|
||||
* IPvGO api
|
||||
* @public
|
||||
@@ -3941,10 +3941,9 @@ export interface Go {
|
||||
x: number,
|
||||
y: number,
|
||||
): Promise<{
|
||||
type: "invalid" | "move" | "pass" | "gameOver";
|
||||
x: number;
|
||||
y: number;
|
||||
success: boolean;
|
||||
type: "move" | "pass" | "gameOver";
|
||||
x: number | null;
|
||||
y: number | null;
|
||||
}>;
|
||||
|
||||
/**
|
||||
@@ -3961,10 +3960,26 @@ export interface Go {
|
||||
*
|
||||
*/
|
||||
passTurn(): Promise<{
|
||||
type: "invalid" | "move" | "pass" | "gameOver";
|
||||
x: number;
|
||||
y: number;
|
||||
success: boolean;
|
||||
type: "move" | "pass" | "gameOver";
|
||||
x: number | null;
|
||||
y: number | null;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Returns a promise that resolves with the success or failure state of your last move, and the AI's response, if applicable.
|
||||
* x:0 y:0 represents the bottom-left corner of the board in the UI.
|
||||
*
|
||||
* @param logOpponentMove optional, if false prevents logging opponent move
|
||||
*
|
||||
* @remarks
|
||||
* RAM cost: 0 GB
|
||||
*
|
||||
* @returns a promise that contains if your last move was valid and successful, the opponent move's x and y coordinates (or pass) in response, or an indication if the game has ended
|
||||
*/
|
||||
opponentNextTurn(logOpponentMove: boolean = true): Promise<{
|
||||
type: "move" | "pass" | "gameOver";
|
||||
x: number | null;
|
||||
y: number | null;
|
||||
}>;
|
||||
|
||||
/**
|
||||
@@ -3972,15 +3987,16 @@ export interface Go {
|
||||
* "#" are dead nodes that are not part of the subnet. (They are not territory nor open nodes.)
|
||||
*
|
||||
* For example, a 5x5 board might look like this:
|
||||
```
|
||||
[
|
||||
"XX.O.",
|
||||
"X..OO",
|
||||
".XO..",
|
||||
"XXO.#",
|
||||
".XO.#",
|
||||
]
|
||||
```
|
||||
*
|
||||
* <pre lang="javascript">
|
||||
* [
|
||||
* "XX.O.",
|
||||
* "X..OO",
|
||||
* ".XO..",
|
||||
* "XXO.#",
|
||||
* ".XO.#",
|
||||
* ]
|
||||
* </pre>
|
||||
*
|
||||
* Each string represents a vertical column on the board, and each character in the string represents a point.
|
||||
*
|
||||
@@ -3995,6 +4011,24 @@ export interface Go {
|
||||
*/
|
||||
getBoardState(): string[];
|
||||
|
||||
/**
|
||||
* Returns the color of the current player, or 'None' if the game is over.
|
||||
* @returns "White" | "Black" | "None"
|
||||
*/
|
||||
getCurrentPlayer(): "White" | "Black" | "None";
|
||||
|
||||
/**
|
||||
* Gets the status of the current game.
|
||||
* Shows the current player, current score, and the previous move coordinates.
|
||||
* Previous move coordinates will be [-1, -1] for a pass, or if there are no prior moves.
|
||||
*/
|
||||
getGameState(): {
|
||||
currentPlayer: "White" | "Black" | "None";
|
||||
whiteScore: number;
|
||||
blackScore: number;
|
||||
previousMove: [number, number] | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the name of the opponent faction in the current subnet.
|
||||
*/
|
||||
@@ -4024,11 +4058,9 @@ export interface Go {
|
||||
* Shows if each point on the board is a valid move for the player.
|
||||
*
|
||||
* The true/false validity of each move can be retrieved via the X and Y coordinates of the move.
|
||||
```
|
||||
const validMoves = ns.go.analysis.getValidMoves();
|
||||
|
||||
const moveIsValid = validMoves[x][y];
|
||||
```
|
||||
* `const validMoves = ns.go.analysis.getValidMoves();`
|
||||
*
|
||||
* `const moveIsValid = validMoves[x][y];`
|
||||
*
|
||||
* Note that the [0][0] point is shown on the bottom-left on the visual board (as is traditional), and each
|
||||
* string represents a vertical column on the board. In other words, the printed example above can be understood to
|
||||
@@ -4048,16 +4080,15 @@ export interface Go {
|
||||
*
|
||||
* For example, a 5x5 board might look like this. There is a large chain #1 on the left side, smaller chains
|
||||
* 2 and 3 on the right, and a large chain 0 taking up the center of the board.
|
||||
*
|
||||
```
|
||||
[
|
||||
[ 0,0,0,3,4],
|
||||
[ 1,0,0,3,3],
|
||||
[ 1,1,0,0,0],
|
||||
[null,1,0,2,2],
|
||||
[null,1,0,2,5],
|
||||
]
|
||||
```
|
||||
* <pre lang="javascript">
|
||||
* [
|
||||
* [ 0,0,0,3,4],
|
||||
* [ 1,0,0,3,3],
|
||||
* [ 1,1,0,0,0],
|
||||
* [null,1,0,2,2],
|
||||
* [null,1,0,2,5],
|
||||
* ]
|
||||
* </pre>
|
||||
* @remarks
|
||||
* RAM cost: 16 GB
|
||||
* (This is intentionally expensive; you can derive this info from just getBoardState() )
|
||||
@@ -4072,15 +4103,15 @@ export interface Go {
|
||||
* For example, a 5x5 board might look like this. The chain in the top-left touches 5 total empty nodes, and the one
|
||||
* in the center touches four. The group in the bottom-right only has one liberty; it is in danger of being captured!
|
||||
*
|
||||
```
|
||||
[
|
||||
[-1, 5,-1,-1, 2],
|
||||
[ 5, 5,-1,-1,-1],
|
||||
[-1,-1, 4,-1,-1],
|
||||
[ 3,-1,-1, 3, 1],
|
||||
[ 3,-1,-1, 3, 1],
|
||||
]
|
||||
```
|
||||
* <pre lang="javascript">
|
||||
* [
|
||||
* [-1, 5,-1,-1, 2],
|
||||
* [ 5, 5,-1,-1,-1],
|
||||
* [-1,-1, 4,-1,-1],
|
||||
* [ 3,-1,-1, 3, 1],
|
||||
* [ 3,-1,-1, 3, 1],
|
||||
* ]
|
||||
* </pre>
|
||||
*
|
||||
* @remarks
|
||||
* RAM cost: 16 GB
|
||||
@@ -4096,15 +4127,16 @@ export interface Go {
|
||||
* Filled points of any color are indicated with '.'
|
||||
*
|
||||
* In this example, white encircles some space in the top-left, black encircles some in the top-right, and between their routers is contested space in the center:
|
||||
```
|
||||
[
|
||||
"OO..?",
|
||||
"OO.?.",
|
||||
"O.?.X",
|
||||
".?.XX",
|
||||
"?..X#",
|
||||
]
|
||||
```
|
||||
*
|
||||
* <pre lang="javascript">
|
||||
* [
|
||||
* "OO..?",
|
||||
* "OO.?.",
|
||||
* "O.?.X",
|
||||
* ".?.XX",
|
||||
* "?..X#",
|
||||
* ]
|
||||
* </pre>
|
||||
*
|
||||
* @remarks
|
||||
* RAM cost: 16 GB
|
||||
@@ -4147,10 +4179,9 @@ export interface Go {
|
||||
x: number,
|
||||
y: number,
|
||||
): Promise<{
|
||||
type: "invalid" | "move" | "pass" | "gameOver";
|
||||
x: number;
|
||||
y: number;
|
||||
success: boolean;
|
||||
type: "move" | "pass" | "gameOver";
|
||||
x: number | null;
|
||||
y: number | null;
|
||||
}>;
|
||||
/**
|
||||
* Attempts to place two routers at once on empty nodes. Note that this ignores other move restrictions, so you can
|
||||
@@ -4173,10 +4204,9 @@ export interface Go {
|
||||
x2: number,
|
||||
y2: number,
|
||||
): Promise<{
|
||||
type: "invalid" | "move" | "pass" | "gameOver";
|
||||
x: number;
|
||||
y: number;
|
||||
success: boolean;
|
||||
type: "move" | "pass" | "gameOver";
|
||||
x: number | null;
|
||||
y: number | null;
|
||||
}>;
|
||||
|
||||
/**
|
||||
@@ -4197,10 +4227,9 @@ export interface Go {
|
||||
x: number,
|
||||
y: number,
|
||||
): Promise<{
|
||||
type: "invalid" | "move" | "pass" | "gameOver";
|
||||
x: number;
|
||||
y: number;
|
||||
success: boolean;
|
||||
type: "move" | "pass" | "gameOver";
|
||||
x: number | null;
|
||||
y: number | null;
|
||||
}>;
|
||||
|
||||
/**
|
||||
@@ -4222,10 +4251,9 @@ export interface Go {
|
||||
x: number,
|
||||
y: number,
|
||||
): Promise<{
|
||||
type: "invalid" | "move" | "pass" | "gameOver";
|
||||
x: number;
|
||||
y: number;
|
||||
success: boolean;
|
||||
type: "move" | "pass" | "gameOver";
|
||||
x: number | null;
|
||||
y: number | null;
|
||||
}>;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user