2022-03-22 12:24:32 +01:00
|
|
|
import { Augmentation } from "./Augmentation";
|
2019-05-15 09:15:07 +02:00
|
|
|
import { Augmentations } from "./Augmentations";
|
2021-09-24 22:02:38 +02:00
|
|
|
import { PlayerOwnedAugmentation, IPlayerOwnedAugmentation } from "./PlayerOwnedAugmentation";
|
2019-05-15 09:15:07 +02:00
|
|
|
import { AugmentationNames } from "./data/AugmentationNames";
|
|
|
|
|
|
|
|
import { CONSTANTS } from "../Constants";
|
|
|
|
import { Factions, factionExists } from "../Faction/Factions";
|
|
|
|
import { Player } from "../Player";
|
|
|
|
import { prestigeAugmentation } from "../Prestige";
|
2021-08-15 08:14:07 +02:00
|
|
|
import { SourceFileFlags } from "../SourceFile/SourceFileFlags";
|
2019-05-15 09:15:07 +02:00
|
|
|
|
2021-09-25 20:42:57 +02:00
|
|
|
import { dialogBoxCreate } from "../ui/React/DialogBox";
|
|
|
|
import { clearObject } from "../utils/helpers/clearObject";
|
2019-05-15 09:15:07 +02:00
|
|
|
|
2022-03-19 09:09:59 +01:00
|
|
|
import { FactionNames } from "../Faction/data/FactionNames";
|
2022-03-22 12:24:32 +01:00
|
|
|
import {
|
|
|
|
bladeburnerAugmentations,
|
|
|
|
churchOfTheMachineGodAugmentations,
|
|
|
|
generalAugmentations,
|
2022-03-29 17:42:57 +02:00
|
|
|
infiltratorsAugmentations,
|
2022-03-22 12:24:32 +01:00
|
|
|
initNeuroFluxGovernor,
|
|
|
|
initUnstableCircadianModulator,
|
2022-03-31 13:00:15 +02:00
|
|
|
} from "./data/AugmentationCreator";
|
2022-03-22 12:24:32 +01:00
|
|
|
import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers";
|
2016-12-22 16:56:15 +01:00
|
|
|
|
2022-03-30 13:17:24 +02:00
|
|
|
export function AddToAugmentations(aug: Augmentation): void {
|
|
|
|
const name = aug.name;
|
|
|
|
Augmentations[name] = aug;
|
|
|
|
}
|
|
|
|
|
2022-03-24 15:33:38 +01:00
|
|
|
export function getNextNeuroFluxLevel(): number {
|
|
|
|
// Get current Neuroflux level based on Player's augmentations
|
2021-09-05 01:09:30 +02:00
|
|
|
let currLevel = 0;
|
|
|
|
for (let i = 0; i < Player.augmentations.length; ++i) {
|
|
|
|
if (Player.augmentations[i].name === AugmentationNames.NeuroFluxGovernor) {
|
|
|
|
currLevel = Player.augmentations[i].level;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-24 15:33:38 +01:00
|
|
|
// Account for purchased but uninstalled Augmentations
|
2021-09-05 01:09:30 +02:00
|
|
|
for (let i = 0; i < Player.queuedAugmentations.length; ++i) {
|
2022-03-24 15:33:38 +01:00
|
|
|
if (Player.queuedAugmentations[i].name == AugmentationNames.NeuroFluxGovernor) {
|
|
|
|
++currLevel;
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
|
|
|
}
|
2022-03-24 15:33:38 +01:00
|
|
|
return currLevel + 1;
|
|
|
|
}
|
2021-09-05 01:09:30 +02:00
|
|
|
|
2022-03-22 12:24:32 +01:00
|
|
|
function createAugmentations(): void {
|
|
|
|
[
|
|
|
|
initNeuroFluxGovernor(),
|
|
|
|
initUnstableCircadianModulator(),
|
|
|
|
...generalAugmentations,
|
2022-03-29 17:42:57 +02:00
|
|
|
...infiltratorsAugmentations,
|
2022-03-22 12:24:32 +01:00
|
|
|
...(factionExists(FactionNames.Bladeburners) ? bladeburnerAugmentations : []),
|
|
|
|
...(factionExists(FactionNames.ChurchOfTheMachineGod) ? churchOfTheMachineGodAugmentations : []),
|
|
|
|
].map(resetAugmentation);
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2017-08-13 07:01:33 +02:00
|
|
|
|
2022-03-22 12:24:32 +01:00
|
|
|
function resetFactionAugmentations(): void {
|
2022-01-16 01:45:03 +01:00
|
|
|
for (const name of Object.keys(Factions)) {
|
2021-09-05 01:09:30 +02:00
|
|
|
if (Factions.hasOwnProperty(name)) {
|
|
|
|
Factions[name].augmentations = [];
|
|
|
|
}
|
|
|
|
}
|
2022-03-22 12:24:32 +01:00
|
|
|
}
|
2021-09-05 01:09:30 +02:00
|
|
|
|
2022-03-22 12:24:32 +01:00
|
|
|
function initAugmentations(): void {
|
|
|
|
resetFactionAugmentations();
|
2021-09-05 01:09:30 +02:00
|
|
|
clearObject(Augmentations);
|
2022-03-22 12:24:32 +01:00
|
|
|
createAugmentations();
|
|
|
|
updateAugmentationCosts();
|
|
|
|
Player.reapplyAllAugmentations();
|
|
|
|
}
|
2022-03-19 05:15:24 +01:00
|
|
|
|
2022-03-22 16:02:15 +01:00
|
|
|
function getBaseAugmentationPriceMultiplier(): number {
|
|
|
|
return CONSTANTS.MultipleAugMultiplier * [1, 0.96, 0.94, 0.93][SourceFileFlags[11]];
|
|
|
|
}
|
|
|
|
export function getGenericAugmentationPriceMultiplier(): number {
|
|
|
|
return Math.pow(getBaseAugmentationPriceMultiplier(), Player.queuedAugmentations.length);
|
|
|
|
}
|
|
|
|
|
2022-03-24 14:19:49 +01:00
|
|
|
function updateNeuroFluxGovernorCosts(neuroFluxGovernorAugmentation: Augmentation): void {
|
|
|
|
let nextLevel = getNextNeuroFluxLevel();
|
|
|
|
--nextLevel;
|
|
|
|
const multiplier = Math.pow(CONSTANTS.NeuroFluxGovernorLevelMult, nextLevel);
|
2022-03-30 13:14:51 +02:00
|
|
|
neuroFluxGovernorAugmentation.baseRepRequirement =
|
|
|
|
neuroFluxGovernorAugmentation.startingRepRequirement * multiplier * BitNodeMultipliers.AugmentationRepCost;
|
|
|
|
neuroFluxGovernorAugmentation.baseCost =
|
|
|
|
neuroFluxGovernorAugmentation.startingCost * multiplier * BitNodeMultipliers.AugmentationMoneyCost;
|
2022-03-24 14:19:49 +01:00
|
|
|
|
2022-03-30 15:53:53 +02:00
|
|
|
for (let i = 0; i < Player.queuedAugmentations.length; ++i) {
|
2022-03-24 14:19:49 +01:00
|
|
|
neuroFluxGovernorAugmentation.baseCost *= getBaseAugmentationPriceMultiplier();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateInfiltratorCosts(infiltratorAugmentation: Augmentation): void {
|
|
|
|
const infiltratorMultiplier =
|
2022-03-29 17:42:57 +02:00
|
|
|
infiltratorsAugmentations.filter((augmentation) => Player.hasAugmentation(augmentation.name)).length + 1;
|
|
|
|
infiltratorAugmentation.baseCost = Math.pow(infiltratorAugmentation.startingCost * 1000, infiltratorMultiplier);
|
|
|
|
if (infiltratorsAugmentations.find((augmentation) => augmentation.name === infiltratorAugmentation.name)) {
|
|
|
|
infiltratorAugmentation.baseRepRequirement = infiltratorAugmentation.startingRepRequirement * infiltratorMultiplier;
|
2022-03-24 14:19:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-22 12:24:32 +01:00
|
|
|
export function updateAugmentationCosts(): void {
|
2022-01-16 01:45:03 +01:00
|
|
|
for (const name of Object.keys(Augmentations)) {
|
2021-09-05 01:09:30 +02:00
|
|
|
if (Augmentations.hasOwnProperty(name)) {
|
2022-03-22 12:24:32 +01:00
|
|
|
const augmentationToUpdate = Augmentations[name];
|
|
|
|
if (augmentationToUpdate.name === AugmentationNames.NeuroFluxGovernor) {
|
2022-03-24 14:19:49 +01:00
|
|
|
updateNeuroFluxGovernorCosts(augmentationToUpdate);
|
2022-03-22 12:24:32 +01:00
|
|
|
} else if (augmentationToUpdate.factions.includes(FactionNames.Infiltrators)) {
|
2022-03-24 14:19:49 +01:00
|
|
|
updateInfiltratorCosts(augmentationToUpdate);
|
2022-03-21 16:17:36 +01:00
|
|
|
} else {
|
2022-03-31 16:40:53 +02:00
|
|
|
augmentationToUpdate.baseCost = augmentationToUpdate.startingCost * getGenericAugmentationPriceMultiplier();
|
2022-03-21 16:17:36 +01:00
|
|
|
}
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
|
|
|
}
|
2018-05-02 19:38:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//Resets an Augmentation during (re-initizliation)
|
2022-03-19 05:15:24 +01:00
|
|
|
function resetAugmentation(aug: Augmentation): void {
|
|
|
|
aug.addToFactions(aug.factions);
|
|
|
|
const name = aug.name;
|
2021-09-05 01:09:30 +02:00
|
|
|
if (augmentationExists(name)) {
|
|
|
|
delete Augmentations[name];
|
|
|
|
}
|
2022-03-19 05:15:24 +01:00
|
|
|
AddToAugmentations(aug);
|
2016-12-22 16:56:15 +01:00
|
|
|
}
|
|
|
|
|
2021-09-24 22:02:38 +02:00
|
|
|
function applyAugmentation(aug: IPlayerOwnedAugmentation, reapply = false): void {
|
2021-09-05 01:09:30 +02:00
|
|
|
Augmentations[aug.name].owned = true;
|
2019-01-15 14:11:14 +01:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
const augObj = Augmentations[aug.name];
|
2019-01-17 06:15:00 +01:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
// Apply multipliers
|
2022-01-16 01:45:03 +01:00
|
|
|
for (const mult of Object.keys(augObj.mults)) {
|
2021-09-24 22:02:38 +02:00
|
|
|
const v = Player.getMult(mult) * augObj.mults[mult];
|
|
|
|
Player.setMult(mult, v);
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2019-01-15 14:11:14 +01:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
// Special logic for NeuroFlux Governor
|
|
|
|
if (aug.name === AugmentationNames.NeuroFluxGovernor) {
|
|
|
|
if (!reapply) {
|
|
|
|
Augmentations[aug.name].level = aug.level;
|
|
|
|
for (let i = 0; i < Player.augmentations.length; ++i) {
|
2021-09-09 05:47:34 +02:00
|
|
|
if (Player.augmentations[i].name == AugmentationNames.NeuroFluxGovernor) {
|
2021-09-05 01:09:30 +02:00
|
|
|
Player.augmentations[i].level = aug.level;
|
|
|
|
return;
|
|
|
|
// break;
|
2019-01-15 14:11:14 +01:00
|
|
|
}
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2017-02-17 23:19:25 +01:00
|
|
|
}
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2017-02-17 23:19:25 +01:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
// Push onto Player's Augmentation list
|
|
|
|
if (!reapply) {
|
2021-09-25 07:26:03 +02:00
|
|
|
const ownedAug = new PlayerOwnedAugmentation(aug.name);
|
2021-09-05 01:09:30 +02:00
|
|
|
Player.augmentations.push(ownedAug);
|
|
|
|
}
|
2017-05-30 00:37:38 +02:00
|
|
|
}
|
|
|
|
|
2021-09-25 08:36:49 +02:00
|
|
|
function installAugmentations(): boolean {
|
2021-09-05 01:09:30 +02:00
|
|
|
if (Player.queuedAugmentations.length == 0) {
|
|
|
|
dialogBoxCreate("You have not purchased any Augmentations to install!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
let augmentationList = "";
|
|
|
|
let nfgIndex = -1;
|
|
|
|
for (let i = Player.queuedAugmentations.length - 1; i >= 0; i--) {
|
2021-09-09 05:47:34 +02:00
|
|
|
if (Player.queuedAugmentations[i].name === AugmentationNames.NeuroFluxGovernor) {
|
2021-09-05 01:09:30 +02:00
|
|
|
nfgIndex = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (let i = 0; i < Player.queuedAugmentations.length; ++i) {
|
|
|
|
const ownedAug = Player.queuedAugmentations[i];
|
|
|
|
const aug = Augmentations[ownedAug.name];
|
|
|
|
if (aug == null) {
|
|
|
|
console.error(`Invalid augmentation: ${ownedAug.name}`);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
applyAugmentation(Player.queuedAugmentations[i]);
|
2021-09-09 05:47:34 +02:00
|
|
|
if (ownedAug.name === AugmentationNames.NeuroFluxGovernor && i !== nfgIndex) continue;
|
2021-09-05 01:09:30 +02:00
|
|
|
|
|
|
|
let level = "";
|
|
|
|
if (ownedAug.name === AugmentationNames.NeuroFluxGovernor) {
|
|
|
|
level = ` - ${ownedAug.level}`;
|
|
|
|
}
|
|
|
|
augmentationList += aug.name + level + "<br>";
|
|
|
|
}
|
|
|
|
Player.queuedAugmentations = [];
|
|
|
|
dialogBoxCreate(
|
|
|
|
"You slowly drift to sleep as scientists put you under in order " +
|
2022-03-22 12:24:32 +01:00
|
|
|
"to install the following Augmentations:<br>" +
|
|
|
|
augmentationList +
|
|
|
|
"<br>You wake up in your home...you feel different...",
|
2021-09-05 01:09:30 +02:00
|
|
|
);
|
|
|
|
prestigeAugmentation();
|
2021-09-25 08:36:49 +02:00
|
|
|
return true;
|
2017-06-26 01:39:17 +02:00
|
|
|
}
|
|
|
|
|
2021-09-25 08:36:49 +02:00
|
|
|
function augmentationExists(name: string): boolean {
|
2021-09-05 01:09:30 +02:00
|
|
|
return Augmentations.hasOwnProperty(name);
|
2017-06-18 06:36:16 +02:00
|
|
|
}
|
|
|
|
|
2021-09-24 22:02:38 +02:00
|
|
|
export function isRepeatableAug(aug: Augmentation): boolean {
|
2021-09-05 01:09:30 +02:00
|
|
|
const augName = aug instanceof Augmentation ? aug.name : aug;
|
2022-03-01 20:37:47 +01:00
|
|
|
return augName === AugmentationNames.NeuroFluxGovernor;
|
2019-05-14 10:35:37 +02:00
|
|
|
}
|
2018-03-27 02:46:21 +02:00
|
|
|
|
2021-09-09 05:47:34 +02:00
|
|
|
export { installAugmentations, initAugmentations, applyAugmentation, augmentationExists };
|