feat: spectre loadouts (#719)

This commit is contained in:
Sainan 2025-01-06 01:21:37 +01:00 committed by GitHub
parent eb6baa5e15
commit 709c2a401b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 97 additions and 19 deletions

View File

@ -59,6 +59,30 @@ export const claimCompletedRecipeController: RequestHandler = async (req, res) =
});
} else {
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 = {};
if (recipe.consumeOnUse) {
const recipeChanges = [

View File

@ -6,6 +6,7 @@ import { getRecipe } from "@/src/services/itemDataService";
import { addMiscItems, getInventory, updateCurrency } from "@/src/services/inventoryService";
import { unixTimesInMs } from "@/src/constants/timeConstants";
import { Types } from "mongoose";
import { ISpectreLoadout } from "@/src/types/inventoryTypes/inventoryTypes";
interface IStartRecipeRequest {
RecipeName: string;
@ -43,6 +44,59 @@ export const startRecipeController: RequestHandler = async (req, res) => {
_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();
res.json({

View File

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

View File

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