diff --git a/src/controllers/custom/addItemsController.ts b/src/controllers/custom/addItemsController.ts index 4add37ac..ff05fc7b 100644 --- a/src/controllers/custom/addItemsController.ts +++ b/src/controllers/custom/addItemsController.ts @@ -1,14 +1,91 @@ import { getAccountIdForRequest } from "../../services/loginService.ts"; -import { getInventory, addItem } from "../../services/inventoryService.ts"; +import { + getInventory, + addItem, + addMiscItem, + addMods, + addShipDecorations, + addPowerSuit, + addEquipment, + addMechSuit, + addSentinel, + addSentinelWeapon, + addCustomization, + addSkin, + productCategoryToInventoryBin, + occupySlot +} from "../../services/inventoryService.ts"; import type { RequestHandler } from "express"; import { broadcastInventoryUpdate } from "../../services/wsService.ts"; +import { InventorySlot } from "../../types/inventoryTypes/inventoryTypes.ts"; export const addItemsController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); const requests = req.body as IAddItemRequest[]; const inventory = await getInventory(accountId); + const productCategory = (req.query.productCategory as string) || ""; for (const request of requests) { - await addItem(inventory, request.ItemType, request.ItemCount, true, undefined, request.Fingerprint, true); + switch (productCategory) { + case "MiscItems": + addMiscItem(inventory, request.ItemType, request.ItemCount); + break; + + case "RawUpgrades": + addMods(inventory, [request]); + break; + + case "ShipDecorations": + addShipDecorations(inventory, [request]); + break; + + case "Suits": + await addPowerSuit(inventory, request.ItemType); + occupySlot(inventory, InventorySlot.SUITS, true); + break; + + case "MechSuits": + await addMechSuit(inventory, request.ItemType); + occupySlot(inventory, InventorySlot.MECHSUITS, true); + break; + + case "Sentinels": + addSentinel(inventory, request.ItemType, true); + break; + + case "SentinelWeapons": + addSentinelWeapon(inventory, request.ItemType, true); + break; + + case "FlavourItems": + addCustomization(inventory, request.ItemType); + break; + + case "WeaponSkins": + addSkin(inventory, request.ItemType); + break; + + case "LongGuns": + case "Pistols": + case "Melee": + case "SpaceSuits": + case "SpaceGuns": + case "SpaceMelee": + addEquipment(inventory, productCategory, request.ItemType); + occupySlot(inventory, productCategoryToInventoryBin(productCategory) ?? InventorySlot.WEAPONS, true); + break; + + default: + await addItem( + inventory, + request.ItemType, + request.ItemCount, + true, + undefined, + request.Fingerprint, + true + ); + break; + } } await inventory.save(); res.end(); diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 17cdf370..e84d178c 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -941,7 +941,7 @@ export const applyDefaultUpgrades = ( }; //TODO: maybe genericMethod for all the add methods, they share a lot of logic -const addSentinel = ( +export const addSentinel = ( inventory: TInventoryDatabaseDocument, sentinelName: string, premiumPurchase: boolean, @@ -972,11 +972,11 @@ const addSentinel = ( return inventoryChanges; }; -const addSentinelWeapon = ( +export const addSentinelWeapon = ( inventory: TInventoryDatabaseDocument, typeName: string, premiumPurchase: boolean, - inventoryChanges: IInventoryChanges + inventoryChanges: IInventoryChanges = {} ): void => { // Sentinel weapons also occupy a slot in the sentinels bin combineInventoryChanges(inventoryChanges, occupySlot(inventory, InventorySlot.SENTINELS, premiumPurchase)); diff --git a/static/webui/index.html b/static/webui/index.html index b14e004b..e0d610bf 100644 --- a/static/webui/index.html +++ b/static/webui/index.html @@ -116,9 +116,31 @@
productCategory, some of which will allow you to change the number of items added.`,
inventory_suits: `Warframes`,
inventory_longGuns: `Primärwaffen`,
inventory_pistols: `Sekundärwaffen`,
@@ -308,6 +309,7 @@ dict = {
worldState_incompatibleWith: `Inkompatibel mit:`,
enabled: `Aktiviert`,
disabled: `Deaktiviert`,
+ notSpecified: `[UNTRANSLATED] Not specified`,
worldState_we1: `Wochenende 1`,
worldState_we2: `Wochenende 2`,
worldState_we3: `Wochenende 3`,
diff --git a/static/webui/translations/en.js b/static/webui/translations/en.js
index 7a0af074..0e04914c 100644
--- a/static/webui/translations/en.js
+++ b/static/webui/translations/en.js
@@ -97,6 +97,7 @@ dict = {
inventory_addItems: `Add Items`,
inventory_addItemByItemType: `Raw`,
inventory_addItemByItemType_warning: `Use this feature at your own risk. It may break your inventory, and you will need to remove items manually if something goes wrong.`,
+ inventory_addItemByItemType_productCategory: `You can also specify productCategory, some of which will allow you to change the number of items added.`,
inventory_suits: `Warframes`,
inventory_longGuns: `Primary Weapons`,
inventory_pistols: `Secondary Weapons`,
@@ -307,6 +308,7 @@ dict = {
worldState_incompatibleWith: `Incompatible with:`,
enabled: `Enabled`,
disabled: `Disabled`,
+ notSpecified: `Not specified`,
worldState_we1: `Weekend 1`,
worldState_we2: `Weekend 2`,
worldState_we3: `Weekend 3`,
diff --git a/static/webui/translations/es.js b/static/webui/translations/es.js
index 58eab8c8..011bf7a7 100644
--- a/static/webui/translations/es.js
+++ b/static/webui/translations/es.js
@@ -98,6 +98,7 @@ dict = {
inventory_addItems: `Agregar objetos`,
inventory_addItemByItemType: `Sin refinar`,
inventory_addItemByItemType_warning: `Usa esta función bajo tu propio riesgo. Podría dañar tu inventario, y tendrías que eliminar los objetos manualmente si algo sale mal.`,
+ inventory_addItemByItemType_productCategory: `[UNTRANSLATED] You can also specify productCategory, some of which will allow you to change the number of items added.`,
inventory_suits: `Warframes`,
inventory_longGuns: `Armas primarias`,
inventory_pistols: `Armas secundarias`,
@@ -308,6 +309,7 @@ dict = {
worldState_incompatibleWith: `No compatible con:`,
enabled: `Activado`,
disabled: `Desactivado`,
+ notSpecified: `[UNTRANSLATED] Not specified`,
worldState_we1: `Semana 1`,
worldState_we2: `Semana 2`,
worldState_we3: `Semana 3`,
diff --git a/static/webui/translations/fr.js b/static/webui/translations/fr.js
index 3fa19019..139c0e01 100644
--- a/static/webui/translations/fr.js
+++ b/static/webui/translations/fr.js
@@ -98,6 +98,7 @@ dict = {
inventory_addItems: `Ajouter des items`,
inventory_addItemByItemType: `Brut`,
inventory_addItemByItemType_warning: `Cette fonctionnalité comporte des risques. Il faudra rajouter les items manuellement si l'inventaire est compris.`,
+ inventory_addItemByItemType_productCategory: `[UNTRANSLATED] You can also specify productCategory, some of which will allow you to change the number of items added.`,
inventory_suits: `Warframes`,
inventory_longGuns: `Armes principales`,
inventory_pistols: `Armes secondaires`,
@@ -308,6 +309,7 @@ dict = {
worldState_incompatibleWith: `Incompatible avec :`,
enabled: `Activé`,
disabled: `Désactivé`,
+ notSpecified: `[UNTRANSLATED] Not specified`,
worldState_we1: `Weekend 1`,
worldState_we2: `Weekend 2`,
worldState_we3: `Weekend 3`,
diff --git a/static/webui/translations/ru.js b/static/webui/translations/ru.js
index bb80e3ed..9d22fb1b 100644
--- a/static/webui/translations/ru.js
+++ b/static/webui/translations/ru.js
@@ -98,6 +98,7 @@ dict = {
inventory_addItems: `Добавить предметы`,
inventory_addItemByItemType: `Необработанные данные`,
inventory_addItemByItemType_warning: `Используйте эту функцию на свой страх и риск. Она может повредить ваш инвентарь, и в случае проблем вам придётся удалять предметы вручную.`,
+ inventory_addItemByItemType_productCategory: `Вы также можете указать productCategory, некоторые из них позволят вам изменить количество добавленных преметов.`,
inventory_suits: `Варфреймы`,
inventory_longGuns: `Основное оружие`,
inventory_pistols: `Вторичное оружие`,
@@ -308,6 +309,7 @@ dict = {
worldState_incompatibleWith: `Несовместимо с:`,
enabled: `Включено`,
disabled: `Отключено`,
+ notSpecified: `Не указано`,
worldState_we1: `Выходные 1`,
worldState_we2: `Выходные 2`,
worldState_we3: `Выходные 3`,
diff --git a/static/webui/translations/uk.js b/static/webui/translations/uk.js
index e36a9939..9293746f 100644
--- a/static/webui/translations/uk.js
+++ b/static/webui/translations/uk.js
@@ -98,6 +98,7 @@ dict = {
inventory_addItems: `Додати предмети`,
inventory_addItemByItemType: `Необроблені дані`,
inventory_addItemByItemType_warning: `Використовуйте цю функцію на власний ризик. Вона може пошкодити ваше спорядження, і вам доведеться видаляти предмети вручну, якщо щось піде не так.`,
+ inventory_addItemByItemType_productCategory: `[UNTRANSLATED] You can also specify productCategory, some of which will allow you to change the number of items added.`,
inventory_suits: `Ворфрейми`,
inventory_longGuns: `Основна зброя`,
inventory_pistols: `Допоміжна зброя`,
@@ -308,6 +309,7 @@ dict = {
worldState_incompatibleWith: `Несумісне з:`,
enabled: `Увімкнено`,
disabled: `Вимкнено`,
+ notSpecified: `[UNTRANSLATED] Not specified`,
worldState_we1: `Вихідні 1`,
worldState_we2: `Вихідні 2`,
worldState_we3: `Вихідні 3`,
diff --git a/static/webui/translations/zh.js b/static/webui/translations/zh.js
index e856f8b9..b1d2d4a4 100644
--- a/static/webui/translations/zh.js
+++ b/static/webui/translations/zh.js
@@ -98,6 +98,7 @@ dict = {
inventory_addItems: `添加物品`,
inventory_addItemByItemType: `[UNTRANSLATED] Raw`,
inventory_addItemByItemType_warning: `[UNTRANSLATED] Use this feature at your own risk. It may break your inventory, and you will need to remove items manually if something goes wrong.`,
+ inventory_addItemByItemType_productCategory: `[UNTRANSLATED] You can also specify productCategory, some of which will allow you to change the number of items added.`,
inventory_suits: `战甲`,
inventory_longGuns: `主要武器`,
inventory_pistols: `次要武器`,
@@ -308,6 +309,7 @@ dict = {
worldState_incompatibleWith: `不兼容的活动:`,
enabled: `启用`,
disabled: `关闭/取消配置`,
+ notSpecified: `[UNTRANSLATED] Not specified`,
worldState_we1: `活动阶段:第一周`,
worldState_we2: `活动阶段:第二周`,
worldState_we3: `活动阶段:第三周`,