mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-11 02:03:58 +01:00
reafactored augmentations helpers to have another file it was getting tooooo big
reused duplicated code
This commit is contained in:
parent
dc9c05b345
commit
78c0cac50b
2056
src/Augmentation/AugmentationCreator.tsx
Normal file
2056
src/Augmentation/AugmentationCreator.tsx
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -19,7 +19,8 @@ import { SourceFileFlags } from "../SourceFile/SourceFileFlags";
|
|||||||
import { dialogBoxCreate } from "../ui/React/DialogBox";
|
import { dialogBoxCreate } from "../ui/React/DialogBox";
|
||||||
import { InvitationEvent } from "./ui/InvitationModal";
|
import { InvitationEvent } from "./ui/InvitationModal";
|
||||||
import { FactionNames } from "./data/FactionNames";
|
import { FactionNames } from "./data/FactionNames";
|
||||||
import { infiltratorsAugmentations } from "../Augmentation/AugmentationHelpers";
|
import { updateAugmentationCosts } from "../Augmentation/AugmentationHelpers";
|
||||||
|
import { getNextNeuroFluxLevel } from "../Augmentation/AugmentationCreator";
|
||||||
|
|
||||||
export function inviteToFaction(faction: Faction): void {
|
export function inviteToFaction(faction: Faction): void {
|
||||||
Player.receiveInvite(faction.name);
|
Player.receiveInvite(faction.name);
|
||||||
@ -33,9 +34,8 @@ export function joinFaction(faction: Faction): void {
|
|||||||
if (faction.isMember) return;
|
if (faction.isMember) return;
|
||||||
faction.isMember = true;
|
faction.isMember = true;
|
||||||
Player.factions.push(faction.name);
|
Player.factions.push(faction.name);
|
||||||
const allFactions = Object.values(FactionNames).map(faction => faction as string)
|
const allFactions = Object.values(FactionNames).map((faction) => faction as string);
|
||||||
Player.factions.sort((a, b) =>
|
Player.factions.sort((a, b) => allFactions.indexOf(a) - allFactions.indexOf(b));
|
||||||
allFactions.indexOf(a) - allFactions.indexOf(b));
|
|
||||||
const factionInfo = faction.getInfo();
|
const factionInfo = faction.getInfo();
|
||||||
|
|
||||||
//Determine what factions you are banned from now that you have joined this faction
|
//Determine what factions you are banned from now that you have joined this faction
|
||||||
@ -105,7 +105,7 @@ export function purchaseAugmentation(aug: Augmentation, fac: Faction, sing = fal
|
|||||||
} else if (aug.baseCost === 0 || Player.money >= aug.baseCost * factionInfo.augmentationPriceMult) {
|
} else if (aug.baseCost === 0 || Player.money >= aug.baseCost * factionInfo.augmentationPriceMult) {
|
||||||
const queuedAugmentation = new PlayerOwnedAugmentation(aug.name);
|
const queuedAugmentation = new PlayerOwnedAugmentation(aug.name);
|
||||||
if (aug.name == AugmentationNames.NeuroFluxGovernor) {
|
if (aug.name == AugmentationNames.NeuroFluxGovernor) {
|
||||||
queuedAugmentation.level = getNextNeurofluxLevel();
|
queuedAugmentation.level = getNextNeuroFluxLevel();
|
||||||
}
|
}
|
||||||
Player.queuedAugmentations.push(queuedAugmentation);
|
Player.queuedAugmentations.push(queuedAugmentation);
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ export function purchaseAugmentation(aug: Augmentation, fac: Faction, sing = fal
|
|||||||
|
|
||||||
// If you just purchased Neuroflux Governor, recalculate the cost
|
// If you just purchased Neuroflux Governor, recalculate the cost
|
||||||
if (aug.name == AugmentationNames.NeuroFluxGovernor) {
|
if (aug.name == AugmentationNames.NeuroFluxGovernor) {
|
||||||
let nextLevel = getNextNeurofluxLevel();
|
let nextLevel = getNextNeuroFluxLevel();
|
||||||
--nextLevel;
|
--nextLevel;
|
||||||
const mult = Math.pow(CONSTANTS.NeuroFluxGovernorLevelMult, nextLevel);
|
const mult = Math.pow(CONSTANTS.NeuroFluxGovernorLevelMult, nextLevel);
|
||||||
aug.baseRepRequirement = 500 * mult * BitNodeMultipliers.AugmentationRepCost;
|
aug.baseRepRequirement = 500 * mult * BitNodeMultipliers.AugmentationRepCost;
|
||||||
@ -124,22 +124,7 @@ export function purchaseAugmentation(aug: Augmentation, fac: Faction, sing = fal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If you just purchased an infiltrator aug, recalculate cost
|
updateAugmentationCosts();
|
||||||
if (infiltratorsAugmentations.map(augmentation => augmentation.name).includes(aug.name)) {
|
|
||||||
const unpurchasedInfiltrationAugs = infiltratorsAugmentations.filter(augmentation => Player.hasAugmentation(augmentation.name, false))
|
|
||||||
const purchasedInfiltrationAugsCount = infiltratorsAugmentations.length - unpurchasedInfiltrationAugs.length
|
|
||||||
unpurchasedInfiltrationAugs
|
|
||||||
.map(augmentation => {
|
|
||||||
augmentation.baseRepRequirement = augmentation.startingCost * purchasedInfiltrationAugsCount
|
|
||||||
augmentation.baseCost = augmentation.startingRepRequirement ^ purchasedInfiltrationAugsCount
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const name of Object.keys(Augmentations)) {
|
|
||||||
if (Augmentations.hasOwnProperty(name)) {
|
|
||||||
Augmentations[name].baseCost *= CONSTANTS.MultipleAugMultiplier * [1, 0.96, 0.94, 0.93][SourceFileFlags[11]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sing) {
|
if (sing) {
|
||||||
return "You purchased " + aug.name;
|
return "You purchased " + aug.name;
|
||||||
@ -163,24 +148,6 @@ export function purchaseAugmentation(aug: Augmentation, fac: Faction, sing = fal
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getNextNeurofluxLevel(): number {
|
|
||||||
// Get current Neuroflux level based on Player's augmentations
|
|
||||||
let currLevel = 0;
|
|
||||||
for (let i = 0; i < Player.augmentations.length; ++i) {
|
|
||||||
if (Player.augmentations[i].name === AugmentationNames.NeuroFluxGovernor) {
|
|
||||||
currLevel = Player.augmentations[i].level;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Account for purchased but uninstalled Augmentations
|
|
||||||
for (let i = 0; i < Player.queuedAugmentations.length; ++i) {
|
|
||||||
if (Player.queuedAugmentations[i].name == AugmentationNames.NeuroFluxGovernor) {
|
|
||||||
++currLevel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return currLevel + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function processPassiveFactionRepGain(numCycles: number): void {
|
export function processPassiveFactionRepGain(numCycles: number): void {
|
||||||
for (const name of Object.keys(Factions)) {
|
for (const name of Object.keys(Factions)) {
|
||||||
if (name === Player.currentWorkFactionName) continue;
|
if (name === Player.currentWorkFactionName) continue;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
|
|
||||||
import { getNextNeurofluxLevel, hasAugmentationPrereqs, purchaseAugmentation } from "../FactionHelpers";
|
import { hasAugmentationPrereqs, purchaseAugmentation } from "../FactionHelpers";
|
||||||
import { PurchaseAugmentationModal } from "./PurchaseAugmentationModal";
|
import { PurchaseAugmentationModal } from "./PurchaseAugmentationModal";
|
||||||
|
|
||||||
import { Augmentations } from "../../Augmentation/Augmentations";
|
import { Augmentations } from "../../Augmentation/Augmentations";
|
||||||
@ -22,6 +22,7 @@ import Tooltip from "@mui/material/Tooltip";
|
|||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import { TableCell } from "../../ui/React/Table";
|
import { TableCell } from "../../ui/React/Table";
|
||||||
import TableRow from "@mui/material/TableRow";
|
import TableRow from "@mui/material/TableRow";
|
||||||
|
import { getNextNeuroFluxLevel } from "../../Augmentation/AugmentationCreator";
|
||||||
|
|
||||||
interface IReqProps {
|
interface IReqProps {
|
||||||
augName: string;
|
augName: string;
|
||||||
@ -96,7 +97,7 @@ export function PurchaseableAugmentation(props: IProps): React.ReactElement {
|
|||||||
// Determine button txt
|
// Determine button txt
|
||||||
let btnTxt = aug.name;
|
let btnTxt = aug.name;
|
||||||
if (aug.name === AugmentationNames.NeuroFluxGovernor) {
|
if (aug.name === AugmentationNames.NeuroFluxGovernor) {
|
||||||
btnTxt += ` - Level ${getNextNeurofluxLevel()}`;
|
btnTxt += ` - Level ${getNextNeuroFluxLevel()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
let tooltip = <></>;
|
let tooltip = <></>;
|
||||||
|
Loading…
Reference in New Issue
Block a user