bitburner-src/src/Bladeburner/Operation.ts

58 lines
1.7 KiB
TypeScript
Raw Normal View History

2021-05-01 09:17:31 +02:00
import { IBladeburner } from "./IBladeburner";
import { BladeburnerConstants } from "./data/Constants";
import { Action, IActionParams } from "./Action";
2021-09-09 05:47:34 +02:00
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver";
export interface IOperationParams extends IActionParams {
2021-09-05 01:09:30 +02:00
reqdRank?: number;
teamCount?: number;
}
export class Operation extends Action {
2021-09-05 01:09:30 +02:00
reqdRank = 100;
teamCount = 0;
constructor(params: IOperationParams | null = null) {
super(params);
if (params && params.reqdRank) this.reqdRank = params.reqdRank;
if (params && params.teamCount) this.teamCount = params.teamCount;
}
// For actions that have teams. To be implemented by subtypes.
getTeamSuccessBonus(inst: IBladeburner): number {
if (this.teamCount && this.teamCount > 0) {
this.teamCount = Math.min(this.teamCount, inst.teamSize);
const teamMultiplier = Math.pow(this.teamCount, 0.05);
return teamMultiplier;
}
2021-09-05 01:09:30 +02:00
return 1;
}
getActionTypeSkillSuccessBonus(inst: IBladeburner): number {
return inst.skillMultipliers.successChanceOperation;
}
2021-09-09 05:47:34 +02:00
getChaosDifficultyBonus(inst: IBladeburner /*, params: ISuccessChanceParams*/): number {
2021-09-05 01:09:30 +02:00
const city = inst.getCurrentCity();
if (city.chaos > BladeburnerConstants.ChaosThreshold) {
const diff = 1 + (city.chaos - BladeburnerConstants.ChaosThreshold);
const mult = Math.pow(diff, 0.1);
return mult;
}
2021-09-05 01:09:30 +02:00
return 1;
}
2021-09-05 01:09:30 +02:00
toJSON(): any {
return Generic_toJSON("Operation", this);
}
2021-05-01 09:17:31 +02:00
2021-09-05 01:09:30 +02:00
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
static fromJSON(value: any): Operation {
return Generic_fromJSON(Operation, value.data);
}
}
2021-09-05 01:09:30 +02:00
Reviver.constructors.Operation = Operation;