mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 09:43:54 +01:00
Implement CraftableAugmentation
This commit is contained in:
parent
dc5b925f65
commit
fef5ab31b2
@ -109,6 +109,8 @@ export const CONSTANTS: {
|
|||||||
CodingContractBaseFactionRepGain: number;
|
CodingContractBaseFactionRepGain: number;
|
||||||
CodingContractBaseCompanyRepGain: number;
|
CodingContractBaseCompanyRepGain: number;
|
||||||
CodingContractBaseMoneyGain: number;
|
CodingContractBaseMoneyGain: number;
|
||||||
|
AugmentationCraftingCostMult: number;
|
||||||
|
AugmentationCraftingTimeMult: number;
|
||||||
TotalNumBitNodes: number;
|
TotalNumBitNodes: number;
|
||||||
LatestUpdate: string;
|
LatestUpdate: string;
|
||||||
} = {
|
} = {
|
||||||
@ -271,6 +273,11 @@ export const CONSTANTS: {
|
|||||||
CodingContractBaseCompanyRepGain: 4000,
|
CodingContractBaseCompanyRepGain: 4000,
|
||||||
CodingContractBaseMoneyGain: 75e6,
|
CodingContractBaseMoneyGain: 75e6,
|
||||||
|
|
||||||
|
// Augmentation crafting multipliers
|
||||||
|
// TODO: Get these right
|
||||||
|
AugmentationCraftingCostMult: 1.2,
|
||||||
|
AugmentationCraftingTimeMult: 1,
|
||||||
|
|
||||||
// BitNode/Source-File related stuff
|
// BitNode/Source-File related stuff
|
||||||
TotalNumBitNodes: 24,
|
TotalNumBitNodes: 24,
|
||||||
|
|
||||||
|
26
src/PersonObjects/Grafting/CraftableAugmentation.ts
Normal file
26
src/PersonObjects/Grafting/CraftableAugmentation.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import { Augmentation } from "../../Augmentation/Augmentation";
|
||||||
|
import { CONSTANTS } from "../../Constants";
|
||||||
|
|
||||||
|
export interface IConstructorParams {
|
||||||
|
augmentation: Augmentation;
|
||||||
|
readonly cost: number;
|
||||||
|
readonly time: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CraftableAugmentation {
|
||||||
|
// The augmentation that this craftable corresponds to
|
||||||
|
augmentation: Augmentation;
|
||||||
|
|
||||||
|
constructor(augmentation: Augmentation) {
|
||||||
|
this.augmentation = augmentation;
|
||||||
|
}
|
||||||
|
|
||||||
|
get cost(): number {
|
||||||
|
return this.augmentation.startingCost * CONSTANTS.AugmentationCraftingCostMult;
|
||||||
|
}
|
||||||
|
|
||||||
|
get time(): number {
|
||||||
|
// CONSTANTS.AugmentationCraftingTimeMult
|
||||||
|
return 15000;
|
||||||
|
}
|
||||||
|
}
|
@ -14,13 +14,19 @@ import {
|
|||||||
} from "@mui/icons-material";
|
} from "@mui/icons-material";
|
||||||
|
|
||||||
import { use } from "../../../ui/Context";
|
import { use } from "../../../ui/Context";
|
||||||
|
import { Money } from "../../../ui/React/Money";
|
||||||
import { Augmentations } from "../../../Augmentation/Augmentations";
|
import { Augmentations } from "../../../Augmentation/Augmentations";
|
||||||
import { AugmentationNames } from "../../../Augmentation/data/AugmentationNames"
|
import { AugmentationNames } from "../../../Augmentation/data/AugmentationNames"
|
||||||
import { Settings } from "../../../Settings/Settings";
|
import { Settings } from "../../../Settings/Settings";
|
||||||
import { CONSTANTS } from "../../../Constants";
|
import { IMap } from "../../../types";
|
||||||
|
import { convertTimeMsToTimeElapsedString } from "../../../utils/StringHelperFunctions";
|
||||||
|
|
||||||
import { IPlayer } from "../../IPlayer";
|
import { IPlayer } from "../../IPlayer";
|
||||||
|
|
||||||
|
import { CraftableAugmentation } from "../CraftableAugmentation";
|
||||||
|
|
||||||
|
const CraftableAugmentations: IMap<CraftableAugmentation> = {}
|
||||||
|
|
||||||
const getAvailableAugs = (player: IPlayer): string[] => {
|
const getAvailableAugs = (player: IPlayer): string[] => {
|
||||||
const augs: string[] = [];
|
const augs: string[] = [];
|
||||||
|
|
||||||
@ -41,6 +47,13 @@ const getAvailableAugs = (player: IPlayer): string[] => {
|
|||||||
export const GraftingRoot = (): React.ReactElement => {
|
export const GraftingRoot = (): React.ReactElement => {
|
||||||
const player = use.Player();
|
const player = use.Player();
|
||||||
const router = use.Router();
|
const router = use.Router();
|
||||||
|
|
||||||
|
for (const aug of Object.values(Augmentations)) {
|
||||||
|
const name = aug.name;
|
||||||
|
const craftableAug = new CraftableAugmentation(aug);
|
||||||
|
CraftableAugmentations[name] = craftableAug;
|
||||||
|
}
|
||||||
|
|
||||||
const [selectedAug, setSelectedAug] = useState(getAvailableAugs(player)[0]);
|
const [selectedAug, setSelectedAug] = useState(getAvailableAugs(player)[0]);
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
@ -78,16 +91,22 @@ export const GraftingRoot = (): React.ReactElement => {
|
|||||||
<Button
|
<Button
|
||||||
onClick={event => {
|
onClick={event => {
|
||||||
if (!event.isTrusted) return;
|
if (!event.isTrusted) return;
|
||||||
player.startCraftAugmentationWork(selectedAug, 15000);
|
const craftableAug = CraftableAugmentations[selectedAug];
|
||||||
|
player.loseMoney(craftableAug.cost, "augmentations");
|
||||||
|
player.startCraftAugmentationWork(selectedAug, craftableAug.time);
|
||||||
player.startFocusing();
|
player.startFocusing();
|
||||||
router.toWork();
|
router.toWork();
|
||||||
}}
|
}}
|
||||||
sx={{ width: '100%' }}
|
sx={{ width: '100%' }}
|
||||||
|
disabled={player.money < CraftableAugmentations[selectedAug].cost}
|
||||||
>
|
>
|
||||||
Craft Augmentation (<Typography color={Settings.theme.money}>$foo</Typography>)
|
Craft Augmentation (
|
||||||
|
<Typography color={Settings.theme.money}>
|
||||||
|
<Money money={CraftableAugmentations[selectedAug].cost} player={player} />
|
||||||
|
</Typography>)
|
||||||
</Button>
|
</Button>
|
||||||
<Typography color={Settings.theme.info}>
|
<Typography color={Settings.theme.info}>
|
||||||
<b>Time to Craft:</b> bar
|
<b>Time to Craft:</b> {convertTimeMsToTimeElapsedString(CraftableAugmentations[selectedAug].time)}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography sx={{ maxHeight: 305, overflowY: 'scroll' }}>
|
<Typography sx={{ maxHeight: 305, overflowY: 'scroll' }}>
|
||||||
{(() => {
|
{(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user