feat: collectible series #1025
							
								
								
									
										27
									
								
								src/controllers/api/startCollectibleEntryController.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/controllers/api/startCollectibleEntryController.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,27 @@
 | 
			
		||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { IIncentiveState } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const startCollectibleEntryController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
    const inventory = await getInventory(accountId);
 | 
			
		||||
    const request = getJSONfromString<IStartCollectibleEntryRequest>(String(req.body));
 | 
			
		||||
    inventory.CollectibleSeries ??= [];
 | 
			
		||||
    inventory.CollectibleSeries.push({
 | 
			
		||||
        CollectibleType: request.target,
 | 
			
		||||
        Count: 0,
 | 
			
		||||
        Tracking: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
 | 
			
		||||
        ReqScans: request.reqScans,
 | 
			
		||||
        IncentiveStates: request.other
 | 
			
		||||
    });
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
    res.status(200).end();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
interface IStartCollectibleEntryRequest {
 | 
			
		||||
    target: string;
 | 
			
		||||
    reqScans: number;
 | 
			
		||||
    other: IIncentiveState[];
 | 
			
		||||
}
 | 
			
		||||
@ -71,7 +71,9 @@ import {
 | 
			
		||||
    ILibraryDailyTaskInfo,
 | 
			
		||||
    IDroneDatabase,
 | 
			
		||||
    IDroneClient,
 | 
			
		||||
    IAlignment
 | 
			
		||||
    IAlignment,
 | 
			
		||||
    ICollectibleEntry,
 | 
			
		||||
    IIncentiveState
 | 
			
		||||
} from "../../types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { IOid } from "../../types/commonTypes";
 | 
			
		||||
