forked from OpenWF/SpaceNinjaServer
		
	feat: library personal target progress (#1083)
Closes #1081 Reviewed-on: OpenWF/SpaceNinjaServer#1083
This commit is contained in:
		
							parent
							
								
									57b3a5b9b3
								
							
						
					
					
						commit
						b8b1c5e008
					
				@ -8,7 +8,7 @@ export const startLibraryPersonalTargetController: RequestHandler = async (req,
 | 
			
		||||
    inventory.LibraryPersonalTarget = req.query.target as string;
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
    res.json({
 | 
			
		||||
        IsQuest: false,
 | 
			
		||||
        IsQuest: req.query.target == "/Lotus/Types/Game/Library/Targets/DragonframeQuestTarget",
 | 
			
		||||
        Target: req.query.target
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -74,7 +74,8 @@ import {
 | 
			
		||||
    IAlignment,
 | 
			
		||||
    ICollectibleEntry,
 | 
			
		||||
    IIncentiveState,
 | 
			
		||||
    ISongChallenge
 | 
			
		||||
    ISongChallenge,
 | 
			
		||||
    ILibraryPersonalProgress
 | 
			
		||||
} from "../../types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { IOid } from "../../types/commonTypes";
 | 
			
		||||
import {
 | 
			
		||||
@ -1005,6 +1006,15 @@ pendingCouponSchema.set("toJSON", {
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const libraryPersonalProgressSchema = new Schema<ILibraryPersonalProgress>(
 | 
			
		||||
    {
 | 
			
		||||
        TargetType: String,
 | 
			
		||||
        Scans: Number,
 | 
			
		||||
        Completed: Boolean
 | 
			
		||||
    },
 | 
			
		||||
    { _id: false }
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
const libraryDailyTaskInfoSchema = new Schema<ILibraryDailyTaskInfo>(
 | 
			
		||||
    {
 | 
			
		||||
        EnemyTypes: [String],
 | 
			
		||||
@ -1271,7 +1281,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
 | 
			
		||||
 | 
			
		||||
        LibraryPersonalTarget: String,
 | 
			
		||||
        //Cephalon Simaris Entries Example:"TargetType"+"Scans"(1-10)+"Completed": true|false
 | 
			
		||||
        LibraryPersonalProgress: [Schema.Types.Mixed],
 | 
			
		||||
        LibraryPersonalProgress: { type: [libraryPersonalProgressSchema], default: [] },
 | 
			
		||||
        //Cephalon Simaris Daily Task
 | 
			
		||||
        LibraryAvailableDailyTaskInfo: libraryDailyTaskInfoSchema,
 | 
			
		||||
        LibraryActiveDailyTaskInfo: libraryDailyTaskInfoSchema,
 | 
			
		||||
 | 
			
		||||
@ -191,17 +191,48 @@ export const addMissionInventoryUpdates = (
 | 
			
		||||
                break;
 | 
			
		||||
            case "LibraryScans":
 | 
			
		||||
                value.forEach(scan => {
 | 
			
		||||
                    if (inventory.LibraryActiveDailyTaskInfo) {
 | 
			
		||||
                        if (inventory.LibraryActiveDailyTaskInfo.EnemyTypes.find(x => x == scan.EnemyType)) {
 | 
			
		||||
                    let synthesisIgnored = true;
 | 
			
		||||
                    if (
 | 
			
		||||
                        inventory.LibraryPersonalTarget &&
 | 
			
		||||
                        libraryPersonalTargetToAvatar[inventory.LibraryPersonalTarget] == scan.EnemyType
 | 
			
		||||
                    ) {
 | 
			
		||||
                        let progress = inventory.LibraryPersonalProgress.find(
 | 
			
		||||
                            x => x.TargetType == inventory.LibraryPersonalTarget
 | 
			
		||||
                        );
 | 
			
		||||
                        if (!progress) {
 | 
			
		||||
                            progress =
 | 
			
		||||
                                inventory.LibraryPersonalProgress[
 | 
			
		||||
                                    inventory.LibraryPersonalProgress.push({
 | 
			
		||||
                                        TargetType: inventory.LibraryPersonalTarget,
 | 
			
		||||
                                        Scans: 0,
 | 
			
		||||
                                        Completed: false
 | 
			
		||||
                                    }) - 1
 | 
			
		||||
                                ];
 | 
			
		||||
                        }
 | 
			
		||||
                        progress.Scans += scan.Count;
 | 
			
		||||
                        if (
 | 
			
		||||
                            progress.Scans >=
 | 
			
		||||
                            (inventory.LibraryPersonalTarget ==
 | 
			
		||||
                            "/Lotus/Types/Game/Library/Targets/DragonframeQuestTarget"
 | 
			
		||||
                                ? 3
 | 
			
		||||
                                : 10)
 | 
			
		||||
                        ) {
 | 
			
		||||
                            progress.Completed = true;
 | 
			
		||||
                        }
 | 
			
		||||
                        logger.debug(`synthesis of ${scan.EnemyType} added to personal target progress`);
 | 
			
		||||
                        synthesisIgnored = false;
 | 
			
		||||
                    }
 | 
			
		||||
                    if (
 | 
			
		||||
                        inventory.LibraryActiveDailyTaskInfo &&
 | 
			
		||||
                        inventory.LibraryActiveDailyTaskInfo.EnemyTypes.find(x => x == scan.EnemyType)
 | 
			
		||||
                    ) {
 | 
			
		||||
                        inventory.LibraryActiveDailyTaskInfo.Scans ??= 0;
 | 
			
		||||
                        inventory.LibraryActiveDailyTaskInfo.Scans += scan.Count;
 | 
			
		||||
                        } else {
 | 
			
		||||
                            logger.warn(
 | 
			
		||||
                                `ignoring synthesis of ${scan.EnemyType} as it's not part of the active daily task`
 | 
			
		||||
                            );
 | 
			
		||||
                        logger.debug(`synthesis of ${scan.EnemyType} added to daily task progress`);
 | 
			
		||||
                        synthesisIgnored = false;
 | 
			
		||||
                    }
 | 
			
		||||
                    } else {
 | 
			
		||||
                        logger.warn(`no library daily task active, ignoring synthesis of ${scan.EnemyType}`);
 | 
			
		||||
                    if (synthesisIgnored) {
 | 
			
		||||
                        logger.warn(`ignoring synthesis of ${scan.EnemyType} due to not knowing why you did that`);
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
                break;
 | 
			
		||||
@ -534,3 +565,25 @@ const corruptedMods = [
 | 
			
		||||
    "/Lotus/StoreItems/Upgrades/Mods/Rifle/DualStat/CorruptedReloadSpeedMaxClipRifle", // Depleted Reload
 | 
			
		||||
    "/Lotus/StoreItems/Upgrades/Mods/Warframe/DualStat/FixedShieldAndShieldGatingDuration" // Catalyzing Shields
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
const libraryPersonalTargetToAvatar: Record<string, string> = {
 | 
			
		||||
    "/Lotus/Types/Game/Library/Targets/DragonframeQuestTarget":
 | 
			
		||||
        "/Lotus/Types/Enemies/Grineer/Desert/Avatars/RifleLancerAvatar",
 | 
			
		||||
    "/Lotus/Types/Game/Library/Targets/Research1Target":
 | 
			
		||||
        "/Lotus/Types/Enemies/Grineer/Desert/Avatars/RifleLancerAvatar",
 | 
			
		||||
    "/Lotus/Types/Game/Library/Targets/Research2Target":
 | 
			
		||||
        "/Lotus/Types/Enemies/Corpus/BipedRobot/AIWeek/LaserDiscBipedAvatar",
 | 
			
		||||
    "/Lotus/Types/Game/Library/Targets/Research3Target":
 | 
			
		||||
        "/Lotus/Types/Enemies/Grineer/Desert/Avatars/EvisceratorLancerAvatar",
 | 
			
		||||
    "/Lotus/Types/Game/Library/Targets/Research4Target": "/Lotus/Types/Enemies/Orokin/OrokinHealingAncientAvatar",
 | 
			
		||||
    "/Lotus/Types/Game/Library/Targets/Research5Target":
 | 
			
		||||
        "/Lotus/Types/Enemies/Corpus/Spaceman/AIWeek/ShotgunSpacemanAvatar",
 | 
			
		||||
    "/Lotus/Types/Game/Library/Targets/Research6Target": "/Lotus/Types/Enemies/Infested/AiWeek/Runners/RunnerAvatar",
 | 
			
		||||
    "/Lotus/Types/Game/Library/Targets/Research7Target":
 | 
			
		||||
        "/Lotus/Types/Enemies/Grineer/AIWeek/Avatars/GrineerMeleeStaffAvatar",
 | 
			
		||||
    "/Lotus/Types/Game/Library/Targets/Research8Target": "/Lotus/Types/Enemies/Orokin/OrokinHeavyFemaleAvatar",
 | 
			
		||||
    "/Lotus/Types/Game/Library/Targets/Research9Target":
 | 
			
		||||
        "/Lotus/Types/Enemies/Infested/AiWeek/Quadrupeds/QuadrupedAvatar",
 | 
			
		||||
    "/Lotus/Types/Game/Library/Targets/Research10Target":
 | 
			
		||||
        "/Lotus/Types/Enemies/Corpus/Spaceman/AIWeek/NullifySpacemanAvatar"
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -313,7 +313,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
 | 
			
		||||
    Quests: any[];
 | 
			
		||||
    Robotics: any[];
 | 
			
		||||
    UsedDailyDeals: any[];
 | 
			
		||||
    LibraryPersonalTarget: string;
 | 
			
		||||
    LibraryPersonalTarget?: string;
 | 
			
		||||
    LibraryPersonalProgress: ILibraryPersonalProgress[];
 | 
			
		||||
    CollectibleSeries?: ICollectibleEntry[];
 | 
			
		||||
    LibraryAvailableDailyTaskInfo?: ILibraryDailyTaskInfo;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user