use addStanding in more places
All checks were successful
Build / build (pull_request) Successful in 1m24s
All checks were successful
Build / build (pull_request) Successful in 1m24s
This commit is contained in:
parent
ef5c31993f
commit
8191d51847
@ -1,10 +1,9 @@
|
|||||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||||
import { getMaxStanding } from "@/src/helpers/syndicateStandingHelper";
|
import { addMiscItems, addStanding, getInventory } from "@/src/services/inventoryService";
|
||||||
import { addMiscItems, getInventory, getStandingLimit, updateStandingLimit } from "@/src/services/inventoryService";
|
|
||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
|
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
import { ExportResources, ExportSyndicates } from "warframe-public-export-plus";
|
import { ExportResources } from "warframe-public-export-plus";
|
||||||
|
|
||||||
export const fishmongerController: RequestHandler = async (req, res) => {
|
export const fishmongerController: RequestHandler = async (req, res) => {
|
||||||
const accountId = await getAccountIdForRequest(req);
|
const accountId = await getAccountIdForRequest(req);
|
||||||
@ -31,25 +30,7 @@ export const fishmongerController: RequestHandler = async (req, res) => {
|
|||||||
miscItemChanges.push({ ItemType: fish.ItemType, ItemCount: fish.ItemCount * -1 });
|
miscItemChanges.push({ ItemType: fish.ItemType, ItemCount: fish.ItemCount * -1 });
|
||||||
}
|
}
|
||||||
addMiscItems(inventory, miscItemChanges);
|
addMiscItems(inventory, miscItemChanges);
|
||||||
if (gainedStanding && syndicateTag) {
|
if (gainedStanding && syndicateTag) addStanding(inventory, syndicateTag, gainedStanding);
|
||||||
let syndicate = inventory.Affiliations.find(x => x.Tag == syndicateTag);
|
|
||||||
if (!syndicate) {
|
|
||||||
syndicate = inventory.Affiliations[inventory.Affiliations.push({ Tag: syndicateTag, Standing: 0 }) - 1];
|
|
||||||
}
|
|
||||||
const syndicateMeta = ExportSyndicates[syndicateTag];
|
|
||||||
|
|
||||||
const max = getMaxStanding(syndicateMeta, syndicate.Title ?? 0);
|
|
||||||
if (syndicate.Standing + gainedStanding > max) {
|
|
||||||
gainedStanding = max - syndicate.Standing;
|
|
||||||
}
|
|
||||||
if (gainedStanding > getStandingLimit(inventory, syndicateMeta.dailyLimitBin)) {
|
|
||||||
gainedStanding = getStandingLimit(inventory, syndicateMeta.dailyLimitBin);
|
|
||||||
}
|
|
||||||
|
|
||||||
syndicate.Standing += gainedStanding;
|
|
||||||
|
|
||||||
updateStandingLimit(inventory, syndicateMeta.dailyLimitBin, gainedStanding);
|
|
||||||
}
|
|
||||||
await inventory.save();
|
await inventory.save();
|
||||||
res.json({
|
res.json({
|
||||||
InventoryChanges: {
|
InventoryChanges: {
|
||||||
|
@ -1,16 +1,9 @@
|
|||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
import {
|
import { addMiscItems, addStanding, freeUpSlot, getInventory } from "@/src/services/inventoryService";
|
||||||
addMiscItems,
|
|
||||||
freeUpSlot,
|
|
||||||
getInventory,
|
|
||||||
getStandingLimit,
|
|
||||||
updateStandingLimit
|
|
||||||
} from "@/src/services/inventoryService";
|
|
||||||
import { IMiscItem, InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
|
import { IMiscItem, InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||||
import { IOid } from "@/src/types/commonTypes";
|
import { IOid } from "@/src/types/commonTypes";
|
||||||
import { ExportSyndicates, ExportWeapons } from "warframe-public-export-plus";
|
import { ExportSyndicates, ExportWeapons } from "warframe-public-export-plus";
|
||||||
import { getMaxStanding } from "@/src/helpers/syndicateStandingHelper";
|
|
||||||
import { logger } from "@/src/utils/logger";
|
import { logger } from "@/src/utils/logger";
|
||||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
|
import { IInventoryChanges } from "@/src/types/purchaseTypes";
|
||||||
import { EquipmentFeatures } from "@/src/types/inventoryTypes/commonInventoryTypes";
|
import { EquipmentFeatures } from "@/src/types/inventoryTypes/commonInventoryTypes";
|
||||||
@ -61,38 +54,13 @@ export const syndicateStandingBonusController: RequestHandler = async (req, res)
|
|||||||
inventoryChanges[slotBin] = { count: -1, platinum: 0, Slots: 1 };
|
inventoryChanges[slotBin] = { count: -1, platinum: 0, Slots: 1 };
|
||||||
}
|
}
|
||||||
|
|
||||||
let syndicate = inventory.Affiliations.find(x => x.Tag == request.Operation.AffiliationTag);
|
const affiliationMod = addStanding(inventory, request.Operation.AffiliationTag, gainedStanding, true);
|
||||||
if (!syndicate) {
|
|
||||||
syndicate =
|
|
||||||
inventory.Affiliations[
|
|
||||||
inventory.Affiliations.push({ Tag: request.Operation.AffiliationTag, Standing: 0 }) - 1
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
const max = getMaxStanding(syndicateMeta, syndicate.Title ?? 0);
|
|
||||||
if (syndicate.Standing + gainedStanding > max) {
|
|
||||||
gainedStanding = max - syndicate.Standing;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (syndicateMeta.medallionsCappedByDailyLimit) {
|
|
||||||
if (gainedStanding > getStandingLimit(inventory, syndicateMeta.dailyLimitBin)) {
|
|
||||||
gainedStanding = getStandingLimit(inventory, syndicateMeta.dailyLimitBin);
|
|
||||||
}
|
|
||||||
updateStandingLimit(inventory, syndicateMeta.dailyLimitBin, gainedStanding);
|
|
||||||
}
|
|
||||||
|
|
||||||
syndicate.Standing += gainedStanding;
|
|
||||||
|
|
||||||
await inventory.save();
|
await inventory.save();
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
InventoryChanges: inventoryChanges,
|
InventoryChanges: inventoryChanges,
|
||||||
AffiliationMods: [
|
AffiliationMods: [affiliationMod]
|
||||||
{
|
|
||||||
Tag: request.Operation.AffiliationTag,
|
|
||||||
Standing: gainedStanding
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -931,18 +931,14 @@ const standingLimitBinToInventoryKey: Record<
|
|||||||
|
|
||||||
export const allDailyAffiliationKeys: (keyof IDailyAffiliations)[] = Object.values(standingLimitBinToInventoryKey);
|
export const allDailyAffiliationKeys: (keyof IDailyAffiliations)[] = Object.values(standingLimitBinToInventoryKey);
|
||||||
|
|
||||||
export const getStandingLimit = (inventory: IDailyAffiliations, bin: TStandingLimitBin): number => {
|
const getStandingLimit = (inventory: IDailyAffiliations, bin: TStandingLimitBin): number => {
|
||||||
if (bin == "STANDING_LIMIT_BIN_NONE" || config.noDailyStandingLimits) {
|
if (bin == "STANDING_LIMIT_BIN_NONE" || config.noDailyStandingLimits) {
|
||||||
return Number.MAX_SAFE_INTEGER;
|
return Number.MAX_SAFE_INTEGER;
|
||||||
}
|
}
|
||||||
return inventory[standingLimitBinToInventoryKey[bin]];
|
return inventory[standingLimitBinToInventoryKey[bin]];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateStandingLimit = (
|
const updateStandingLimit = (inventory: IDailyAffiliations, bin: TStandingLimitBin, subtrahend: number): void => {
|
||||||
inventory: IDailyAffiliations,
|
|
||||||
bin: TStandingLimitBin,
|
|
||||||
subtrahend: number
|
|
||||||
): void => {
|
|
||||||
if (bin != "STANDING_LIMIT_BIN_NONE" && !config.noDailyStandingLimits) {
|
if (bin != "STANDING_LIMIT_BIN_NONE" && !config.noDailyStandingLimits) {
|
||||||
inventory[standingLimitBinToInventoryKey[bin]] -= subtrahend;
|
inventory[standingLimitBinToInventoryKey[bin]] -= subtrahend;
|
||||||
}
|
}
|
||||||
@ -951,7 +947,8 @@ export const updateStandingLimit = (
|
|||||||
export const addStanding = (
|
export const addStanding = (
|
||||||
inventory: TInventoryDatabaseDocument,
|
inventory: TInventoryDatabaseDocument,
|
||||||
syndicateTag: string,
|
syndicateTag: string,
|
||||||
gainedStanding: number
|
gainedStanding: number,
|
||||||
|
isMedallion: boolean = false
|
||||||
): IAffiliationMods => {
|
): IAffiliationMods => {
|
||||||
let syndicate = inventory.Affiliations.find(x => x.Tag == syndicateTag);
|
let syndicate = inventory.Affiliations.find(x => x.Tag == syndicateTag);
|
||||||
const syndicateMeta = ExportSyndicates[syndicateTag];
|
const syndicateMeta = ExportSyndicates[syndicateTag];
|
||||||
@ -964,10 +961,12 @@ export const addStanding = (
|
|||||||
const max = getMaxStanding(syndicateMeta, syndicate.Title ?? 0);
|
const max = getMaxStanding(syndicateMeta, syndicate.Title ?? 0);
|
||||||
if (syndicate.Standing + gainedStanding > max) gainedStanding = max - syndicate.Standing;
|
if (syndicate.Standing + gainedStanding > max) gainedStanding = max - syndicate.Standing;
|
||||||
|
|
||||||
if (gainedStanding > getStandingLimit(inventory, syndicateMeta.dailyLimitBin)) {
|
if (!isMedallion || (isMedallion && syndicateMeta.medallionsCappedByDailyLimit)) {
|
||||||
gainedStanding = getStandingLimit(inventory, syndicateMeta.dailyLimitBin);
|
if (gainedStanding > getStandingLimit(inventory, syndicateMeta.dailyLimitBin)) {
|
||||||
|
gainedStanding = getStandingLimit(inventory, syndicateMeta.dailyLimitBin);
|
||||||
|
}
|
||||||
|
updateStandingLimit(inventory, syndicateMeta.dailyLimitBin, gainedStanding);
|
||||||
}
|
}
|
||||||
updateStandingLimit(inventory, syndicateMeta.dailyLimitBin, gainedStanding);
|
|
||||||
|
|
||||||
syndicate.Standing += gainedStanding;
|
syndicate.Standing += gainedStanding;
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user