feat: moa pet assembly
This commit is contained in:
		
							parent
							
								
									f091676f4b
								
							
						
					
					
						commit
						1725fad275
					
				@ -1,6 +1,6 @@
 | 
				
			|||||||
import { RequestHandler } from "express";
 | 
					import { RequestHandler } from "express";
 | 
				
			||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
					import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
				
			||||||
import { getInventory, addMiscItems, addWeapon } from "@/src/services/inventoryService";
 | 
					import { getInventory, addMiscItems, addEquipment } from "@/src/services/inventoryService";
 | 
				
			||||||
import { IMiscItem, TFocusPolarity } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
					import { IMiscItem, TFocusPolarity } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
				
			||||||
import { logger } from "@/src/utils/logger";
 | 
					import { logger } from "@/src/utils/logger";
 | 
				
			||||||
import { ExportFocusUpgrades } from "warframe-public-export-plus";
 | 
					import { ExportFocusUpgrades } from "warframe-public-export-plus";
 | 
				
			||||||
@ -81,7 +81,7 @@ export const focusController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
                "/Lotus/Weapons/Sentients/OperatorAmplifiers/SentTrainingAmplifier/SentAmpTrainingChassis",
 | 
					                "/Lotus/Weapons/Sentients/OperatorAmplifiers/SentTrainingAmplifier/SentAmpTrainingChassis",
 | 
				
			||||||
                "/Lotus/Weapons/Sentients/OperatorAmplifiers/SentTrainingAmplifier/SentAmpTrainingBarrel"
 | 
					                "/Lotus/Weapons/Sentients/OperatorAmplifiers/SentTrainingAmplifier/SentAmpTrainingBarrel"
 | 
				
			||||||
            ];
 | 
					            ];
 | 
				
			||||||
            const result = await addWeapon("OperatorAmps", request.StartingWeaponType, accountId, parts);
 | 
					            const result = await addEquipment("OperatorAmps", request.StartingWeaponType, accountId, parts);
 | 
				
			||||||
            res.json(result);
 | 
					            res.json(result);
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -1,17 +1,18 @@
 | 
				
			|||||||
import { RequestHandler } from "express";
 | 
					import { RequestHandler } from "express";
 | 
				
			||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
					import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
				
			||||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
					import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
				
			||||||
