mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-19 15:54:09 +02:00
32 lines
900 B
TypeScript
32 lines
900 B
TypeScript
import { sum } from "lodash";
|
|
|
|
import { Augmentation } from "../../Augmentation/Augmentation";
|
|
import { CONSTANTS } from "../../Constants";
|
|
|
|
export interface IConstructorParams {
|
|
augmentation: Augmentation;
|
|
readonly cost: number;
|
|
readonly time: number;
|
|
}
|
|
|
|
export class GraftableAugmentation {
|
|
// The augmentation that this craftable corresponds to
|
|
augmentation: Augmentation;
|
|
|
|
constructor(augmentation: Augmentation) {
|
|
this.augmentation = augmentation;
|
|
}
|
|
|
|
get cost(): number {
|
|
return this.augmentation.startingCost * CONSTANTS.AugmentationGraftingCostMult;
|
|
}
|
|
|
|
get time(): number {
|
|
// Time = 1 hour * log_2(sum(aug multipliers) || 1) + 30 minutes
|
|
const antiLog = Math.max(sum(Object.values(this.augmentation.mults)), 1);
|
|
|
|
const mult = Math.log2(antiLog);
|
|
return (CONSTANTS.AugmentationGraftingTimeBase * mult + CONSTANTS.MillisecondsPerHalfHour) / 2;
|
|
}
|
|
}
|