feat: apply & track daily standing limit when trading in medallions
This commit is contained in:
parent
8ee22e9e88
commit
983aa94802
@ -1,6 +1,6 @@
|
||||
import { RequestHandler } from "express";
|
||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||
import { addMiscItems, getInventory } from "@/src/services/inventoryService";
|
||||
import { addMiscItems, getInventory, getStandingLimit, updateStandingLimit } from "@/src/services/inventoryService";
|
||||
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
import { IOid } from "@/src/types/commonTypes";
|
||||
import { ExportSyndicates, ISyndicate } from "warframe-public-export-plus";
|
||||
@ -36,10 +36,13 @@ export const syndicateStandingBonusController: RequestHandler = async (req, res)
|
||||
if (syndicate.Standing + gainedStanding > max) {
|
||||
gainedStanding = max - syndicate.Standing;
|
||||
}
|
||||
if (gainedStanding > getStandingLimit(inventory, syndicateMeta.dailyLimitBin)) {
|
||||
gainedStanding = getStandingLimit(inventory, syndicateMeta.dailyLimitBin);
|
||||
}
|
||||
|
||||
syndicate.Standing += gainedStanding;
|
||||
|
||||
// TODO: Subtract from daily limit bin; maybe also a cheat to skip that.
|
||||
updateStandingLimit(inventory, syndicateMeta.dailyLimitBin, gainedStanding);
|
||||
|
||||
await inventory.save();
|
||||
|
||||
|
@ -16,7 +16,8 @@ import {
|
||||
IWeaponSkinClient,
|
||||
TEquipmentKey,
|
||||
equipmentKeys,
|
||||
IFusionTreasure
|
||||
IFusionTreasure,
|
||||
IInventoryDatabase
|
||||
} from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
import { IGenericUpdate } from "../types/genericUpdate";
|
||||
import {
|
||||
@ -36,7 +37,8 @@ import {
|
||||
ExportRecipes,
|
||||
ExportResources,
|
||||
ExportSentinels,
|
||||
ExportUpgrades
|
||||
ExportUpgrades,
|
||||
TStandingLimitBin
|
||||
} from "warframe-public-export-plus";
|
||||
import { createShip } from "./shipService";
|
||||
|
||||
@ -492,6 +494,43 @@ export const updateCurrencyByAccountId = async (
|
||||
return currencyChanges;
|
||||
};
|
||||
|
||||
const standingLimitBinToInventoryKey: Record<
|
||||
Exclude<TStandingLimitBin, "STANDING_LIMIT_BIN_NONE">,
|
||||
keyof IInventoryDatabase
|
||||
> = {
|
||||
STANDING_LIMIT_BIN_NORMAL: "DailyAffiliation",
|
||||
STANDING_LIMIT_BIN_PVP: "DailyAffiliationPvp",
|
||||
STANDING_LIMIT_BIN_LIBRARY: "DailyAffiliationLibrary",
|
||||
STANDING_LIMIT_BIN_CETUS: "DailyAffiliationCetus",
|
||||
STANDING_LIMIT_BIN_QUILLS: "DailyAffiliationQuills",
|
||||
STANDING_LIMIT_BIN_SOLARIS: "DailyAffiliationSolaris",
|
||||
STANDING_LIMIT_BIN_VENTKIDS: "DailyAffiliationVentkids",
|
||||
STANDING_LIMIT_BIN_VOX: "DailyAffiliationVox",
|
||||
STANDING_LIMIT_BIN_ENTRATI: "DailyAffiliationEntrati",
|
||||
STANDING_LIMIT_BIN_NECRALOID: "DailyAffiliationNecraloid",
|
||||
STANDING_LIMIT_BIN_ZARIMAN: "DailyAffiliationZariman",
|
||||
STANDING_LIMIT_BIN_KAHL: "DailyAffiliationKahl",
|
||||
STANDING_LIMIT_BIN_CAVIA: "DailyAffiliationCavia",
|
||||
STANDING_LIMIT_BIN_HEX: "DailyAffiliationHex"
|
||||
};
|
||||
|
||||
export const getStandingLimit = (inventory: TInventoryDatabaseDocument, bin: TStandingLimitBin): number => {
|
||||
if (bin == "STANDING_LIMIT_BIN_NONE") {
|
||||
return Number.MAX_SAFE_INTEGER;
|
||||
}
|
||||
return inventory[standingLimitBinToInventoryKey[bin]] as number;
|
||||
};
|
||||
|
||||
export const updateStandingLimit = (
|
||||
inventory: TInventoryDatabaseDocument,
|
||||
bin: TStandingLimitBin,
|
||||
subtrahend: number
|
||||
): void => {
|
||||
if (bin != "STANDING_LIMIT_BIN_NONE") {
|
||||
(inventory[standingLimitBinToInventoryKey[bin]] as number) -= subtrahend;
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: AffiliationMods support (Nightwave).
|
||||
export const updateGeneric = async (data: IGenericUpdate, accountId: string): Promise<void> => {
|
||||
const inventory = await getInventory(accountId);
|
||||
|
Loading…
x
Reference in New Issue
Block a user