2021-05-01 09:17:31 +02:00
|
|
|
import { IBladeburner } from "./IBladeburner";
|
2021-03-13 21:10:55 +01:00
|
|
|
import { BladeburnerConstants } from "./data/Constants";
|
|
|
|
import { Action, IActionParams } from "./Action";
|
2022-07-15 01:00:10 +02:00
|
|
|
import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver";
|
2021-03-13 21:10:55 +01:00
|
|
|
|
|
|
|
export interface IOperationParams extends IActionParams {
|
2021-09-05 01:09:30 +02:00
|
|
|
reqdRank?: number;
|
|
|
|
teamCount?: number;
|
2021-03-13 21:10:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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-03-13 21:10:55 +01:00
|
|
|
}
|
|
|
|
|
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);
|
2021-10-22 21:54:14 +02:00
|
|
|
const mult = Math.pow(diff, 0.5);
|
2021-09-05 01:09:30 +02:00
|
|
|
return mult;
|
2021-03-13 21:10:55 +01:00
|
|
|
}
|
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2021-03-13 21:10:55 +01:00
|
|
|
|
2022-07-15 01:00:10 +02:00
|
|
|
toJSON(): IReviverValue {
|
2021-09-05 01:09:30 +02:00
|
|
|
return Generic_toJSON("Operation", this);
|
|
|
|
}
|
2021-05-01 09:17:31 +02:00
|
|
|
|
2022-07-15 01:00:10 +02:00
|
|
|
static fromJSON(value: IReviverValue): Operation {
|
2021-09-05 01:09:30 +02:00
|
|
|
return Generic_fromJSON(Operation, value.data);
|
|
|
|
}
|
2021-03-13 21:10:55 +01:00
|
|
|
}
|
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
Reviver.constructors.Operation = Operation;
|