2022-03-22 12:24:32 +01:00
|
|
|
import { Augmentation } from "./Augmentation";
|
2022-04-14 19:19:51 +02:00
|
|
|
import { StaticAugmentations } from "./StaticAugmentations";
|
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-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 {
|
2022-04-04 13:50:01 +02:00
|
|
|
initBladeburnerAugmentations,
|
|
|
|
initChurchOfTheMachineGodAugmentations,
|
|
|
|
initGeneralAugmentations,
|
2022-04-22 21:30:49 +02:00
|
|
|
initSoAAugmentations,
|
2022-03-22 12:24:32 +01:00
|
|
|
initNeuroFluxGovernor,
|
|
|
|
initUnstableCircadianModulator,
|
2022-03-31 13:00:15 +02:00
|
|
|
} from "./data/AugmentationCreator";
|
2022-04-04 12:29:43 +02:00
|
|
|
import { Router } from "../ui/GameRoot";
|
2016-12-22 16:56:15 +01:00
|
|
|
|
2022-04-14 19:19:51 +02:00
|
|
|
export function AddToStaticAugmentations(aug: Augmentation): void {
|
2022-03-30 13:17:24 +02:00
|
|
|
const name = aug.name;
|
2022-04-14 19:19:51 +02:00
|
|
|
StaticAugmentations[name] = aug;
|
2022-03-24 15:33:38 +01:00
|
|
|
}
|
2021-09-05 01:09:30 +02:00
|
|
|
|
2022-03-22 12:24:32 +01:00
|
|
|
function createAugmentations(): void {
|
|
|
|
[
|
|
|
|
initNeuroFluxGovernor(),
|
|
|
|
initUnstableCircadianModulator(),
|
2022-04-04 13:50:01 +02:00
|
|
|
...initGeneralAugmentations(),
|
2022-04-22 21:30:49 +02:00
|
|
|
...initSoAAugmentations(),
|
2022-04-04 13:50:01 +02:00
|
|
|
...(factionExists(FactionNames.Bladeburners) ? initBladeburnerAugmentations() : []),
|
|
|
|
...(factionExists(FactionNames.ChurchOfTheMachineGod) ? initChurchOfTheMachineGodAugmentations() : []),
|
2022-03-22 12:24:32 +01:00
|
|
|
].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();
|
2022-04-14 19:19:51 +02:00
|
|
|
clearObject(StaticAugmentations);
|
2022-03-22 12:24:32 +01:00
|
|
|
createAugmentations();
|
|
|
|
Player.reapplyAllAugmentations();
|
|
|
|
}
|
2022-03-19 05:15:24 +01:00
|
|
|
|
2022-04-14 19:39:38 +02:00
|
|
|
export function getBaseAugmentationPriceMultiplier(): number {
|
2022-04-14 07:22:50 +02:00
|
|
|
return CONSTANTS.MultipleAugMultiplier * [1, 0.96, 0.94, 0.93][Player.sourceFileLvl(11)];
|
2022-03-22 16:02:15 +01:00
|
|
|
}
|
|
|
|
export function getGenericAugmentationPriceMultiplier(): number {
|
|
|
|
return Math.pow(getBaseAugmentationPriceMultiplier(), Player.queuedAugmentations.length);
|
|
|
|
}
|
|
|
|
|
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)) {
|
2022-04-14 19:19:51 +02:00
|
|
|
delete StaticAugmentations[name];
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2022-04-14 19:19:51 +02:00
|
|
|
AddToStaticAugmentations(aug);
|
2016-12-22 16:56:15 +01:00
|
|
|
}
|
|
|
|
|
2021-09-24 22:02:38 +02:00
|
|
|
function applyAugmentation(aug: IPlayerOwnedAugmentation, reapply = false): void {
|
2022-04-14 19:19:51 +02:00
|
|
|
const staticAugmentation = StaticAugmentations[aug.name];
|
2019-01-17 06:15:00 +01:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
// Apply multipliers
|
2022-04-14 19:19:51 +02:00
|
|
|
for (const mult of Object.keys(staticAugmentation.mults)) {
|
|
|
|
const v = Player.getMult(mult) * staticAugmentation.mults[mult];
|
2021-09-24 22:02:38 +02:00
|
|
|
Player.setMult(mult, v);
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2019-01-15 14:11:14 +01:00
|
|
|
|
2022-04-07 07:48:39 +02:00
|
|
|
// Special logic for Congruity Implant
|
2022-04-07 18:25:12 +02:00
|
|
|
if (aug.name === AugmentationNames.CongruityImplant && !reapply) {
|
2022-04-07 07:48:39 +02:00
|
|
|
Player.entropy = 0;
|
2022-04-07 18:45:21 +02:00
|
|
|
Player.applyEntropy(Player.entropy);
|
2022-04-07 07:48:39 +02: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
|
|
|
}
|
|
|
|
|
2022-04-08 06:28:37 +02:00
|
|
|
function installAugmentations(force?: boolean): boolean {
|
|
|
|
if (Player.queuedAugmentations.length == 0 && !force) {
|
2021-09-05 01:09:30 +02:00
|
|
|
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];
|
2022-04-14 19:19:51 +02:00
|
|
|
const aug = StaticAugmentations[ownedAug.name];
|
2021-09-05 01:09:30 +02:00
|
|
|
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 = [];
|
2022-04-08 06:28:37 +02:00
|
|
|
if (!force) {
|
|
|
|
dialogBoxCreate(
|
|
|
|
"You slowly drift to sleep as scientists put you under in order " +
|
|
|
|
"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();
|
2022-04-04 12:29:43 +02:00
|
|
|
Router.toTerminal();
|
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 {
|
2022-04-14 19:19:51 +02:00
|
|
|
return StaticAugmentations.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 };
|