handle eight claw goal progress
This commit is contained in:
		
							parent
							
								
									d75df788c7
								
							
						
					
					
						commit
						b6fe0f7b6c
					
				@ -816,3 +816,85 @@ export const getAllianceClient = async (
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const handleGuildGoalProgress = async (
 | 
				
			||||||
 | 
					    guild: TGuildDatabaseDocument,
 | 
				
			||||||
 | 
					    upload: { Count: number; Tag: string; goalId: Types.ObjectId }
 | 
				
			||||||
 | 
					) => {
 | 
				
			||||||
 | 
					    guild.GoalProgress ??= [];
 | 
				
			||||||
 | 
					    const goalProgress = guild.GoalProgress.find(x => x.goalId.equals(upload.goalId));
 | 
				
			||||||
 | 
					    if (!goalProgress) {
 | 
				
			||||||
 | 
					        guild.GoalProgress.push({
 | 
				
			||||||
 | 
					            Count: upload.Count,
 | 
				
			||||||
 | 
					            Tag: upload.Tag,
 | 
				
			||||||
 | 
					            goalId: upload.goalId
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    const totalCount = (goalProgress?.Count ?? 0) + upload.Count;
 | 
				
			||||||
 | 
					    const guildRewards = goalGuildRewardByTag[upload.Tag].rewards;
 | 
				
			||||||
 | 
					    const tierGoals = goalGuildRewardByTag[upload.Tag].guildGoals[guild.Tier - 1];
 | 
				
			||||||
 | 
					    const rewards = [];
 | 
				
			||||||
 | 
					    if (tierGoals.length && guildRewards.length) {
 | 
				
			||||||
 | 
					        for (let i = 0; i < tierGoals.length; i++) {
 | 
				
			||||||
 | 
					            if (
 | 
				
			||||||
 | 
					                tierGoals[i] &&
 | 
				
			||||||
 | 
					                tierGoals[i] <= totalCount &&
 | 
				
			||||||
 | 
					                (!goalProgress || goalProgress.Count < tierGoals[i]) &&
 | 
				
			||||||
 | 
					                guildRewards[i]
 | 
				
			||||||
 | 
					            ) {
 | 
				
			||||||
 | 
					                rewards.push(guildRewards[i]);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (rewards.length) {
 | 
				
			||||||
 | 
					            logger.debug(`guild goal rewards`, rewards);
 | 
				
			||||||
 | 
					            guild.VaultDecoRecipes ??= [];
 | 
				
			||||||
 | 
					            rewards.forEach(type => {
 | 
				
			||||||
 | 
					                guild.VaultDecoRecipes!.push({
 | 
				
			||||||
 | 
					                    ItemType: type,
 | 
				
			||||||
 | 
					                    ItemCount: 1
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (goalProgress) {
 | 
				
			||||||
 | 
					        goalProgress.Count += upload.Count;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    await guild.save();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const goalGuildRewardByTag: Record<string, { guildGoals: number[][]; rewards: string[] }> = {
 | 
				
			||||||
 | 
					    JadeShadowsEvent: {
 | 
				
			||||||
 | 
					        guildGoals: [
 | 
				
			||||||
 | 
					            // I don't know what ClanGoal means
 | 
				
			||||||
 | 
					            [15, 30, 45, 60],
 | 
				
			||||||
 | 
					            [45, 90, 135, 180],
 | 
				
			||||||
 | 
					            [150, 300, 450, 600],
 | 
				
			||||||
 | 
					            [450, 900, 1350, 1800],
 | 
				
			||||||
 | 
					            [1500, 3000, 4500, 6000]
 | 
				
			||||||
 | 
					        ],
 | 
				
			||||||
 | 
					        rewards: [
 | 
				
			||||||
 | 
					            "/Lotus/Levels/ClanDojo/ComponentPropRecipes/JadeShadowsEventPewterTrophyRecipe",
 | 
				
			||||||
 | 
					            "/Lotus/Levels/ClanDojo/ComponentPropRecipes/JadeShadowsEventBronzeTrophyRecipe",
 | 
				
			||||||
 | 
					            "/Lotus/Levels/ClanDojo/ComponentPropRecipes/JadeShadowsEventSilverTrophyRecipe",
 | 
				
			||||||
 | 
					            "/Lotus/Levels/ClanDojo/ComponentPropRecipes/JadeShadowsEventGoldTrophyRecipe"
 | 
				
			||||||
 | 
					        ]
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    DuviriMurmurEvent: {
 | 
				
			||||||
 | 
					        guildGoals: [
 | 
				
			||||||
 | 
					            // I don't know what ClanGoal means
 | 
				
			||||||
 | 
					            [260, 519, 779, 1038],
 | 
				
			||||||
 | 
					            [779, 1557, 2336, 3114],
 | 
				
			||||||
 | 
					            [2595, 5190, 7785, 10380],
 | 
				
			||||||
 | 
					            [7785, 15570, 23355, 31140],
 | 
				
			||||||
 | 
					            [29950, 51900, 77850, 103800]
 | 
				
			||||||
 | 
					        ],
 | 
				
			||||||
 | 
					        rewards: [
 | 
				
			||||||
 | 
					            "/Lotus/Levels/ClanDojo/ComponentPropRecipes/DuviriMurmurEventClayTrophyRecipe",
 | 
				
			||||||
 | 
					            "/Lotus/Levels/ClanDojo/ComponentPropRecipes/DuviriMurmurEventBronzeTrophyRecipe",
 | 
				
			||||||
 | 
					            "/Lotus/Levels/ClanDojo/ComponentPropRecipes/DuviriMurmurEventSilverTrophyRecipe",
 | 
				
			||||||
 | 
					            "/Lotus/Levels/ClanDojo/ComponentPropRecipes/DuviriMurmurEventGoldTrophyRecipe"
 | 
				
			||||||
 | 
					        ]
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -82,6 +82,7 @@ import { TAccountDocument } from "@/src/services/loginService";
 | 
				
			|||||||
import { ITypeCount } from "@/src/types/commonTypes";
 | 
					import { ITypeCount } from "@/src/types/commonTypes";
 | 
				
			||||||
import { IEquipmentClient } from "@/src/types/equipmentTypes";
 | 
					import { IEquipmentClient } from "@/src/types/equipmentTypes";
 | 
				
			||||||
import { Guild } from "@/src/models/guildModel";
 | 
					import { Guild } from "@/src/models/guildModel";
 | 
				
			||||||
 | 
					import { handleGuildGoalProgress } from "@/src/services/guildService";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const getRotations = (rewardInfo: IRewardInfo, tierOverride?: number): number[] => {
 | 
					const getRotations = (rewardInfo: IRewardInfo, tierOverride?: number): number[] => {
 | 
				
			||||||
    // Disruption missions just tell us (https://onlyg.it/OpenWF/SpaceNinjaServer/issues/2599)
 | 
					    // Disruption missions just tell us (https://onlyg.it/OpenWF/SpaceNinjaServer/issues/2599)
 | 
				
			||||||
@ -720,47 +721,11 @@ export const addMissionInventoryUpdates = async (
 | 
				
			|||||||
                    if (goal && goal.ClanGoal && inventory.GuildId) {
 | 
					                    if (goal && goal.ClanGoal && inventory.GuildId) {
 | 
				
			||||||
                        const guild = await Guild.findById(inventory.GuildId, "GoalProgress Tier VaultDecoRecipes");
 | 
					                        const guild = await Guild.findById(inventory.GuildId, "GoalProgress Tier VaultDecoRecipes");
 | 
				
			||||||
                        if (guild) {
 | 
					                        if (guild) {
 | 
				
			||||||
                            guild.GoalProgress ??= [];
 | 
					                            handleGuildGoalProgress(guild, {
 | 
				
			||||||
                            const goalProgress = guild.GoalProgress.find(x => x.goalId.equals(goal._id.$oid));
 | 
					                                Count: uploadProgress.Count,
 | 
				
			||||||
                            if (!goalProgress) {
 | 
					                                Tag: goal.Tag,
 | 
				
			||||||
                                guild.GoalProgress.push({
 | 
					                                goalId: new Types.ObjectId(goal._id.$oid)
 | 
				
			||||||
                                    Count: uploadProgress.Count,
 | 
					                            });
 | 
				
			||||||
                                    Tag: goal.Tag,
 | 
					 | 
				
			||||||
                                    goalId: new Types.ObjectId(goal._id.$oid)
 | 
					 | 
				
			||||||
                                });
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            const totalCount = (goalProgress?.Count ?? 0) + uploadProgress.Count;
 | 
					 | 
				
			||||||
                            const guildRewards = goalGuildRewardByTag[goal.Tag].rewards;
 | 
					 | 
				
			||||||
                            const tierGoals = goalGuildRewardByTag[goal.Tag].guildGoals[guild.Tier - 1];
 | 
					 | 
				
			||||||
                            const rewards = [];
 | 
					 | 
				
			||||||
                            if (tierGoals.length && guildRewards.length) {
 | 
					 | 
				
			||||||
                                for (let i = 0; i < tierGoals.length; i++) {
 | 
					 | 
				
			||||||
                                    if (
 | 
					 | 
				
			||||||
                                        tierGoals[i] &&
 | 
					 | 
				
			||||||
                                        tierGoals[i] <= totalCount &&
 | 
					 | 
				
			||||||
                                        (!goalProgress || goalProgress.Count < tierGoals[i]) &&
 | 
					 | 
				
			||||||
                                        guildRewards[i]
 | 
					 | 
				
			||||||
                                    ) {
 | 
					 | 
				
			||||||
                                        rewards.push(guildRewards[i]);
 | 
					 | 
				
			||||||
                                    }
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                                if (rewards.length) {
 | 
					 | 
				
			||||||
                                    logger.debug(`guild goal rewards`, rewards);
 | 
					 | 
				
			||||||
                                    guild.VaultDecoRecipes ??= [];
 | 
					 | 
				
			||||||
                                    rewards.forEach(type => {
 | 
					 | 
				
			||||||
                                        guild.VaultDecoRecipes!.push({
 | 
					 | 
				
			||||||
                                            ItemType: type,
 | 
					 | 
				
			||||||
                                            ItemCount: 1
 | 
					 | 
				
			||||||
                                        });
 | 
					 | 
				
			||||||
                                    });
 | 
					 | 
				
			||||||
                                }
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                            if (goalProgress) {
 | 
					 | 
				
			||||||
                                goalProgress.Count += uploadProgress.Count;
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                            await guild.save();
 | 
					 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@ -2432,38 +2397,3 @@ const goalMessagesByKey: Record<string, { sndr: string; msg: string; sub: string
 | 
				
			|||||||
        icon: "/Lotus/Interface/Icons/Npcs/Lotus_d.png"
 | 
					        icon: "/Lotus/Interface/Icons/Npcs/Lotus_d.png"
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					 | 
				
			||||||
const goalGuildRewardByTag: Record<string, { guildGoals: number[][]; rewards: string[] }> = {
 | 
					 | 
				
			||||||
    JadeShadowsEvent: {
 | 
					 | 
				
			||||||
        guildGoals: [
 | 
					 | 
				
			||||||
            // I don't know what ClanGoal means
 | 
					 | 
				
			||||||
            [15, 30, 45, 60],
 | 
					 | 
				
			||||||
            [45, 90, 135, 180],
 | 
					 | 
				
			||||||
            [150, 300, 450, 600],
 | 
					 | 
				
			||||||
            [450, 900, 1350, 1800],
 | 
					 | 
				
			||||||
            [1500, 3000, 4500, 6000]
 | 
					 | 
				
			||||||
        ],
 | 
					 | 
				
			||||||
        rewards: [
 | 
					 | 
				
			||||||
            "/Lotus/Levels/ClanDojo/ComponentPropRecipes/JadeShadowsEventPewterTrophyRecipe",
 | 
					 | 
				
			||||||
            "/Lotus/Levels/ClanDojo/ComponentPropRecipes/JadeShadowsEventBronzeTrophyRecipe",
 | 
					 | 
				
			||||||
            "/Lotus/Levels/ClanDojo/ComponentPropRecipes/JadeShadowsEventSilverTrophyRecipe",
 | 
					 | 
				
			||||||
            "/Lotus/Levels/ClanDojo/ComponentPropRecipes/JadeShadowsEventGoldTrophyRecipe"
 | 
					 | 
				
			||||||
        ]
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
    DuviriMurmurEvent: {
 | 
					 | 
				
			||||||
        guildGoals: [
 | 
					 | 
				
			||||||
            // I don't know what ClanGoal means
 | 
					 | 
				
			||||||
            [260, 519, 779, 1038],
 | 
					 | 
				
			||||||
            [779, 1557, 2336, 3114],
 | 
					 | 
				
			||||||
            [2595, 5190, 7785, 10380],
 | 
					 | 
				
			||||||
            [7785, 15570, 23355, 31140],
 | 
					 | 
				
			||||||
            [29950, 51900, 77850, 103800]
 | 
					 | 
				
			||||||
        ],
 | 
					 | 
				
			||||||
        rewards: [
 | 
					 | 
				
			||||||
            "/Lotus/Levels/ClanDojo/ComponentPropRecipes/DuviriMurmurEventClayTrophyRecipe",
 | 
					 | 
				
			||||||
            "/Lotus/Levels/ClanDojo/ComponentPropRecipes/DuviriMurmurEventBronzeTrophyRecipe",
 | 
					 | 
				
			||||||
            "/Lotus/Levels/ClanDojo/ComponentPropRecipes/DuviriMurmurEventSilverTrophyRecipe",
 | 
					 | 
				
			||||||
            "/Lotus/Levels/ClanDojo/ComponentPropRecipes/DuviriMurmurEventGoldTrophyRecipe"
 | 
					 | 
				
			||||||
        ]
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -36,6 +36,10 @@ import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/invento
 | 
				
			|||||||
import { fromStoreItem, toStoreItem } from "@/src/services/itemDataService";
 | 
					import { fromStoreItem, toStoreItem } from "@/src/services/itemDataService";
 | 
				
			||||||
import { DailyDeal } from "@/src/models/worldStateModel";
 | 
					import { DailyDeal } from "@/src/models/worldStateModel";
 | 
				
			||||||
import { fromMongoDate, toMongoDate } from "@/src/helpers/inventoryHelpers";
 | 
					import { fromMongoDate, toMongoDate } from "@/src/helpers/inventoryHelpers";
 | 
				
			||||||
 | 
					import { Account } from "@/src/models/loginModel";
 | 
				
			||||||
 | 
					import { Guild } from "@/src/models/guildModel";
 | 
				
			||||||
 | 
					import { handleGuildGoalProgress } from "@/src/services/guildService";
 | 
				
			||||||
 | 
					import { Types } from "mongoose";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const getStoreItemCategory = (storeItem: string): string => {
 | 
					export const getStoreItemCategory = (storeItem: string): string => {
 | 
				
			||||||
    const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/");
 | 
					    const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/");
 | 
				
			||||||
@ -137,6 +141,22 @@ export const handlePurchase = async (
 | 
				
			|||||||
                    updateCurrency(inventory, offer.PremiumPrice[0], true, prePurchaseInventoryChanges);
 | 
					                    updateCurrency(inventory, offer.PremiumPrice[0], true, prePurchaseInventoryChanges);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            if (
 | 
				
			||||||
 | 
					                inventory.GuildId &&
 | 
				
			||||||
 | 
					                offer.ItemPrices &&
 | 
				
			||||||
 | 
					                manifest.VendorInfo.TypeName ==
 | 
				
			||||||
 | 
					                    "/Lotus/Types/Game/VendorManifests/Events/DuviriMurmurInvasionVendorManifest"
 | 
				
			||||||
 | 
					            ) {
 | 
				
			||||||
 | 
					                const guild = await Guild.findById(inventory.GuildId, "GoalProgress Tier VaultDecoRecipes");
 | 
				
			||||||
 | 
					                const goal = getWorldState().Goals.find(x => x.Tag == "DuviriMurmurEvent");
 | 
				
			||||||
 | 
					                if (guild && goal) {
 | 
				
			||||||
 | 
					                    handleGuildGoalProgress(guild, {
 | 
				
			||||||
 | 
					                        Count: offer.ItemPrices[0].ItemCount * purchaseRequest.PurchaseParams.Quantity,
 | 
				
			||||||
 | 
					                        Tag: goal.Tag,
 | 
				
			||||||
 | 
					                        goalId: new Types.ObjectId(goal._id.$oid)
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            if (!config.dontSubtractPurchaseItemCost) {
 | 
					            if (!config.dontSubtractPurchaseItemCost) {
 | 
				
			||||||
                if (offer.ItemPrices) {
 | 
					                if (offer.ItemPrices) {
 | 
				
			||||||
                    handleItemPrices(
 | 
					                    handleItemPrices(
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user