bitburner-src/src/PersonObjects/Sleeve/SleeveHelpers.ts

109 lines
2.9 KiB
TypeScript
Raw Normal View History

import { FactionNames } from '../../Faction/data/FactionNames';
import { Sleeve } from "./Sleeve";
import { IPlayer } from "../IPlayer";
import { Augmentation } from "../../Augmentation/Augmentation";
import { Augmentations } from "../../Augmentation/Augmentations";
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
import { Faction } from "../../Faction/Faction";
import { Factions } from "../../Faction/Factions";
2021-09-09 05:47:34 +02:00
export function findSleevePurchasableAugs(sleeve: Sleeve, p: IPlayer): Augmentation[] {
2021-09-05 01:09:30 +02:00
// You can only purchase Augmentations that are actually available from
// your factions. I.e. you must be in a faction that has the Augmentation
// and you must also have enough rep in that faction in order to purchase it.
2021-09-05 01:09:30 +02:00
const ownedAugNames: string[] = sleeve.augmentations.map((e) => {
return e.name;
});
const availableAugs: Augmentation[] = [];
2021-09-05 01:09:30 +02:00
// Helper function that helps filter out augs that are already owned
// and augs that aren't allowed for sleeves
function isAvailableForSleeve(aug: Augmentation): boolean {
if (aug.name === AugmentationNames.NeuroFluxGovernor) {
return false;
}
if (ownedAugNames.includes(aug.name)) {
return false;
}
if (availableAugs.includes(aug)) {
return false;
}
if (aug.isSpecial) {
return false;
}
const validMults = [
"hacking_mult",
"strength_mult",
"defense_mult",
"dexterity_mult",
"agility_mult",
"charisma_mult",
"hacking_exp_mult",
"strength_exp_mult",
"defense_exp_mult",
"dexterity_exp_mult",
"agility_exp_mult",
"charisma_exp_mult",
"company_rep_mult",
"faction_rep_mult",
"crime_money_mult",
"crime_success_mult",
"work_money_mult",
];
for (const mult of Object.keys(aug.mults)) {
if (validMults.includes(mult)) {
return true;
}
}
return false;
2021-09-05 01:09:30 +02:00
}
2021-09-05 01:09:30 +02:00
// If player is in a gang, then we return all augs that the player
// has enough reputation for (since that gang offers all augs)
if (p.inGang()) {
const fac = p.getGangFaction();
2022-01-16 01:45:03 +01:00
for (const augName of Object.keys(Augmentations)) {
2021-09-05 01:09:30 +02:00
const aug = Augmentations[augName];
if (!isAvailableForSleeve(aug)) {
continue;
}
2021-09-05 01:09:30 +02:00
if (fac.playerReputation > aug.baseRepRequirement) {
availableAugs.push(aug);
}
}
2021-09-05 01:09:30 +02:00
}
for (const facName of p.factions) {
if (facName === FactionNames.Bladeburners) {
2021-09-05 01:09:30 +02:00
continue;
}
if (facName === FactionNames.Netburners) {
2021-09-05 01:09:30 +02:00
continue;
}
const fac: Faction | null = Factions[facName];
if (fac == null) {
continue;
}
2021-09-05 01:09:30 +02:00
for (const augName of fac.augmentations) {
const aug: Augmentation = Augmentations[augName];
if (!isAvailableForSleeve(aug)) {
continue;
}
2021-09-05 01:09:30 +02:00
if (fac.playerReputation > aug.baseRepRequirement) {
availableAugs.push(aug);
}
}
2021-09-05 01:09:30 +02:00
}
2021-09-05 01:09:30 +02:00
return availableAugs;
}