Auto adding exalted items (#277)

Co-authored-by: AMelonInsideLemon <AMelonInsideLemon@users.noreply.github.com>
This commit is contained in:
AMelonInsideLemon 2024-06-07 15:58:20 +02:00 committed by GitHub
parent e35a7fd69f
commit 01a9bf24c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 45 additions and 3 deletions

View File

@ -381,6 +381,7 @@ DuviriInfoSchema.set("toJSON", {
}
});
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const GenericItemSchema2 = new Schema<IGenericItem2>({
ItemType: String,
ItemName: String,
@ -703,7 +704,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 +1007,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 = 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,31 @@ export const addPowerSuit = async (powersuitName: string, accountId: string): Pr
};
export const addMechSuit = async (mechsuitName: string, accountId: string) => {
const specialItems = 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,7 @@ 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">;
@ -109,6 +110,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
@ -126,6 +136,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;