mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 09:43:54 +01:00
Implement standardized grafting time calcs
This commit is contained in:
parent
304e7e69d5
commit
8b34d2776a
@ -4,7 +4,7 @@ import { CityName } from "../Locations/data/CityNames";
|
|||||||
import { getRamCost } from "../Netscript/RamCostGenerator";
|
import { getRamCost } from "../Netscript/RamCostGenerator";
|
||||||
import { WorkerScript } from "../Netscript/WorkerScript";
|
import { WorkerScript } from "../Netscript/WorkerScript";
|
||||||
import { GraftableAugmentation } from "../PersonObjects/Grafting/GraftableAugmentation";
|
import { GraftableAugmentation } from "../PersonObjects/Grafting/GraftableAugmentation";
|
||||||
import { getGraftingAvailableAugs } from "../PersonObjects/Grafting/GraftingHelpers";
|
import { getGraftingAvailableAugs, calculateGraftingTimeWithBonus } from "../PersonObjects/Grafting/GraftingHelpers";
|
||||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||||
import { Grafting as IGrafting } from "../ScriptEditor/NetscriptDefinitions";
|
import { Grafting as IGrafting } from "../ScriptEditor/NetscriptDefinitions";
|
||||||
import { Router } from "../ui/GameRoot";
|
import { Router } from "../ui/GameRoot";
|
||||||
@ -31,8 +31,8 @@ export function NetscriptGrafting(player: IPlayer, workerScript: WorkerScript, h
|
|||||||
if (!getGraftingAvailableAugs(player).includes(augName) || !Augmentations.hasOwnProperty(augName)) {
|
if (!getGraftingAvailableAugs(player).includes(augName) || !Augmentations.hasOwnProperty(augName)) {
|
||||||
throw helper.makeRuntimeErrorMsg("grafting.getAugmentationGraftPrice", `Invalid aug: ${augName}`);
|
throw helper.makeRuntimeErrorMsg("grafting.getAugmentationGraftPrice", `Invalid aug: ${augName}`);
|
||||||
}
|
}
|
||||||
const craftableAug = new GraftableAugmentation(Augmentations[augName]);
|
const graftableAug = new GraftableAugmentation(Augmentations[augName]);
|
||||||
return craftableAug.cost;
|
return graftableAug.cost;
|
||||||
},
|
},
|
||||||
|
|
||||||
getAugmentationGraftTime: (_augName: string): number => {
|
getAugmentationGraftTime: (_augName: string): number => {
|
||||||
@ -42,8 +42,8 @@ export function NetscriptGrafting(player: IPlayer, workerScript: WorkerScript, h
|
|||||||
if (!getGraftingAvailableAugs(player).includes(augName) || !Augmentations.hasOwnProperty(augName)) {
|
if (!getGraftingAvailableAugs(player).includes(augName) || !Augmentations.hasOwnProperty(augName)) {
|
||||||
throw helper.makeRuntimeErrorMsg("grafting.getAugmentationGraftTime", `Invalid aug: ${augName}`);
|
throw helper.makeRuntimeErrorMsg("grafting.getAugmentationGraftTime", `Invalid aug: ${augName}`);
|
||||||
}
|
}
|
||||||
const craftableAug = new GraftableAugmentation(Augmentations[augName]);
|
const graftableAug = new GraftableAugmentation(Augmentations[augName]);
|
||||||
return craftableAug.time;
|
return calculateGraftingTimeWithBonus(player, graftableAug);
|
||||||
},
|
},
|
||||||
|
|
||||||
getGraftableAugmentations: (): string[] => {
|
getGraftableAugmentations: (): string[] => {
|
||||||
|
@ -15,7 +15,11 @@ export const getGraftingAvailableAugs = (player: IPlayer): string[] => {
|
|||||||
return augs.filter((augmentation: string) => !player.hasAugmentation(augmentation));
|
return augs.filter((augmentation: string) => !player.hasAugmentation(augmentation));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const graftingIntBonus = (player: IPlayer): number => {
|
||||||
|
return 1 + (player.getIntelligenceBonus(3) - 1) / 3;
|
||||||
|
};
|
||||||
|
|
||||||
export const calculateGraftingTimeWithBonus = (player: IPlayer, aug: GraftableAugmentation): number => {
|
export const calculateGraftingTimeWithBonus = (player: IPlayer, aug: GraftableAugmentation): number => {
|
||||||
const baseTime = aug.time;
|
const baseTime = aug.time;
|
||||||
return baseTime / (1 + (player.getIntelligenceBonus(3) - 1) / 3);
|
return baseTime / graftingIntBonus(player);
|
||||||
};
|
};
|
||||||
|
@ -15,7 +15,7 @@ import { ConfirmationModal } from "../../../ui/React/ConfirmationModal";
|
|||||||
import { Money } from "../../../ui/React/Money";
|
import { Money } from "../../../ui/React/Money";
|
||||||
import { convertTimeMsToTimeElapsedString, formatNumber } from "../../../utils/StringHelperFunctions";
|
import { convertTimeMsToTimeElapsedString, formatNumber } from "../../../utils/StringHelperFunctions";
|
||||||
import { IPlayer } from "../../IPlayer";
|
import { IPlayer } from "../../IPlayer";
|
||||||
import { getGraftingAvailableAugs } from "../GraftingHelpers";
|
import { getGraftingAvailableAugs, calculateGraftingTimeWithBonus } from "../GraftingHelpers";
|
||||||
import { GraftableAugmentation } from "../GraftableAugmentation";
|
import { GraftableAugmentation } from "../GraftableAugmentation";
|
||||||
|
|
||||||
const GraftableAugmentations: IMap<GraftableAugmentation> = {};
|
const GraftableAugmentations: IMap<GraftableAugmentation> = {};
|
||||||
@ -132,7 +132,7 @@ export const GraftingRoot = (): React.ReactElement => {
|
|||||||
<Typography color={Settings.theme.info}>
|
<Typography color={Settings.theme.info}>
|
||||||
<b>Time to Graft:</b>{" "}
|
<b>Time to Graft:</b>{" "}
|
||||||
{convertTimeMsToTimeElapsedString(
|
{convertTimeMsToTimeElapsedString(
|
||||||
GraftableAugmentations[selectedAug].time / (1 + (player.getIntelligenceBonus(3) - 1) / 3),
|
calculateGraftingTimeWithBonus(player, GraftableAugmentations[selectedAug]),
|
||||||
)}
|
)}
|
||||||
{/* Use formula so the displayed creation time is accurate to player bonus */}
|
{/* Use formula so the displayed creation time is accurate to player bonus */}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
@ -65,6 +65,7 @@ import { SnackbarEvents, ToastVariant } from "../../ui/React/Snackbar";
|
|||||||
import { calculateClassEarnings } from "../formulas/work";
|
import { calculateClassEarnings } from "../formulas/work";
|
||||||
import { achievements } from "../../Achievements/Achievements";
|
import { achievements } from "../../Achievements/Achievements";
|
||||||
import { FactionNames } from "../../Faction/data/FactionNames";
|
import { FactionNames } from "../../Faction/data/FactionNames";
|
||||||
|
import { graftingIntBonus } from "../Grafting/GraftingHelpers";
|
||||||
|
|
||||||
export function init(this: IPlayer): void {
|
export function init(this: IPlayer): void {
|
||||||
/* Initialize Player's home computer */
|
/* Initialize Player's home computer */
|
||||||
@ -1350,7 +1351,7 @@ export function craftAugmentationWork(this: IPlayer, numCycles: number): boolean
|
|||||||
focusBonus = this.focus ? 1 : CONSTANTS.BaseFocusBonus;
|
focusBonus = this.focus ? 1 : CONSTANTS.BaseFocusBonus;
|
||||||
}
|
}
|
||||||
|
|
||||||
let skillMult = 1 + (this.getIntelligenceBonus(3) - 1) / 3;
|
let skillMult = graftingIntBonus(this);
|
||||||
skillMult *= focusBonus;
|
skillMult *= focusBonus;
|
||||||
|
|
||||||
this.timeWorked += CONSTANTS._idleSpeed * numCycles;
|
this.timeWorked += CONSTANTS._idleSpeed * numCycles;
|
||||||
|
Loading…
Reference in New Issue
Block a user