forked from OpenWF/SpaceNinjaServer
		
	fix: allow completion of unknown nodes (#1395)
Reviewed-on: OpenWF/SpaceNinjaServer#1395 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
							
								
									23f8901505
								
							
						
					
					
						commit
						b0f0b61d49
					
				@ -24,7 +24,6 @@ import {
 | 
				
			|||||||
    ExportGear,
 | 
					    ExportGear,
 | 
				
			||||||
    ExportKeys,
 | 
					    ExportKeys,
 | 
				
			||||||
    ExportRecipes,
 | 
					    ExportRecipes,
 | 
				
			||||||
    ExportRegions,
 | 
					 | 
				
			||||||
    ExportResources,
 | 
					    ExportResources,
 | 
				
			||||||
    ExportSentinels,
 | 
					    ExportSentinels,
 | 
				
			||||||
    ExportWarframes,
 | 
					    ExportWarframes,
 | 
				
			||||||
@ -34,7 +33,6 @@ import {
 | 
				
			|||||||
    IMissionReward,
 | 
					    IMissionReward,
 | 
				
			||||||
    IPowersuit,
 | 
					    IPowersuit,
 | 
				
			||||||
    IRecipe,
 | 
					    IRecipe,
 | 
				
			||||||
    IRegion,
 | 
					 | 
				
			||||||
    TReward
 | 
					    TReward
 | 
				
			||||||
} from "warframe-public-export-plus";
 | 
					} from "warframe-public-export-plus";
 | 
				
			||||||
import questCompletionItems from "@/static/fixed_responses/questCompletionRewards.json";
 | 
					import questCompletionItems from "@/static/fixed_responses/questCompletionRewards.json";
 | 
				
			||||||
@ -192,16 +190,6 @@ export const getLevelKeyRewards = (
 | 
				
			|||||||
    };
 | 
					    };
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const getNode = (nodeName: string): IRegion => {
 | 
					 | 
				
			||||||
    const node = ExportRegions[nodeName];
 | 
					 | 
				
			||||||
    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
 | 
					 | 
				
			||||||
    if (!node) {
 | 
					 | 
				
			||||||
        throw new Error(`Node ${nodeName} not found`);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return node;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export const getQuestCompletionItems = (questKey: string): ITypeCount[] | undefined => {
 | 
					export const getQuestCompletionItems = (questKey: string): ITypeCount[] | undefined => {
 | 
				
			||||||
    if (questKey in questCompletionItems) {
 | 
					    if (questKey in questCompletionItems) {
 | 
				
			||||||
        return questCompletionItems[questKey as keyof typeof questCompletionItems];
 | 
					        return questCompletionItems[questKey as keyof typeof questCompletionItems];
 | 
				
			||||||
 | 
				
			|||||||
@ -4,6 +4,7 @@ import {
 | 
				
			|||||||
    ExportRegions,
 | 
					    ExportRegions,
 | 
				
			||||||
    ExportRewards,
 | 
					    ExportRewards,
 | 
				
			||||||
    IMissionReward as IMissionRewardExternal,
 | 
					    IMissionReward as IMissionRewardExternal,
 | 
				
			||||||
 | 
					    IRegion,
 | 
				
			||||||
    IReward
 | 
					    IReward
 | 
				
			||||||
} from "warframe-public-export-plus";
 | 
					} from "warframe-public-export-plus";
 | 
				
			||||||
import { IMissionInventoryUpdateRequest, IRewardInfo } from "../types/requestTypes";
 | 
					import { IMissionInventoryUpdateRequest, IRewardInfo } from "../types/requestTypes";
 | 
				
			||||||
@ -32,7 +33,7 @@ import {
 | 
				
			|||||||
import { updateQuestKey } from "@/src/services/questService";
 | 
					import { updateQuestKey } from "@/src/services/questService";
 | 
				
			||||||
import { HydratedDocument, Types } from "mongoose";
 | 
					import { HydratedDocument, Types } from "mongoose";
 | 
				
			||||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
					import { IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
				
			||||||
import { getLevelKeyRewards, getNode, toStoreItem } from "@/src/services/itemDataService";
 | 
					import { getLevelKeyRewards, toStoreItem } from "@/src/services/itemDataService";
 | 
				
			||||||
import { InventoryDocumentProps, TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
 | 
					import { InventoryDocumentProps, TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
 | 
				
			||||||
import { getEntriesUnsafe } from "@/src/utils/ts-utils";
 | 
					import { getEntriesUnsafe } from "@/src/utils/ts-utils";
 | 
				
			||||||
import { IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
					import { IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
				
			||||||
@ -469,15 +470,15 @@ export const addMissionRewards = async (
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (
 | 
					    // ignoring tags not in ExportRegions, because it can just be garbage:
 | 
				
			||||||
        missions &&
 | 
					    // - https://onlyg.it/OpenWF/SpaceNinjaServer/issues/1013
 | 
				
			||||||
        missions.Tag != "" // https://onlyg.it/OpenWF/SpaceNinjaServer/issues/1013
 | 
					    // - https://onlyg.it/OpenWF/SpaceNinjaServer/issues/1365
 | 
				
			||||||
    ) {
 | 
					    if (missions && missions.Tag in ExportRegions) {
 | 
				
			||||||
        const node = getNode(missions.Tag);
 | 
					        const node = ExportRegions[missions.Tag];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //node based credit rewards for mission completion
 | 
					        //node based credit rewards for mission completion
 | 
				
			||||||
        if (node.missionIndex !== 28) {
 | 
					        if (node.missionIndex !== 28) {
 | 
				
			||||||
            const levelCreditReward = getLevelCreditRewards(missions.Tag);
 | 
					            const levelCreditReward = getLevelCreditRewards(node);
 | 
				
			||||||
            missionCompletionCredits += levelCreditReward;
 | 
					            missionCompletionCredits += levelCreditReward;
 | 
				
			||||||
            inventory.RegularCredits += levelCreditReward;
 | 
					            inventory.RegularCredits += levelCreditReward;
 | 
				
			||||||
            logger.debug(`levelCreditReward ${levelCreditReward}`);
 | 
					            logger.debug(`levelCreditReward ${levelCreditReward}`);
 | 
				
			||||||
@ -660,8 +661,8 @@ export const addFixedLevelRewards = (
 | 
				
			|||||||
    return missionBonusCredits;
 | 
					    return missionBonusCredits;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function getLevelCreditRewards(nodeName: string): number {
 | 
					function getLevelCreditRewards(node: IRegion): number {
 | 
				
			||||||
    const minEnemyLevel = getNode(nodeName).minEnemyLevel;
 | 
					    const minEnemyLevel = node.minEnemyLevel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return 1000 + (minEnemyLevel - 1) * 100;
 | 
					    return 1000 + (minEnemyLevel - 1) * 100;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user