feat: consume search pulse for doing netracells (#2675)
Reviewed-on: #2675 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
							
								
									4b46938dab
								
							
						
					
					
						commit
						03b8b610db
					
				@ -1,6 +1,6 @@
 | 
				
			|||||||
import { toMongoDate } from "@/src/helpers/inventoryHelpers";
 | 
					import { toMongoDate } from "@/src/helpers/inventoryHelpers";
 | 
				
			||||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
					import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
				
			||||||
import { getInventory } from "@/src/services/inventoryService";
 | 
					import { getInventory, updateEntratiVault } from "@/src/services/inventoryService";
 | 
				
			||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
					import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
				
			||||||
import { RequestHandler } from "express";
 | 
					import { RequestHandler } from "express";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -11,26 +11,7 @@ export const entratiLabConquestModeController: RequestHandler = async (req, res)
 | 
				
			|||||||
        "EntratiVaultCountResetDate EntratiVaultCountLastPeriod EntratiLabConquestUnlocked EchoesHexConquestUnlocked EchoesHexConquestActiveFrameVariants EchoesHexConquestActiveStickers EntratiLabConquestActiveFrameVariants EntratiLabConquestCacheScoreMission EchoesHexConquestCacheScoreMission"
 | 
					        "EntratiVaultCountResetDate EntratiVaultCountLastPeriod EntratiLabConquestUnlocked EchoesHexConquestUnlocked EchoesHexConquestActiveFrameVariants EchoesHexConquestActiveStickers EntratiLabConquestActiveFrameVariants EntratiLabConquestCacheScoreMission EchoesHexConquestCacheScoreMission"
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
    const body = getJSONfromString<IEntratiLabConquestModeRequest>(String(req.body));
 | 
					    const body = getJSONfromString<IEntratiLabConquestModeRequest>(String(req.body));
 | 
				
			||||||
    if (!inventory.EntratiVaultCountResetDate || Date.now() >= inventory.EntratiVaultCountResetDate.getTime()) {
 | 
					    updateEntratiVault(inventory);
 | 
				
			||||||
        const EPOCH = 1734307200 * 1000; // Mondays, amirite?
 | 
					 | 
				
			||||||
        const day = Math.trunc((Date.now() - EPOCH) / 86400000);
 | 
					 | 
				
			||||||
        const week = Math.trunc(day / 7);
 | 
					 | 
				
			||||||
        const weekStart = EPOCH + week * 604800000;
 | 
					 | 
				
			||||||
        const weekEnd = weekStart + 604800000;
 | 
					 | 
				
			||||||
        inventory.EntratiVaultCountLastPeriod = 0;
 | 
					 | 
				
			||||||
        inventory.EntratiVaultCountResetDate = new Date(weekEnd);
 | 
					 | 
				
			||||||
        if (inventory.EntratiLabConquestUnlocked) {
 | 
					 | 
				
			||||||
            inventory.EntratiLabConquestUnlocked = 0;
 | 
					 | 
				
			||||||
            inventory.EntratiLabConquestCacheScoreMission = 0;
 | 
					 | 
				
			||||||
            inventory.EntratiLabConquestActiveFrameVariants = [];
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if (inventory.EchoesHexConquestUnlocked) {
 | 
					 | 
				
			||||||
            inventory.EchoesHexConquestUnlocked = 0;
 | 
					 | 
				
			||||||
            inventory.EchoesHexConquestCacheScoreMission = 0;
 | 
					 | 
				
			||||||
            inventory.EchoesHexConquestActiveFrameVariants = [];
 | 
					 | 
				
			||||||
            inventory.EchoesHexConquestActiveStickers = [];
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    if (body.BuyMode) {
 | 
					    if (body.BuyMode) {
 | 
				
			||||||
        inventory.EntratiVaultCountLastPeriod! += 2;
 | 
					        inventory.EntratiVaultCountLastPeriod! += 2;
 | 
				
			||||||
        if (body.IsEchoesDeepArchemedea) {
 | 
					        if (body.IsEchoesDeepArchemedea) {
 | 
				
			||||||
@ -51,7 +32,7 @@ export const entratiLabConquestModeController: RequestHandler = async (req, res)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    await inventory.save();
 | 
					    await inventory.save();
 | 
				
			||||||
    res.json({
 | 
					    res.json({
 | 
				
			||||||
        EntratiVaultCountResetDate: toMongoDate(inventory.EntratiVaultCountResetDate),
 | 
					        EntratiVaultCountResetDate: toMongoDate(inventory.EntratiVaultCountResetDate!),
 | 
				
			||||||
        EntratiVaultCountLastPeriod: inventory.EntratiVaultCountLastPeriod,
 | 
					        EntratiVaultCountLastPeriod: inventory.EntratiVaultCountLastPeriod,
 | 
				
			||||||
        EntratiLabConquestUnlocked: inventory.EntratiLabConquestUnlocked,
 | 
					        EntratiLabConquestUnlocked: inventory.EntratiLabConquestUnlocked,
 | 
				
			||||||
        EntratiLabConquestCacheScoreMission: inventory.EntratiLabConquestCacheScoreMission,
 | 
					        EntratiLabConquestCacheScoreMission: inventory.EntratiLabConquestCacheScoreMission,
 | 
				
			||||||
 | 
				
			|||||||
@ -2449,3 +2449,26 @@ export const giveNemesisPetRecipe = (
 | 
				
			|||||||
export const getEffectiveAvatarImageType = (inventory: TInventoryDatabaseDocument): string => {
 | 
					export const getEffectiveAvatarImageType = (inventory: TInventoryDatabaseDocument): string => {
 | 
				
			||||||
    return inventory.ActiveAvatarImageType ?? "/Lotus/Types/StoreItems/AvatarImages/AvatarImageDefault";
 | 
					    return inventory.ActiveAvatarImageType ?? "/Lotus/Types/StoreItems/AvatarImages/AvatarImageDefault";
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const updateEntratiVault = (inventory: TInventoryDatabaseDocument): void => {
 | 
				
			||||||
 | 
					    if (!inventory.EntratiVaultCountResetDate || Date.now() >= inventory.EntratiVaultCountResetDate.getTime()) {
 | 
				
			||||||
 | 
					        const EPOCH = 1734307200 * 1000; // Mondays, amirite?
 | 
				
			||||||
 | 
					        const day = Math.trunc((Date.now() - EPOCH) / 86400000);
 | 
				
			||||||
 | 
					        const week = Math.trunc(day / 7);
 | 
				
			||||||
 | 
					        const weekStart = EPOCH + week * 604800000;
 | 
				
			||||||
 | 
					        const weekEnd = weekStart + 604800000;
 | 
				
			||||||
 | 
					        inventory.EntratiVaultCountLastPeriod = 0;
 | 
				
			||||||
 | 
					        inventory.EntratiVaultCountResetDate = new Date(weekEnd);
 | 
				
			||||||
 | 
					        if (inventory.EntratiLabConquestUnlocked) {
 | 
				
			||||||
 | 
					            inventory.EntratiLabConquestUnlocked = 0;
 | 
				
			||||||
 | 
					            inventory.EntratiLabConquestCacheScoreMission = 0;
 | 
				
			||||||
 | 
					            inventory.EntratiLabConquestActiveFrameVariants = [];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if (inventory.EchoesHexConquestUnlocked) {
 | 
				
			||||||
 | 
					            inventory.EchoesHexConquestUnlocked = 0;
 | 
				
			||||||
 | 
					            inventory.EchoesHexConquestCacheScoreMission = 0;
 | 
				
			||||||
 | 
					            inventory.EchoesHexConquestActiveFrameVariants = [];
 | 
				
			||||||
 | 
					            inventory.EchoesHexConquestActiveStickers = [];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -39,6 +39,7 @@ import {
 | 
				
			|||||||
    giveNemesisPetRecipe,
 | 
					    giveNemesisPetRecipe,
 | 
				
			||||||
    giveNemesisWeaponRecipe,
 | 
					    giveNemesisWeaponRecipe,
 | 
				
			||||||
    updateCurrency,
 | 
					    updateCurrency,
 | 
				
			||||||
 | 
					    updateEntratiVault,
 | 
				
			||||||
    updateSyndicate
 | 
					    updateSyndicate
 | 
				
			||||||
} from "@/src/services/inventoryService";
 | 
					} from "@/src/services/inventoryService";
 | 
				
			||||||
import { updateQuestKey } from "@/src/services/questService";
 | 
					import { updateQuestKey } from "@/src/services/questService";
 | 
				
			||||||
@ -1084,6 +1085,22 @@ const droptableAliases: Record<string, string> = {
 | 
				
			|||||||
        "/Lotus/Types/DropTables/WF1999DropTables/LasrianTankHardModeDropTable"
 | 
					        "/Lotus/Types/DropTables/WF1999DropTables/LasrianTankHardModeDropTable"
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const isEligibleForCreditReward = (rewardInfo: IRewardInfo, missions: IMission, node: IRegion): boolean => {
 | 
				
			||||||
 | 
					    // (E)SO should not give credits for only completing zone 1, in which case it has no rewardQualifications (https://onlyg.it/OpenWF/SpaceNinjaServer/issues/1823)
 | 
				
			||||||
 | 
					    if (getRotations(rewardInfo).length == 0) {
 | 
				
			||||||
 | 
					        return missions.Tag == "SolNode720"; // Netracells don't use rewardQualifications but probably should give credits anyway
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // The rest here might not be needed anymore, but just to be sure we don't give undue credits...
 | 
				
			||||||
 | 
					    return (
 | 
				
			||||||
 | 
					        node.missionIndex != 23 && // junction
 | 
				
			||||||
 | 
					        node.missionIndex != 28 && // open world
 | 
				
			||||||
 | 
					        missions.Tag != "SolNode761" && // the index
 | 
				
			||||||
 | 
					        missions.Tag != "SolNode762" && // the index
 | 
				
			||||||
 | 
					        missions.Tag != "SolNode763" && // the index
 | 
				
			||||||
 | 
					        missions.Tag != "CrewBattleNode556" // free flight
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//TODO: return type of partial missioninventoryupdate response
 | 
					//TODO: return type of partial missioninventoryupdate response
 | 
				
			||||||
export const addMissionRewards = async (
 | 
					export const addMissionRewards = async (
 | 
				
			||||||
    account: TAccountDocument,
 | 
					    account: TAccountDocument,
 | 
				
			||||||
@ -1176,15 +1193,7 @@ export const addMissionRewards = async (
 | 
				
			|||||||
        const node = ExportRegions[missions.Tag];
 | 
					        const node = ExportRegions[missions.Tag];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //node based credit rewards for mission completion
 | 
					        //node based credit rewards for mission completion
 | 
				
			||||||
        if (
 | 
					        if (isEligibleForCreditReward(rewardInfo, missions, node)) {
 | 
				
			||||||
            node.missionIndex != 23 && // junction
 | 
					 | 
				
			||||||
            node.missionIndex != 28 && // open world
 | 
					 | 
				
			||||||
            missions.Tag != "SolNode761" && // the index
 | 
					 | 
				
			||||||
            missions.Tag != "SolNode762" && // the index
 | 
					 | 
				
			||||||
            missions.Tag != "SolNode763" && // the index
 | 
					 | 
				
			||||||
            missions.Tag != "CrewBattleNode556" && // free flight
 | 
					 | 
				
			||||||
            getRotations(rewardInfo).length > 0 // (E)SO should not give credits for only completing zone 1, in which case it has no rewardQualifications (https://onlyg.it/OpenWF/SpaceNinjaServer/issues/1823)
 | 
					 | 
				
			||||||
        ) {
 | 
					 | 
				
			||||||
            const levelCreditReward = getLevelCreditRewards(node);
 | 
					            const levelCreditReward = getLevelCreditRewards(node);
 | 
				
			||||||
            missionCompletionCredits += levelCreditReward;
 | 
					            missionCompletionCredits += levelCreditReward;
 | 
				
			||||||
            logger.debug(`levelCreditReward ${levelCreditReward}`);
 | 
					            logger.debug(`levelCreditReward ${levelCreditReward}`);
 | 
				
			||||||
@ -1214,6 +1223,12 @@ export const addMissionRewards = async (
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            ]);
 | 
					            ]);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Consume netracells search pulse. Moved here to only cover successful completions. Discussed in https://onlyg.it/OpenWF/SpaceNinjaServer/issues/2673
 | 
				
			||||||
 | 
					        if (missions.Tag == "SolNode720") {
 | 
				
			||||||
 | 
					            updateEntratiVault(inventory);
 | 
				
			||||||
 | 
					            inventory.EntratiVaultCountLastPeriod! += 1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (rewardInfo.useVaultManifest) {
 | 
					    if (rewardInfo.useVaultManifest) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user