feat: implement helminth naming & archon shard installation
This commit is contained in:
		
							parent
							
								
									be9ba026f7
								
							
						
					
					
						commit
						418ccbac19
					
				
							
								
								
									
										85
									
								
								src/controllers/api/infestedFoundryController.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								src/controllers/api/infestedFoundryController.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,85 @@
 | 
				
			|||||||
 | 
					import { RequestHandler } from "express";
 | 
				
			||||||
 | 
					import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
				
			||||||
 | 
					import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
				
			||||||
 | 
					import { getInventory, addMiscItems } from "@/src/services/inventoryService";
 | 
				
			||||||
 | 
					import { IOid } from "@/src/types/commonTypes";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const infestedFoundryController: RequestHandler = async (req, res) => {
 | 
				
			||||||
 | 
					    const accountId = await getAccountIdForRequest(req);
 | 
				
			||||||
 | 
					    const payload = getJSONfromString(req.body.toString());
 | 
				
			||||||
 | 
					    switch (req.query.mode) {
 | 
				
			||||||
 | 
					        case "s": { // shard installation
 | 
				
			||||||
 | 
					            const request = payload as IShardInstallRequest;
 | 
				
			||||||
 | 
					            const inventory = await getInventory(accountId);
 | 
				
			||||||
 | 
					            const suit = inventory.Suits.find(suit => suit._id.toString() == request.SuitId.$oid)!;
 | 
				
			||||||
 | 
					            if (!suit.ArchonCrystalUpgrades
 | 
				
			||||||
 | 
					                || suit.ArchonCrystalUpgrades.length != 5 // we shouldn't have an array like this, but older inventories may disagree...
 | 
				
			||||||
 | 
					            ) {
 | 
				
			||||||
 | 
					                suit.ArchonCrystalUpgrades = [ {}, {}, {}, {}, {} ];
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            suit.ArchonCrystalUpgrades[request.Slot] = {
 | 
				
			||||||
 | 
					                UpgradeType: request.UpgradeType,
 | 
				
			||||||
 | 
					                Color: request.Color
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            const miscItemChanges = [
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    ItemType: colorToShard[request.Color],
 | 
				
			||||||
 | 
					                    ItemCount: -1
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            ];
 | 
				
			||||||
 | 
					            addMiscItems(inventory, miscItemChanges);
 | 
				
			||||||
 | 
					            await inventory.save();
 | 
				
			||||||
 | 
					            res.json({
 | 
				
			||||||
 | 
					                InventoryChanges: {
 | 
				
			||||||
 | 
					                    MiscItems: miscItemChanges
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        case "n": { // name the beast
 | 
				
			||||||
 | 
					            const inventory = await getInventory(accountId);
 | 
				
			||||||
 | 
					            inventory.InfestedFoundry ??= {};
 | 
				
			||||||
 | 
					            inventory.InfestedFoundry.Name = payload.newName as string;
 | 
				
			||||||
 | 
					            await inventory.save();
 | 
				
			||||||
 | 
					            res.json({
 | 
				
			||||||
 | 
					                InventoryChanges: {
 | 
				
			||||||
 | 
					                    InfestedFoundry: {
 | 
				
			||||||
 | 
					                        Name: inventory.InfestedFoundry.Name
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        case "o": // offerings update
 | 
				
			||||||
 | 
					            // {"OfferingsIndex":540,"SuitTypes":["/Lotus/Powersuits/PaxDuviricus/PaxDuviricusBaseSuit","/Lotus/Powersuits/Nezha/NezhaBaseSuit","/Lotus/Powersuits/Devourer/DevourerBaseSuit"],"Extra":false}
 | 
				
			||||||
 | 
					            res.status(404).end();
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        default:
 | 
				
			||||||
 | 
					            throw new Error(`unhandled infestedFoundry mode: ${req.query.mode}`);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					interface IShardInstallRequest {
 | 
				
			||||||
 | 
					    SuitId: IOid;
 | 
				
			||||||
 | 
					    Slot: number;
 | 
				
			||||||
 | 
					    UpgradeType: string;
 | 
				
			||||||
 | 
					    Color: string;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const colorToShard: Record<string, string> = {
 | 
				
			||||||
 | 
					    "ACC_RED": "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalAmar",
 | 
				
			||||||
 | 
					    "ACC_RED_MYTHIC": "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalAmarMythic",
 | 
				
			||||||
 | 
					    "ACC_YELLOW": "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalNira",
 | 
				
			||||||
 | 
					    "ACC_YELLOW_MYTHIC": "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalNiraMythic",
 | 
				
			||||||
 | 
					    "ACC_BLUE": "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalBoreal",
 | 
				
			||||||
 | 
					    "ACC_BLUE_MYTHIC": "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalBorealMythic",
 | 
				
			||||||
 | 
					    "ACC_GREEN": "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalGreen",
 | 
				
			||||||
 | 
					    "ACC_GREEN_MYTHIC": "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalGreenMythic",
 | 
				
			||||||
 | 
					    "ACC_ORANGE": "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalOrange",
 | 
				
			||||||
 | 
					    "ACC_ORANGE_MYTHIC": "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalOrangeMythic",
 | 
				
			||||||
 | 
					    "ACC_PURPLE": "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalViolet",
 | 
				
			||||||
 | 
					    "ACC_PURPLE_MYTHIC": "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalVioletMythic",
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@ -45,7 +45,8 @@ import {
 | 
				
			|||||||
    IOperatorConfigDatabase,
 | 
					    IOperatorConfigDatabase,
 | 
				
			||||||
    IPolarity,
 | 
					    IPolarity,
 | 
				
			||||||
    IEquipmentDatabase,
 | 
					    IEquipmentDatabase,
 | 
				
			||||||
    IOperatorConfigClient
 | 
					    IOperatorConfigClient,
 | 
				
			||||||
 | 
					    IArchonCrystalUpgrade
 | 
				
			||||||
} from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
					} from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
				
			||||||
import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
 | 
					import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -182,6 +183,17 @@ ItemConfigSchema.set("toJSON", {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const ArchonCrystalUpgradeSchema = new Schema<IArchonCrystalUpgrade>({
 | 
				
			||||||
 | 
					    UpgradeType: String,
 | 
				
			||||||
 | 
					    Color: String
 | 
				
			||||||
 | 
					}, { _id: false });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ArchonCrystalUpgradeSchema.set("toJSON", {
 | 
				
			||||||
 | 
					    transform(_document, returnedObject) {
 | 
				
			||||||
 | 
					        delete returnedObject.__v;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const EquipmentSchema = new Schema<IEquipmentDatabase>({
 | 
					const EquipmentSchema = new Schema<IEquipmentDatabase>({
 | 
				
			||||||
    ItemType: String,
 | 
					    ItemType: String,
 | 
				
			||||||
    Configs: [ItemConfigSchema],
 | 
					    Configs: [ItemConfigSchema],
 | 
				
			||||||
@ -193,7 +205,7 @@ const EquipmentSchema = new Schema<IEquipmentDatabase>({
 | 
				
			|||||||
    FocusLens: String,
 | 
					    FocusLens: String,
 | 
				
			||||||
    ModSlotPurchases: Number,
 | 
					    ModSlotPurchases: Number,
 | 
				
			||||||
    CustomizationSlotPurchases: Number,
 | 
					    CustomizationSlotPurchases: Number,
 | 
				
			||||||
    UpgradeType: Schema.Types.Mixed, //todo
 | 
					    UpgradeType: String,
 | 
				
			||||||
    UpgradeFingerprint: String,
 | 
					    UpgradeFingerprint: String,
 | 
				
			||||||
    ItemName: String,
 | 
					    ItemName: String,
 | 
				
			||||||
    InfestationDate: Date,
 | 
					    InfestationDate: Date,
 | 
				
			||||||
@ -203,7 +215,7 @@ const EquipmentSchema = new Schema<IEquipmentDatabase>({
 | 
				
			|||||||
    UnlockLevel: Number,
 | 
					    UnlockLevel: Number,
 | 
				
			||||||
    Expiry: Date,
 | 
					    Expiry: Date,
 | 
				
			||||||
    SkillTree: String,
 | 
					    SkillTree: String,
 | 
				
			||||||
    ArchonCrystalUpgrades: [Schema.Types.Mixed] //TODO
 | 
					    ArchonCrystalUpgrades: { type: [ArchonCrystalUpgradeSchema], default: undefined }
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
EquipmentSchema.virtual("ItemId").get(function () {
 | 
					EquipmentSchema.virtual("ItemId").get(function () {
 | 
				
			||||||
@ -434,14 +446,14 @@ const consumedSchuitsSchema = new Schema<IConsumedSuit>({
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const infestedFoundrySchema = new Schema<IInfestedFoundry>({
 | 
					const infestedFoundrySchema = new Schema<IInfestedFoundry>({
 | 
				
			||||||
    Name: String,
 | 
					    Name: String,
 | 
				
			||||||
    Resources: [typeCountSchema],
 | 
					    Resources: { type: [typeCountSchema], default: undefined },
 | 
				
			||||||
    Slots: Number,
 | 
					    Slots: Number,
 | 
				
			||||||
    XP: Number,
 | 
					    XP: Number,
 | 
				
			||||||
    ConsumedSuits: [consumedSchuitsSchema],
 | 
					    ConsumedSuits: { type: [consumedSchuitsSchema], default: undefined },
 | 
				
			||||||
    InvigorationIndex: Number,
 | 
					    InvigorationIndex: Number,
 | 
				
			||||||
    InvigorationSuitOfferings: [String],
 | 
					    InvigorationSuitOfferings: { type: [String], default: undefined },
 | 
				
			||||||
    InvigorationsApplied: Number
 | 
					    InvigorationsApplied: Number
 | 
				
			||||||
});
 | 
					}, { _id: false });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const questProgressSchema = new Schema<IQuestProgress>({
 | 
					const questProgressSchema = new Schema<IQuestProgress>({
 | 
				
			||||||
    c: Number,
 | 
					    c: Number,
 | 
				
			||||||
 | 
				
			|||||||
@ -25,6 +25,7 @@ import { hostSessionController } from "@/src/controllers/api/hostSessionControll
 | 
				
			|||||||
import { hubController } from "@/src/controllers/api/hubController";
 | 
					import { hubController } from "@/src/controllers/api/hubController";
 | 
				
			||||||
import { hubInstancesController } from "@/src/controllers/api/hubInstancesController";
 | 
					import { hubInstancesController } from "@/src/controllers/api/hubInstancesController";
 | 
				
			||||||
import { inboxController } from "@/src/controllers/api/inboxController";
 | 
					import { inboxController } from "@/src/controllers/api/inboxController";
 | 
				
			||||||
 | 
					import { infestedFoundryController } from "@/src/controllers/api/infestedFoundryController";
 | 
				
			||||||
import { inventoryController } from "@/src/controllers/api/inventoryController";
 | 
					import { inventoryController } from "@/src/controllers/api/inventoryController";
 | 
				
			||||||
import { inventorySlotsController } from "@/src/controllers/api/inventorySlotsController";
 | 
					import { inventorySlotsController } from "@/src/controllers/api/inventorySlotsController";
 | 
				
			||||||
import { joinSessionController } from "@/src/controllers/api/joinSessionController";
 | 
					import { joinSessionController } from "@/src/controllers/api/joinSessionController";
 | 
				
			||||||
@ -101,6 +102,7 @@ apiRouter.post("/genericUpdate.php", genericUpdateController);
 | 
				
			|||||||
apiRouter.post("/getAlliance.php", getAllianceController);
 | 
					apiRouter.post("/getAlliance.php", getAllianceController);
 | 
				
			||||||
apiRouter.post("/guildTech.php", guildTechController);
 | 
					apiRouter.post("/guildTech.php", guildTechController);
 | 
				
			||||||
apiRouter.post("/hostSession.php", hostSessionController);
 | 
					apiRouter.post("/hostSession.php", hostSessionController);
 | 
				
			||||||
 | 
					apiRouter.post("/infestedFoundry.php", infestedFoundryController);
 | 
				
			||||||
apiRouter.post("/inventorySlots.php", inventorySlotsController);
 | 
					apiRouter.post("/inventorySlots.php", inventorySlotsController);
 | 
				
			||||||
apiRouter.post("/joinSession.php", joinSessionController);
 | 
					apiRouter.post("/joinSession.php", joinSessionController);
 | 
				
			||||||
apiRouter.post("/login.php", loginController);
 | 
					apiRouter.post("/login.php", loginController);
 | 
				
			||||||
 | 
				
			|||||||
@ -103,6 +103,11 @@ export interface IEquipmentDatabase {
 | 
				
			|||||||
    UnlockLevel?: number;
 | 
					    UnlockLevel?: number;
 | 
				
			||||||
    Expiry?: IMongoDate;
 | 
					    Expiry?: IMongoDate;
 | 
				
			||||||
    SkillTree?: string;
 | 
					    SkillTree?: string;
 | 
				
			||||||
    ArchonCrystalUpgrades?: []; //TODO
 | 
					    ArchonCrystalUpgrades?: IArchonCrystalUpgrade[];
 | 
				
			||||||
    _id: Types.ObjectId;
 | 
					    _id: Types.ObjectId;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface IArchonCrystalUpgrade {
 | 
				
			||||||
 | 
					    UpgradeType?: string;
 | 
				
			||||||
 | 
					    Color?: string;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -232,7 +232,7 @@ export interface IInventoryResponse {
 | 
				
			|||||||
    DailyAffiliationEntrati: number;
 | 
					    DailyAffiliationEntrati: number;
 | 
				
			||||||
    DailyAffiliationNecraloid: number;
 | 
					    DailyAffiliationNecraloid: number;
 | 
				
			||||||
    MechSuits: IEquipmentDatabase[];
 | 
					    MechSuits: IEquipmentDatabase[];
 | 
				
			||||||
    InfestedFoundry: IInfestedFoundry;
 | 
					    InfestedFoundry?: IInfestedFoundry;
 | 
				
			||||||
    BlessingCooldown: IMongoDate;
 | 
					    BlessingCooldown: IMongoDate;
 | 
				
			||||||
    CrewShipHarnesses: IEquipmentDatabase[];
 | 
					    CrewShipHarnesses: IEquipmentDatabase[];
 | 
				
			||||||
    CrewShipRawSalvage: IConsumable[];
 | 
					    CrewShipRawSalvage: IConsumable[];
 | 
				
			||||||
@ -482,14 +482,14 @@ export interface IFusionTreasure {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface IInfestedFoundry {
 | 
					export interface IInfestedFoundry {
 | 
				
			||||||
    Name: string;
 | 
					    Name?: string;
 | 
				
			||||||
    Resources: ITypeCount[];
 | 
					    Resources?: ITypeCount[];
 | 
				
			||||||
    Slots: number;
 | 
					    Slots?: number;
 | 
				
			||||||
    XP: number;
 | 
					    XP?: number;
 | 
				
			||||||
    ConsumedSuits: IConsumedSuit[];
 | 
					    ConsumedSuits?: IConsumedSuit[];
 | 
				
			||||||
    InvigorationIndex: number;
 | 
					    InvigorationIndex?: number;
 | 
				
			||||||
    InvigorationSuitOfferings: string[];
 | 
					    InvigorationSuitOfferings?: string[];
 | 
				
			||||||
    InvigorationsApplied: number;
 | 
					    InvigorationsApplied?: number;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface IConsumedSuit {
 | 
					export interface IConsumedSuit {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user