import {
 | 
			
		||||
@ -943,6 +945,26 @@ const calenderProgressSchema = new Schema<ICalendarProgress>(
 | 
			
		||||
    { _id: false }
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
const incentiveStateSchema = new Schema<IIncentiveState>(
 | 
			
		||||
    {
 | 
			
		||||
        threshold: Number,
 | 
			
		||||
        complete: Boolean,
 | 
			
		||||
        sent: Boolean
 | 
			
		||||
    },
 | 
			
		||||
    { _id: false }
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
const collectibleEntrySchema = new Schema<ICollectibleEntry>(
 | 
			
		||||
    {
 | 
			
		||||
        CollectibleType: String,
 | 
			
		||||
        Count: Number,
 | 
			
		||||
        Tracking: String,
 | 
			
		||||
        ReqScans: Number,
 | 
			
		||||
        IncentiveStates: [incentiveStateSchema]
 | 
			
		||||
    },
 | 
			
		||||
    { _id: false }
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
const pendingCouponSchema = new Schema<IPendingCouponDatabase>(
 | 
			
		||||
    {
 | 
			
		||||
        Expiry: { type: Date, default: new Date(0) },
 | 
			
		||||
@ -1286,7 +1308,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
 | 
			
		||||
        RecentVendorPurchases: [Schema.Types.Mixed],
 | 
			
		||||
        Robotics: [Schema.Types.Mixed],
 | 
			
		||||
        UsedDailyDeals: [Schema.Types.Mixed],
 | 
			
		||||
        CollectibleSeries: [Schema.Types.Mixed],
 | 
			
		||||
        CollectibleSeries: { type: [collectibleEntrySchema], default: undefined },
 | 
			
		||||
        HasResetAccount: { type: Boolean, default: false },
 | 
			
		||||
 | 
			
		||||
        //Discount Coupon
 | 
			
		||||
 | 
			
		||||
@ -76,6 +76,7 @@ import { setShipFavouriteLoadoutController } from "@/src/controllers/api/setShip
 | 
			
		||||
import { setSupportedSyndicateController } from "@/src/controllers/api/setSupportedSyndicateController";
 | 
			
		||||
import { setWeaponSkillTreeController } from "@/src/controllers/api/setWeaponSkillTreeController";
 | 
			
		||||
import { shipDecorationsController } from "@/src/controllers/api/shipDecorationsController";
 | 
			
		||||
import { startCollectibleEntryController } from "@/src/controllers/api/startCollectibleEntryController";
 | 
			
		||||
import { startDojoRecipeController } from "@/src/controllers/api/startDojoRecipeController";
 | 
			
		||||
import { startLibraryDailyTaskController } from "@/src/controllers/api/startLibraryDailyTaskController";
 | 
			
		||||
import { startLibraryPersonalTargetController } from "@/src/controllers/api/startLibraryPersonalTargetController";
 | 
			
		||||
@ -181,6 +182,7 @@ apiRouter.post("/setShipCustomizations.php", setShipCustomizationsController);
 | 
			
		||||
apiRouter.post("/setShipFavouriteLoadout.php", setShipFavouriteLoadoutController);
 | 
			
		||||
apiRouter.post("/setWeaponSkillTree.php", setWeaponSkillTreeController);
 | 
			
		||||
apiRouter.post("/shipDecorations.php", shipDecorationsController);
 | 
			
		||||
apiRouter.post("/startCollectibleEntry.php", startCollectibleEntryController);
 | 
			
		||||
apiRouter.post("/startDojoRecipe.php", startDojoRecipeController);
 | 
			
		||||
apiRouter.post("/startRecipe.php", startRecipeController);
 | 
			
		||||
apiRouter.post("/stepSequencers.php", stepSequencersController);
 | 
			
		||||
 | 
			
		||||
@ -34,6 +34,10 @@ import { IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryType
 | 
			
		||||
import { handleStoreItemAcquisition } from "./purchaseService";
 | 
			
		||||
import { IMissionReward } from "../types/missionTypes";
 | 
			
		||||
import { crackRelic } from "@/src/helpers/relicHelper";
 | 
			
		||||
import { createMessage } from "./inboxService";
 | 
			
		||||
import kuriaMessage50 from "@/static/fixed_responses/kuriaMessages/fiftyPercent.json";
 | 
			
		||||
import kuriaMessage75 from "@/static/fixed_responses/kuriaMessages/seventyFivePercent.json";
 | 
			
		||||
import kuriaMessage100 from "@/static/fixed_responses/kuriaMessages/oneHundredPercent.json";
 | 
			
		||||
 | 
			
		||||
const getRotations = (rotationCount: number): number[] => {
 | 
			
		||||
    if (rotationCount === 0) return [0];
 | 
			
		||||
@ -201,6 +205,34 @@ export const addMissionInventoryUpdates = (
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
                break;
 | 
			
		||||
            case "CollectibleScans":
 | 
			
		||||
                value.forEach(scan => {
 | 
			
		||||
                    const entry = inventory.CollectibleSeries?.find(x => x.CollectibleType == scan.CollectibleType);
 | 
			
		||||
                    if (entry) {
 | 
			
		||||
                        entry.Count = scan.Count;
 | 
			
		||||
                        entry.Tracking = scan.Tracking;
 | 
			
		||||
                        if (entry.CollectibleType == "/Lotus/Objects/Orokin/Props/CollectibleSeriesOne") {
 | 
			
		||||
                            const progress = entry.Count / entry.ReqScans;
 | 
			
		||||
                            entry.IncentiveStates.forEach(gate => {
 | 
			
		||||
                                gate.complete = progress >= gate.threshold;
 | 
			
		||||
                                if (gate.complete && !gate.sent) {
 | 
			
		||||
                                    gate.sent = true;
 | 
			
		||||
                                    if (gate.threshold == 0.5) {
 | 
			
		||||
                                        void createMessage(inventory.accountOwnerId.toString(), [kuriaMessage50]);
 | 
			
		||||
                                    } else {
 | 
			
		||||
                                        void createMessage(inventory.accountOwnerId.toString(), [kuriaMessage75]);
 | 
			
		||||
                                    }
 | 
			
		||||
                                }
 | 
			
		||||
                            });
 | 
			
		||||
                            if (progress >= 1.0) {
 | 
			
		||||
                                void createMessage(inventory.accountOwnerId.toString(), [kuriaMessage100]);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    } else {
 | 
			
		||||
                        logger.warn(`${scan.CollectibleType} was not found in inventory, ignoring scans`);
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
                break;
 | 
			
		||||
            case "Upgrades":
 | 
			
		||||
                value.forEach(clientUpgrade => {
 | 
			
		||||
                    const upgrade = inventory.Upgrades.id(clientUpgrade.ItemId.$oid)!;
 | 
			
		||||
 | 
			
		||||
@ -315,7 +315,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
 | 
			
		||||
    UsedDailyDeals: any[];
 | 
			
		||||
    LibraryPersonalTarget: string;
 | 
			
		||||
    LibraryPersonalProgress: ILibraryPersonalProgress[];
 | 
			
		||||
    CollectibleSeries: ICollectibleSery[];
 | 
			
		||||
    CollectibleSeries?: ICollectibleEntry[];
 | 
			
		||||
    LibraryAvailableDailyTaskInfo?: ILibraryDailyTaskInfo;
 | 
			
		||||
    LibraryActiveDailyTaskInfo?: ILibraryDailyTaskInfo;
 | 
			
		||||
    HasResetAccount: boolean;
 | 
			
		||||
@ -364,7 +364,7 @@ export interface IChallengeProgress {
 | 
			
		||||
    Completed?: string[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ICollectibleSery {
 | 
			
		||||
export interface ICollectibleEntry {
 | 
			
		||||
    CollectibleType: string;
 | 
			
		||||
    Count: number;
 | 
			
		||||
    Tracking: string;
 | 
			
		||||
 | 
			
		||||
@ -15,7 +15,8 @@ import {
 | 
			
		||||
    IPlayerSkills,
 | 
			
		||||
    IQuestKeyDatabase,
 | 
			
		||||
    ILoreFragmentScan,
 | 
			
		||||
    IUpgradeClient
 | 
			
		||||
    IUpgradeClient,
 | 
			
		||||
    ICollectibleEntry
 | 
			
		||||
} from "./inventoryTypes/inventoryTypes";
 | 
			
		||||
 | 
			
		||||
export interface IThemeUpdateRequest {
 | 
			
		||||
@ -99,6 +100,7 @@ export type IMissionInventoryUpdateRequest = {
 | 
			
		||||
        CodexScanCount: number;
 | 
			
		||||
        Standing: number;
 | 
			
		||||
    }[];
 | 
			
		||||
    CollectibleScans?: ICollectibleEntry[];
 | 
			
		||||
    Upgrades?: IUpgradeClient[]; // riven challenge progress
 | 
			
		||||
} & {
 | 
			
		||||
    [K in TEquipmentKey]?: IEquipmentClient[];
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										7
									
								
								static/fixed_responses/kuriaMessages/fiftyPercent.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								static/fixed_responses/kuriaMessages/fiftyPercent.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
			
		||||
{
 | 
			
		||||
  "sub": "/Lotus/Language/Oddities/SeriesOne50PercentInboxMessageSubject",
 | 
			
		||||
  "sndr": "/Lotus/Language/Menu/ScribeName",
 | 
			
		||||
  "msg": "/Lotus/Language/Oddities/SeriesOne50PercentInboxMessage",
 | 
			
		||||
  "icon": "/Lotus/Interface/Icons/Syndicates/FactionOddityGold.png",
 | 
			
		||||
  "att": ["/Lotus/Upgrades/Skins/Clan/OrokittyBadgeItem"]
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,8 @@
 | 
			
		||||
{
 | 
			
		||||
  "sub": "/Lotus/Language/Oddities/SeriesOneRewardSubject",
 | 
			
		||||
  "sndr": "/Lotus/Language/Menu/ScribeName",
 | 
			
		||||
  "msg": "/Lotus/Language/Oddities/SeriesOneRewardInboxMessage",
 | 
			
		||||
  "icon": "/Lotus/Interface/Icons/Syndicates/FactionOddityGold.png",
 | 
			
		||||
  "att": ["/Lotus/Types/Items/ShipDecos/OrokinFelisBobbleHead"],
 | 
			
		||||
  "highPriority": true
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,7 @@
 | 
			
		||||
{
 | 
			
		||||
  "sub": "/Lotus/Language/Oddities/SeriesOne75PercentInboxMessageSubject",
 | 
			
		||||
  "sndr": "/Lotus/Language/Menu/ScribeName",
 | 
			
		||||
  "msg": "/Lotus/Language/Oddities/SeriesOne75PercentInboxMessage",
 | 
			
		||||
  "icon": "/Lotus/Interface/Icons/Syndicates/FactionOddityGold.png",
 | 
			
		||||
  "att": ["/Lotus/Types/StoreItems/AvatarImages/AvatarImageOroKitty"]
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user