Implement CraftableAugmentation

This commit is contained in:
nickofolas 2022-03-19 11:03:18 -05:00
parent dc5b925f65
commit fef5ab31b2
3 changed files with 56 additions and 4 deletions

@ -109,6 +109,8 @@ export const CONSTANTS: {
CodingContractBaseFactionRepGain: number;
CodingContractBaseCompanyRepGain: number;
CodingContractBaseMoneyGain: number;
AugmentationCraftingCostMult: number;
AugmentationCraftingTimeMult: number;
TotalNumBitNodes: number;
LatestUpdate: string;
} = {
@ -271,6 +273,11 @@ export const CONSTANTS: {
CodingContractBaseCompanyRepGain: 4000,
CodingContractBaseMoneyGain: 75e6,
// Augmentation crafting multipliers
// TODO: Get these right
AugmentationCraftingCostMult: 1.2,
AugmentationCraftingTimeMult: 1,
// BitNode/Source-File related stuff
TotalNumBitNodes: 24,

@ -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";
import { use } from "../../../ui/Context";
import { Money } from "../../../ui/React/Money";
import { Augmentations } from "../../../Augmentation/Augmentations";
import { AugmentationNames } from "../../../Augmentation/data/AugmentationNames"
import { Settings } from "../../../Settings/Settings";
import { CONSTANTS } from "../../../Constants";
import { IMap } from "../../../types";
import { convertTimeMsToTimeElapsedString } from "../../../utils/StringHelperFunctions";
import { IPlayer } from "../../IPlayer";
import { CraftableAugmentation } from "../CraftableAugmentation";
const CraftableAugmentations: IMap<CraftableAugmentation> = {}
const getAvailableAugs = (player: IPlayer): string[] => {
const augs: string[] = [];
@ -41,6 +47,13 @@ const getAvailableAugs = (player: IPlayer): string[] => {
export const GraftingRoot = (): React.ReactElement => {
const player = use.Player();
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]);
return <>
@ -78,16 +91,22 @@ export const GraftingRoot = (): React.ReactElement => {
<Button
onClick={event => {
if (!event.isTrusted) return;
player.startCraftAugmentationWork(selectedAug, 15000);
const craftableAug = CraftableAugmentations[selectedAug];
player.loseMoney(craftableAug.cost, "augmentations");
player.startCraftAugmentationWork(selectedAug, craftableAug.time);
player.startFocusing();
router.toWork();
}}
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>
<Typography color={Settings.theme.info}>
<b>Time to Craft:</b> bar
<b>Time to Craft:</b> {convertTimeMsToTimeElapsedString(CraftableAugmentations[selectedAug].time)}
</Typography>
<Typography sx={{ maxHeight: 305, overflowY: 'scroll' }}>
{(() => {