feat: moa pet assembly (#423)

This commit is contained in:
Sainan 2024-06-29 15:11:12 +02:00 committed by GitHub
parent 2206ce4235
commit 81cc773faa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 27 additions and 19 deletions

View File

@ -1,6 +1,6 @@
import { RequestHandler } from "express";
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 { logger } from "@/src/utils/logger";
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/SentAmpTrainingBarrel"
];
const result = await addWeapon("OperatorAmps", request.StartingWeaponType, accountId, parts);
const result = await addEquipment("OperatorAmps", request.StartingWeaponType, accountId, parts);
res.json(result);
break;
}

View File

@ -1,17 +1,18 @@
import { RequestHandler } from "express";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { WeaponTypeInternal } from "@/src/services/itemDataService";
import { getInventory, updateCurrency, addWeapon, addMiscItems } from "@/src/services/inventoryService";
import { TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
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/Secondary/LotusModularSecondary": "Pistols",
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryBeam": "Pistols",
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryShotgun": "Pistols",
"/Lotus/Weapons/Ostron/Melee/LotusModularWeapon": "Melee",
"/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 {
@ -29,10 +30,14 @@ export const modularWeaponCraftingController: RequestHandler = async (req, res)
const category = modularWeaponTypes[data.WeaponType];
// Give weapon
const weapon = await addWeapon(category, data.WeaponType, accountId, data.Parts);
const weapon = await addEquipment(category, data.WeaponType, accountId, data.Parts);
// 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
const miscItemChanges = [];

View File

@ -1,7 +1,7 @@
import { getAccountIdForRequest } from "@/src/services/loginService";
import { ItemType, toAddItemRequest } from "@/src/helpers/customHelpers/addItemHelpers";
import { getWeaponType } from "@/src/services/itemDataService";
import { addPowerSuit, addWeapon } from "@/src/services/inventoryService";
import { addPowerSuit, addEquipment } from "@/src/services/inventoryService";
import { RequestHandler } from "express";
// eslint-disable-next-line @typescript-eslint/no-misused-promises
@ -16,7 +16,7 @@ const addItemController: RequestHandler = async (req, res) => {
return;
case ItemType.Weapon:
const weaponType = getWeaponType(request.InternalName);
const weapon = await addWeapon(weaponType, request.InternalName, accountId);
const weapon = await addEquipment(weaponType, request.InternalName, accountId);
res.json(weapon);
break;
default:

View File

@ -983,6 +983,7 @@ type InventoryDocumentProps = {
SpaceMelee: Types.DocumentArray<IEquipmentDatabase>;
SentinelWeapons: Types.DocumentArray<IEquipmentDatabase>;
Hoverboards: Types.DocumentArray<IEquipmentDatabase>;
MoaPets: Types.DocumentArray<IEquipmentDatabase>;
WeaponSkins: Types.DocumentArray<IWeaponSkinDatabase>;
};

View File

@ -26,7 +26,7 @@ import {
IUpdateChallengeProgressRequest
} from "../types/requestTypes";
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 { IEquipmentClient } from "../types/inventoryTypes/commonInventoryTypes";
import { ExportCustoms, ExportFlavour, ExportRecipes, ExportResources } from "warframe-public-export-plus";
@ -172,7 +172,7 @@ export const addItem = async (
break;
case "Weapons":
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);
return {
InventoryChanges: {
@ -444,23 +444,23 @@ export const syndicateSacrifice = async (
return res;
};
export const addWeapon = async (
weaponType: WeaponTypeInternal | "Hoverboards",
weaponName: string,
export const addEquipment = async (
category: TEquipmentKey,
type: string,
accountId: string,
modularParts: string[] | undefined = undefined
): Promise<IEquipmentClient> => {
const inventory = await getInventory(accountId);
const weaponIndex = inventory[weaponType].push({
ItemType: weaponName,
const index = inventory[category].push({
ItemType: type,
Configs: [],
XP: 0,
ModularParts: modularParts
});
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> => {

View File

@ -72,7 +72,9 @@ export const equipmentKeys = [
"SpaceSuits",
"SpaceGuns",
"SpaceMelee",
"Hoverboards"
"Hoverboards",
"OperatorAmps",
"MoaPets"
] as const;
export type TEquipmentKey = (typeof equipmentKeys)[number];