BUGFIX: Wrong success chance in ns.bladeburner.getActionEstimatedSuccessChance (#1450)

This commit is contained in:
catloversg 2024-07-03 05:07:56 +07:00 committed by GitHub
parent 922f0bfcc5
commit 960fe5aa8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 18 additions and 14 deletions

@ -9,7 +9,7 @@ Get estimate success chance of an action.
**Signature:** **Signature:**
```typescript ```typescript
getActionEstimatedSuccessChance(type: string, name: string, sleeve?: number): [number, number]; getActionEstimatedSuccessChance(type: string, name: string, sleeveNumber?: number): [number, number];
``` ```
## Parameters ## Parameters
@ -18,7 +18,7 @@ getActionEstimatedSuccessChance(type: string, name: string, sleeve?: number): [n
| --- | --- | --- | | --- | --- | --- |
| type | string | Type of action. | | type | string | Type of action. |
| name | string | Name of action. Must be an exact match. | | name | string | Name of action. Must be an exact match. |
| sleeve | number | _(Optional)_ Optional. Sleeve number to check for success. | | sleeveNumber | number | _(Optional)_ Optional. Index of the sleeve to retrieve information. |
**Returns:** **Returns:**

@ -24,7 +24,7 @@ You have to be employed in the Bladeburner division and be in BitNode-7 or have
| [getActionCountRemaining(type, name)](./bitburner.bladeburner.getactioncountremaining.md) | Get action count remaining. | | [getActionCountRemaining(type, name)](./bitburner.bladeburner.getactioncountremaining.md) | Get action count remaining. |
| [getActionCurrentLevel(type, name)](./bitburner.bladeburner.getactioncurrentlevel.md) | Get the current level of an action. | | [getActionCurrentLevel(type, name)](./bitburner.bladeburner.getactioncurrentlevel.md) | Get the current level of an action. |
| [getActionCurrentTime()](./bitburner.bladeburner.getactioncurrenttime.md) | Get the time elapsed on current action. | | [getActionCurrentTime()](./bitburner.bladeburner.getactioncurrenttime.md) | Get the time elapsed on current action. |
| [getActionEstimatedSuccessChance(type, name, sleeve)](./bitburner.bladeburner.getactionestimatedsuccesschance.md) | Get estimate success chance of an action. | | [getActionEstimatedSuccessChance(type, name, sleeveNumber)](./bitburner.bladeburner.getactionestimatedsuccesschance.md) | Get estimate success chance of an action. |
| [getActionMaxLevel(type, name)](./bitburner.bladeburner.getactionmaxlevel.md) | Get the maximum level of an action. | | [getActionMaxLevel(type, name)](./bitburner.bladeburner.getactionmaxlevel.md) | Get the maximum level of an action. |
| [getActionRepGain(type, name, level)](./bitburner.bladeburner.getactionrepgain.md) | Get the reputation gain of an action. | | [getActionRepGain(type, name, level)](./bitburner.bladeburner.getactionrepgain.md) | Get the reputation gain of an action. |
| [getActionSuccesses(type, name)](./bitburner.bladeburner.getactionsuccesses.md) | Get action successes. | | [getActionSuccesses(type, name)](./bitburner.bladeburner.getactionsuccesses.md) | Get action successes. |

@ -120,16 +120,21 @@ export function NetscriptBladeburner(): InternalAPI<INetscriptBladeburner> {
getActionEstimatedSuccessChance: (ctx) => (type, name, _sleeve) => { getActionEstimatedSuccessChance: (ctx) => (type, name, _sleeve) => {
const bladeburner = getBladeburner(ctx); const bladeburner = getBladeburner(ctx);
const action = getAction(ctx, type, name); const action = getAction(ctx, type, name);
if (_sleeve != null) { if (_sleeve == null) {
return action.getSuccessRange(bladeburner, Player);
}
checkSleeveAPIAccess(ctx); checkSleeveAPIAccess(ctx);
const sleeveNumber = helpers.number(ctx, "sleeve", _sleeve); const sleeveNumber = helpers.number(ctx, "sleeve", _sleeve);
checkSleeveNumber(ctx, sleeveNumber); checkSleeveNumber(ctx, sleeveNumber);
if (action.type === BladeActionType.contract) { switch (action.type) {
case BladeActionType.general:
return [1, 1];
case BladeActionType.contract: {
const sleevePerson = Player.sleeves[sleeveNumber]; const sleevePerson = Player.sleeves[sleeveNumber];
return action.getSuccessRange(bladeburner, sleevePerson); return action.getSuccessRange(bladeburner, sleevePerson);
} else return [0, 0]; }
} else { default:
return action.getSuccessRange(bladeburner, Player); return [0, 0];
} }
}, },
getActionRepGain: (ctx) => (type, name, _level) => { getActionRepGain: (ctx) => (type, name, _level) => {

@ -28,7 +28,6 @@ export const checkSleeveAPIAccess = function (ctx: NetscriptContext) {
export const checkSleeveNumber = function (ctx: NetscriptContext, sleeveNumber: number) { export const checkSleeveNumber = function (ctx: NetscriptContext, sleeveNumber: number) {
if (sleeveNumber >= Player.sleeves.length || sleeveNumber < 0) { if (sleeveNumber >= Player.sleeves.length || sleeveNumber < 0) {
const msg = `Invalid sleeve number: ${sleeveNumber}`; const msg = `Invalid sleeve number: ${sleeveNumber}`;
helpers.log(ctx, () => msg);
throw helpers.errorMessage(ctx, msg); throw helpers.errorMessage(ctx, msg);
} }
}; };

@ -3145,10 +3145,10 @@ export interface Bladeburner {
* *
* @param type - Type of action. * @param type - Type of action.
* @param name - Name of action. Must be an exact match. * @param name - Name of action. Must be an exact match.
* @param sleeve - Optional. Sleeve number to check for success. * @param sleeveNumber - Optional. Index of the sleeve to retrieve information.
* @returns Estimated success chance for the specified action. * @returns Estimated success chance for the specified action.
*/ */
getActionEstimatedSuccessChance(type: string, name: string, sleeve?: number): [number, number]; getActionEstimatedSuccessChance(type: string, name: string, sleeveNumber?: number): [number, number];
/** /**
* Get the reputation gain of an action. * Get the reputation gain of an action.