forked from OpenWF/SpaceNinjaServer
		
	feat: handle classic syndicate alignments when trading in medals (#2157)
Reviewed-on: OpenWF/SpaceNinjaServer#2157 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
							
								
									8b27fcf459
								
							
						
					
					
						commit
						b67ddf6df2
					
				@ -30,15 +30,14 @@ export const fishmongerController: RequestHandler = async (req, res) => {
 | 
			
		||||
        miscItemChanges.push({ ItemType: fish.ItemType, ItemCount: fish.ItemCount * -1 });
 | 
			
		||||
    }
 | 
			
		||||
    addMiscItems(inventory, miscItemChanges);
 | 
			
		||||
    let affiliationMod;
 | 
			
		||||
    if (gainedStanding && syndicateTag) affiliationMod = addStanding(inventory, syndicateTag, gainedStanding);
 | 
			
		||||
    if (gainedStanding && syndicateTag) addStanding(inventory, syndicateTag, gainedStanding);
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
    res.json({
 | 
			
		||||
        InventoryChanges: {
 | 
			
		||||
            MiscItems: miscItemChanges
 | 
			
		||||
        },
 | 
			
		||||
        SyndicateTag: syndicateTag,
 | 
			
		||||
        StandingChange: affiliationMod?.Standing || 0
 | 
			
		||||
        StandingChange: gainedStanding
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -5,7 +5,7 @@ import { IMiscItem, InventorySlot } from "@/src/types/inventoryTypes/inventoryTy
 | 
			
		||||
import { IOid } from "@/src/types/commonTypes";
 | 
			
		||||
import { ExportSyndicates, ExportWeapons } from "warframe-public-export-plus";
 | 
			
		||||
import { logger } from "@/src/utils/logger";
 | 
			
		||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
			
		||||
import { IAffiliationMods, IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
			
		||||
import { EquipmentFeatures } from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
			
		||||
 | 
			
		||||
export const syndicateStandingBonusController: RequestHandler = async (req, res) => {
 | 
			
		||||
@ -54,13 +54,14 @@ export const syndicateStandingBonusController: RequestHandler = async (req, res)
 | 
			
		||||
        inventoryChanges[slotBin] = { count: -1, platinum: 0, Slots: 1 };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const affiliationMod = addStanding(inventory, request.Operation.AffiliationTag, gainedStanding, true);
 | 
			
		||||
    const affiliationMods: IAffiliationMods[] = [];
 | 
			
		||||
    addStanding(inventory, request.Operation.AffiliationTag, gainedStanding, affiliationMods, true);
 | 
			
		||||
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
 | 
			
		||||
    res.json({
 | 
			
		||||
        InventoryChanges: inventoryChanges,
 | 
			
		||||
        AffiliationMods: [affiliationMod]
 | 
			
		||||
        AffiliationMods: affiliationMods
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -10,3 +10,14 @@ export const getMaxStanding = (syndicate: ISyndicate, title: number): number =>
 | 
			
		||||
    }
 | 
			
		||||
    return syndicate.titles.find(x => x.level == title)!.maxStanding;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getMinStanding = (syndicate: ISyndicate, title: number): number => {
 | 
			
		||||
    if (!syndicate.titles) {
 | 
			
		||||
        // LibrarySyndicate
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
    if (title == 0) {
 | 
			
		||||
        return syndicate.titles.find(x => x.level == -1)!.maxStanding;
 | 
			
		||||
    }
 | 
			
		||||
    return syndicate.titles.find(x => x.level == title)!.minStanding;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -82,7 +82,7 @@ import { handleBundleAcqusition } from "./purchaseService";
 | 
			
		||||
import libraryDailyTasks from "@/static/fixed_responses/libraryDailyTasks.json";
 | 
			
		||||
import { getRandomElement, getRandomInt, getRandomWeightedReward, SRng } from "./rngService";
 | 
			
		||||
import { createMessage } from "./inboxService";
 | 
			
		||||
import { getMaxStanding } from "@/src/helpers/syndicateStandingHelper";
 | 
			
		||||
import { getMaxStanding, getMinStanding } from "@/src/helpers/syndicateStandingHelper";
 | 
			
		||||
import { getNightwaveSyndicateTag, getWorldState } from "./worldStateService";
 | 
			
		||||
import { generateNemesisProfile, INemesisProfile } from "../helpers/nemesisHelpers";
 | 
			
		||||
import { TAccountDocument } from "./loginService";
 | 
			
		||||
@ -1202,8 +1202,10 @@ export const addStanding = (
 | 
			
		||||
    inventory: TInventoryDatabaseDocument,
 | 
			
		||||
    syndicateTag: string,
 | 
			
		||||
    gainedStanding: number,
 | 
			
		||||
    isMedallion: boolean = false
 | 
			
		||||
): IAffiliationMods => {
 | 
			
		||||
    affiliationMods: IAffiliationMods[] = [],
 | 
			
		||||
    isMedallion: boolean = false,
 | 
			
		||||
    propagateAlignments: boolean = true
 | 
			
		||||
): void => {
 | 
			
		||||
    let syndicate = inventory.Affiliations.find(x => x.Tag == syndicateTag);
 | 
			
		||||
    const syndicateMeta = ExportSyndicates[syndicateTag];
 | 
			
		||||
 | 
			
		||||
@ -1215,6 +1217,10 @@ export const addStanding = (
 | 
			
		||||
    const max = getMaxStanding(syndicateMeta, syndicate.Title ?? 0);
 | 
			
		||||
    if (syndicate.Standing + gainedStanding > max) gainedStanding = max - syndicate.Standing;
 | 
			
		||||
 | 
			
		||||
    if (syndicate.Title == -2 && syndicate.Standing + gainedStanding < -71000) {
 | 
			
		||||
        gainedStanding = -71000 + syndicate.Standing;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (!isMedallion || syndicateMeta.medallionsCappedByDailyLimit) {
 | 
			
		||||
        if (gainedStanding > getStandingLimit(inventory, syndicateMeta.dailyLimitBin)) {
 | 
			
		||||
            gainedStanding = getStandingLimit(inventory, syndicateMeta.dailyLimitBin);
 | 
			
		||||
@ -1223,10 +1229,27 @@ export const addStanding = (
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    syndicate.Standing += gainedStanding;
 | 
			
		||||
    return {
 | 
			
		||||
    const affiliationMod: IAffiliationMods = {
 | 
			
		||||
        Tag: syndicateTag,
 | 
			
		||||
        Standing: gainedStanding
 | 
			
		||||
    };
 | 
			
		||||
    affiliationMods.push(affiliationMod);
 | 
			
		||||
 | 
			
		||||
    if (syndicateMeta.alignments) {
 | 
			
		||||
        if (propagateAlignments) {
 | 
			
		||||
            for (const [tag, factor] of Object.entries(syndicateMeta.alignments)) {
 | 
			
		||||
                addStanding(inventory, tag, gainedStanding * factor, affiliationMods, isMedallion, false);
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            while (syndicate.Standing < getMinStanding(syndicateMeta, syndicate.Title ?? 0)) {
 | 
			
		||||
                syndicate.Title ??= 0;
 | 
			
		||||
                syndicate.Title -= 1;
 | 
			
		||||
                affiliationMod.Title ??= 0;
 | 
			
		||||
                affiliationMod.Title -= 1;
 | 
			
		||||
                logger.debug(`${syndicateTag} is decreasing to title ${syndicate.Title} after applying alignment`);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// TODO: AffiliationMods support (Nightwave).
 | 
			
		||||
 | 
			
		||||
@ -1236,19 +1236,18 @@ export const addMissionRewards = async (
 | 
			
		||||
                SyndicateXPItemReward = medallionAmount;
 | 
			
		||||
            } else {
 | 
			
		||||
                if (rewardInfo.JobTier! >= 0) {
 | 
			
		||||
                    AffiliationMods.push(
 | 
			
		||||
                        addStanding(
 | 
			
		||||
                            inventory,
 | 
			
		||||
                            syndicateEntry.Tag,
 | 
			
		||||
                            Math.floor(currentJob.xpAmounts[rewardInfo.JobStage] / (rewardInfo.Q ? 0.8 : 1))
 | 
			
		||||
                        )
 | 
			
		||||
                    addStanding(
 | 
			
		||||
                        inventory,
 | 
			
		||||
                        syndicateEntry.Tag,
 | 
			
		||||
                        Math.floor(currentJob.xpAmounts[rewardInfo.JobStage] / (rewardInfo.Q ? 0.8 : 1)),
 | 
			
		||||
                        AffiliationMods
 | 
			
		||||
                    );
 | 
			
		||||
                } else {
 | 
			
		||||
                    if (jobType.endsWith("Heists/HeistProfitTakerBountyOne") && rewardInfo.JobStage === 2) {
 | 
			
		||||
                        AffiliationMods.push(addStanding(inventory, syndicateEntry.Tag, 1000));
 | 
			
		||||
                        addStanding(inventory, syndicateEntry.Tag, 1000, AffiliationMods);
 | 
			
		||||
                    }
 | 
			
		||||
                    if (jobType.endsWith("Hunts/AllTeralystsHunt") && rewardInfo.JobStage === 2) {
 | 
			
		||||
                        AffiliationMods.push(addStanding(inventory, syndicateEntry.Tag, 5000));
 | 
			
		||||
                        addStanding(inventory, syndicateEntry.Tag, 5000, AffiliationMods);
 | 
			
		||||
                    }
 | 
			
		||||
                    if (
 | 
			
		||||
                        [
 | 
			
		||||
@ -1259,7 +1258,7 @@ export const addMissionRewards = async (
 | 
			
		||||
                            "Heists/HeistExploiterBountyOne"
 | 
			
		||||
                        ].some(ending => jobType.endsWith(ending))
 | 
			
		||||
                    ) {
 | 
			
		||||
                        AffiliationMods.push(addStanding(inventory, syndicateEntry.Tag, 1000));
 | 
			
		||||
                        addStanding(inventory, syndicateEntry.Tag, 1000, AffiliationMods);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
@ -1284,7 +1283,7 @@ export const addMissionRewards = async (
 | 
			
		||||
            let standingAmount = (tier + 1) * 1000;
 | 
			
		||||
            if (tier > 5) standingAmount = 7500; // InfestedLichBounty
 | 
			
		||||
            if (isSteelPath) standingAmount *= 1.5;
 | 
			
		||||
            AffiliationMods.push(addStanding(inventory, syndicateTag, standingAmount));
 | 
			
		||||
            addStanding(inventory, syndicateTag, standingAmount, AffiliationMods);
 | 
			
		||||
        }
 | 
			
		||||
        if (syndicateTag == "HexSyndicate" && chemistry && tier < 6) {
 | 
			
		||||
            const seed = getWorldState().SyndicateMissions.find(x => x.Tag == "HexSyndicate")!.Seed;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user