feat: purchase additional conclave loadout slots (#2758)
Closes #2756. Also just in general simplified the logic around purchasing loadout slots. Reviewed-on: #2758 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
parent
1066b4a983
commit
3e555b1753
@ -1,23 +0,0 @@
|
||||
import type { SlotPurchase, SlotPurchaseName } from "../types/purchaseTypes.ts";
|
||||
|
||||
export const slotPurchaseNameToSlotName: SlotPurchase = {
|
||||
SuitSlotItem: { name: "SuitBin", purchaseQuantity: 1 },
|
||||
TwoSentinelSlotItem: { name: "SentinelBin", purchaseQuantity: 2 },
|
||||
TwoWeaponSlotItem: { name: "WeaponBin", purchaseQuantity: 2 },
|
||||
SpaceSuitSlotItem: { name: "SpaceSuitBin", purchaseQuantity: 1 },
|
||||
TwoSpaceWeaponSlotItem: { name: "SpaceWeaponBin", purchaseQuantity: 2 },
|
||||
MechSlotItem: { name: "MechBin", purchaseQuantity: 1 },
|
||||
TwoOperatorWeaponSlotItem: { name: "OperatorAmpBin", purchaseQuantity: 2 },
|
||||
RandomModSlotItem: { name: "RandomModBin", purchaseQuantity: 3 },
|
||||
TwoCrewShipSalvageSlotItem: { name: "CrewShipSalvageBin", purchaseQuantity: 2 },
|
||||
CrewMemberSlotItem: { name: "CrewMemberBin", purchaseQuantity: 1 }
|
||||
};
|
||||
|
||||
export const isSlotPurchaseName = (slotPurchaseName: string): slotPurchaseName is SlotPurchaseName => {
|
||||
return slotPurchaseName in slotPurchaseNameToSlotName;
|
||||
};
|
||||
|
||||
export const parseSlotPurchaseName = (slotPurchaseName: string): SlotPurchaseName => {
|
||||
if (!isSlotPurchaseName(slotPurchaseName)) throw new Error(`invalid slot name ${slotPurchaseName}`);
|
||||
return slotPurchaseName;
|
||||
};
|
||||
@ -1,4 +1,3 @@
|
||||
import { parseSlotPurchaseName, slotPurchaseNameToSlotName } from "../helpers/purchaseHelpers.ts";
|
||||
import { getSubstringFromKeyword } from "../helpers/stringHelpers.ts";
|
||||
import {
|
||||
addBooster,
|
||||
@ -15,7 +14,8 @@ import type {
|
||||
IPurchaseRequest,
|
||||
IPurchaseResponse,
|
||||
IInventoryChanges,
|
||||
IPurchaseParams
|
||||
IPurchaseParams,
|
||||
SlotNames
|
||||
} from "../types/purchaseTypes.ts";
|
||||
import { PurchaseSource } from "../types/purchaseTypes.ts";
|
||||
import { logger } from "../utils/logger.ts";
|
||||
@ -489,6 +489,20 @@ export const handleStoreItemAcquisition = async (
|
||||
return purchaseResponse;
|
||||
};
|
||||
|
||||
const slotPurchaseNameToSlotName: Record<string, { name: SlotNames; purchaseQuantity: number }> = {
|
||||
SuitSlotItem: { name: "SuitBin", purchaseQuantity: 1 },
|
||||
TwoSentinelSlotItem: { name: "SentinelBin", purchaseQuantity: 2 },
|
||||
TwoWeaponSlotItem: { name: "WeaponBin", purchaseQuantity: 2 },
|
||||
SpaceSuitSlotItem: { name: "SpaceSuitBin", purchaseQuantity: 1 },
|
||||
TwoSpaceWeaponSlotItem: { name: "SpaceWeaponBin", purchaseQuantity: 2 },
|
||||
MechSlotItem: { name: "MechBin", purchaseQuantity: 1 },
|
||||
TwoOperatorWeaponSlotItem: { name: "OperatorAmpBin", purchaseQuantity: 2 },
|
||||
RandomModSlotItem: { name: "RandomModBin", purchaseQuantity: 3 },
|
||||
TwoCrewShipSalvageSlotItem: { name: "CrewShipSalvageBin", purchaseQuantity: 2 },
|
||||
CrewMemberSlotItem: { name: "CrewMemberBin", purchaseQuantity: 1 },
|
||||
PvPLoadoutSlotItem: { name: "PvpBonusLoadoutBin", purchaseQuantity: 1 }
|
||||
};
|
||||
|
||||
// // extra = everything above the base +2 slots (depending on slot type)
|
||||
// // new slot above base = extra + 1 and slots +1
|
||||
// // new frame = slots -1
|
||||
@ -500,9 +514,8 @@ const handleSlotPurchase = (
|
||||
ignorePurchaseQuantity: boolean
|
||||
): IPurchaseResponse => {
|
||||
logger.debug(`slot name ${slotPurchaseNameFull}`);
|
||||
const slotPurchaseName = parseSlotPurchaseName(
|
||||
slotPurchaseNameFull.substring(slotPurchaseNameFull.lastIndexOf("/") + 1)
|
||||
);
|
||||
const slotPurchaseName = slotPurchaseNameFull.substring(slotPurchaseNameFull.lastIndexOf("/") + 1);
|
||||
if (!(slotPurchaseName in slotPurchaseNameToSlotName)) throw new Error(`invalid slot name ${slotPurchaseName}`);
|
||||
logger.debug(`slot purchase name ${slotPurchaseName}`);
|
||||
|
||||
const slotName = slotPurchaseNameToSlotName[slotPurchaseName].name;
|
||||
|
||||
@ -120,18 +120,6 @@ export type IBinChanges = {
|
||||
Extra?: number;
|
||||
};
|
||||
|
||||
export type SlotPurchaseName =
|
||||
| "SuitSlotItem"
|
||||
| "TwoSentinelSlotItem"
|
||||
| "TwoWeaponSlotItem"
|
||||
| "SpaceSuitSlotItem"
|
||||
| "TwoSpaceWeaponSlotItem"
|
||||
| "MechSlotItem"
|
||||
| "TwoOperatorWeaponSlotItem"
|
||||
| "RandomModSlotItem"
|
||||
| "TwoCrewShipSalvageSlotItem"
|
||||
| "CrewMemberSlotItem";
|
||||
|
||||
export const slotNames = [
|
||||
"SuitBin",
|
||||
"WeaponBin",
|
||||
@ -148,7 +136,3 @@ export const slotNames = [
|
||||
] as const;
|
||||
|
||||
export type SlotNames = (typeof slotNames)[number];
|
||||
|
||||
export type SlotPurchase = {
|
||||
[P in SlotPurchaseName]: { name: SlotNames; purchaseQuantity: number };
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user