From 0bf378a1b0f0e6af0cfa4a8532d9b944b1012589 Mon Sep 17 00:00:00 2001 From: ballardrog Date: Sun, 27 Oct 2024 18:52:23 -0700 Subject: [PATCH] IPVGO: Add getCheatCount(). (#1734) --- markdown/bitburner.gocheat.getcheatcount.md | 21 +++++++++++++++++++ ...bitburner.gocheat.getcheatsuccesschance.md | 11 ++++++++-- markdown/bitburner.gocheat.md | 3 ++- src/Netscript/RamCostGenerator.ts | 1 + src/NetscriptFunctions/Go.ts | 11 ++++++++-- src/ScriptEditor/NetscriptDefinitions.d.ts | 15 +++++++++++-- 6 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 markdown/bitburner.gocheat.getcheatcount.md diff --git a/markdown/bitburner.gocheat.getcheatcount.md b/markdown/bitburner.gocheat.getcheatcount.md new file mode 100644 index 000000000..9ae51998b --- /dev/null +++ b/markdown/bitburner.gocheat.getcheatcount.md @@ -0,0 +1,21 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [GoCheat](./bitburner.gocheat.md) > [getCheatCount](./bitburner.gocheat.getcheatcount.md) + +## GoCheat.getCheatCount() method + +Returns the number of times you've attempted to cheat in the current game. + +**Signature:** + +```typescript +getCheatCount(): number; +``` +**Returns:** + +number + +## Remarks + +RAM cost: 1 GB Requires BitNode 14.2 to use + diff --git a/markdown/bitburner.gocheat.getcheatsuccesschance.md b/markdown/bitburner.gocheat.getcheatsuccesschance.md index caf99af11..e56317fca 100644 --- a/markdown/bitburner.gocheat.getcheatsuccesschance.md +++ b/markdown/bitburner.gocheat.getcheatsuccesschance.md @@ -4,15 +4,22 @@ ## GoCheat.getCheatSuccessChance() method -Returns your chance of successfully playing one of the special moves in the ns.go.cheat API. Scales with your crime success rate stat. +Returns your chance of successfully playing one of the special moves in the ns.go.cheat API. Scales up with your crime success rate stat. Scales down with the number of times you've attempted to cheat in the current game. Warning: if you fail to play a cheat move, your turn will be skipped. After your first cheat attempt, if you fail, there is a small (\~10%) chance you will instantly be ejected from the subnet. **Signature:** ```typescript -getCheatSuccessChance(): number; +getCheatSuccessChance(cheatCount?: number): number; ``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| cheatCount | number | _(Optional)_ Optional override for the number of cheats already attempted. Defaults to the number of cheats attempted in the current game. | + **Returns:** number diff --git a/markdown/bitburner.gocheat.md b/markdown/bitburner.gocheat.md index caf62f00c..b54a65d83 100644 --- a/markdown/bitburner.gocheat.md +++ b/markdown/bitburner.gocheat.md @@ -17,7 +17,8 @@ export interface GoCheat | Method | Description | | --- | --- | | [destroyNode(x, y)](./bitburner.gocheat.destroynode.md) |

Attempts to destroy an empty node, leaving an offline dead space that does not count as territory or provide open node access to adjacent routers.

Success chance can be seen via ns.go.getCheatSuccessChance()

Warning: if you fail to play a cheat move, your turn will be skipped. After your first cheat attempt, if you fail, there is a small (\~10%) chance you will instantly be ejected from the subnet.

| -| [getCheatSuccessChance()](./bitburner.gocheat.getcheatsuccesschance.md) |

Returns your chance of successfully playing one of the special moves in the ns.go.cheat API. Scales with your crime success rate stat.

Warning: if you fail to play a cheat move, your turn will be skipped. After your first cheat attempt, if you fail, there is a small (\~10%) chance you will instantly be ejected from the subnet.

| +| [getCheatCount()](./bitburner.gocheat.getcheatcount.md) | Returns the number of times you've attempted to cheat in the current game. | +| [getCheatSuccessChance(cheatCount)](./bitburner.gocheat.getcheatsuccesschance.md) |

Returns your chance of successfully playing one of the special moves in the ns.go.cheat API. Scales up with your crime success rate stat. Scales down with the number of times you've attempted to cheat in the current game.

Warning: if you fail to play a cheat move, your turn will be skipped. After your first cheat attempt, if you fail, there is a small (\~10%) chance you will instantly be ejected from the subnet.

| | [playTwoMoves(x1, y1, x2, y2)](./bitburner.gocheat.playtwomoves.md) |

Attempts to place two routers at once on empty nodes. Note that this ignores other move restrictions, so you can suicide your own routers if they have no access to empty ports and do not capture any enemy routers.

Success chance can be seen via ns.go.getCheatSuccessChance()

Warning: if you fail to play a cheat move, your turn will be skipped. After your first cheat attempt, if you fail, there is a small (\~10%) chance you will instantly be ejected from the subnet.

| | [removeRouter(x, y)](./bitburner.gocheat.removerouter.md) |

Attempts to remove an existing router, leaving an empty node behind.

Success chance can be seen via ns.go.getCheatSuccessChance()

Warning: if you fail to play a cheat move, your turn will be skipped. After your first cheat attempt, if you fail, there is a small (\~10%) chance you will instantly be ejected from the subnet.

| | [repairOfflineNode(x, y)](./bitburner.gocheat.repairofflinenode.md) |

Attempts to repair an offline node, leaving an empty playable node behind.

Success chance can be seen via ns.go.getCheatSuccessChance()

Warning: if you fail to play a cheat move, your turn will be skipped. After your first cheat attempt, if you fail, there is a small (\~10%) chance you will instantly be ejected from the subnet.

| diff --git a/src/Netscript/RamCostGenerator.ts b/src/Netscript/RamCostGenerator.ts index d49e2f7c2..05fe899b2 100644 --- a/src/Netscript/RamCostGenerator.ts +++ b/src/Netscript/RamCostGenerator.ts @@ -272,6 +272,7 @@ const go = { }, cheat: { getCheatSuccessChance: 1, + getCheatCount: 1, removeRouter: 8, playTwoMoves: 8, repairOfflineNode: 8, diff --git a/src/NetscriptFunctions/Go.ts b/src/NetscriptFunctions/Go.ts index f47843315..09cc67e55 100644 --- a/src/NetscriptFunctions/Go.ts +++ b/src/NetscriptFunctions/Go.ts @@ -100,9 +100,16 @@ export function NetscriptGo(): InternalAPI { }, }, cheat: { - getCheatSuccessChance: (ctx: NetscriptContext) => () => { + getCheatSuccessChance: + (ctx: NetscriptContext) => + (_cheatCount = Go.currentGame.cheatCount) => { + checkCheatApiAccess(error(ctx)); + const cheatCount = helpers.number(ctx, "cheatCount", _cheatCount); + return cheatSuccessChance(cheatCount); + }, + getCheatCount: (ctx: NetscriptContext) => () => { checkCheatApiAccess(error(ctx)); - return cheatSuccessChance(Go.currentGame.cheatCount); + return Go.currentGame.cheatCount; }, removeRouter: (ctx: NetscriptContext) => diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index aa51654e8..b0087245f 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -4399,16 +4399,27 @@ export interface GoAnalysis { export interface GoCheat { /** * Returns your chance of successfully playing one of the special moves in the ns.go.cheat API. - * Scales with your crime success rate stat. + * Scales up with your crime success rate stat. + * Scales down with the number of times you've attempted to cheat in the current game. * * Warning: if you fail to play a cheat move, your turn will be skipped. After your first cheat attempt, if you fail, there is a * small (~10%) chance you will instantly be ejected from the subnet. * + * @param cheatCount - Optional override for the number of cheats already attempted. Defaults to the number of cheats attempted in the current game. + * * @remarks * RAM cost: 1 GB * Requires BitNode 14.2 to use */ - getCheatSuccessChance(): number; + getCheatSuccessChance(cheatCount?: number): number; + /** + * Returns the number of times you've attempted to cheat in the current game. + * + * @remarks + * RAM cost: 1 GB + * Requires BitNode 14.2 to use + */ + getCheatCount(): number; /** * Attempts to remove an existing router, leaving an empty node behind. *