feat: apply & track daily standing limit when trading in medallions #788
@ -17,7 +17,7 @@ import {
 | 
				
			|||||||
    TEquipmentKey,
 | 
					    TEquipmentKey,
 | 
				
			||||||
    equipmentKeys,
 | 
					    equipmentKeys,
 | 
				
			||||||
    IFusionTreasure,
 | 
					    IFusionTreasure,
 | 
				
			||||||
    IInventoryDatabase
 | 
					    IDailyAffiliations
 | 
				
			||||||
} from "@/src/types/inventoryTypes/inventoryTypes";
 | 
					} from "@/src/types/inventoryTypes/inventoryTypes";
 | 
				
			||||||
import { IGenericUpdate } from "../types/genericUpdate";
 | 
					import { IGenericUpdate } from "../types/genericUpdate";
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
@ -496,7 +496,7 @@ export const updateCurrencyByAccountId = async (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const standingLimitBinToInventoryKey: Record<
 | 
					const standingLimitBinToInventoryKey: Record<
 | 
				
			||||||
    Exclude<TStandingLimitBin, "STANDING_LIMIT_BIN_NONE">,
 | 
					    Exclude<TStandingLimitBin, "STANDING_LIMIT_BIN_NONE">,
 | 
				
			||||||
    keyof IInventoryDatabase
 | 
					    keyof IDailyAffiliations
 | 
				
			||||||
> = {
 | 
					> = {
 | 
				
			||||||
    STANDING_LIMIT_BIN_NORMAL: "DailyAffiliation",
 | 
					    STANDING_LIMIT_BIN_NORMAL: "DailyAffiliation",
 | 
				
			||||||
    STANDING_LIMIT_BIN_PVP: "DailyAffiliationPvp",
 | 
					    STANDING_LIMIT_BIN_PVP: "DailyAffiliationPvp",
 | 
				
			||||||
@ -514,20 +514,20 @@ const standingLimitBinToInventoryKey: Record<
 | 
				
			|||||||
    STANDING_LIMIT_BIN_HEX: "DailyAffiliationHex"
 | 
					    STANDING_LIMIT_BIN_HEX: "DailyAffiliationHex"
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const getStandingLimit = (inventory: TInventoryDatabaseDocument, bin: TStandingLimitBin): number => {
 | 
					export const getStandingLimit = (inventory: IDailyAffiliations, bin: TStandingLimitBin): number => {
 | 
				
			||||||
    if (bin == "STANDING_LIMIT_BIN_NONE") {
 | 
					    if (bin == "STANDING_LIMIT_BIN_NONE") {
 | 
				
			||||||
        return Number.MAX_SAFE_INTEGER;
 | 
					        return Number.MAX_SAFE_INTEGER;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return inventory[standingLimitBinToInventoryKey[bin]] as number;
 | 
					    return inventory[standingLimitBinToInventoryKey[bin]];
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const updateStandingLimit = (
 | 
					export const updateStandingLimit = (
 | 
				
			||||||
    inventory: TInventoryDatabaseDocument,
 | 
					    inventory: IDailyAffiliations,
 | 
				
			||||||
    bin: TStandingLimitBin,
 | 
					    bin: TStandingLimitBin,
 | 
				
			||||||
    subtrahend: number
 | 
					    subtrahend: number
 | 
				
			||||||
): void => {
 | 
					): void => {
 | 
				
			||||||
    if (bin != "STANDING_LIMIT_BIN_NONE") {
 | 
					    if (bin != "STANDING_LIMIT_BIN_NONE") {
 | 
				
			||||||
        (inventory[standingLimitBinToInventoryKey[bin]] as number) -= subtrahend;
 | 
					        inventory[standingLimitBinToInventoryKey[bin]] -= subtrahend;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -110,7 +110,25 @@ export type TSolarMapRegion =
 | 
				
			|||||||
export interface IPendingRecipeResponse extends Omit<IPendingRecipe, "CompletionDate"> {
 | 
					export interface IPendingRecipeResponse extends Omit<IPendingRecipe, "CompletionDate"> {
 | 
				
			||||||
    CompletionDate: IMongoDate;
 | 
					    CompletionDate: IMongoDate;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
export interface IInventoryResponse {
 | 
					
 | 
				
			||||||
 | 
					export interface IDailyAffiliations {
 | 
				
			||||||
 | 
					    DailyAffiliation: number;
 | 
				
			||||||
 | 
					    DailyAffiliationPvp: number;
 | 
				
			||||||
 | 
					    DailyAffiliationLibrary: number;
 | 
				
			||||||
 | 
					    DailyAffiliationCetus: number;
 | 
				
			||||||
 | 
					    DailyAffiliationQuills: number;
 | 
				
			||||||
 | 
					    DailyAffiliationSolaris: number;
 | 
				
			||||||
 | 
					    DailyAffiliationVentkids: number;
 | 
				
			||||||
 | 
					    DailyAffiliationVox: number;
 | 
				
			||||||
 | 
					    DailyAffiliationEntrati: number;
 | 
				
			||||||
 | 
					    DailyAffiliationNecraloid: number;
 | 
				
			||||||
 | 
					    DailyAffiliationZariman: number;
 | 
				
			||||||
 | 
					    DailyAffiliationKahl: number;
 | 
				
			||||||
 | 
					    DailyAffiliationCavia: number;
 | 
				
			||||||
 | 
					    DailyAffiliationHex: number;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface IInventoryResponse extends IDailyAffiliations {
 | 
				
			||||||
    Horses: IEquipmentDatabase[];
 | 
					    Horses: IEquipmentDatabase[];
 | 
				
			||||||
    DrifterMelee: IEquipmentDatabase[];
 | 
					    DrifterMelee: IEquipmentDatabase[];
 | 
				
			||||||
    DrifterGuns: IEquipmentDatabase[];
 | 
					    DrifterGuns: IEquipmentDatabase[];
 | 
				
			||||||
@ -138,9 +156,6 @@ export interface IInventoryResponse {
 | 
				
			|||||||
    OperatorAmpBin: ISlots;
 | 
					    OperatorAmpBin: ISlots;
 | 
				
			||||||
    CrewShipSalvageBin: ISlots;
 | 
					    CrewShipSalvageBin: ISlots;
 | 
				
			||||||
    TradesRemaining: number;
 | 
					    TradesRemaining: number;
 | 
				
			||||||
    DailyAffiliation: number;
 | 
					 | 
				
			||||||
    DailyAffiliationPvp: number;
 | 
					 | 
				
			||||||
    DailyAffiliationLibrary: number;
 | 
					 | 
				
			||||||
    DailyFocus: number;
 | 
					    DailyFocus: number;
 | 
				
			||||||
    GiftsRemaining: number;
 | 
					    GiftsRemaining: number;
 | 
				
			||||||
    HandlerPoints: number;
 | 
					    HandlerPoints: number;
 | 
				
			||||||
@ -220,8 +235,6 @@ export interface IInventoryResponse {
 | 
				
			|||||||
    ActiveAvatarImageType: string;
 | 
					    ActiveAvatarImageType: string;
 | 
				
			||||||
    KubrowPets: IEquipmentDatabase[];
 | 
					    KubrowPets: IEquipmentDatabase[];
 | 
				
			||||||
    ShipDecorations: IConsumable[];
 | 
					    ShipDecorations: IConsumable[];
 | 
				
			||||||
    DailyAffiliationCetus: number;
 | 
					 | 
				
			||||||
    DailyAffiliationQuills: number;
 | 
					 | 
				
			||||||
    DiscoveredMarkers: IDiscoveredMarker[];
 | 
					    DiscoveredMarkers: IDiscoveredMarker[];
 | 
				
			||||||
    CompletedJobs: ICompletedJob[];
 | 
					    CompletedJobs: ICompletedJob[];
 | 
				
			||||||
    FocusAbility: string;
 | 
					    FocusAbility: string;
 | 
				
			||||||
@ -232,7 +245,6 @@ export interface IInventoryResponse {
 | 
				
			|||||||
    KubrowPetPrints: IKubrowPetPrint[];
 | 
					    KubrowPetPrints: IKubrowPetPrint[];
 | 
				
			||||||
    AlignmentReplay: IAlignment;
 | 
					    AlignmentReplay: IAlignment;
 | 
				
			||||||
    PersonalGoalProgress: IPersonalGoalProgress[];
 | 
					    PersonalGoalProgress: IPersonalGoalProgress[];
 | 
				
			||||||
    DailyAffiliationSolaris: number;
 | 
					 | 
				
			||||||
    SpecialItems: IEquipmentDatabase[];
 | 
					    SpecialItems: IEquipmentDatabase[];
 | 
				
			||||||
    ThemeStyle: string;
 | 
					    ThemeStyle: string;
 | 
				
			||||||
    ThemeBackground: string;
 | 
					    ThemeBackground: string;
 | 
				
			||||||
@ -241,8 +253,6 @@ export interface IInventoryResponse {
 | 
				
			|||||||
    ChallengeInstanceStates: IChallengeInstanceState[];
 | 
					    ChallengeInstanceStates: IChallengeInstanceState[];
 | 
				
			||||||
    LoginMilestoneRewards: string[];
 | 
					    LoginMilestoneRewards: string[];
 | 
				
			||||||
    OperatorLoadOuts: IOperatorConfigClient[];
 | 
					    OperatorLoadOuts: IOperatorConfigClient[];
 | 
				
			||||||
    DailyAffiliationVentkids: number;
 | 
					 | 
				
			||||||
    DailyAffiliationVox: number;
 | 
					 | 
				
			||||||
    RecentVendorPurchases: Array<number | string>;
 | 
					    RecentVendorPurchases: Array<number | string>;
 | 
				
			||||||
    Hoverboards: IEquipmentDatabase[];
 | 
					    Hoverboards: IEquipmentDatabase[];
 | 
				
			||||||
    NodeIntrosCompleted: string[];
 | 
					    NodeIntrosCompleted: string[];
 | 
				
			||||||
@ -268,8 +278,6 @@ export interface IInventoryResponse {
 | 
				
			|||||||
    TradeBannedUntil?: IMongoDate;
 | 
					    TradeBannedUntil?: IMongoDate;
 | 
				
			||||||
    PlayedParkourTutorial: boolean;
 | 
					    PlayedParkourTutorial: boolean;
 | 
				
			||||||
    SubscribedToEmailsPersonalized: number;
 | 
					    SubscribedToEmailsPersonalized: number;
 | 
				
			||||||
    DailyAffiliationEntrati: number;
 | 
					 | 
				
			||||||
    DailyAffiliationNecraloid: number;
 | 
					 | 
				
			||||||
    MechSuits: IEquipmentDatabase[];
 | 
					    MechSuits: IEquipmentDatabase[];
 | 
				
			||||||
    InfestedFoundry?: IInfestedFoundry;
 | 
					    InfestedFoundry?: IInfestedFoundry;
 | 
				
			||||||
    BlessingCooldown: IMongoDate;
 | 
					    BlessingCooldown: IMongoDate;
 | 
				
			||||||
@ -279,11 +287,7 @@ export interface IInventoryResponse {
 | 
				
			|||||||
    AdultOperatorLoadOuts: IOperatorConfigClient[];
 | 
					    AdultOperatorLoadOuts: IOperatorConfigClient[];
 | 
				
			||||||
    LotusCustomization: ILotusCustomization;
 | 
					    LotusCustomization: ILotusCustomization;
 | 
				
			||||||
    UseAdultOperatorLoadout?: boolean;
 | 
					    UseAdultOperatorLoadout?: boolean;
 | 
				
			||||||
    DailyAffiliationZariman: number;
 | 
					 | 
				
			||||||
    NemesisAbandonedRewards: string[];
 | 
					    NemesisAbandonedRewards: string[];
 | 
				
			||||||
    DailyAffiliationKahl: number;
 | 
					 | 
				
			||||||
    DailyAffiliationCavia: number;
 | 
					 | 
				
			||||||
    DailyAffiliationHex: number;
 | 
					 | 
				
			||||||
    LastInventorySync: IOid;
 | 
					    LastInventorySync: IOid;
 | 
				
			||||||
    NextRefill: IMongoDate; // Next time argon crystals will have a decay tick
 | 
					    NextRefill: IMongoDate; // Next time argon crystals will have a decay tick
 | 
				
			||||||
    FoundToday?: IMiscItem[]; // for Argon Crystals
 | 
					    FoundToday?: IMiscItem[]; // for Argon Crystals
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user