findSleevePurchasableAugs as a class member

This commit is contained in:
Snarling 2022-09-20 00:40:07 -04:00
parent dcd9023b93
commit 475a8812bb
4 changed files with 8 additions and 7 deletions

@ -1,5 +1,4 @@
import { Player } from "../Player"; import { Player } from "../Player";
import { findSleevePurchasableAugs } from "../PersonObjects/Sleeve/SleeveHelpers";
import { StaticAugmentations } from "../Augmentation/StaticAugmentations"; import { StaticAugmentations } from "../Augmentation/StaticAugmentations";
import { CityName } from "../Locations/data/CityNames"; import { CityName } from "../Locations/data/CityNames";
import { findCrime } from "../Crime/CrimeHelpers"; import { findCrime } from "../Crime/CrimeHelpers";
@ -251,7 +250,7 @@ export function NetscriptSleeve(): InternalAPI<ISleeve> {
checkSleeveAPIAccess(ctx); checkSleeveAPIAccess(ctx);
checkSleeveNumber(ctx, sleeveNumber); checkSleeveNumber(ctx, sleeveNumber);
const purchasableAugs = findSleevePurchasableAugs(Player.sleeves[sleeveNumber]); const purchasableAugs = Player.sleeves[sleeveNumber].findPurchasableAugs();
const augs = []; const augs = [];
for (let i = 0; i < purchasableAugs.length; i++) { for (let i = 0; i < purchasableAugs.length; i++) {
const aug = purchasableAugs[i]; const aug = purchasableAugs[i];

@ -44,6 +44,7 @@ import { SleeveInfiltrateWork } from "./Work/SleeveInfiltrateWork";
import { SleeveSupportWork } from "./Work/SleeveSupportWork"; import { SleeveSupportWork } from "./Work/SleeveSupportWork";
import { SleeveBladeburnerWork } from "./Work/SleeveBladeburnerWork"; import { SleeveBladeburnerWork } from "./Work/SleeveBladeburnerWork";
import { SleeveCrimeWork } from "./Work/SleeveCrimeWork"; import { SleeveCrimeWork } from "./Work/SleeveCrimeWork";
import * as sleeveMethods from "./SleeveMethods";
export class Sleeve extends Person { export class Sleeve extends Person {
currentWork: Work | null = null; currentWork: Work | null = null;
@ -79,6 +80,8 @@ export class Sleeve extends Person {
this.shockRecovery(); this.shockRecovery();
} }
findPurchasableAugs = sleeveMethods.findPurchasableAugs;
shockBonus(): number { shockBonus(): number {
return this.shock / 100; return this.shock / 100;
} }

@ -10,12 +10,12 @@ import { Multipliers } from "../Multipliers";
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames"; import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
import { getFactionAugmentationsFiltered } from "../../Faction/FactionHelpers"; import { getFactionAugmentationsFiltered } from "../../Faction/FactionHelpers";
export function findSleevePurchasableAugs(sleeve: Sleeve): Augmentation[] { export function findPurchasableAugs(this: Sleeve): Augmentation[] {
// You can only purchase Augmentations that are actually available from // You can only purchase Augmentations that are actually available from
// your factions. I.e. you must be in a faction that has the Augmentation // 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. // and you must also have enough rep in that faction in order to purchase it.
const ownedAugNames = sleeve.augmentations.map((e) => e.name); const ownedAugNames = this.augmentations.map((e) => e.name);
const availableAugs: Augmentation[] = []; const availableAugs: Augmentation[] = [];
// Helper function that helps filter out augs that are already owned // Helper function that helps filter out augs that are already owned
@ -85,7 +85,7 @@ export function findSleevePurchasableAugs(sleeve: Sleeve): Augmentation[] {
} }
// Add the stanek sleeve aug // Add the stanek sleeve aug
if (!ownedAugNames.includes(AugmentationNames.ZOE) && p.factions.includes(FactionNames.ChurchOfTheMachineGod)) { if (!ownedAugNames.includes(AugmentationNames.ZOE) && Player.factions.includes(FactionNames.ChurchOfTheMachineGod)) {
const aug = StaticAugmentations[AugmentationNames.ZOE]; const aug = StaticAugmentations[AugmentationNames.ZOE];
availableAugs.push(aug); availableAugs.push(aug);
} }

@ -4,7 +4,6 @@ import { PurchasableAugmentations } from "../../../Augmentation/ui/PurchasableAu
import { Player } from "../../../Player"; import { Player } from "../../../Player";
import { Modal } from "../../../ui/React/Modal"; import { Modal } from "../../../ui/React/Modal";
import { Sleeve } from "../Sleeve"; import { Sleeve } from "../Sleeve";
import { findSleevePurchasableAugs } from "../SleeveHelpers";
interface IProps { interface IProps {
open: boolean; open: boolean;
@ -29,7 +28,7 @@ export function SleeveAugmentationsModal(props: IProps): React.ReactElement {
// You can only purchase Augmentations that are actually available from // You can only purchase Augmentations that are actually available from
// your factions. I.e. you must be in a faction that has the Augmentation // 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. // and you must also have enough rep in that faction in order to purchase it.
const availableAugs = findSleevePurchasableAugs(props.sleeve); const availableAugs = props.sleeve.findPurchasableAugs();
return ( return (
<Modal open={props.open} onClose={props.onClose}> <Modal open={props.open} onClose={props.onClose}>