wip
This commit is contained in:
parent
4a102b9d3b
commit
7aaa51b3eb
10
src/controllers/api/claimCompletedRecipeController.ts
Normal file
10
src/controllers/api/claimCompletedRecipeController.ts
Normal file
@ -0,0 +1,10 @@
|
||||
//this is a controller for the claimCompletedRecipe route
|
||||
//it will claim a recipe for the user
|
||||
|
||||
import { Request, RequestHandler, Response } from "express";
|
||||
import { logger } from "@/src/utils/logger";
|
||||
|
||||
export const claimCompletedRecipeController: RequestHandler = async (_req: Request, res: Response) => {
|
||||
logger.debug("Claiming Completed Recipe");
|
||||
res.json({ status: "success" });
|
||||
};
|
@ -24,6 +24,7 @@ const inventoryController: RequestHandler = async (request: Request, response: R
|
||||
return;
|
||||
}
|
||||
|
||||
//TODO: make a function that converts from database representation to client
|
||||
const inventoryJSON = inventory.toJSON();
|
||||
|
||||
const inventoryResponse = toInventoryResponse(inventoryJSON);
|
||||
|
21
src/controllers/api/startRecipeController.ts
Normal file
21
src/controllers/api/startRecipeController.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { parseString } from "@/src/helpers/general";
|
||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||
import { startRecipe } from "@/src/services/recipeService";
|
||||
import { logger } from "@/src/utils/logger";
|
||||
import { RequestHandler } from "express";
|
||||
|
||||
interface IStartRecipeRequest {
|
||||
RecipeName: string;
|
||||
Ids: string[];
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
export const startRecipeController: RequestHandler = async (req, res) => {
|
||||
const startRecipeRequest = getJSONfromString(req.body.toString()) as IStartRecipeRequest;
|
||||
logger.debug("StartRecipe Request", { startRecipeRequest });
|
||||
|
||||
const accountId = parseString(req.query.accountId);
|
||||
|
||||
const newRecipeId = await startRecipe(startRecipeRequest.RecipeName, accountId);
|
||||
res.json(newRecipeId);
|
||||
};
|
@ -1,5 +1,5 @@
|
||||
import { ItemType, toAddItemRequest } from "@/src/helpers/customHelpers/addItemHelpers";
|
||||
import { getWeaponType } from "@/src/helpers/purchaseHelpers";
|
||||
import { getWeaponType } from "@/src/services/itemDataService";
|
||||
import { addPowerSuit, addWeapon } from "@/src/services/inventoryService";
|
||||
import { RequestHandler } from "express";
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { isString, parseString } from "@/src/helpers/general";
|
||||
import { items } from "@/static/data/items";
|
||||
import { items } from "@/src/services/itemDataService";
|
||||
|
||||
export enum ItemType {
|
||||
Powersuit = "Powersuit",
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { parseBoolean, parseNumber, parseString } from "@/src/helpers/general";
|
||||
import { WeaponTypeInternal } from "@/src/services/inventoryService";
|
||||
import { weapons } from "@/src/services/itemDataService";
|
||||
import { slotPurchaseNameToSlotName } from "@/src/services/purchaseService";
|
||||
import { IPurchaseRequest, SlotPurchaseName } from "@/src/types/purchaseTypes";
|
||||
import { weapons } from "@/static/data/items";
|
||||
|
||||
export const toPurchaseRequest = (purchaseRequest: unknown): IPurchaseRequest => {
|
||||
if (!purchaseRequest || typeof purchaseRequest !== "object") {
|
||||
@ -41,22 +40,6 @@ export const toPurchaseRequest = (purchaseRequest: unknown): IPurchaseRequest =>
|
||||
throw new Error("invalid purchaseRequest");
|
||||
};
|
||||
|
||||
export const getWeaponType = (weaponName: string) => {
|
||||
const weaponInfo = weapons.find(i => i.uniqueName === weaponName);
|
||||
|
||||
if (!weaponInfo) {
|
||||
throw new Error(`unknown weapon ${weaponName}`);
|
||||
}
|
||||
|
||||
const weaponType = weaponInfo.productCategory as WeaponTypeInternal;
|
||||
|
||||
if (!weaponType) {
|
||||
throw new Error(`unknown weapon category for item ${weaponName}`);
|
||||
}
|
||||
|
||||
return weaponType;
|
||||
};
|
||||
|
||||
export const isSlotPurchaseName = (slotPurchaseName: string): slotPurchaseName is SlotPurchaseName => {
|
||||
return slotPurchaseName in slotPurchaseNameToSlotName;
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
export const getJSONfromString = (str: string): any => {
|
||||
export const getJSONfromString = (str: string) => {
|
||||
const jsonSubstring = str.substring(0, str.lastIndexOf("}") + 1);
|
||||
return JSON.parse(jsonSubstring);
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Model, Schema, Types, model } from "mongoose";
|
||||
import { HydratedDocument, Model, Schema, Types, model } from "mongoose";
|
||||
import {
|
||||
IFlavourItem,
|
||||
IRawUpgrade,
|
||||
@ -10,7 +10,9 @@ import {
|
||||
ISlots,
|
||||
IGenericItem,
|
||||
IMailbox,
|
||||
IDuviriInfo
|
||||
IDuviriInfo,
|
||||
IPendingRecipe as IPendingRecipeDatabase,
|
||||
IPendingRecipeResponse
|
||||
} from "../../types/inventoryTypes/inventoryTypes";
|
||||
import { IMongoDate, IOid } from "../../types/commonTypes";
|
||||
import { ISuitDatabase } from "@/src/types/inventoryTypes/SuitTypes";
|
||||
@ -25,6 +27,29 @@ import {
|
||||
} from "@/src/types/inventoryTypes/commonInventoryTypes";
|
||||
import { toOid } from "@/src/helpers/inventoryHelpers";
|
||||
|
||||
const pendingRecipeSchema = new Schema<IPendingRecipeDatabase>(
|
||||
{
|
||||
ItemType: String,
|
||||
CompletionDate: Date
|
||||
},
|
||||
{ id: false }
|
||||
);
|
||||
|
||||
pendingRecipeSchema.virtual("ItemId").get(function () {
|
||||
return { $oid: this._id.toString() };
|
||||
});
|
||||
|
||||
pendingRecipeSchema.set("toJSON", {
|
||||
virtuals: true,
|
||||
transform(_document, returnedObject) {
|
||||
delete returnedObject._id;
|
||||
delete returnedObject.__v;
|
||||
(returnedObject as IPendingRecipeResponse).CompletionDate = {
|
||||
$date: { $numberLong: (returnedObject as IPendingRecipeDatabase).CompletionDate.getTime().toString() }
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
const polaritySchema = new Schema<IPolarity>({
|
||||
Slot: Number,
|
||||
Value: String
|
||||
@ -296,7 +321,6 @@ DuviriInfoSchema.set("toJSON", {
|
||||
});
|
||||
|
||||
const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>({
|
||||
|
||||
accountOwnerId: Schema.Types.ObjectId,
|
||||
SubscribedToEmails: Number,
|
||||
Created: Schema.Types.Mixed,
|
||||
@ -325,7 +349,6 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>({
|
||||
MechBin: slotsBinSchema,
|
||||
CrewMemberBin: slotsBinSchema,
|
||||
|
||||
|
||||
//How many trades do you have left
|
||||
TradesRemaining: Number,
|
||||
//How many Gift do you have left*(gift spends the trade)
|
||||
@ -351,10 +374,9 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>({
|
||||
DailyAffiliationZariman: Number,
|
||||
DailyAffiliationKahl: Number,
|
||||
|
||||
|
||||
//Daily Focus limit
|
||||
DailyFocus: Number,
|
||||
//you not used Focus
|
||||
//you not used Focus
|
||||
FocusXP: Schema.Types.Mixed,
|
||||
//Curent active like Active school focuses is = "Zenurik"
|
||||
FocusAbility: String,
|
||||
@ -441,24 +463,21 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>({
|
||||
//Railjack/Components(https://warframe.fandom.com/wiki/Railjack/Components)
|
||||
CrewShipRawSalvage: [Schema.Types.Mixed],
|
||||
|
||||
|
||||
//Default RailJack
|
||||
CrewShips: [Schema.Types.Mixed],
|
||||
CrewShipAmmo: [Schema.Types.Mixed],
|
||||
CrewShipWeapons: [Schema.Types.Mixed],
|
||||
CrewShipWeaponSkins: [Schema.Types.Mixed],
|
||||
|
||||
|
||||
//NPC Crew and weapon
|
||||
CrewMembers: [Schema.Types.Mixed],
|
||||
CrewShipSalvagedWeaponSkins: [Schema.Types.Mixed],
|
||||
CrewShipSalvagedWeapons: [Schema.Types.Mixed],
|
||||
|
||||
|
||||
//Complete Mission\Quests
|
||||
Missions: [Schema.Types.Mixed],
|
||||
QuestKeys: [Schema.Types.Mixed],
|
||||
//item like DojoKey or Boss missions key
|
||||
//item like DojoKey or Boss missions key
|
||||
LevelKeys: [Schema.Types.Mixed],
|
||||
//Active quests
|
||||
Quests: [Schema.Types.Mixed],
|
||||
@ -478,25 +497,22 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>({
|
||||
//Retries rank up(3 time)
|
||||
TrainingRetriesLeft: Number,
|
||||
|
||||
|
||||
//you saw last played Region when you opened the star map
|
||||
LastRegionPlayed: String,
|
||||
|
||||
//Blueprint
|
||||
Recipes: [Schema.Types.Mixed],
|
||||
//Crafting Blueprint(Item Name + CompletionDate)
|
||||
PendingRecipes: [Schema.Types.Mixed],
|
||||
PendingRecipes: [pendingRecipeSchema],
|
||||
|
||||
//warframe\Weapon skins
|
||||
WeaponSkins: [Schema.Types.Mixed],
|
||||
|
||||
|
||||
//Ayatan Item
|
||||
FusionTreasures: [Schema.Types.Mixed],
|
||||
//"node": "TreasureTutorial", "state": "TS_COMPLETED"
|
||||
TauntHistory: [Schema.Types.Mixed],
|
||||
|
||||
|
||||
//noShow2FA,VisitPrimeVault etc
|
||||
WebFlags: Schema.Types.Mixed,
|
||||
//Id CompletedAlerts
|
||||
@ -508,7 +524,6 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>({
|
||||
//Alert->Kuva Siphon
|
||||
PeriodicMissionCompletions: [Schema.Types.Mixed],
|
||||
|
||||
|
||||
//Codex->LoreFragment
|
||||
LoreFragmentScans: [Schema.Types.Mixed],
|
||||
|
||||
@ -520,7 +535,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>({
|
||||
ActiveDojoColorResearch: String,
|
||||
|
||||
SentientSpawnChanceBoosters: Schema.Types.Mixed,
|
||||
|
||||
|
||||
QualifyingInvasions: [Schema.Types.Mixed],
|
||||
FactionScores: [Number],
|
||||
|
||||
@ -530,11 +545,9 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>({
|
||||
//If you want change Spectre Gear id
|
||||
PendingSpectreLoadouts: [Schema.Types.Mixed],
|
||||
|
||||
|
||||
//New quest Email spam
|
||||
//example:"ItemType": "/Lotus/Types/Keys/RailJackBuildQuest/RailjackBuildQuestEmailItem",
|
||||
EmailItems: [Schema.Types.Mixed],
|
||||
|
||||
|
||||
//Profile->Wishlist
|
||||
Wishlist: [String],
|
||||
@ -561,7 +574,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>({
|
||||
|
||||
//Game mission\ivent score example "Tag": "WaterFight", "Best": 170, "Count": 1258,
|
||||
PersonalGoalProgress: [Schema.Types.Mixed],
|
||||
|
||||
|
||||
//Setting interface Style
|
||||
ThemeStyle: String,
|
||||
ThemeBackground: String,
|
||||
@ -579,7 +592,6 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>({
|
||||
//Night Wave Challenge
|
||||
SeasonChallengeHistory: [Schema.Types.Mixed],
|
||||
|
||||
|
||||
//Cephalon Simaris Entries Example:"TargetType"+"Scans"(1-10)+"Completed": true|false
|
||||
LibraryPersonalProgress: [Schema.Types.Mixed],
|
||||
//Cephalon Simaris Daily Task
|
||||
@ -587,23 +599,23 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>({
|
||||
|
||||
//https://warframe.fandom.com/wiki/Invasion
|
||||
InvasionChainProgress: [Schema.Types.Mixed],
|
||||
|
||||
|
||||
//https://warframe.fandom.com/wiki/Parazon
|
||||
DataKnives: [GenericItemSchema],
|
||||
|
||||
|
||||
//CorpusLich or GrineerLich
|
||||
NemesisAbandonedRewards: [String],
|
||||
//CorpusLich\KuvaLich
|
||||
//CorpusLich\KuvaLich
|
||||
NemesisHistory: [Schema.Types.Mixed],
|
||||
LastNemesisAllySpawnTime: Schema.Types.Mixed,
|
||||
|
||||
|
||||
//TradingRulesConfirmed,ShowFriendInvNotifications(Option->Social)
|
||||
Settings: Schema.Types.Mixed,
|
||||
|
||||
//Railjack craft
|
||||
//Railjack craft
|
||||
//https://warframe.fandom.com/wiki/Rising_Tide
|
||||
PersonalTechProjects: [Schema.Types.Mixed],
|
||||
|
||||
|
||||
//Modulars lvl and exp(Railjack|Duviri)
|
||||
//https://warframe.fandom.com/wiki/Intrinsics
|
||||
PlayerSkills: Schema.Types.Mixed,
|
||||
@ -611,7 +623,6 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>({
|
||||
//TradeBannedUntil data
|
||||
TradeBannedUntil: Schema.Types.Mixed,
|
||||
|
||||
|
||||
//https://warframe.fandom.com/wiki/Helminth
|
||||
InfestedFoundry: Schema.Types.Mixed,
|
||||
NextRefill: Schema.Types.Mixed,
|
||||
@ -624,7 +635,6 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>({
|
||||
//https://warframe.fandom.com/wiki/Incarnon
|
||||
EvolutionProgress: [Schema.Types.Mixed],
|
||||
|
||||
|
||||
//Unknown and system
|
||||
DuviriInfo: DuviriInfoSchema,
|
||||
Mailbox: MailboxSchema,
|
||||
@ -650,7 +660,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>({
|
||||
CollectibleSeries: [Schema.Types.Mixed],
|
||||
HasResetAccount: Boolean,
|
||||
|
||||
//Discount Coupon
|
||||
//Discount Coupon
|
||||
PendingCoupon: Schema.Types.Mixed,
|
||||
//Like BossAladV,BossCaptainVor come for you on missions % chance
|
||||
DeathMarks: [String],
|
||||
@ -685,13 +695,14 @@ type InventoryDocumentProps = {
|
||||
MiscItems: Types.DocumentArray<IMiscItem>;
|
||||
Boosters: Types.DocumentArray<IBooster>;
|
||||
OperatorLoadOuts: Types.DocumentArray<IOperatorConfigClient>;
|
||||
AdultOperatorLoadOuts: Types.DocumentArray<IOperatorConfigClient>;
|
||||
AdultOperatorLoadOuts: Types.DocumentArray<IOperatorConfigClient>; //TODO: this should still contain _id
|
||||
MechSuits: Types.DocumentArray<ISuitDatabase>;
|
||||
Scoops: Types.DocumentArray<IGenericItem>;
|
||||
DataKnives: Types.DocumentArray<IGenericItem>;
|
||||
DrifterMelee: Types.DocumentArray<IGenericItem>;
|
||||
Sentinels: Types.DocumentArray<IWeaponDatabase>;
|
||||
Horses: Types.DocumentArray<IGenericItem>;
|
||||
PendingRecipes: Types.DocumentArray<IPendingRecipeDatabase>;
|
||||
};
|
||||
|
||||
type InventoryModelType = Model<IInventoryDatabase, {}, InventoryDocumentProps>;
|
||||
|
@ -35,6 +35,8 @@ import express from "express";
|
||||
import { setBootLocationController } from "@/src/controllers/api/setBootLocationController";
|
||||
import { focusController } from "@/src/controllers/api/focusController";
|
||||
import { inventorySlotsController } from "@/src/controllers/api/inventorySlotsController";
|
||||
import { startRecipeController } from "@/src/controllers/api/startRecipeController";
|
||||
import { claimCompletedRecipeController } from "@/src/controllers/api/claimCompletedRecipeController";
|
||||
|
||||
const apiRouter = express.Router();
|
||||
|
||||
@ -62,6 +64,9 @@ apiRouter.get("/logout.php", logoutController);
|
||||
apiRouter.get("/setBootLocation.php", setBootLocationController);
|
||||
|
||||
// post
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
apiRouter.post("/claimCompletedRecipe.php", claimCompletedRecipeController);
|
||||
apiRouter.post("/startRecipe.php", startRecipeController);
|
||||
apiRouter.post("/inventorySlots.php", inventorySlotsController);
|
||||
apiRouter.post("/focus.php", focusController);
|
||||
apiRouter.post("/artifacts.php", artifactsController);
|
||||
|
@ -17,6 +17,7 @@ import {
|
||||
import { IGenericUpdate } from "../types/genericUpdate";
|
||||
import { IArtifactsRequest, IMissionInventoryUpdateRequest } from "../types/requestTypes";
|
||||
import { logger } from "@/src/utils/logger";
|
||||
import { WeaponTypeInternal } from "@/src/services/itemDataService";
|
||||
|
||||
export const createInventory = async (accountOwnerId: Types.ObjectId, loadOutPresetId: Types.ObjectId) => {
|
||||
try {
|
||||
@ -145,8 +146,6 @@ export const updateGeneric = async (data: IGenericUpdate, accountId: string) =>
|
||||
return data;
|
||||
};
|
||||
|
||||
export type WeaponTypeInternal = "LongGuns" | "Pistols" | "Melee";
|
||||
|
||||
export const addWeapon = async (
|
||||
weaponType: WeaponTypeInternal,
|
||||
weaponName: string,
|
||||
|
93
src/services/itemDataService.ts
Normal file
93
src/services/itemDataService.ts
Normal file
@ -0,0 +1,93 @@
|
||||
import { logger } from "@/src/utils/logger";
|
||||
import Items, { Buildable, Category, Item, Warframe, Weapon } from "warframe-items";
|
||||
import { log } from "winston";
|
||||
|
||||
type MinWeapon = Omit<Weapon, "patchlogs">;
|
||||
type MinItem = Omit<Item, "patchlogs">;
|
||||
|
||||
export const weapons: MinWeapon[] = (new Items({ category: ["Primary", "Secondary", "Melee"] }) as Weapon[]).map(
|
||||
item => {
|
||||
const next = { ...item };
|
||||
delete next.patchlogs;
|
||||
return next;
|
||||
}
|
||||
);
|
||||
|
||||
export type WeaponTypeInternal = "LongGuns" | "Pistols" | "Melee";
|
||||
|
||||
export const items: MinItem[] = new Items({ category: ["All"] }).map(item => {
|
||||
const next = { ...item };
|
||||
delete next.patchlogs;
|
||||
return next;
|
||||
});
|
||||
|
||||
export const getWeaponType = (weaponName: string) => {
|
||||
const weaponInfo = weapons.find(i => i.uniqueName === weaponName);
|
||||
|
||||
if (!weaponInfo) {
|
||||
throw new Error(`unknown weapon ${weaponName}`);
|
||||
}
|
||||
|
||||
const weaponType = weaponInfo.productCategory as WeaponTypeInternal;
|
||||
|
||||
if (!weaponType) {
|
||||
logger.error(`unknown weapon category for item ${weaponName}`);
|
||||
throw new Error(`unknown weapon category for item ${weaponName}`);
|
||||
}
|
||||
|
||||
return weaponType;
|
||||
};
|
||||
|
||||
const getNamesObj = (category: Category) =>
|
||||
new Items({ category: [category] }).reduce<{ [index: string]: string }>((acc, item) => {
|
||||
acc[item.name!.replace("'S", "'s")] = item.uniqueName!;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
export const modNames = getNamesObj("Mods");
|
||||
export const resourceNames = getNamesObj("Resources");
|
||||
export const miscNames = getNamesObj("Misc");
|
||||
export const relicNames = getNamesObj("Relics");
|
||||
export const skinNames = getNamesObj("Skins");
|
||||
export const arcaneNames = getNamesObj("Arcanes");
|
||||
export const gearNames = getNamesObj("Gear");
|
||||
//logger.debug(`gear names`, { gearNames });
|
||||
|
||||
export const craftNames = Object.fromEntries(
|
||||
(
|
||||
new Items({
|
||||
category: [
|
||||
"Warframes",
|
||||
"Gear",
|
||||
"Melee",
|
||||
"Primary",
|
||||
"Secondary",
|
||||
"Sentinels",
|
||||
"Misc",
|
||||
"Arch-Gun",
|
||||
"Arch-Melee"
|
||||
]
|
||||
}) as Warframe[]
|
||||
)
|
||||
.flatMap(item => item.components || [])
|
||||
.filter(item => item.drops && item.drops[0])
|
||||
.map(item => [item.drops![0].type, item.uniqueName])
|
||||
);
|
||||
|
||||
export const blueprintNames = Object.fromEntries(
|
||||
Object.keys(craftNames)
|
||||
.filter(name => name.includes("Blueprint"))
|
||||
.map(name => [name, craftNames[name]])
|
||||
);
|
||||
|
||||
const items2 = new Items({
|
||||
category: ["Warframes", "Gear", "Melee", "Primary", "Secondary", "Sentinels", "Misc", "Arch-Gun", "Arch-Melee"]
|
||||
});
|
||||
|
||||
items2.flatMap(item => item.components || []);
|
||||
// for (const item of items2) {
|
||||
// console.log(item.category === "Warframes");
|
||||
// if (item.category === "Warframes") {
|
||||
// console.log(item);
|
||||
// }
|
||||
// }
|
@ -1,7 +1,14 @@
|
||||
import { IMissionRewardResponse, IReward, IInventoryFieldType, inventoryFields } from "@/src/types/missionTypes";
|
||||
|
||||
import missionsDropTable from "@/static/json/missions-drop-table.json";
|
||||
import { modNames, relicNames, miscNames, resourceNames, gearNames, blueprintNames } from "@/static/data/items";
|
||||
import {
|
||||
modNames,
|
||||
relicNames,
|
||||
miscNames,
|
||||
resourceNames,
|
||||
gearNames,
|
||||
blueprintNames
|
||||
} from "@/src/services/itemDataService";
|
||||
import { IMissionInventoryUpdateRequest } from "../types/requestTypes";
|
||||
import { logger } from "@/src/utils/logger";
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { getWeaponType, parseSlotPurchaseName } from "@/src/helpers/purchaseHelpers";
|
||||
import { parseSlotPurchaseName } from "@/src/helpers/purchaseHelpers";
|
||||
import { getWeaponType } from "@/src/services/itemDataService";
|
||||
import { getSubstringFromKeyword } from "@/src/helpers/stringHelpers";
|
||||
import {
|
||||
addBooster,
|
||||
|
20
src/services/recipeService.ts
Normal file
20
src/services/recipeService.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { getInventory } from "@/src/services/inventoryService";
|
||||
import { Types } from "mongoose";
|
||||
|
||||
export const startRecipe = async (recipeName: string, accountId: string) => {
|
||||
//get recipe data
|
||||
|
||||
//consume resources
|
||||
const inventory = await getInventory(accountId);
|
||||
inventory.PendingRecipes.push({
|
||||
ItemType: recipeName,
|
||||
CompletionDate: new Date(),
|
||||
_id: new Types.ObjectId()
|
||||
});
|
||||
|
||||
const newInventory = await inventory.save();
|
||||
|
||||
return {
|
||||
RecipeId: { $oid: newInventory.PendingRecipes[newInventory.PendingRecipes.length - 1]._id?.toString() }
|
||||
};
|
||||
};
|
@ -14,11 +14,13 @@ import { IOperatorLoadOutSigcol, IWeaponDatabase } from "@/src/types/inventoryTy
|
||||
|
||||
//Document extends will be deleted soon. TODO: delete and migrate uses to ...
|
||||
export interface IInventoryDatabaseDocument extends IInventoryDatabase, Document {}
|
||||
export interface IInventoryDatabase extends Omit<IInventoryResponse, "TrainingDate" | "LoadOutPresets" | "Mailbox"> {
|
||||
export interface IInventoryDatabase
|
||||
extends Omit<IInventoryResponse, "TrainingDate" | "LoadOutPresets" | "Mailbox" | "PendingRecipes"> {
|
||||
accountOwnerId: Types.ObjectId;
|
||||
TrainingDate: Date; // TrainingDate changed from IMongoDate to Date
|
||||
LoadOutPresets: Types.ObjectId; // LoadOutPresets changed from ILoadOutPresets to Types.ObjectId for population
|
||||
Mailbox: Types.ObjectId; // Mailbox changed from IMailbox to Types.ObjectId
|
||||
PendingRecipes: IPendingRecipe[];
|
||||
}
|
||||
|
||||
export interface IInventoryResponseDocument extends IInventoryResponse, Document {}
|
||||
@ -41,6 +43,11 @@ export interface IMailbox {
|
||||
LastInboxId: IOid;
|
||||
}
|
||||
|
||||
//TODO: perhaps split response and database into their own files
|
||||
|
||||
export interface IPendingRecipeResponse extends Omit<IPendingRecipe, "CompletionDate"> {
|
||||
CompletionDate: IMongoDate;
|
||||
}
|
||||
export interface IInventoryResponse {
|
||||
Horses: IGenericItem[];
|
||||
DrifterMelee: IGenericItem[];
|
||||
@ -96,7 +103,7 @@ export interface IInventoryResponse {
|
||||
XPInfo: IEmailItem[];
|
||||
Recipes: IConsumable[];
|
||||
WeaponSkins: IWeaponSkin[];
|
||||
PendingRecipes: IPendingRecipe[];
|
||||
PendingRecipes: IPendingRecipeResponse[];
|
||||
TrainingDate: IMongoDate;
|
||||
PlayerLevel: number;
|
||||
Upgrades: ICrewShipSalvagedWeaponSkin[];
|
||||
@ -816,7 +823,7 @@ export interface IPendingCoupon {
|
||||
|
||||
export interface IPendingRecipe {
|
||||
ItemType: string;
|
||||
CompletionDate: IMongoDate;
|
||||
CompletionDate: Date;
|
||||
ItemId: IOid;
|
||||
}
|
||||
|
||||
|
@ -1,60 +0,0 @@
|
||||
import Items, { Category, Item, Warframe, Weapon } from "warframe-items";
|
||||
|
||||
type MinWeapon = Omit<Weapon, "patchlogs">;
|
||||
type MinItem = Omit<Item, "patchlogs">;
|
||||
|
||||
export const weapons: MinWeapon[] = (new Items({ category: ["Primary", "Secondary", "Melee"] }) as Weapon[]).map(
|
||||
item => {
|
||||
const next = { ...item };
|
||||
delete next.patchlogs;
|
||||
return next;
|
||||
}
|
||||
);
|
||||
|
||||
export const items: MinItem[] = new Items({ category: ["All"] }).map(item => {
|
||||
const next = { ...item };
|
||||
delete next.patchlogs;
|
||||
return next;
|
||||
});
|
||||
|
||||
const getNamesObj = (category: Category) =>
|
||||
new Items({ category: [category] }).reduce((acc, item) => {
|
||||
acc[item.name!.replace("'S", "'s")] = item.uniqueName!;
|
||||
return acc;
|
||||
}, {} as ImportAssertions);
|
||||
|
||||
export const modNames = getNamesObj("Mods");
|
||||
export const resourceNames = getNamesObj("Resources");
|
||||
export const miscNames = getNamesObj("Misc");
|
||||
export const relicNames = getNamesObj("Relics");
|
||||
export const skinNames = getNamesObj("Skins");
|
||||
export const arcaneNames = getNamesObj("Arcanes");
|
||||
export const gearNames = getNamesObj("Gear");
|
||||
|
||||
export const craftNames: ImportAssertions = Object.fromEntries(
|
||||
(
|
||||
new Items({
|
||||
category: [
|
||||
"Warframes",
|
||||
"Gear",
|
||||
"Melee",
|
||||
"Primary",
|
||||
"Secondary",
|
||||
"Sentinels",
|
||||
"Misc",
|
||||
"Arch-Gun",
|
||||
"Arch-Melee"
|
||||
]
|
||||
}) as Warframe[]
|
||||
)
|
||||
.flatMap(item => item.components || [])
|
||||
.filter(item => item.drops && item.drops[0])
|
||||
.map(item => [item.drops![0].type, item.uniqueName])
|
||||
);
|
||||
craftNames["Forma Blueprint"] = "/Lotus/Types/Recipes/Components/FormaBlueprint";
|
||||
|
||||
export const blueprintNames: ImportAssertions = Object.fromEntries(
|
||||
Object.keys(craftNames)
|
||||
.filter(name => name.includes("Blueprint"))
|
||||
.map(name => [name, craftNames[name]])
|
||||
);
|
Loading…
x
Reference in New Issue
Block a user