move noDailyStandingLimits logic from syndicateStandingBonusController to inventoryService
This commit is contained in:
		
							parent
							
								
									bbca21467b
								
							
						
					
					
						commit
						e020930e6e
					
				@ -4,7 +4,6 @@ import { addMiscItems, getInventory, getStandingLimit, updateStandingLimit } fro
 | 
			
		||||
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { IOid } from "@/src/types/commonTypes";
 | 
			
		||||
import { ExportSyndicates, ISyndicate } from "warframe-public-export-plus";
 | 
			
		||||
import { config } from "@/src/services/configService";
 | 
			
		||||
 | 
			
		||||
export const syndicateStandingBonusController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
@ -37,15 +36,13 @@ export const syndicateStandingBonusController: RequestHandler = async (req, res)
 | 
			
		||||
    if (syndicate.Standing + gainedStanding > max) {
 | 
			
		||||
        gainedStanding = max - syndicate.Standing;
 | 
			
		||||
    }
 | 
			
		||||
    if (!config.noDailyStandingLimits && gainedStanding > getStandingLimit(inventory, syndicateMeta.dailyLimitBin)) {
 | 
			
		||||
    if (gainedStanding > getStandingLimit(inventory, syndicateMeta.dailyLimitBin)) {
 | 
			
		||||
        gainedStanding = getStandingLimit(inventory, syndicateMeta.dailyLimitBin);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    syndicate.Standing += gainedStanding;
 | 
			
		||||
 | 
			
		||||
    if (!config.noDailyStandingLimits) {
 | 
			
		||||
        updateStandingLimit(inventory, syndicateMeta.dailyLimitBin, gainedStanding);
 | 
			
		||||
    }
 | 
			
		||||
    updateStandingLimit(inventory, syndicateMeta.dailyLimitBin, gainedStanding);
 | 
			
		||||
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -519,7 +519,7 @@ export const allDailyAffiliationKeys: (keyof IDailyAffiliations)[] = Object.entr
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
export const getStandingLimit = (inventory: IDailyAffiliations, bin: TStandingLimitBin): number => {
 | 
			
		||||
    if (bin == "STANDING_LIMIT_BIN_NONE") {
 | 
			
		||||
    if (bin == "STANDING_LIMIT_BIN_NONE" || config.noDailyStandingLimits) {
 | 
			
		||||
        return Number.MAX_SAFE_INTEGER;
 | 
			
		||||
    }
 | 
			
		||||
    return inventory[standingLimitBinToInventoryKey[bin]];
 | 
			
		||||
@ -530,7 +530,7 @@ export const updateStandingLimit = (
 | 
			
		||||
    bin: TStandingLimitBin,
 | 
			
		||||
    subtrahend: number
 | 
			
		||||
): void => {
 | 
			
		||||
    if (bin != "STANDING_LIMIT_BIN_NONE") {
 | 
			
		||||
    if (bin != "STANDING_LIMIT_BIN_NONE" && !config.noDailyStandingLimits) {
 | 
			
		||||
        inventory[standingLimitBinToInventoryKey[bin]] -= subtrahend;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user