diff --git a/src/Faction/ui/AugmentationsPage.tsx b/src/Faction/ui/AugmentationsPage.tsx
index 1c5116a2f..2e5db62be 100644
--- a/src/Faction/ui/AugmentationsPage.tsx
+++ b/src/Faction/ui/AugmentationsPage.tsx
@@ -10,6 +10,7 @@ import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
import { Faction } from "../../Faction/Faction";
import { PurchaseAugmentationsOrderSetting } from "../../Settings/SettingEnums";
import { Settings } from "../../Settings/Settings";
+import { hasAugmentationPrereqs } from "../FactionHelpers";
import { StdButton } from "../../ui/React/StdButton";
import { use } from "../../ui/Context";
@@ -59,6 +60,9 @@ export function AugmentationsPage(props: IProps): React.ReactElement {
case PurchaseAugmentationsOrderSetting.Reputation: {
return getAugsSortedByReputation();
}
+ case PurchaseAugmentationsOrderSetting.Purchasable: {
+ return getAugsSortedByPurchasable();
+ }
default:
return getAugsSortedByDefault();
}
@@ -79,6 +83,41 @@ export function AugmentationsPage(props: IProps): React.ReactElement {
return augs;
}
+ function getAugsSortedByPurchasable(): string[] {
+ const augs = getAugs();
+ function canBuy(augName: string): boolean {
+ const aug = Augmentations[augName];
+ const moneyCost = aug.baseCost * props.faction.getInfo().augmentationPriceMult;
+ const repCost = aug.baseRepRequirement * props.faction.getInfo().augmentationRepRequirementMult;
+ const hasReq = props.faction.playerReputation >= repCost;
+ const hasRep = hasAugmentationPrereqs(aug);
+ const hasCost =
+ aug.baseCost !== 0 && player.money.gt(aug.baseCost * props.faction.getInfo().augmentationPriceMult);
+ return hasCost && hasReq && hasRep;
+ }
+ const buy = augs.filter(canBuy).sort((augName1, augName2) => {
+ const aug1 = Augmentations[augName1],
+ aug2 = Augmentations[augName2];
+ if (aug1 == null || aug2 == null) {
+ throw new Error("Invalid Augmentation Names");
+ }
+
+ return aug1.baseCost - aug2.baseCost;
+ });
+ const cantBuy = augs
+ .filter((aug) => !canBuy(aug))
+ .sort((augName1, augName2) => {
+ const aug1 = Augmentations[augName1],
+ aug2 = Augmentations[augName2];
+ if (aug1 == null || aug2 == null) {
+ throw new Error("Invalid Augmentation Names");
+ }
+ return aug1.baseRepRequirement - aug2.baseRepRequirement;
+ });
+
+ return buy.concat(cantBuy);
+ }
+
function getAugsSortedByReputation(): string[] {
const augs = getAugs();
augs.sort((augName1, augName2) => {
@@ -148,6 +187,9 @@ export function AugmentationsPage(props: IProps): React.ReactElement {
+