mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-20 05:05:47 +01:00
Merge pull request #3702 from borisflagell/FIX#3508
BLADEBURNER: FIX #3508 Add GetActionCurrentTime() to Bitburner API
This commit is contained in:
commit
570c6d6b32
@ -287,6 +287,8 @@ export class Bladeburner implements IBladeburner {
|
|||||||
|
|
||||||
resetAction(): void {
|
resetAction(): void {
|
||||||
this.action = new ActionIdentifier({ type: ActionTypes.Idle });
|
this.action = new ActionIdentifier({ type: ActionTypes.Idle });
|
||||||
|
this.actionTimeCurrent = 0;
|
||||||
|
this.actionTimeToComplete = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearConsole(): void {
|
clearConsole(): void {
|
||||||
|
@ -226,6 +226,7 @@ const bladeburner: IMap<any> = {
|
|||||||
stopBladeburnerAction: RamCostConstants.ScriptBladeburnerApiBaseRamCost / 2,
|
stopBladeburnerAction: RamCostConstants.ScriptBladeburnerApiBaseRamCost / 2,
|
||||||
getCurrentAction: RamCostConstants.ScriptBladeburnerApiBaseRamCost / 4,
|
getCurrentAction: RamCostConstants.ScriptBladeburnerApiBaseRamCost / 4,
|
||||||
getActionTime: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
|
getActionTime: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
|
||||||
|
getActionCurrentTime: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
|
||||||
getActionEstimatedSuccessChance: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
|
getActionEstimatedSuccessChance: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
|
||||||
getActionRepGain: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
|
getActionRepGain: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
|
||||||
getActionCountRemaining: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
|
getActionCountRemaining: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
|
||||||
|
@ -137,6 +137,19 @@ export function NetscriptBladeburner(player: IPlayer, workerScript: WorkerScript
|
|||||||
throw ctx.makeRuntimeErrorMsg(e);
|
throw ctx.makeRuntimeErrorMsg(e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
getActionCurrentTime: (ctx: NetscriptContext) => (): number => {
|
||||||
|
checkBladeburnerAccess(ctx);
|
||||||
|
const bladeburner = player.bladeburner;
|
||||||
|
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||||
|
try {
|
||||||
|
const timecomputed =
|
||||||
|
Math.min(bladeburner.actionTimeCurrent + bladeburner.actionTimeOverflow, bladeburner.actionTimeToComplete) *
|
||||||
|
1000;
|
||||||
|
return timecomputed;
|
||||||
|
} catch (e: any) {
|
||||||
|
throw ctx.makeRuntimeErrorMsg(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
getActionEstimatedSuccessChance:
|
getActionEstimatedSuccessChance:
|
||||||
(ctx: NetscriptContext) =>
|
(ctx: NetscriptContext) =>
|
||||||
(_type: unknown, _name: unknown): [number, number] => {
|
(_type: unknown, _name: unknown): [number, number] => {
|
||||||
|
13
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
13
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -2884,7 +2884,7 @@ export interface Bladeburner {
|
|||||||
* @remarks
|
* @remarks
|
||||||
* RAM cost: 4 GB
|
* RAM cost: 4 GB
|
||||||
*
|
*
|
||||||
* Returns the number of seconds it takes to complete the specified action
|
* Returns the number of milliseconds it takes to complete the specified action
|
||||||
*
|
*
|
||||||
* @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.
|
||||||
@ -2892,6 +2892,17 @@ export interface Bladeburner {
|
|||||||
*/
|
*/
|
||||||
getActionTime(type: string, name: string): number;
|
getActionTime(type: string, name: string): number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the time elapsed on current action.
|
||||||
|
* @remarks
|
||||||
|
* RAM cost: 4 GB
|
||||||
|
*
|
||||||
|
* Returns the number of milliseconds already spent on the current action.
|
||||||
|
*
|
||||||
|
* @returns Number of milliseconds already spent on the current action.
|
||||||
|
*/
|
||||||
|
getActionCurrentTime(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get estimate success chance of an action.
|
* Get estimate success chance of an action.
|
||||||
* @remarks
|
* @remarks
|
||||||
|
Loading…
Reference in New Issue
Block a user