feat: spectre loadouts

This commit is contained in:
Sainan 2025-01-05 10:13:55 +01:00
parent 06bc0123ba
commit a2a159f261
4 changed files with 97 additions and 19 deletions

View File

@ -59,6 +59,30 @@ export const claimCompletedRecipeController: RequestHandler = async (req, res) =
}); });
} else { } else {
logger.debug("Claiming Recipe", { recipe, pendingRecipe }); logger.debug("Claiming Recipe", { recipe, pendingRecipe });
if (recipe.secretIngredientAction == "SIA_SPECTRE_LOADOUT_COPY") {
const inventory = await getInventory(accountId);
inventory.PendingSpectreLoadouts ??= [];
inventory.SpectreLoadouts ??= [];
const pendingLoadoutIndex = inventory.PendingSpectreLoadouts.findIndex(
x => x.ItemType == recipe.resultType
);
if (pendingLoadoutIndex != -1) {
const loadoutIndex = inventory.SpectreLoadouts.findIndex(x => x.ItemType == recipe.resultType);
if (loadoutIndex != -1) {
inventory.SpectreLoadouts.splice(loadoutIndex, 1);
}
logger.debug(
"moving spectre loadout from pending to active",
inventory.toJSON().PendingSpectreLoadouts![pendingLoadoutIndex]
);
inventory.SpectreLoadouts.push(inventory.PendingSpectreLoadouts[pendingLoadoutIndex]);
inventory.PendingSpectreLoadouts.splice(pendingLoadoutIndex, 1);
await inventory.save();
}
}
let InventoryChanges = {}; let InventoryChanges = {};
if (recipe.consumeOnUse) { if (recipe.consumeOnUse) {
const recipeChanges = [ const recipeChanges = [

View File

@ -6,6 +6,7 @@ import { getRecipe } from "@/src/services/itemDataService";
import { addMiscItems, getInventory, updateCurrency } from "@/src/services/inventoryService"; import { addMiscItems, getInventory, updateCurrency } from "@/src/services/inventoryService";
import { unixTimesInMs } from "@/src/constants/timeConstants"; import { unixTimesInMs } from "@/src/constants/timeConstants";
import { Types } from "mongoose"; import { Types } from "mongoose";
import { ISpectreLoadout } from "@/src/types/inventoryTypes/inventoryTypes";
interface IStartRecipeRequest { interface IStartRecipeRequest {
RecipeName: string; RecipeName: string;
@ -43,6 +44,59 @@ export const startRecipeController: RequestHandler = async (req, res) => {
_id: new Types.ObjectId() _id: new Types.ObjectId()
}); });
if (recipe.secretIngredientAction == "SIA_SPECTRE_LOADOUT_COPY") {
const spectreLoadout: ISpectreLoadout = {
ItemType: recipe.resultType,
Suits: "",
LongGuns: "",
Pistols: "",
Melee: ""
};
for (
let secretIngredientsIndex = 0;
secretIngredientsIndex != recipe.secretIngredients!.length;
++secretIngredientsIndex
) {
const type = recipe.secretIngredients![secretIngredientsIndex].ItemType;
const oid = startRecipeRequest.Ids[recipe.ingredients.length + secretIngredientsIndex];
if (oid == "ffffffffffffffffffffffff") {
// user chose to preserve the active loadout
break;
}
if (type == "/Lotus/Types/Game/PowerSuits/PlayerPowerSuit") {
const item = inventory.Suits.find(x => x._id.toString() == oid)!;
spectreLoadout.Suits = item.ItemType;
} else if (type == "/Lotus/Weapons/Tenno/Pistol/LotusPistol") {
const item = inventory.Pistols.find(x => x._id.toString() == oid)!;
spectreLoadout.Pistols = item.ItemType;
spectreLoadout.PistolsModularParts = item.ModularParts;
} else if (type == "/Lotus/Weapons/Tenno/LotusLongGun") {
const item = inventory.LongGuns.find(x => x._id.toString() == oid)!;
spectreLoadout.LongGuns = item.ItemType;
spectreLoadout.LongGunsModularParts = item.ModularParts;
} else {
console.assert(type == "/Lotus/Types/Game/LotusMeleeWeapon");
const item = inventory.Melee.find(x => x._id.toString() == oid)!;
spectreLoadout.Melee = item.ItemType;
spectreLoadout.MeleeModularParts = item.ModularParts;
}
}
if (
spectreLoadout.Suits != "" &&
spectreLoadout.LongGuns != "" &&
spectreLoadout.Pistols != "" &&
spectreLoadout.Melee != ""
) {
inventory.PendingSpectreLoadouts ??= [];
const existingIndex = inventory.PendingSpectreLoadouts.findIndex(x => x.ItemType == recipe.resultType);
if (existingIndex != -1) {
inventory.PendingSpectreLoadouts.splice(existingIndex, 1);
}
inventory.PendingSpectreLoadouts.push(spectreLoadout);
logger.debug("pending spectre loadout", spectreLoadout);
}
}
const newInventory = await inventory.save(); const newInventory = await inventory.save();
res.json({ res.json({

View File

@ -532,13 +532,14 @@ const fusionTreasuresSchema = new Schema<IFusionTreasure>().add(typeCountSchema)
const spectreLoadoutsSchema = new Schema<ISpectreLoadout>( const spectreLoadoutsSchema = new Schema<ISpectreLoadout>(
{ {
LongGuns: String, ItemType: String,
Melee: String,
Pistols: String,
PistolsFeatures: Number,
PistolsModularParts: [String],
Suits: String, Suits: String,
ItemType: String LongGuns: String,
LongGunsModularParts: { type: [String], default: undefined },
Pistols: String,
PistolsModularParts: { type: [String], default: undefined },
Melee: String,
MeleeModularParts: { type: [String], default: undefined }
}, },
{ _id: false } { _id: false }
); );
@ -920,11 +921,9 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
QualifyingInvasions: [Schema.Types.Mixed], QualifyingInvasions: [Schema.Types.Mixed],
FactionScores: [Number], FactionScores: [Number],
//Have only Suit+Pistols+LongGuns+Melee+ItemType(BronzeSpectre,GoldSpectre,PlatinumSpectreArmy,SilverSpectreArmy) // https://warframe.fandom.com/wiki/Specter_(Tenno)
//"/Lotus/Types/Game/SpectreArmies/BronzeSpectreArmy": "Vapor Specter Regiment", PendingSpectreLoadouts: { type: [spectreLoadoutsSchema], default: undefined },
SpectreLoadouts: [spectreLoadoutsSchema], SpectreLoadouts: { type: [spectreLoadoutsSchema], default: undefined },
//If you want change Spectre Gear id
PendingSpectreLoadouts: [Schema.Types.Mixed],
//New Quest Email //New Quest Email
EmailItems: [TypeXPItemSchema], EmailItems: [TypeXPItemSchema],

View File

@ -203,8 +203,8 @@ export interface IInventoryResponse {
SpaceMelee: IEquipmentDatabase[]; SpaceMelee: IEquipmentDatabase[];
SpaceGuns: IEquipmentDatabase[]; SpaceGuns: IEquipmentDatabase[];
ArchwingEnabled: boolean; ArchwingEnabled: boolean;
PendingSpectreLoadouts: any[]; PendingSpectreLoadouts?: ISpectreLoadout[];
SpectreLoadouts: ISpectreLoadout[]; SpectreLoadouts?: ISpectreLoadout[];
SentinelWeapons: IEquipmentDatabase[]; SentinelWeapons: IEquipmentDatabase[];
Sentinels: IEquipmentDatabase[]; Sentinels: IEquipmentDatabase[];
EmailItems: ITypeCount[]; EmailItems: ITypeCount[];
@ -869,13 +869,14 @@ export interface IShipInventory {
} }
export interface ISpectreLoadout { export interface ISpectreLoadout {
LongGuns: string;
Melee: string;
Pistols: string;
PistolsFeatures: number;
PistolsModularParts: string[];
Suits: string;
ItemType: string; ItemType: string;
Suits: string;
LongGuns: string;
LongGunsModularParts?: string[];
Pistols: string;
PistolsModularParts?: string[];
Melee: string;
MeleeModularParts?: string[];
} }
export interface IStepSequencer { export interface IStepSequencer {