improve: adding special weapons at powersuit creation #277

Merged
AMelonInsideLemon merged 10 commits from SpecialItems into main 2024-06-07 06:58:20 -07:00
4 changed files with 39 additions and 26 deletions
Showing only changes of commit 242c9c2a50 - Show all commits

View File

@ -381,29 +381,6 @@ DuviriInfoSchema.set("toJSON", {
}
});
const GenericItemSchema2 = new Schema<IGenericItem2>({
ItemType: String,
ItemName: String,
XP: Number,
UpgradeVer: Number, //this is probably __v
Features: Number,
Polarized: Number,
CustomizationSlotPurchases: Number,
ModSlotPurchases: Number,
FocusLens: String,
Expiry: Date, //TODO: needs conversion
Polarity: [polaritySchema],
Configs: [ItemConfigSchema],
ModularParts: [String],
SkillTree: String,
UpgradeType: String,
UpgradeFingerprint: String,
OffensiveUpgrade: String,
DefensiveUpgrade: String,
UpgradesExpiry: Date, //TODO: needs conversion
ArchonCrystalUpgrades: []
});
const TypeXPItemSchema = new Schema<ITypeXPItem>(
OrdisPrime commented 2024-06-07 04:01:54 -07:00 (Migrated from github.com)
Review

please undo removal of all genericItem2 instances. it has a purpose for later.

please undo removal of all genericItem2 instances. it has a purpose for later.
{
ItemType: String,
@ -703,7 +680,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
//Melee Weapon
Melee: [WeaponSchema],
//Ability Weapon like Ultimate Mech\Excalibur\Ivara etc
SpecialItems: [GenericItemSchema2],
SpecialItems: [GenericItemSchema],
//The Mandachord(Octavia) is a step sequencer
StepSequencers: [StepSequencersSchema],
@ -1006,6 +983,7 @@ type InventoryDocumentProps = {
MiscItems: Types.DocumentArray<IMiscItem>;
Boosters: Types.DocumentArray<IBooster>;
OperatorLoadOuts: Types.DocumentArray<IOperatorConfigClient>;
SpecialItems: Types.DocumentArray<IGenericItem>;
AdultOperatorLoadOuts: Types.DocumentArray<IOperatorConfigClient>; //TODO: this should still contain _id
MechSuits: Types.DocumentArray<ISuitDatabase>;
Scoops: Types.DocumentArray<IGenericItem>;

View File

@ -24,7 +24,7 @@ import {
IUpdateChallengeProgressRequest
} from "../types/requestTypes";
import { logger } from "@/src/utils/logger";
import { WeaponTypeInternal } from "@/src/services/itemDataService";
import { WeaponTypeInternal, getExalted } from "@/src/services/itemDataService";
import { ISyndicateSacrifice, ISyndicateSacrificeResponse } from "../types/syndicateTypes";
export const createInventory = async (
@ -74,6 +74,12 @@ export const addSentinel = async (sentinelName: string, accountId: string) => {
};
export const addPowerSuit = async (powersuitName: string, accountId: string): Promise<ISuitClient> => {
const specialItems = await getExalted(powersuitName);
if(specialItems != false){
for await (const specialItem of specialItems) {
await addSpecialItem(specialItem, accountId)
}
}
const inventory = await getInventory(accountId);
const suitIndex = inventory.Suits.push({ ItemType: powersuitName, Configs: [], UpgradeVer: 101, XP: 0 });
const changedInventory = await inventory.save();
@ -81,12 +87,25 @@ export const addPowerSuit = async (powersuitName: string, accountId: string): Pr
};
export const addMechSuit = async (mechsuitName: string, accountId: string) => {
const specialItems = await getExalted(mechsuitName);
if(specialItems != false){
for await (const specialItem of specialItems) {
await addSpecialItem(specialItem, accountId)
}
}
const inventory = await getInventory(accountId);
const suitIndex = inventory.MechSuits.push({ ItemType: mechsuitName, Configs: [], UpgradeVer: 101, XP: 0 });
const changedInventory = await inventory.save();
return changedInventory.MechSuits[suitIndex - 1].toJSON();
};
export const addSpecialItem = async (itemName: string, accountId: string) => {
const inventory = await getInventory(accountId);
const specialItemIndex = inventory.SpecialItems.push({ ItemType: itemName, Configs: [], Features: 1, UpgradeVer: 101, XP: 0 });
const changedInventory = await inventory.save();
return changedInventory.SpecialItems[specialItemIndex -1].toJSON();
};
export const updateSlots = async (accountId: string, slotName: SlotNames, slotAmount: number, extraAmount: number) => {
const inventory = await getInventory(accountId);

View File

@ -3,6 +3,8 @@ import { logger } from "@/src/utils/logger";
import Items, { Buildable, Category, MinimalItem, Warframe, Weapon } from "warframe-items";
import badItems from "@/static/json/exclude-mods.json";
import dict_en from "@/node_modules/warframe-public-export-plus/dict.en.json";
import exportSuits from "@/node_modules/warframe-public-export-plus/ExportWarframes.json";
export type MinWarframe = Omit<Warframe, "patchlogs">;
export type MinWeapon = Omit<Weapon, "patchlogs">;
@ -104,6 +106,15 @@ export const getItemByBlueprint = (uniqueName: string): (MinItem & Buildable) |
return item;
};
export const getExalted = (uniqueName: string) => {
const suit = getSuitByUniqueName(uniqueName);
if(suit?.exalted !== undefined){
return suit.exalted;
} else {
return false
}
}
export const getItemCategoryByUniqueName = (uniqueName: string) => {
//Lotus/Types/Items/MiscItems/PolymerBundle
@ -121,6 +132,11 @@ export const getItemCategoryByUniqueName = (uniqueName: string) => {
return category;
};
export const getSuitByUniqueName = (uniqueName: string) => {
const suit = exportSuits.find(suit => suit.uniqueName === uniqueName);
return suit;
};
export const getItemByUniqueName = (uniqueName: string) => {
const item = items.find(item => item.uniqueName === uniqueName);
return item;

View File

@ -231,7 +231,7 @@ export interface IInventoryResponse {
AlignmentReplay: IAlignment;
PersonalGoalProgress: IPersonalGoalProgress[];
DailyAffiliationSolaris: number;
SpecialItems: IGenericItem2[];
SpecialItems: IGenericItem[];
ThemeStyle: string;
ThemeBackground: string;
ThemeSounds: string;