2019-04-30 05:54:20 +02:00
|
|
|
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-05 01:09:30 +02:00
|
|
|
export function findSleevePurchasableAugs(
|
|
|
|
sleeve: Sleeve,
|
|
|
|
p: IPlayer,
|
|
|
|
): Augmentation[] {
|
|
|
|
// 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.
|
2019-04-30 05:54:20 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
const ownedAugNames: string[] = sleeve.augmentations.map((e) => {
|
|
|
|
return e.name;
|
|
|
|
});
|
|
|
|
const availableAugs: Augmentation[] = [];
|
2019-04-30 05:54:20 +02:00
|
|
|
|
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;
|
2019-04-30 05:54:20 +02:00
|
|
|
}
|
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
return true;
|
|
|
|
}
|
2019-04-30 05:54:20 +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();
|
2019-04-30 05:54:20 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
for (const augName in Augmentations) {
|
|
|
|
const aug = Augmentations[augName];
|
|
|
|
if (!isAvailableForSleeve(aug)) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-04-30 05:54:20 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
if (fac.playerReputation > aug.baseRepRequirement) {
|
|
|
|
availableAugs.push(aug);
|
|
|
|
}
|
2019-04-30 05:54:20 +02:00
|
|
|
}
|
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
return availableAugs;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const facName of p.factions) {
|
|
|
|
if (facName === "Bladeburners") {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (facName === "Netburners") {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
const fac: Faction | null = Factions[facName];
|
|
|
|
if (fac == null) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-04-30 05:54:20 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
for (const augName of fac.augmentations) {
|
|
|
|
const aug: Augmentation = Augmentations[augName];
|
|
|
|
if (!isAvailableForSleeve(aug)) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-04-30 05:54:20 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
if (fac.playerReputation > aug.baseRepRequirement) {
|
|
|
|
availableAugs.push(aug);
|
|
|
|
}
|
2019-04-30 05:54:20 +02:00
|
|
|
}
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2019-04-30 05:54:20 +02:00
|
|
|
|
2021-09-05 01:09:30 +02:00
|
|
|
return availableAugs;
|
2019-04-30 05:54:20 +02:00
|
|
|
}
|