mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-27 19:37:07 +02:00
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { sum } from "lodash";
|
|
|
|
import { Augmentation } from "../../Augmentation/Augmentation";
|
|
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
|
|
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 {
|
|
// Sell the Grafting-exclusive Aug at its starting price only
|
|
if (this.augmentation.name === AugmentationNames.CongruityImplant) {
|
|
return this.augmentation.startingCost;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|