import { WeaponTypeInternal } from "@/src/services/itemDataService";
 | 
					import { TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
				
			||||||
import { getInventory, updateCurrency, addWeapon, addMiscItems } from "@/src/services/inventoryService";
 | 
					import { getInventory, updateCurrency, addEquipment, addMiscItems } from "@/src/services/inventoryService";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const modularWeaponTypes: Record<string, WeaponTypeInternal | "Hoverboards"> = {
 | 
					const modularWeaponTypes: Record<string, TEquipmentKey> = {
 | 
				
			||||||
    "/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryBeam": "LongGuns",
 | 
					    "/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryBeam": "LongGuns",
 | 
				
			||||||
    "/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondary": "Pistols",
 | 
					    "/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondary": "Pistols",
 | 
				
			||||||
    "/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryBeam": "Pistols",
 | 
					    "/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryBeam": "Pistols",
 | 
				
			||||||
    "/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryShotgun": "Pistols",
 | 
					    "/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryShotgun": "Pistols",
 | 
				
			||||||
    "/Lotus/Weapons/Ostron/Melee/LotusModularWeapon": "Melee",
 | 
					    "/Lotus/Weapons/Ostron/Melee/LotusModularWeapon": "Melee",
 | 
				
			||||||
    "/Lotus/Weapons/Sentients/OperatorAmplifiers/OperatorAmpWeapon": "OperatorAmps",
 | 
					    "/Lotus/Weapons/Sentients/OperatorAmplifiers/OperatorAmpWeapon": "OperatorAmps",
 | 
				
			||||||
    "/Lotus/Types/Vehicles/Hoverboard/HoverboardSuit": "Hoverboards"
 | 
					    "/Lotus/Types/Vehicles/Hoverboard/HoverboardSuit": "Hoverboards",
 | 
				
			||||||
 | 
					    "/Lotus/Types/Friendly/Pets/MoaPets/MoaPetPowerSuit": "MoaPets"
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface IModularCraftRequest {
 | 
					interface IModularCraftRequest {
 | 
				
			||||||
@ -29,10 +30,14 @@ export const modularWeaponCraftingController: RequestHandler = async (req, res)
 | 
				
			|||||||
    const category = modularWeaponTypes[data.WeaponType];
 | 
					    const category = modularWeaponTypes[data.WeaponType];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Give weapon
 | 
					    // Give weapon
 | 
				
			||||||
    const weapon = await addWeapon(category, data.WeaponType, accountId, data.Parts);
 | 
					    const weapon = await addEquipment(category, data.WeaponType, accountId, data.Parts);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Remove credits
 | 
					    // Remove credits
 | 
				
			||||||
    const currencyChanges = await updateCurrency(category == "Hoverboards" ? 5000 : 4000, false, accountId);
 | 
					    const currencyChanges = await updateCurrency(
 | 
				
			||||||
 | 
					        category == "Hoverboards" || category == "MoaPets" ? 5000 : 4000,
 | 
				
			||||||
 | 
					        false,
 | 
				
			||||||
 | 
					        accountId
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Remove parts
 | 
					    // Remove parts
 | 
				
			||||||
    const miscItemChanges = [];
 | 
					    const miscItemChanges = [];
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,7 @@
 | 
				
			|||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
					import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
				
			||||||
import { ItemType, toAddItemRequest } from "@/src/helpers/customHelpers/addItemHelpers";
 | 
					import { ItemType, toAddItemRequest } from "@/src/helpers/customHelpers/addItemHelpers";
 | 
				
			||||||
import { getWeaponType } from "@/src/services/itemDataService";
 | 
					import { getWeaponType } from "@/src/services/itemDataService";
 | 
				
			||||||
import { addPowerSuit, addWeapon } from "@/src/services/inventoryService";
 | 
					import { addPowerSuit, addEquipment } from "@/src/services/inventoryService";
 | 
				
			||||||
import { RequestHandler } from "express";
 | 
					import { RequestHandler } from "express";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
 | 
					// eslint-disable-next-line @typescript-eslint/no-misused-promises
 | 
				
			||||||
@ -16,7 +16,7 @@ const addItemController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
            return;
 | 
					            return;
 | 
				
			||||||
        case ItemType.Weapon:
 | 
					        case ItemType.Weapon:
 | 
				
			||||||
            const weaponType = getWeaponType(request.InternalName);
 | 
					            const weaponType = getWeaponType(request.InternalName);
 | 
				
			||||||
            const weapon = await addWeapon(weaponType, request.InternalName, accountId);
 | 
					            const weapon = await addEquipment(weaponType, request.InternalName, accountId);
 | 
				
			||||||
            res.json(weapon);
 | 
					            res.json(weapon);
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
 | 
				
			|||||||
@ -983,6 +983,7 @@ type InventoryDocumentProps = {
 | 
				
			|||||||
    SpaceMelee: Types.DocumentArray<IEquipmentDatabase>;
 | 
					    SpaceMelee: Types.DocumentArray<IEquipmentDatabase>;
 | 
				
			||||||
    SentinelWeapons: Types.DocumentArray<IEquipmentDatabase>;
 | 
					    SentinelWeapons: Types.DocumentArray<IEquipmentDatabase>;
 | 
				
			||||||
    Hoverboards: Types.DocumentArray<IEquipmentDatabase>;
 | 
					    Hoverboards: Types.DocumentArray<IEquipmentDatabase>;
 | 
				
			||||||
 | 
					    MoaPets: Types.DocumentArray<IEquipmentDatabase>;
 | 
				
			||||||
    WeaponSkins: Types.DocumentArray<IWeaponSkinDatabase>;
 | 
					    WeaponSkins: Types.DocumentArray<IWeaponSkinDatabase>;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -26,7 +26,7 @@ import {
 | 
				
			|||||||
    IUpdateChallengeProgressRequest
 | 
					    IUpdateChallengeProgressRequest
 | 
				
			||||||
} from "../types/requestTypes";
 | 
					} from "../types/requestTypes";
 | 
				
			||||||
import { logger } from "@/src/utils/logger";
 | 
					import { logger } from "@/src/utils/logger";
 | 
				
			||||||
import { WeaponTypeInternal, getWeaponType, getExalted } from "@/src/services/itemDataService";
 | 
					import { getWeaponType, getExalted } from "@/src/services/itemDataService";
 | 
				
			||||||
import { ISyndicateSacrifice, ISyndicateSacrificeResponse } from "../types/syndicateTypes";
 | 
					import { ISyndicateSacrifice, ISyndicateSacrificeResponse } from "../types/syndicateTypes";
 | 
				
			||||||
import { IEquipmentClient } from "../types/inventoryTypes/commonInventoryTypes";
 | 
					import { IEquipmentClient } from "../types/inventoryTypes/commonInventoryTypes";
 | 
				
			||||||
import { ExportCustoms, ExportFlavour, ExportRecipes, ExportResources } from "warframe-public-export-plus";
 | 
					import { ExportCustoms, ExportFlavour, ExportRecipes, ExportResources } from "warframe-public-export-plus";
 | 
				
			||||||
@ -172,7 +172,7 @@ export const addItem = async (
 | 
				
			|||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case "Weapons":
 | 
					        case "Weapons":
 | 
				
			||||||
            const weaponType = getWeaponType(typeName);
 | 
					            const weaponType = getWeaponType(typeName);
 | 
				
			||||||
            const weapon = await addWeapon(weaponType, typeName, accountId);
 | 
					            const weapon = await addEquipment(weaponType, typeName, accountId);
 | 
				
			||||||
            await updateSlots(accountId, InventorySlot.WEAPONS, 0, 1);
 | 
					            await updateSlots(accountId, InventorySlot.WEAPONS, 0, 1);
 | 
				
			||||||
            return {
 | 
					            return {
 | 
				
			||||||
                InventoryChanges: {
 | 
					                InventoryChanges: {
 | 
				
			||||||
@ -444,23 +444,23 @@ export const syndicateSacrifice = async (
 | 
				
			|||||||
    return res;
 | 
					    return res;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const addWeapon = async (
 | 
					export const addEquipment = async (
 | 
				
			||||||
    weaponType: WeaponTypeInternal | "Hoverboards",
 | 
					    category: TEquipmentKey,
 | 
				
			||||||
    weaponName: string,
 | 
					    type: string,
 | 
				
			||||||
    accountId: string,
 | 
					    accountId: string,
 | 
				
			||||||
    modularParts: string[] | undefined = undefined
 | 
					    modularParts: string[] | undefined = undefined
 | 
				
			||||||
): Promise<IEquipmentClient> => {
 | 
					): Promise<IEquipmentClient> => {
 | 
				
			||||||
    const inventory = await getInventory(accountId);
 | 
					    const inventory = await getInventory(accountId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const weaponIndex = inventory[weaponType].push({
 | 
					    const index = inventory[category].push({
 | 
				
			||||||
        ItemType: weaponName,
 | 
					        ItemType: type,
 | 
				
			||||||
        Configs: [],
 | 
					        Configs: [],
 | 
				
			||||||
        XP: 0,
 | 
					        XP: 0,
 | 
				
			||||||
        ModularParts: modularParts
 | 
					        ModularParts: modularParts
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const changedInventory = await inventory.save();
 | 
					    const changedInventory = await inventory.save();
 | 
				
			||||||
    return changedInventory[weaponType][weaponIndex - 1].toJSON();
 | 
					    return changedInventory[category][index - 1].toJSON();
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const addCustomization = async (customizatonName: string, accountId: string): Promise<IFlavourItem> => {
 | 
					export const addCustomization = async (customizatonName: string, accountId: string): Promise<IFlavourItem> => {
 | 
				
			||||||
 | 
				
			|||||||
@ -73,7 +73,8 @@ export const equipmentKeys = [
 | 
				
			|||||||
    "SpaceGuns",
 | 
					    "SpaceGuns",
 | 
				
			||||||
    "SpaceMelee",
 | 
					    "SpaceMelee",
 | 
				
			||||||
    "Hoverboards",
 | 
					    "Hoverboards",
 | 
				
			||||||
    "OperatorAmps"
 | 
					    "OperatorAmps",
 | 
				
			||||||
 | 
					    "MoaPets"
 | 
				
			||||||
] as const;
 | 
					] as const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export type TEquipmentKey = (typeof equipmentKeys)[number];
 | 
					export type TEquipmentKey = (typeof equipmentKeys)[number];
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user