merge base

This commit is contained in:
phyzical 2022-03-31 22:36:47 +08:00
commit 2edfb6e35d
16 changed files with 207 additions and 148 deletions

32
dist/vendor.bundle.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -110,7 +110,6 @@ function updateGeneralAugmentationPrice(augmentation: Augmentation): void {
} }
export function updateAugmentationCosts(): void { export function updateAugmentationCosts(): void {
console.log(Player.queuedAugmentations);
for (const name of Object.keys(Augmentations)) { for (const name of Object.keys(Augmentations)) {
if (Augmentations.hasOwnProperty(name)) { if (Augmentations.hasOwnProperty(name)) {
const augmentationToUpdate = Augmentations[name]; const augmentationToUpdate = Augmentations[name];

@ -863,7 +863,7 @@ export const generalAugmentations = [
"so that the brain doesn't have to.", "so that the brain doesn't have to.",
hacking_speed_mult: 1.01, hacking_speed_mult: 1.01,
hacking_mult: 1.05, hacking_mult: 1.05,
factions: [FactionNames.CyberSec], factions: [FactionNames.CyberSec, FactionNames.NiteSec],
}), }),
new Augmentation({ new Augmentation({
name: AugmentationNames.CranialSignalProcessorsG2, name: AugmentationNames.CranialSignalProcessorsG2,

@ -82,7 +82,9 @@ BitNodes["BitNode2"] = new BitNode(
<br /> <br />
The amount of money gained from crimes and Infiltration is tripled The amount of money gained from crimes and Infiltration is tripled
<br /> <br />
Certain Factions ({FactionNames.SlumSnakes}, {FactionNames.Tetrads}, {FactionNames.TheSyndicate}, {FactionNames.TheDarkArmy}, {FactionNames.SpeakersForTheDead}, {FactionNames.NiteSec}, {FactionNames.TheBlackHand}) give the player the ability to form and manage their own gangs. These gangs will earn the player money and Certain Factions ({FactionNames.SlumSnakes}, {FactionNames.Tetrads}, {FactionNames.TheSyndicate},{" "}
{FactionNames.TheDarkArmy}, {FactionNames.SpeakersForTheDead}, {FactionNames.NiteSec}, {FactionNames.TheBlackHand}
) give the player the ability to form and manage their own gangs. These gangs will earn the player money and
reputation with the corresponding Faction reputation with the corresponding Faction
<br /> <br />
Every Augmentation in the game will be available through the Factions listed above Every Augmentation in the game will be available through the Factions listed above
@ -225,15 +227,15 @@ BitNodes["BitNode6"] = new BitNode(
"Like Tears in Rain", "Like Tears in Rain",
( (
<> <>
In the middle of the 21st century, {FactionNames.OmniTekIncorporated} began designing and manufacturing advanced synthetic In the middle of the 21st century, {FactionNames.OmniTekIncorporated} began designing and manufacturing advanced
androids, or Synthoids for short. They achieved a major technological breakthrough in the sixth generation of synthetic androids, or Synthoids for short. They achieved a major technological breakthrough in the sixth
their Synthoid design, called MK-VI, by developing a hyperintelligent AI. Many argue that this was the first generation of their Synthoid design, called MK-VI, by developing a hyperintelligent AI. Many argue that this was
sentient AI ever created. This resulted in Synthoid models that were stronger, faster, and more intelligent than the first sentient AI ever created. This resulted in Synthoid models that were stronger, faster, and more
the humans that had created them. intelligent than the humans that had created them.
<br /> <br />
<br /> <br />
In this BitNode you will be able to access the {FactionNames.Bladeburners} Division at the NSA, which provides a new mechanic for In this BitNode you will be able to access the {FactionNames.Bladeburners} Division at the NSA, which provides a
progression. Furthermore: new mechanic for progression. Furthermore:
<br /> <br />
<br /> <br />
Hacking and Hacknet Nodes will be less profitable Hacking and Hacknet Nodes will be less profitable
@ -250,9 +252,9 @@ BitNodes["BitNode6"] = new BitNode(
<br /> <br />
<br /> <br />
Destroying this BitNode will give you Source-File 6, or if you already have this Source-File it will upgrade its Destroying this BitNode will give you Source-File 6, or if you already have this Source-File it will upgrade its
level up to a maximum of 3. This Source-File allows you to access the NSA's {FactionNames.Bladeburners} Division in other level up to a maximum of 3. This Source-File allows you to access the NSA's {FactionNames.Bladeburners} Division
BitNodes. In addition, this Source-File will raise both the level and experience gain rate of all your combat in other BitNodes. In addition, this Source-File will raise both the level and experience gain rate of all your
stats by: combat stats by:
<br /> <br />
<br /> <br />
Level 1: 8% Level 1: 8%
@ -270,14 +272,15 @@ BitNodes["BitNode7"] = new BitNode(
"More human than humans", "More human than humans",
( (
<> <>
In the middle of the 21st century, you were doing cutting-edge work at {FactionNames.OmniTekIncorporated} as part of the AI In the middle of the 21st century, you were doing cutting-edge work at {FactionNames.OmniTekIncorporated} as part
design team for advanced synthetic androids, or Synthoids for short. You helped achieve a major technological of the AI design team for advanced synthetic androids, or Synthoids for short. You helped achieve a major
breakthrough in the sixth generation of the company's Synthoid design, called MK-VI, by developing a technological breakthrough in the sixth generation of the company's Synthoid design, called MK-VI, by developing a
hyperintelligent AI. Many argue that this was the first sentient AI ever created. This resulted in Synthoid models hyperintelligent AI. Many argue that this was the first sentient AI ever created. This resulted in Synthoid models
that were stronger, faster, and more intelligent than the humans that had created them. that were stronger, faster, and more intelligent than the humans that had created them.
<br /> <br />
<br /> <br />
In this BitNode you will be able to access the {FactionNames.Bladeburners} API, which allows you to access {FactionNames.Bladeburners} In this BitNode you will be able to access the {FactionNames.Bladeburners} API, which allows you to access{" "}
{FactionNames.Bladeburners}
functionality through Netscript. Furthermore: <br /> functionality through Netscript. Furthermore: <br />
<br /> <br />
The rank you gain from {FactionNames.Bladeburners} contracts/operations is reduced by 40% The rank you gain from {FactionNames.Bladeburners} contracts/operations is reduced by 40%
@ -300,8 +303,9 @@ BitNodes["BitNode7"] = new BitNode(
<br /> <br />
<br /> <br />
Destroying this BitNode will give you Source-File 7, or if you already have this Source-File it will upgrade its Destroying this BitNode will give you Source-File 7, or if you already have this Source-File it will upgrade its
level up to a maximum of 3. This Source-File allows you to access the {FactionNames.Bladeburners} Netscript API in other BitNodes. level up to a maximum of 3. This Source-File allows you to access the {FactionNames.Bladeburners} Netscript API in
In addition, this Source-File will increase all of your {FactionNames.Bladeburners} multipliers by: other BitNodes. In addition, this Source-File will increase all of your {FactionNames.Bladeburners} multipliers
by:
<br /> <br />
<br /> <br />
Level 1: 8% Level 1: 8%
@ -364,10 +368,10 @@ BitNodes["BitNode9"] = new BitNode(
"Hacknet Unleashed", "Hacknet Unleashed",
( (
<> <>
When {FactionNames.FulcrumSecretTechnologies} released their open-source Linux distro Chapeau, it quickly became the OS of choice for When {FactionNames.FulcrumSecretTechnologies} released their open-source Linux distro Chapeau, it quickly became
the underground hacking community. Chapeau became especially notorious for powering the Hacknet, a global, the OS of choice for the underground hacking community. Chapeau became especially notorious for powering the
decentralized network used for nefarious purposes. {FactionNames.FulcrumSecretTechnologies} quickly abandoned the project and dissociated Hacknet, a global, decentralized network used for nefarious purposes. {FactionNames.FulcrumSecretTechnologies}{" "}
themselves from it. quickly abandoned the project and dissociated themselves from it.
<br /> <br />
<br /> <br />
This BitNode unlocks the Hacknet Server, an upgraded version of the Hacknet Node. Hacknet Servers generate hashes, This BitNode unlocks the Hacknet Server, an upgraded version of the Hacknet Node. Hacknet Servers generate hashes,
@ -538,8 +542,8 @@ BitNodes["BitNode13"] = new BitNode(
"1 step back, 2 steps forward", "1 step back, 2 steps forward",
( (
<> <>
With the invention of Augmentations in the 2040s a religious group known as the {FactionNames.ChurchOfTheMachineGod} has With the invention of Augmentations in the 2040s a religious group known as the{" "}
rallied far more support than anyone would have hoped. {FactionNames.ChurchOfTheMachineGod} has rallied far more support than anyone would have hoped.
<br /> <br />
<br /> <br />
Their leader, Allison "Mother" Stanek is said to have created her own Augmentation whose power goes beyond any Their leader, Allison "Mother" Stanek is said to have created her own Augmentation whose power goes beyond any
@ -555,7 +559,8 @@ BitNodes["BitNode13"] = new BitNode(
<br /> <br />
<br /> <br />
Destroying this BitNode will give you Source-File 13, or if you already have this Source-File it will upgrade its Destroying this BitNode will give you Source-File 13, or if you already have this Source-File it will upgrade its
level up to a maximum of 3. This Source-File lets the {FactionNames.ChurchOfTheMachineGod} appear in other BitNodes. level up to a maximum of 3. This Source-File lets the {FactionNames.ChurchOfTheMachineGod} appear in other
BitNodes.
<br /> <br />
<br /> <br />
Each level of this Source-File increases the size of Stanek's Gift. Each level of this Source-File increases the size of Stanek's Gift.
@ -624,6 +629,7 @@ export function initBitNodeMultipliers(p: IPlayer): void {
BitNodeMultipliers.PurchasedServerSoftcap = 1.3; BitNodeMultipliers.PurchasedServerSoftcap = 1.3;
BitNodeMultipliers.GangSoftcap = 0.9; BitNodeMultipliers.GangSoftcap = 0.9;
BitNodeMultipliers.WorldDaemonDifficulty = 2; BitNodeMultipliers.WorldDaemonDifficulty = 2;
BitNodeMultipliers.GangUniqueAugs = 0.5;
break; break;
case 4: // The Singularity case 4: // The Singularity
BitNodeMultipliers.ServerMaxMoney = 0.15; BitNodeMultipliers.ServerMaxMoney = 0.15;
@ -642,6 +648,7 @@ export function initBitNodeMultipliers(p: IPlayer): void {
BitNodeMultipliers.StaneksGiftExtraSize = 0; BitNodeMultipliers.StaneksGiftExtraSize = 0;
BitNodeMultipliers.PurchasedServerSoftcap = 1.2; BitNodeMultipliers.PurchasedServerSoftcap = 1.2;
BitNodeMultipliers.WorldDaemonDifficulty = 3; BitNodeMultipliers.WorldDaemonDifficulty = 3;
BitNodeMultipliers.GangUniqueAugs = 0.5;
break; break;
case 5: // Artificial intelligence case 5: // Artificial intelligence
BitNodeMultipliers.ServerMaxMoney = 2; BitNodeMultipliers.ServerMaxMoney = 2;
@ -659,6 +666,7 @@ export function initBitNodeMultipliers(p: IPlayer): void {
BitNodeMultipliers.StaneksGiftExtraSize = 0; BitNodeMultipliers.StaneksGiftExtraSize = 0;
BitNodeMultipliers.PurchasedServerSoftcap = 1.2; BitNodeMultipliers.PurchasedServerSoftcap = 1.2;
BitNodeMultipliers.WorldDaemonDifficulty = 1.5; BitNodeMultipliers.WorldDaemonDifficulty = 1.5;
BitNodeMultipliers.GangUniqueAugs = 0.5;
break; break;
case 6: // Bladeburner case 6: // Bladeburner
BitNodeMultipliers.HackingLevelMultiplier = 0.35; BitNodeMultipliers.HackingLevelMultiplier = 0.35;
@ -679,6 +687,7 @@ export function initBitNodeMultipliers(p: IPlayer): void {
BitNodeMultipliers.GangSoftcap = 0.7; BitNodeMultipliers.GangSoftcap = 0.7;
BitNodeMultipliers.CorporationSoftCap = 0.9; BitNodeMultipliers.CorporationSoftCap = 0.9;
BitNodeMultipliers.WorldDaemonDifficulty = 2; BitNodeMultipliers.WorldDaemonDifficulty = 2;
BitNodeMultipliers.GangUniqueAugs = 0.2;
break; break;
case 7: // Bladeburner 2079 case 7: // Bladeburner 2079
BitNodeMultipliers.BladeburnerRank = 0.6; BitNodeMultipliers.BladeburnerRank = 0.6;
@ -704,6 +713,7 @@ export function initBitNodeMultipliers(p: IPlayer): void {
BitNodeMultipliers.GangSoftcap = 0.7; BitNodeMultipliers.GangSoftcap = 0.7;
BitNodeMultipliers.CorporationSoftCap = 0.9; BitNodeMultipliers.CorporationSoftCap = 0.9;
BitNodeMultipliers.WorldDaemonDifficulty = 2; BitNodeMultipliers.WorldDaemonDifficulty = 2;
BitNodeMultipliers.GangUniqueAugs = 0.2;
break; break;
case 8: // Ghost of Wall Street case 8: // Ghost of Wall Street
BitNodeMultipliers.ScriptHackMoney = 0.3; BitNodeMultipliers.ScriptHackMoney = 0.3;
@ -720,6 +730,7 @@ export function initBitNodeMultipliers(p: IPlayer): void {
BitNodeMultipliers.PurchasedServerSoftcap = 4; BitNodeMultipliers.PurchasedServerSoftcap = 4;
BitNodeMultipliers.GangSoftcap = 0; BitNodeMultipliers.GangSoftcap = 0;
BitNodeMultipliers.CorporationSoftCap = 0; BitNodeMultipliers.CorporationSoftCap = 0;
BitNodeMultipliers.GangUniqueAugs = 0;
break; break;
case 9: // Hacktocracy case 9: // Hacktocracy
BitNodeMultipliers.HackingLevelMultiplier = 0.5; BitNodeMultipliers.HackingLevelMultiplier = 0.5;
@ -746,6 +757,7 @@ export function initBitNodeMultipliers(p: IPlayer): void {
BitNodeMultipliers.GangSoftcap = 0.8; BitNodeMultipliers.GangSoftcap = 0.8;
BitNodeMultipliers.CorporationSoftCap = 0.7; BitNodeMultipliers.CorporationSoftCap = 0.7;
BitNodeMultipliers.WorldDaemonDifficulty = 2; BitNodeMultipliers.WorldDaemonDifficulty = 2;
BitNodeMultipliers.GangUniqueAugs = 0.25;
break; break;
case 10: // Digital Carbon case 10: // Digital Carbon
BitNodeMultipliers.HackingLevelMultiplier = 0.35; BitNodeMultipliers.HackingLevelMultiplier = 0.35;
@ -775,6 +787,7 @@ export function initBitNodeMultipliers(p: IPlayer): void {
BitNodeMultipliers.GangSoftcap = 0.9; BitNodeMultipliers.GangSoftcap = 0.9;
BitNodeMultipliers.CorporationSoftCap = 0.9; BitNodeMultipliers.CorporationSoftCap = 0.9;
BitNodeMultipliers.WorldDaemonDifficulty = 2; BitNodeMultipliers.WorldDaemonDifficulty = 2;
BitNodeMultipliers.GangUniqueAugs = 0.25;
break; break;
case 11: //The Big Crash case 11: //The Big Crash
BitNodeMultipliers.HackingLevelMultiplier = 0.6; BitNodeMultipliers.HackingLevelMultiplier = 0.6;
@ -796,6 +809,7 @@ export function initBitNodeMultipliers(p: IPlayer): void {
BitNodeMultipliers.PurchasedServerSoftcap = 2; BitNodeMultipliers.PurchasedServerSoftcap = 2;
BitNodeMultipliers.CorporationSoftCap = 0.9; BitNodeMultipliers.CorporationSoftCap = 0.9;
BitNodeMultipliers.WorldDaemonDifficulty = 1.5; BitNodeMultipliers.WorldDaemonDifficulty = 1.5;
BitNodeMultipliers.GangUniqueAugs = 0.75;
break; break;
case 12: { case 12: {
//The Recursion //The Recursion
@ -870,6 +884,8 @@ export function initBitNodeMultipliers(p: IPlayer): void {
BitNodeMultipliers.GangSoftcap = 0.8; BitNodeMultipliers.GangSoftcap = 0.8;
BitNodeMultipliers.CorporationSoftCap = 0.8; BitNodeMultipliers.CorporationSoftCap = 0.8;
BitNodeMultipliers.WorldDaemonDifficulty = inc; BitNodeMultipliers.WorldDaemonDifficulty = inc;
BitNodeMultipliers.GangUniqueAugs = dec;
break; break;
} }
case 13: { case 13: {
@ -912,6 +928,7 @@ export function initBitNodeMultipliers(p: IPlayer): void {
BitNodeMultipliers.GangSoftcap = 0.3; BitNodeMultipliers.GangSoftcap = 0.3;
BitNodeMultipliers.CorporationSoftCap = 0.3; BitNodeMultipliers.CorporationSoftCap = 0.3;
BitNodeMultipliers.WorldDaemonDifficulty = 3; BitNodeMultipliers.WorldDaemonDifficulty = 3;
BitNodeMultipliers.GangUniqueAugs = 0.1;
break; break;
} }
default: default:

@ -114,6 +114,11 @@ interface IBitNodeMultipliers {
*/ */
GangSoftcap: number; GangSoftcap: number;
/**
* Percentage of unique augs that the gang has.
*/
GangUniqueAugs: number;
/** /**
* Influences the experienced gained when hacking a server. * Influences the experienced gained when hacking a server.
*/ */
@ -300,6 +305,7 @@ export const BitNodeMultipliers: IBitNodeMultipliers = {
BladeburnerSkillCost: 1, BladeburnerSkillCost: 1,
GangSoftcap: 1, GangSoftcap: 1,
GangUniqueAugs: 1,
DaedalusAugsRequirement: 1, DaedalusAugsRequirement: 1,

@ -61,3 +61,35 @@ export class WHRNG implements RNG {
return (this.s1 / 30269.0 + this.s2 / 30307.0 + this.s3 / 30323.0) % 1.0; return (this.s1 / 30269.0 + this.s2 / 30307.0 + this.s3 / 30323.0) % 1.0;
} }
} }
export function SFC32RNG(seed: string): () => number {
let h = 1779033703 ^ seed.length;
for (let i = 0; i < seed.length; i++) {
h = Math.imul(h ^ seed.charCodeAt(i), 3432918353);
h = (h << 13) | (h >>> 19);
}
const genSeed = (): number => {
h = Math.imul(h ^ (h >>> 16), 2246822507);
h = Math.imul(h ^ (h >>> 13), 3266489909);
return (h ^= h >>> 16) >>> 0;
};
let a = genSeed();
let b = genSeed();
let c = genSeed();
let d = genSeed();
return (): number => {
a >>>= 0;
b >>>= 0;
c >>>= 0;
d >>>= 0;
let t = (a + b) | 0;
a = b ^ (b >>> 9);
b = (c + (c << 3)) | 0;
c = (c << 21) | (c >>> 11);
d = (d + 1) | 0;
t = (t + d) | 0;
c = (c + t) | 0;
return (t >>> 0) / 4294967296;
};
}

@ -7,6 +7,7 @@ import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers";
import { Faction } from "./Faction"; import { Faction } from "./Faction";
import { Factions } from "./Factions"; import { Factions } from "./Factions";
import { Player } from "../Player"; import { Player } from "../Player";
import { IPlayer } from "../PersonObjects/IPlayer";
import { Settings } from "../Settings/Settings"; import { Settings } from "../Settings/Settings";
import { import {
getHackingWorkRepGain, getHackingWorkRepGain,
@ -18,6 +19,7 @@ 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 { updateAugmentationCosts, getNextNeuroFluxLevel } from "../Augmentation/AugmentationHelpers"; import { updateAugmentationCosts, getNextNeuroFluxLevel } from "../Augmentation/AugmentationHelpers";
import { SFC32RNG } from "../Casino/RNG";
export function inviteToFaction(faction: Faction): void { export function inviteToFaction(faction: Faction): void {
Player.receiveInvite(faction.name); Player.receiveInvite(faction.name);
@ -156,3 +158,43 @@ export function processPassiveFactionRepGain(numCycles: number): void {
faction.playerReputation += rate * numCycles * Player.faction_rep_mult * BitNodeMultipliers.FactionPassiveRepGain; faction.playerReputation += rate * numCycles * Player.faction_rep_mult * BitNodeMultipliers.FactionPassiveRepGain;
} }
} }
export const getFactionAugmentationsFiltered = (player: IPlayer, faction: Faction): string[] => {
// If player has a gang with this faction, return (almost) all augmentations
if (player.hasGangWith(faction.name)) {
let augs = Object.values(Augmentations);
// Remove special augs
augs = augs.filter((a) => !a.isSpecial);
const blacklist: string[] = [AugmentationNames.NeuroFluxGovernor];
if (player.bitNodeN !== 2) {
// TRP is not available outside of BN2 for Gangs
blacklist.push(AugmentationNames.TheRedPill);
}
const rng = SFC32RNG(`BN${player.bitNodeN}.${player.sourceFileLvl(player.bitNodeN)}`);
// Remove faction-unique augs that don't belong to this faction
const uniqueFilter = (a: Augmentation): boolean => {
// Keep all the non-unique one
if (a.factions.length > 1) {
return true;
}
// Keep all the ones that this faction has anyway.
if (faction.augmentations.includes(a.name)) {
return true;
}
return rng() >= 1 - BitNodeMultipliers.GangUniqueAugs;
};
augs = augs.filter(uniqueFilter);
// Remove blacklisted augs
augs = augs.filter((a) => !blacklist.includes(a.name));
return augs.map((a) => a.name);
}
return faction.augmentations.slice();
};

@ -10,7 +10,7 @@ import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
import { Faction } from "../Faction"; import { Faction } from "../Faction";
import { PurchaseAugmentationsOrderSetting } from "../../Settings/SettingEnums"; import { PurchaseAugmentationsOrderSetting } from "../../Settings/SettingEnums";
import { Settings } from "../../Settings/Settings"; import { Settings } from "../../Settings/Settings";
import { hasAugmentationPrereqs } from "../FactionHelpers"; import { hasAugmentationPrereqs, getFactionAugmentationsFiltered } from "../FactionHelpers";
import { use } from "../../ui/Context"; import { use } from "../../ui/Context";
import { Reputation } from "../../ui/React/Reputation"; import { Reputation } from "../../ui/React/Reputation";
@ -43,28 +43,7 @@ export function AugmentationsPage(props: IProps): React.ReactElement {
} }
function getAugs(): string[] { function getAugs(): string[] {
if (isPlayersGang) { return getFactionAugmentationsFiltered(player, props.faction);
// TODO: this code is duplicated in getAugmentationsFromFaction DRY
let augs = Object.values(Augmentations);
// Remove special augs.
augs = augs.filter((a) => !a.isSpecial);
if (player.bitNodeN !== 2) {
// Remove faction-unique augs outside BN2. (But keep the one for this faction.)
augs = augs.filter((a) => a.factions.length > 1 || props.faction.augmentations.includes(a.name));
// Remove blacklisted augs.
const blacklist = [AugmentationNames.NeuroFluxGovernor, AugmentationNames.TheRedPill].map(
(augmentation) => augmentation as string,
);
augs = augs.filter((a) => !blacklist.includes(a.name));
}
return augs.map((a) => a.name);
} else {
return props.faction.augmentations.slice();
}
} }
function getAugsSorted(): string[] { function getAugsSorted(): string[] {

@ -9,7 +9,7 @@ import { Table, TableCell } from "../../ui/React/Table";
import { IRouter } from "../../ui/Router"; import { IRouter } from "../../ui/Router";
import { Faction } from "../Faction"; import { Faction } from "../Faction";
import { joinFaction } from "../FactionHelpers"; import { joinFaction, getFactionAugmentationsFiltered } from "../FactionHelpers";
import { Factions } from "../Factions"; import { Factions } from "../Factions";
import { FactionNames } from "../data/FactionNames"; import { FactionNames } from "../data/FactionNames";
@ -52,26 +52,7 @@ export function FactionsRoot(props: IProps): React.ReactElement {
} }
const getAugsLeft = (faction: Faction, player: IPlayer): number => { const getAugsLeft = (faction: Faction, player: IPlayer): number => {
const isPlayersGang = player.inGang() && player.getGangName() === faction.name; const augs = getFactionAugmentationsFiltered(player, faction);
let augs: string[] = [];
if (isPlayersGang) {
for (const augName of Object.keys(Augmentations)) {
const aug = Augmentations[augName];
if (
augName === AugmentationNames.NeuroFluxGovernor ||
(augName === AugmentationNames.TheRedPill && player.bitNodeN !== 2) ||
// Special augs (i.e. Bladeburner augs)
aug.isSpecial ||
// Exclusive augs (i.e. QLink)
(aug.factions.length <= 1 && !faction.augmentations.includes(augName) && player.bitNodeN !== 2)
)
continue;
augs.push(augName);
}
} else {
augs = faction.augmentations.slice();
}
return augs.filter((augmentation: string) => !player.hasAugmentation(augmentation)).length; return augs.filter((augmentation: string) => !player.hasAugmentation(augmentation)).length;
}; };

@ -1,5 +1,6 @@
import { CityName } from "../Locations/data/CityNames";
import { Augmentations } from "../Augmentation/Augmentations"; import { Augmentations } from "../Augmentation/Augmentations";
import { hasAugmentationPrereqs } from "../Faction/FactionHelpers";
import { CityName } from "../Locations/data/CityNames";
import { getRamCost } from "../Netscript/RamCostGenerator"; import { getRamCost } from "../Netscript/RamCostGenerator";
import { WorkerScript } from "../Netscript/WorkerScript"; import { WorkerScript } from "../Netscript/WorkerScript";
import { GraftableAugmentation } from "../PersonObjects/Grafting/GraftableAugmentation"; import { GraftableAugmentation } from "../PersonObjects/Grafting/GraftableAugmentation";
@ -70,6 +71,11 @@ export function NetscriptGrafting(player: IPlayer, workerScript: WorkerScript, h
return false; return false;
} }
if (!hasAugmentationPrereqs(craftableAug.augmentation)) {
workerScript.log("grafting.graftAugmentation", () => `You don't have the pre-requisites for ${augName}`);
return false;
}
player.loseMoney(craftableAug.cost, "augmentations"); player.loseMoney(craftableAug.cost, "augmentations");
player.startGraftAugmentationWork(augName, craftableAug.time); player.startGraftAugmentationWork(augName, craftableAug.time);

@ -1,7 +1,7 @@
import { INetscriptHelper } from "./INetscriptHelper"; import { INetscriptHelper } from "./INetscriptHelper";
import { WorkerScript } from "../Netscript/WorkerScript"; import { WorkerScript } from "../Netscript/WorkerScript";
import { IPlayer } from "../PersonObjects/IPlayer"; import { IPlayer } from "../PersonObjects/IPlayer";
import { purchaseAugmentation, joinFaction } from "../Faction/FactionHelpers"; import { purchaseAugmentation, joinFaction, getFactionAugmentationsFiltered } from "../Faction/FactionHelpers";
import { startWorkerScript } from "../NetscriptWorker"; import { startWorkerScript } from "../NetscriptWorker";
import { Augmentation } from "../Augmentation/Augmentation"; import { Augmentation } from "../Augmentation/Augmentation";
import { Augmentations } from "../Augmentation/Augmentations"; import { Augmentations } from "../Augmentation/Augmentations";
@ -118,28 +118,7 @@ export function NetscriptSingularity(
helper.checkSingularityAccess("getAugmentationsFromFaction"); helper.checkSingularityAccess("getAugmentationsFromFaction");
const faction = getFaction("getAugmentationsFromFaction", facName); const faction = getFaction("getAugmentationsFromFaction", facName);
// If player has a gang with this faction, return all augmentations. return getFactionAugmentationsFiltered(player, faction);
if (player.hasGangWith(facName)) {
let augs = Object.values(Augmentations);
// Remove special augs.
augs = augs.filter((a) => !a.isSpecial);
if (player.bitNodeN !== 2) {
// Remove faction-unique augs outside BN2. (But keep the one for this faction.)
augs = augs.filter((a) => a.factions.length > 1 || Factions[facName].augmentations.includes(a.name));
// Remove blacklisted augs.
const blacklist = [AugmentationNames.NeuroFluxGovernor, AugmentationNames.TheRedPill].map(
(augmentation) => augmentation as string,
);
augs = augs.filter((a) => !blacklist.includes(a.name));
}
return augs.map((a) => a.name);
}
return faction.augmentations.slice();
}, },
getAugmentationCost: function (_augName: unknown): [number, number] { getAugmentationCost: function (_augName: unknown): [number, number] {
const augName = helper.string("getAugmentationCost", "augName", _augName); const augName = helper.string("getAugmentationCost", "augName", _augName);
@ -184,24 +163,7 @@ export function NetscriptSingularity(
const fac = getFaction("purchaseAugmentation", facName); const fac = getFaction("purchaseAugmentation", facName);
const aug = getAugmentation("purchaseAugmentation", augName); const aug = getAugmentation("purchaseAugmentation", augName);
let augs = []; const augs = getFactionAugmentationsFiltered(player, fac);
if (player.hasGangWith(facName)) {
for (const augName of Object.keys(Augmentations)) {
const aug = Augmentations[augName];
if (
augName === AugmentationNames.NeuroFluxGovernor ||
(augName === AugmentationNames.TheRedPill && player.bitNodeN !== 2) ||
// Special augs (i.e. Bladeburner augs)
aug.isSpecial ||
// Exclusive augs (i.e. QLink)
(aug.factions.length <= 1 && !fac.augmentations.includes(augName) && player.bitNodeN !== 2)
)
continue;
augs.push(augName);
}
} else {
augs = fac.augmentations;
}
if (!augs.includes(augName)) { if (!augs.includes(augName)) {
workerScript.log( workerScript.log(

@ -30,6 +30,7 @@ export async function compile(player: IPlayer, script: Script, scripts: Script[]
const uurls = _getScriptUrls(script, scripts, []); const uurls = _getScriptUrls(script, scripts, []);
const url = uurls[uurls.length - 1].url; const url = uurls[uurls.length - 1].url;
if (script.url && script.url !== url) { if (script.url && script.url !== url) {
URL.revokeObjectURL(script.url);
// Thoughts: Should we be revoking any URLs here? // Thoughts: Should we be revoking any URLs here?
// If a script is modified repeatedly between two states, // If a script is modified repeatedly between two states,
// we could reuse the blob at a later time. // we could reuse the blob at a later time.
@ -42,8 +43,9 @@ export async function compile(player: IPlayer, script: Script, scripts: Script[]
// }); // });
// } // }
} }
script.url = url; if (script.dependencies.length > 0) script.dependencies.forEach((dep) => URL.revokeObjectURL(dep.url));
script.module = new Promise((resolve) => resolve(eval("import(url)"))); script.url = uurls[uurls.length - 1].url;
script.module = new Promise((resolve) => resolve(eval("import(uurls[uurls.length - 1].url)")));
script.dependencies = uurls; script.dependencies = uurls;
} }

@ -1,22 +1,20 @@
import { Construction, CheckBox, CheckBoxOutlineBlank } from "@mui/icons-material";
import { Box, Button, Container, List, ListItemButton, Paper, Typography } from "@mui/material";
import React, { useState } from "react"; import React, { useState } from "react";
import { Augmentation } from "../../../Augmentation/Augmentation";
import { Typography, Container, Box, Paper, List, ListItemButton, Button } from "@mui/material";
import { Construction } from "@mui/icons-material";
import { use } from "../../../ui/Context";
import { Money } from "../../../ui/React/Money";
import { ConfirmationModal } from "../../../ui/React/ConfirmationModal";
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 { CONSTANTS } from "../../../Constants";
import { IMap } from "../../../types"; import { hasAugmentationPrereqs } from "../../../Faction/FactionHelpers";
import { convertTimeMsToTimeElapsedString, formatNumber } from "../../../utils/StringHelperFunctions";
import { LocationName } from "../../../Locations/data/LocationNames"; import { LocationName } from "../../../Locations/data/LocationNames";
import { Locations } from "../../../Locations/Locations"; import { Locations } from "../../../Locations/Locations";
import { CONSTANTS } from "../../../Constants"; import { Settings } from "../../../Settings/Settings";
import { IMap } from "../../../types";
import { use } from "../../../ui/Context";
import { ConfirmationModal } from "../../../ui/React/ConfirmationModal";
import { Money } from "../../../ui/React/Money";
import { convertTimeMsToTimeElapsedString, formatNumber } from "../../../utils/StringHelperFunctions";
import { IPlayer } from "../../IPlayer"; import { IPlayer } from "../../IPlayer";
import { GraftableAugmentation } from "../GraftableAugmentation"; import { GraftableAugmentation } from "../GraftableAugmentation";
const GraftableAugmentations: IMap<GraftableAugmentation> = {}; const GraftableAugmentations: IMap<GraftableAugmentation> = {};
@ -33,6 +31,36 @@ export const getAvailableAugs = (player: IPlayer): string[] => {
return augs.filter((augmentation: string) => !player.hasAugmentation(augmentation)); return augs.filter((augmentation: string) => !player.hasAugmentation(augmentation));
}; };
const canGraft = (player: IPlayer, aug: GraftableAugmentation): boolean => {
if (player.money < aug.cost) {
return false;
}
return hasAugmentationPrereqs(aug.augmentation);
};
interface IProps {
player: IPlayer;
aug: Augmentation;
}
const AugPreReqsChecklist = (props: IProps): React.ReactElement => {
const aug = props.aug,
player = props.player;
return (
<Typography color={Settings.theme.money}>
<b>Pre-Requisites:</b>
<br />
{aug.prereqs.map((preAug) => (
<span style={{ display: "flex", alignItems: "center" }}>
{player.hasAugmentation(preAug) ? <CheckBox sx={{ mr: 1 }} /> : <CheckBoxOutlineBlank sx={{ mr: 1 }} />}
{preAug}
</span>
))}
</Typography>
);
};
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();
@ -80,7 +108,7 @@ export const GraftingRoot = (): React.ReactElement => {
<Button <Button
onClick={() => setGraftOpen(true)} onClick={() => setGraftOpen(true)}
sx={{ width: "100%" }} sx={{ width: "100%" }}
disabled={player.money < GraftableAugmentations[selectedAug].cost} disabled={!canGraft(player, GraftableAugmentations[selectedAug])}
> >
Graft Augmentation ( Graft Augmentation (
<Typography> <Typography>
@ -115,6 +143,11 @@ export const GraftingRoot = (): React.ReactElement => {
)} )}
{/* Use formula so the displayed creation time is accurate to player bonus */} {/* Use formula so the displayed creation time is accurate to player bonus */}
</Typography> </Typography>
{Augmentations[selectedAug].prereqs.length > 0 && (
<AugPreReqsChecklist player={player} aug={Augmentations[selectedAug]} />
)}
<br />
<Typography sx={{ maxHeight: 305, overflowY: "scroll" }}> <Typography sx={{ maxHeight: 305, overflowY: "scroll" }}>
{(() => { {(() => {
const aug = Augmentations[selectedAug]; const aug = Augmentations[selectedAug];