From 1fe8351dca08ef3cf20e25db23ac4e63c71af394 Mon Sep 17 00:00:00 2001 From: Sainan Date: Wed, 19 Jun 2024 17:46:12 +0200 Subject: [PATCH 1/9] feat: handle purchasing of archwing, archgun, & archmelee (#326) --- src/models/inventoryModels/inventoryModel.ts | 53 ++++++----- src/services/inventoryService.ts | 99 +++++++++++--------- src/types/inventoryTypes/inventoryTypes.ts | 1 + 3 files changed, 88 insertions(+), 65 deletions(-) diff --git a/src/models/inventoryModels/inventoryModel.ts b/src/models/inventoryModels/inventoryModel.ts index 90c4c844..2dc26ef8 100644 --- a/src/models/inventoryModels/inventoryModel.ts +++ b/src/models/inventoryModels/inventoryModel.ts @@ -197,29 +197,32 @@ ArchonCrystalUpgradeSchema.set("toJSON", { } }); -const EquipmentSchema = new Schema({ - ItemType: String, - Configs: [ItemConfigSchema], - UpgradeVer: Number, - XP: Number, - Features: Number, - Polarized: Number, - Polarity: [polaritySchema], - FocusLens: String, - ModSlotPurchases: Number, - CustomizationSlotPurchases: Number, - UpgradeType: String, - UpgradeFingerprint: String, - ItemName: String, - InfestationDate: Date, - InfestationDays: Number, - InfestationType: String, - ModularParts: [String], - UnlockLevel: Number, - Expiry: Date, - SkillTree: String, - ArchonCrystalUpgrades: { type: [ArchonCrystalUpgradeSchema], default: undefined } -}); +const EquipmentSchema = new Schema( + { + ItemType: String, + Configs: [ItemConfigSchema], + UpgradeVer: Number, + XP: Number, + Features: Number, + Polarized: Number, + Polarity: [polaritySchema], + FocusLens: String, + ModSlotPurchases: Number, + CustomizationSlotPurchases: Number, + UpgradeType: String, + UpgradeFingerprint: String, + ItemName: String, + InfestationDate: Date, + InfestationDays: Number, + InfestationType: String, + ModularParts: { type: [String], default: undefined }, + UnlockLevel: Number, + Expiry: Date, + SkillTree: String, + ArchonCrystalUpgrades: { type: [ArchonCrystalUpgradeSchema], default: undefined } + }, + { id: false } +); EquipmentSchema.virtual("ItemId").get(function () { return { $oid: this._id.toString() } satisfies IOid; @@ -955,6 +958,10 @@ type InventoryDocumentProps = { Sentinels: Types.DocumentArray; Horses: Types.DocumentArray; PendingRecipes: Types.DocumentArray; + SpaceSuits: Types.DocumentArray; + SpaceGuns: Types.DocumentArray; + SpaceMelee: Types.DocumentArray; + SentinelWeapons: Types.DocumentArray; }; // eslint-disable-next-line @typescript-eslint/ban-types diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index c7861130..36bda69e 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -92,33 +92,51 @@ export const addItem = async ( // Path-based duck typing switch (typeName.substr(1).split("/")[1]) { case "Powersuits": - if (typeName.includes("EntratiMech")) { - const mechSuit = await addMechSuit(typeName, accountId); - await updateSlots(accountId, InventorySlot.MECHSUITS, 0, 1); - logger.debug("mech suit", mechSuit); - return { - InventoryChanges: { - MechBin: { - count: 1, - platinum: 0, - Slots: -1 - }, - MechSuits: [mechSuit] - } - }; - } - const suit = await addPowerSuit(typeName, accountId); - await updateSlots(accountId, InventorySlot.SUITS, 0, 1); - return { - InventoryChanges: { - SuitBin: { - count: 1, - platinum: 0, - Slots: -1 - }, - Suits: [suit] + switch (typeName.substr(1).split("/")[2]) { + default: { + const suit = await addPowerSuit(typeName, accountId); + await updateSlots(accountId, InventorySlot.SUITS, 0, 1); + return { + InventoryChanges: { + SuitBin: { + count: 1, + platinum: 0, + Slots: -1 + }, + Suits: [suit] + } + }; } - }; + case "Archwing": { + const spaceSuit = await addSpaceSuit(typeName, accountId); + await updateSlots(accountId, InventorySlot.SPACESUITS, 0, 1); + return { + InventoryChanges: { + SpaceSuitBin: { + count: 1, + platinum: 0, + Slots: -1 + }, + SpaceSuits: [spaceSuit] + } + }; + } + case "EntratiMech": { + const mechSuit = await addMechSuit(typeName, accountId); + await updateSlots(accountId, InventorySlot.MECHSUITS, 0, 1); + return { + InventoryChanges: { + MechBin: { + count: 1, + platinum: 0, + Slots: -1 + }, + MechSuits: [mechSuit] + } + }; + } + } + break; case "Weapons": const weaponType = getWeaponType(typeName); const weapon = await addWeapon(weaponType, typeName, accountId); @@ -277,6 +295,13 @@ export const addSpecialItem = async (itemName: string, accountId: string) => { return changedInventory.SpecialItems[specialItemIndex - 1].toJSON(); }; +export const addSpaceSuit = async (spacesuitName: string, accountId: string) => { + const inventory = await getInventory(accountId); + const suitIndex = inventory.SpaceSuits.push({ ItemType: spacesuitName, Configs: [], UpgradeVer: 101, XP: 0 }); + const changedInventory = await inventory.save(); + return changedInventory.SpaceSuits[suitIndex - 1].toJSON(); +}; + export const updateSlots = async (accountId: string, slotName: SlotNames, slotAmount: number, extraAmount: number) => { const inventory = await getInventory(accountId); @@ -391,22 +416,12 @@ export const addWeapon = async ( ): Promise => { const inventory = await getInventory(accountId); - let weaponIndex; - switch (weaponType) { - case "LongGuns": - case "Pistols": - case "Melee": - case "OperatorAmps": - weaponIndex = inventory[weaponType].push({ - ItemType: weaponName, - Configs: [], - XP: 0, - ModularParts: modularParts - }); - break; - default: - throw new Error("unknown weapon type: " + weaponType); - } + const weaponIndex = inventory[weaponType].push({ + ItemType: weaponName, + Configs: [], + XP: 0, + ModularParts: modularParts + }); const changedInventory = await inventory.save(); return changedInventory[weaponType][weaponIndex - 1].toJSON(); diff --git a/src/types/inventoryTypes/inventoryTypes.ts b/src/types/inventoryTypes/inventoryTypes.ts index a8f30308..28423edb 100644 --- a/src/types/inventoryTypes/inventoryTypes.ts +++ b/src/types/inventoryTypes/inventoryTypes.ts @@ -358,6 +358,7 @@ export interface ICombat { export enum InventorySlot { SUITS = "SuitBin", WEAPONS = "WeaponBin", + SPACESUITS = "SpaceSuitBin", MECHSUITS = "MechBin", PVE_LOADOUTS = "PveBonusLoadoutBin", SENTINELS = "SentinelBin" From 2f9ac5dc7b619c3593892f0ff3c4e7c8f11b0add Mon Sep 17 00:00:00 2001 From: Sainan Date: Thu, 20 Jun 2024 11:45:45 +0200 Subject: [PATCH 2/9] chore: update typescript plugins for eslint (#335) --- package-lock.json | 467 +++++------------- package.json | 4 +- src/services/missionInventoryUpdateService.ts | 2 +- 3 files changed, 118 insertions(+), 355 deletions(-) diff --git a/package-lock.json b/package-lock.json index e12a07ef..0725994e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,8 +22,8 @@ "@tsconfig/node20": "^1.0.0", "@types/express": "^4.17.20", "@types/morgan": "^1.9.7", - "@typescript-eslint/eslint-plugin": "^6.9.0", - "@typescript-eslint/parser": "^6.2.0", + "@typescript-eslint/eslint-plugin": "^7.13.1", + "@typescript-eslint/parser": "^7.13.1", "eslint": "^8.56.0", "eslint-plugin-prettier": "^5.1.3", "morgan": "^1.10.0", @@ -364,12 +364,6 @@ "@types/send": "*" } }, - "node_modules/@types/json-schema": { - "version": "7.0.14", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.14.tgz", - "integrity": "sha512-U3PUjAudAdJBeC2pgN8uTIKgxrb4nlDF3SF0++EldXQvQBGkpFZMSnwQiIoDU77tv45VgNkl/L4ouD+rEomujw==", - "dev": true - }, "node_modules/@types/mime": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz", @@ -403,12 +397,6 @@ "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==", "dev": true }, - "node_modules/@types/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-MMzuxN3GdFwskAnb6fz0orFvhfqi752yjaXylr0Rp4oDg5H0Zn1IuyRhDVvYOwAXoJirx2xuS16I3WjxnAIHiQ==", - "dev": true - }, "node_modules/@types/send": { "version": "0.17.1", "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.1.tgz", @@ -460,33 +448,31 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.9.0.tgz", - "integrity": "sha512-lgX7F0azQwRPB7t7WAyeHWVfW1YJ9NIgd9mvGhfQpRY56X6AVf8mwM8Wol+0z4liE7XX3QOt8MN1rUKCfSjRIA==", + "version": "7.13.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.13.1.tgz", + "integrity": "sha512-kZqi+WZQaZfPKnsflLJQCz6Ze9FFSMfXrrIOcyargekQxG37ES7DJNpJUE9Q/X5n3yTIP/WPutVNzgknQ7biLg==", "dev": true, "dependencies": { - "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "6.9.0", - "@typescript-eslint/type-utils": "6.9.0", - "@typescript-eslint/utils": "6.9.0", - "@typescript-eslint/visitor-keys": "6.9.0", - "debug": "^4.3.4", + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "7.13.1", + "@typescript-eslint/type-utils": "7.13.1", + "@typescript-eslint/utils": "7.13.1", + "@typescript-eslint/visitor-keys": "7.13.1", "graphemer": "^1.4.0", - "ignore": "^5.2.4", + "ignore": "^5.3.1", "natural-compare": "^1.4.0", - "semver": "^7.5.4", - "ts-api-utils": "^1.0.1" + "ts-api-utils": "^1.3.0" }, "engines": { - "node": "^16.0.0 || >=18.0.0" + "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^6.0.0 || ^6.0.0-alpha", - "eslint": "^7.0.0 || ^8.0.0" + "@typescript-eslint/parser": "^7.0.0", + "eslint": "^8.56.0" }, "peerDependenciesMeta": { "typescript": { @@ -494,97 +480,27 @@ } } }, - "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/scope-manager": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.0.tgz", - "integrity": "sha512-1R8A9Mc39n4pCCz9o79qRO31HGNDvC7UhPhv26TovDsWPBDx+Sg3rOZdCELIA3ZmNoWAuxaMOT7aWtGRSYkQxw==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/visitor-keys": "6.9.0" - }, - "engines": { - "node": "^16.0.0 || >=18.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/types": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.0.tgz", - "integrity": "sha512-+KB0lbkpxBkBSiVCuQvduqMJy+I1FyDbdwSpM3IoBS7APl4Bu15lStPjgBIdykdRqQNYqYNMa8Kuidax6phaEw==", - "dev": true, - "engines": { - "node": "^16.0.0 || >=18.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/visitor-keys": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.0.tgz", - "integrity": "sha512-dGtAfqjV6RFOtIP8I0B4ZTBRrlTT8NHHlZZSchQx3qReaoDeXhYM++M4So2AgFK9ZB0emRPA6JI1HkafzA2Ibg==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "6.9.0", - "eslint-visitor-keys": "^3.4.1" - }, - "engines": { - "node": "^16.0.0 || >=18.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/eslint-plugin/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/eslint-plugin/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, "node_modules/@typescript-eslint/parser": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.2.0.tgz", - "integrity": "sha512-igVYOqtiK/UsvKAmmloQAruAdUHihsOCvplJpplPZ+3h4aDkC/UKZZNKgB6h93ayuYLuEymU3h8nF1xMRbh37g==", + "version": "7.13.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.13.1.tgz", + "integrity": "sha512-1ELDPlnLvDQ5ybTSrMhRTFDfOQEOXNM+eP+3HT/Yq7ruWpciQw+Avi73pdEbA4SooCawEWo3dtYbF68gN7Ed1A==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "6.2.0", - "@typescript-eslint/types": "6.2.0", - "@typescript-eslint/typescript-estree": "6.2.0", - "@typescript-eslint/visitor-keys": "6.2.0", + "@typescript-eslint/scope-manager": "7.13.1", + "@typescript-eslint/types": "7.13.1", + "@typescript-eslint/typescript-estree": "7.13.1", + "@typescript-eslint/visitor-keys": "7.13.1", "debug": "^4.3.4" }, "engines": { - "node": "^16.0.0 || >=18.0.0" + "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "^7.0.0 || ^8.0.0" + "eslint": "^8.56.0" }, "peerDependenciesMeta": { "typescript": { @@ -593,9 +509,9 @@ } }, "node_modules/@typescript-eslint/parser/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", + "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", "dev": true, "dependencies": { "ms": "2.1.2" @@ -616,16 +532,16 @@ "dev": true }, "node_modules/@typescript-eslint/scope-manager": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.2.0.tgz", - "integrity": "sha512-1ZMNVgm5nnHURU8ZSJ3snsHzpFeNK84rdZjluEVBGNu7jDymfqceB3kdIZ6A4xCfEFFhRIB6rF8q/JIqJd2R0Q==", + "version": "7.13.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.13.1.tgz", + "integrity": "sha512-adbXNVEs6GmbzaCpymHQ0MB6E4TqoiVbC0iqG3uijR8ZYfpAXMGttouQzF4Oat3P2GxDVIrg7bMI/P65LiQZdg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.2.0", - "@typescript-eslint/visitor-keys": "6.2.0" + "@typescript-eslint/types": "7.13.1", + "@typescript-eslint/visitor-keys": "7.13.1" }, "engines": { - "node": "^16.0.0 || >=18.0.0" + "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", @@ -633,25 +549,25 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.9.0.tgz", - "integrity": "sha512-XXeahmfbpuhVbhSOROIzJ+b13krFmgtc4GlEuu1WBT+RpyGPIA4Y/eGnXzjbDj5gZLzpAXO/sj+IF/x2GtTMjQ==", + "version": "7.13.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.13.1.tgz", + "integrity": "sha512-aWDbLu1s9bmgPGXSzNCxELu+0+HQOapV/y+60gPXafR8e2g1Bifxzevaa+4L2ytCWm+CHqpELq4CSoN9ELiwCg==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "6.9.0", - "@typescript-eslint/utils": "6.9.0", + "@typescript-eslint/typescript-estree": "7.13.1", + "@typescript-eslint/utils": "7.13.1", "debug": "^4.3.4", - "ts-api-utils": "^1.0.1" + "ts-api-utils": "^1.3.0" }, "engines": { - "node": "^16.0.0 || >=18.0.0" + "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "^7.0.0 || ^8.0.0" + "eslint": "^8.56.0" }, "peerDependenciesMeta": { "typescript": { @@ -659,67 +575,10 @@ } } }, - "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/types": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.0.tgz", - "integrity": "sha512-+KB0lbkpxBkBSiVCuQvduqMJy+I1FyDbdwSpM3IoBS7APl4Bu15lStPjgBIdykdRqQNYqYNMa8Kuidax6phaEw==", - "dev": true, - "engines": { - "node": "^16.0.0 || >=18.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/typescript-estree": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.0.tgz", - "integrity": "sha512-NJM2BnJFZBEAbCfBP00zONKXvMqihZCrmwCaik0UhLr0vAgb6oguXxLX1k00oQyD+vZZ+CJn3kocvv2yxm4awQ==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/visitor-keys": "6.9.0", - "debug": "^4.3.4", - "globby": "^11.1.0", - "is-glob": "^4.0.3", - "semver": "^7.5.4", - "ts-api-utils": "^1.0.1" - }, - "engines": { - "node": "^16.0.0 || >=18.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/visitor-keys": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.0.tgz", - "integrity": "sha512-dGtAfqjV6RFOtIP8I0B4ZTBRrlTT8NHHlZZSchQx3qReaoDeXhYM++M4So2AgFK9ZB0emRPA6JI1HkafzA2Ibg==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "6.9.0", - "eslint-visitor-keys": "^3.4.1" - }, - "engines": { - "node": "^16.0.0 || >=18.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, "node_modules/@typescript-eslint/type-utils/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", + "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", "dev": true, "dependencies": { "ms": "2.1.2" @@ -740,12 +599,12 @@ "dev": true }, "node_modules/@typescript-eslint/types": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.2.0.tgz", - "integrity": "sha512-1nRRaDlp/XYJQLvkQJG5F3uBTno5SHPT7XVcJ5n1/k2WfNI28nJsvLakxwZRNY5spuatEKO7d5nZWsQpkqXwBA==", + "version": "7.13.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.13.1.tgz", + "integrity": "sha512-7K7HMcSQIAND6RBL4kDl24sG/xKM13cA85dc7JnmQXw2cBDngg7c19B++JzvJHRG3zG36n9j1i451GBzRuHchw==", "dev": true, "engines": { - "node": "^16.0.0 || >=18.0.0" + "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", @@ -753,21 +612,22 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.2.0.tgz", - "integrity": "sha512-Mts6+3HQMSM+LZCglsc2yMIny37IhUgp1Qe8yJUYVyO6rHP7/vN0vajKu3JvHCBIy8TSiKddJ/Zwu80jhnGj1w==", + "version": "7.13.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.13.1.tgz", + "integrity": "sha512-uxNr51CMV7npU1BxZzYjoVz9iyjckBduFBP0S5sLlh1tXYzHzgZ3BR9SVsNed+LmwKrmnqN3Kdl5t7eZ5TS1Yw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.2.0", - "@typescript-eslint/visitor-keys": "6.2.0", + "@typescript-eslint/types": "7.13.1", + "@typescript-eslint/visitor-keys": "7.13.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", - "semver": "^7.5.4", - "ts-api-utils": "^1.0.1" + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" }, "engines": { - "node": "^16.0.0 || >=18.0.0" + "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", @@ -779,10 +639,19 @@ } } }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, "node_modules/@typescript-eslint/typescript-estree/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", + "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", "dev": true, "dependencies": { "ms": "2.1.2" @@ -796,6 +665,21 @@ } } }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { + "version": "9.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", + "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@typescript-eslint/typescript-estree/node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -803,138 +687,38 @@ "dev": true }, "node_modules/@typescript-eslint/utils": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.9.0.tgz", - "integrity": "sha512-5Wf+Jsqya7WcCO8me504FBigeQKVLAMPmUzYgDbWchINNh1KJbxCgVya3EQ2MjvJMVeXl3pofRmprqX6mfQkjQ==", + "version": "7.13.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.13.1.tgz", + "integrity": "sha512-h5MzFBD5a/Gh/fvNdp9pTfqJAbuQC4sCN2WzuXme71lqFJsZtLbjxfSk4r3p02WIArOF9N94pdsLiGutpDbrXQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@types/json-schema": "^7.0.12", - "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.9.0", - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/typescript-estree": "6.9.0", - "semver": "^7.5.4" + "@typescript-eslint/scope-manager": "7.13.1", + "@typescript-eslint/types": "7.13.1", + "@typescript-eslint/typescript-estree": "7.13.1" }, "engines": { - "node": "^16.0.0 || >=18.0.0" + "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "^7.0.0 || ^8.0.0" + "eslint": "^8.56.0" } }, - "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/scope-manager": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.0.tgz", - "integrity": "sha512-1R8A9Mc39n4pCCz9o79qRO31HGNDvC7UhPhv26TovDsWPBDx+Sg3rOZdCELIA3ZmNoWAuxaMOT7aWtGRSYkQxw==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/visitor-keys": "6.9.0" - }, - "engines": { - "node": "^16.0.0 || >=18.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/types": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.0.tgz", - "integrity": "sha512-+KB0lbkpxBkBSiVCuQvduqMJy+I1FyDbdwSpM3IoBS7APl4Bu15lStPjgBIdykdRqQNYqYNMa8Kuidax6phaEw==", - "dev": true, - "engines": { - "node": "^16.0.0 || >=18.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/typescript-estree": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.0.tgz", - "integrity": "sha512-NJM2BnJFZBEAbCfBP00zONKXvMqihZCrmwCaik0UhLr0vAgb6oguXxLX1k00oQyD+vZZ+CJn3kocvv2yxm4awQ==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/visitor-keys": "6.9.0", - "debug": "^4.3.4", - "globby": "^11.1.0", - "is-glob": "^4.0.3", - "semver": "^7.5.4", - "ts-api-utils": "^1.0.1" - }, - "engines": { - "node": "^16.0.0 || >=18.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/visitor-keys": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.0.tgz", - "integrity": "sha512-dGtAfqjV6RFOtIP8I0B4ZTBRrlTT8NHHlZZSchQx3qReaoDeXhYM++M4So2AgFK9ZB0emRPA6JI1HkafzA2Ibg==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "6.9.0", - "eslint-visitor-keys": "^3.4.1" - }, - "engines": { - "node": "^16.0.0 || >=18.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/utils/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/utils/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.2.0.tgz", - "integrity": "sha512-QbaYUQVKKo9bgCzpjz45llCfwakyoxHetIy8CAvYCtd16Zu1KrpzNHofwF8kGkpPOxZB2o6kz+0nqH8ZkIzuoQ==", + "version": "7.13.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.13.1.tgz", + "integrity": "sha512-k/Bfne7lrP7hcb7m9zSsgcBmo+8eicqqfNAJ7uUY+jkTFpKeH2FSkWpFRtimBxgkyvqfu9jTPRbYOvud6isdXA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.2.0", - "eslint-visitor-keys": "^3.4.1" + "@typescript-eslint/types": "7.13.1", + "eslint-visitor-keys": "^3.4.3" }, "engines": { - "node": "^16.0.0 || >=18.0.0" + "node": "^18.18.0 || >=20.0.0" }, "funding": { "type": "opencollective", @@ -1848,9 +1632,9 @@ "dev": true }, "node_modules/fast-glob": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", - "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", "dev": true, "dependencies": { "@nodelib/fs.stat": "^2.0.2", @@ -2245,9 +2029,9 @@ } }, "node_modules/ignore": { - "version": "5.2.4", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", - "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", + "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", "dev": true, "engines": { "node": ">= 4" @@ -2496,18 +2280,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, - "node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/make-error": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", @@ -2550,12 +2322,12 @@ } }, "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", + "integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==", "dev": true, "dependencies": { - "braces": "^3.0.2", + "braces": "^3.0.3", "picomatch": "^2.3.1" }, "engines": { @@ -3261,13 +3033,10 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", + "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==", "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, "bin": { "semver": "bin/semver.js" }, @@ -3658,12 +3427,12 @@ } }, "node_modules/ts-api-utils": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.1.tgz", - "integrity": "sha512-lC/RGlPmwdrIBFTX59wwNzqh7aR2otPNPR/5brHZm/XKFYKsfqxihXUe9pU3JI+3vGkl+vyCoNNnPhJn3aLK1A==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", + "integrity": "sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==", "dev": true, "engines": { - "node": ">=16.13.0" + "node": ">=16" }, "peerDependencies": { "typescript": ">=4.2.0" @@ -4061,12 +3830,6 @@ "node": ">=10" } }, - "node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true - }, "node_modules/yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", diff --git a/package.json b/package.json index 473d3cdc..0acdfc73 100644 --- a/package.json +++ b/package.json @@ -26,8 +26,8 @@ "@tsconfig/node20": "^1.0.0", "@types/express": "^4.17.20", "@types/morgan": "^1.9.7", - "@typescript-eslint/eslint-plugin": "^6.9.0", - "@typescript-eslint/parser": "^6.2.0", + "@typescript-eslint/eslint-plugin": "^7.13.1", + "@typescript-eslint/parser": "^7.13.1", "eslint": "^8.56.0", "eslint-plugin-prettier": "^5.1.3", "morgan": "^1.10.0", diff --git a/src/services/missionInventoryUpdateService.ts b/src/services/missionInventoryUpdateService.ts index 5936adbe..aadcd4ae 100644 --- a/src/services/missionInventoryUpdateService.ts +++ b/src/services/missionInventoryUpdateService.ts @@ -174,7 +174,7 @@ const itemCheck = ( }; for (const key of Object.keys(rewardCheck) as IInventoryFieldType[]) { if (rewardCheck[key]) { - addRewardResponse(InventoryChanges, MissionRewards, name, rewardCheck[key]!, key); + addRewardResponse(InventoryChanges, MissionRewards, name, rewardCheck[key], key); return true; } } From f9414dcf84fb392a5bc279644cbfa48c4a165229 Mon Sep 17 00:00:00 2001 From: Sainan Date: Thu, 20 Jun 2024 11:46:08 +0200 Subject: [PATCH 3/9] fix: switching to drifter doesn't save (#334) --- src/services/saveLoadoutService.ts | 4 ++++ src/types/inventoryTypes/inventoryTypes.ts | 2 +- src/types/saveLoadoutTypes.ts | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/services/saveLoadoutService.ts b/src/services/saveLoadoutService.ts index 502a0e63..9ff6e523 100644 --- a/src/services/saveLoadoutService.ts +++ b/src/services/saveLoadoutService.ts @@ -171,6 +171,10 @@ export const handleInventoryItemConfigChange = async ( inventory.EquippedGear = equipment as string[]; break; } + case "UseAdultOperatorLoadout": { + inventory.UseAdultOperatorLoadout = equipment as boolean; + break; + } default: { logger.error(`category not implemented: ${equipmentName}`, { config: equipment }); } diff --git a/src/types/inventoryTypes/inventoryTypes.ts b/src/types/inventoryTypes/inventoryTypes.ts index 28423edb..d538a7a2 100644 --- a/src/types/inventoryTypes/inventoryTypes.ts +++ b/src/types/inventoryTypes/inventoryTypes.ts @@ -239,7 +239,7 @@ export interface IInventoryResponse { CrewMembers: ICrewMember[]; AdultOperatorLoadOuts: IOperatorConfigClient[]; LotusCustomization: ILotusCustomization; - UseAdultOperatorLoadout: boolean; + UseAdultOperatorLoadout?: boolean; DailyAffiliationZariman: number; NemesisAbandonedRewards: string[]; DailyAffiliationKahl: number; diff --git a/src/types/saveLoadoutTypes.ts b/src/types/saveLoadoutTypes.ts index 4f434eef..9121aadf 100644 --- a/src/types/saveLoadoutTypes.ts +++ b/src/types/saveLoadoutTypes.ts @@ -33,6 +33,7 @@ export interface ISaveLoadoutRequest { CurrentLoadOutIds: IOid[]; ValidNewLoadoutId: string; EquippedGear: string[]; + UseAdultOperatorLoadout: boolean; } export interface ISaveLoadoutRequestNoUpgradeVer extends Omit {} From 722a9aba5b8d0e1b5fa89fba549d19c8f28ae791 Mon Sep 17 00:00:00 2001 From: Sainan Date: Thu, 20 Jun 2024 11:47:21 +0200 Subject: [PATCH 4/9] improve: suppress no-misued-promises when declaring RequestHandler (#332) --- src/controllers/api/addFriendImageController.ts | 1 + src/controllers/api/createGuildController.ts | 1 + src/controllers/api/focusController.ts | 1 + src/controllers/api/getGuildController.ts | 1 + src/controllers/api/getGuildDojoController.ts | 1 + src/controllers/api/hostSessionController.ts | 1 + src/controllers/api/infestedFoundryController.ts | 1 + src/controllers/api/inventoryController.ts | 6 +++--- src/controllers/api/logoutController.ts | 1 + src/controllers/api/modularWeaponCraftingController.ts | 1 + src/controllers/api/nameWeaponController.ts | 1 + src/controllers/api/purchaseController.ts | 5 +++-- src/controllers/api/sellController.ts | 1 + src/controllers/api/setBootLocationController.ts | 1 + src/controllers/api/setSupportedSyndicateController.ts | 1 + src/controllers/api/startDojoRecipeController.ts | 1 + src/controllers/api/stepSequencersController.ts | 1 + src/controllers/api/syndicateSacrificeController.ts | 1 + src/controllers/api/updateChallengeProgressController.ts | 1 + src/controllers/api/upgradesController.ts | 1 + src/controllers/custom/updateConfigDataController.ts | 1 + src/controllers/stats/viewController.ts | 1 + src/routes/cache.ts | 1 + 23 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/controllers/api/addFriendImageController.ts b/src/controllers/api/addFriendImageController.ts index 979bb9fb..6c9a2370 100644 --- a/src/controllers/api/addFriendImageController.ts +++ b/src/controllers/api/addFriendImageController.ts @@ -4,6 +4,7 @@ import { IUpdateGlyphRequest } from "@/src/types/requestTypes"; import { getAccountIdForRequest } from "@/src/services/loginService"; import { getInventory } from "@/src/services/inventoryService"; +// eslint-disable-next-line @typescript-eslint/no-misused-promises const addFriendImageController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); const json = getJSONfromString(req.body.toString()) as IUpdateGlyphRequest; diff --git a/src/controllers/api/createGuildController.ts b/src/controllers/api/createGuildController.ts index f0f56f1b..9499e308 100644 --- a/src/controllers/api/createGuildController.ts +++ b/src/controllers/api/createGuildController.ts @@ -5,6 +5,7 @@ import { Inventory } from "@/src/models/inventoryModels/inventoryModel"; import { Guild } from "@/src/models/guildModel"; import { ICreateGuildRequest } from "@/src/types/guildTypes"; +// eslint-disable-next-line @typescript-eslint/no-misused-promises const createGuildController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); const payload: ICreateGuildRequest = getJSONfromString(req.body.toString()); diff --git a/src/controllers/api/focusController.ts b/src/controllers/api/focusController.ts index b2ac53f6..e13b6057 100644 --- a/src/controllers/api/focusController.ts +++ b/src/controllers/api/focusController.ts @@ -5,6 +5,7 @@ import { IMiscItem, TFocusPolarity } from "@/src/types/inventoryTypes/inventoryT import { logger } from "@/src/utils/logger"; import baseFocusPointCosts from "@/static/json/baseFocusPointCosts.json"; +// eslint-disable-next-line @typescript-eslint/no-misused-promises export const focusController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); switch (req.query.op) { diff --git a/src/controllers/api/getGuildController.ts b/src/controllers/api/getGuildController.ts index d112f996..076e5934 100644 --- a/src/controllers/api/getGuildController.ts +++ b/src/controllers/api/getGuildController.ts @@ -4,6 +4,7 @@ import { Guild } from "@/src/models/guildModel"; import { getAccountIdForRequest } from "@/src/services/loginService"; import { toOid } from "@/src/helpers/inventoryHelpers"; +// eslint-disable-next-line @typescript-eslint/no-misused-promises const getGuildController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); const inventory = await Inventory.findOne({ accountOwnerId: accountId }); diff --git a/src/controllers/api/getGuildDojoController.ts b/src/controllers/api/getGuildDojoController.ts index a220bb7e..af60b492 100644 --- a/src/controllers/api/getGuildDojoController.ts +++ b/src/controllers/api/getGuildDojoController.ts @@ -4,6 +4,7 @@ import { Guild } from "@/src/models/guildModel"; import { IDojoClient, IDojoComponentClient } from "@/src/types/guildTypes"; import { toOid, toMongoDate } from "@/src/helpers/inventoryHelpers"; +// eslint-disable-next-line @typescript-eslint/no-misused-promises export const getGuildDojoController: RequestHandler = async (req, res) => { const guildId = req.query.guildId as string; diff --git a/src/controllers/api/hostSessionController.ts b/src/controllers/api/hostSessionController.ts index 1745d994..94ca633a 100644 --- a/src/controllers/api/hostSessionController.ts +++ b/src/controllers/api/hostSessionController.ts @@ -4,6 +4,7 @@ import { createNewSession } from "@/src/managers/sessionManager"; import { logger } from "@/src/utils/logger"; import { ISession } from "@/src/types/session"; +// eslint-disable-next-line @typescript-eslint/no-misused-promises const hostSessionController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); const hostSessionRequest = JSON.parse(req.body as string) as ISession; diff --git a/src/controllers/api/infestedFoundryController.ts b/src/controllers/api/infestedFoundryController.ts index 26b98803..85c50921 100644 --- a/src/controllers/api/infestedFoundryController.ts +++ b/src/controllers/api/infestedFoundryController.ts @@ -4,6 +4,7 @@ import { getJSONfromString } from "@/src/helpers/stringHelpers"; import { getInventory, addMiscItems } from "@/src/services/inventoryService"; import { IOid } from "@/src/types/commonTypes"; +// eslint-disable-next-line @typescript-eslint/no-misused-promises export const infestedFoundryController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); const payload = getJSONfromString(req.body.toString()); diff --git a/src/controllers/api/inventoryController.ts b/src/controllers/api/inventoryController.ts index b2738bf8..03383df8 100644 --- a/src/controllers/api/inventoryController.ts +++ b/src/controllers/api/inventoryController.ts @@ -1,15 +1,15 @@ -/* eslint-disable @typescript-eslint/no-misused-promises */ +import { RequestHandler } from "express"; import { getAccountIdForRequest } from "@/src/services/loginService"; import { toInventoryResponse } from "@/src/helpers/inventoryHelpers"; import { Inventory } from "@/src/models/inventoryModels/inventoryModel"; -import { Request, RequestHandler, Response } from "express"; import { config } from "@/src/services/configService"; import allMissions from "@/static/fixed_responses/allMissions.json"; import { ILoadoutDatabase } from "@/src/types/saveLoadoutTypes"; import { IShipInventory } from "@/src/types/inventoryTypes/inventoryTypes"; import { ExportCustoms, ExportFlavour, ExportKeys, ExportResources } from "warframe-public-export-plus"; -const inventoryController: RequestHandler = async (request: Request, response: Response) => { +// eslint-disable-next-line @typescript-eslint/no-misused-promises +const inventoryController: RequestHandler = async (request, response) => { let accountId; try { accountId = await getAccountIdForRequest(request); diff --git a/src/controllers/api/logoutController.ts b/src/controllers/api/logoutController.ts index 735014d4..a6faa008 100644 --- a/src/controllers/api/logoutController.ts +++ b/src/controllers/api/logoutController.ts @@ -2,6 +2,7 @@ import { RequestHandler } from "express"; import { getAccountIdForRequest } from "@/src/services/loginService"; import { Account } from "@/src/models/loginModel"; +// eslint-disable-next-line @typescript-eslint/no-misused-promises const logoutController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); const account = await Account.findOne({ _id: accountId }); diff --git a/src/controllers/api/modularWeaponCraftingController.ts b/src/controllers/api/modularWeaponCraftingController.ts index c1cd7bc8..09244764 100644 --- a/src/controllers/api/modularWeaponCraftingController.ts +++ b/src/controllers/api/modularWeaponCraftingController.ts @@ -18,6 +18,7 @@ interface IModularCraftRequest { Parts: string[]; } +// eslint-disable-next-line @typescript-eslint/no-misused-promises export const modularWeaponCraftingController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); const data: IModularCraftRequest = getJSONfromString(req.body.toString()); diff --git a/src/controllers/api/nameWeaponController.ts b/src/controllers/api/nameWeaponController.ts index 7543cbc4..c32f0fe8 100644 --- a/src/controllers/api/nameWeaponController.ts +++ b/src/controllers/api/nameWeaponController.ts @@ -8,6 +8,7 @@ interface INameWeaponRequest { ItemName: string; } +// eslint-disable-next-line @typescript-eslint/no-misused-promises export const nameWeaponController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); const inventory = await getInventory(accountId); diff --git a/src/controllers/api/purchaseController.ts b/src/controllers/api/purchaseController.ts index cf32a95d..9e8bcb45 100644 --- a/src/controllers/api/purchaseController.ts +++ b/src/controllers/api/purchaseController.ts @@ -1,9 +1,10 @@ +import { RequestHandler } from "express"; import { getAccountIdForRequest } from "@/src/services/loginService"; import { toPurchaseRequest } from "@/src/helpers/purchaseHelpers"; import { handlePurchase } from "@/src/services/purchaseService"; -import { Request, Response } from "express"; -export const purchaseController = async (req: Request, res: Response) => { +// eslint-disable-next-line @typescript-eslint/no-misused-promises +export const purchaseController: RequestHandler = async (req, res) => { const purchaseRequest = toPurchaseRequest(JSON.parse(String(req.body))); const accountId = await getAccountIdForRequest(req); const response = await handlePurchase(purchaseRequest, accountId); diff --git a/src/controllers/api/sellController.ts b/src/controllers/api/sellController.ts index a2a36228..f242ccba 100644 --- a/src/controllers/api/sellController.ts +++ b/src/controllers/api/sellController.ts @@ -3,6 +3,7 @@ import { ISellRequest } from "@/src/types/sellTypes"; import { getAccountIdForRequest } from "@/src/services/loginService"; import { getInventory, addMods, addRecipes } from "@/src/services/inventoryService"; +// eslint-disable-next-line @typescript-eslint/no-misused-promises export const sellController: RequestHandler = async (req, res) => { const payload: ISellRequest = JSON.parse(req.body.toString()); const accountId = await getAccountIdForRequest(req); diff --git a/src/controllers/api/setBootLocationController.ts b/src/controllers/api/setBootLocationController.ts index 599044a0..a91f63a1 100644 --- a/src/controllers/api/setBootLocationController.ts +++ b/src/controllers/api/setBootLocationController.ts @@ -3,6 +3,7 @@ import { getAccountIdForRequest } from "@/src/services/loginService"; import { getPersonalRooms } from "@/src/services/personalRoomsService"; import { TBootLocation } from "@/src/types/shipTypes"; +// eslint-disable-next-line @typescript-eslint/no-misused-promises export const setBootLocationController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); const personalRooms = await getPersonalRooms(accountId); diff --git a/src/controllers/api/setSupportedSyndicateController.ts b/src/controllers/api/setSupportedSyndicateController.ts index e22b659f..619fb44c 100644 --- a/src/controllers/api/setSupportedSyndicateController.ts +++ b/src/controllers/api/setSupportedSyndicateController.ts @@ -2,6 +2,7 @@ import { RequestHandler } from "express"; import { getAccountIdForRequest } from "@/src/services/loginService"; import { getInventory } from "@/src/services/inventoryService"; +// eslint-disable-next-line @typescript-eslint/no-misused-promises export const setSupportedSyndicateController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); const inventory = await getInventory(accountId); diff --git a/src/controllers/api/startDojoRecipeController.ts b/src/controllers/api/startDojoRecipeController.ts index 8b4104ac..a278f31c 100644 --- a/src/controllers/api/startDojoRecipeController.ts +++ b/src/controllers/api/startDojoRecipeController.ts @@ -8,6 +8,7 @@ interface IStartDojoRecipeRequest { Revision: number; } +// eslint-disable-next-line @typescript-eslint/no-misused-promises export const startDojoRecipeController: RequestHandler = async (req, res) => { const guild = await getGuildForRequest(req); // At this point, we know that a member of the guild is making this request. Assuming they are allowed to start a build. diff --git a/src/controllers/api/stepSequencersController.ts b/src/controllers/api/stepSequencersController.ts index 45ea01ba..bb963b92 100644 --- a/src/controllers/api/stepSequencersController.ts +++ b/src/controllers/api/stepSequencersController.ts @@ -3,6 +3,7 @@ import { getAccountIdForRequest } from "@/src/services/loginService"; import { getInventory } from "@/src/services/inventoryService"; import { IStepSequencer } from "@/src/types/inventoryTypes/inventoryTypes"; +// eslint-disable-next-line @typescript-eslint/no-misused-promises export const stepSequencersController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); const inventory = await getInventory(accountId); diff --git a/src/controllers/api/syndicateSacrificeController.ts b/src/controllers/api/syndicateSacrificeController.ts index e6ee04b9..d67f68b5 100644 --- a/src/controllers/api/syndicateSacrificeController.ts +++ b/src/controllers/api/syndicateSacrificeController.ts @@ -3,6 +3,7 @@ import { syndicateSacrifice } from "@/src/services/inventoryService"; import { ISyndicateSacrifice } from "@/src/types/syndicateTypes"; import { RequestHandler } from "express"; import { getAccountIdForRequest } from "@/src/services/loginService"; + // eslint-disable-next-line @typescript-eslint/no-misused-promises const syndicateSacrificeController: RequestHandler = async (request, response) => { const accountId = await getAccountIdForRequest(request); diff --git a/src/controllers/api/updateChallengeProgressController.ts b/src/controllers/api/updateChallengeProgressController.ts index e41880e6..bc91f9d3 100644 --- a/src/controllers/api/updateChallengeProgressController.ts +++ b/src/controllers/api/updateChallengeProgressController.ts @@ -4,6 +4,7 @@ import { getAccountIdForRequest } from "@/src/services/loginService"; import { updateChallengeProgress } from "@/src/services/inventoryService"; import { IUpdateChallengeProgressRequest } from "@/src/types/requestTypes"; +// eslint-disable-next-line @typescript-eslint/no-misused-promises const updateChallengeProgressController: RequestHandler = async (req, res) => { const payload: IUpdateChallengeProgressRequest = getJSONfromString(req.body.toString()); const accountId = await getAccountIdForRequest(req); diff --git a/src/controllers/api/upgradesController.ts b/src/controllers/api/upgradesController.ts index 25b548e6..e2f7f052 100644 --- a/src/controllers/api/upgradesController.ts +++ b/src/controllers/api/upgradesController.ts @@ -5,6 +5,7 @@ import { IMiscItem, TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTy import { getAccountIdForRequest } from "@/src/services/loginService"; import { addMiscItems, getInventory, updateCurrency } from "@/src/services/inventoryService"; +// eslint-disable-next-line @typescript-eslint/no-misused-promises export const upgradesController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); const payload = JSON.parse(req.body.toString()) as IUpgradesRequest; diff --git a/src/controllers/custom/updateConfigDataController.ts b/src/controllers/custom/updateConfigDataController.ts index b7521a1a..8a23cd1b 100644 --- a/src/controllers/custom/updateConfigDataController.ts +++ b/src/controllers/custom/updateConfigDataController.ts @@ -1,6 +1,7 @@ import { RequestHandler } from "express"; import { updateConfig } from "@/src/services/configService"; +// eslint-disable-next-line @typescript-eslint/no-misused-promises const updateConfigDataController: RequestHandler = async (req, res) => { await updateConfig(req.body.toString()); res.end(); diff --git a/src/controllers/stats/viewController.ts b/src/controllers/stats/viewController.ts index 03372433..3d6b9e20 100644 --- a/src/controllers/stats/viewController.ts +++ b/src/controllers/stats/viewController.ts @@ -6,6 +6,7 @@ import { config } from "@/src/services/configService"; import view from "@/static/fixed_responses/view.json"; import allScans from "@/static/fixed_responses/allScans.json"; +// eslint-disable-next-line @typescript-eslint/no-misused-promises const viewController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); const inventory = await Inventory.findOne({ accountOwnerId: accountId }); diff --git a/src/routes/cache.ts b/src/routes/cache.ts index adc69b2a..5c1df0d6 100644 --- a/src/routes/cache.ts +++ b/src/routes/cache.ts @@ -16,6 +16,7 @@ cacheRouter.get(/^\/origin\/[a-zA-Z0-9]+\/[0-9]+\/H\.Cache\.bin.*$/, (_req, res) res.sendFile(`static/data/H.Cache_${buildConfig.version}.bin`, { root: "./" }); }); +// eslint-disable-next-line @typescript-eslint/no-misused-promises cacheRouter.get(/\.bk2!/, async (req, res) => { try { const dir = req.path.substr(0, req.path.lastIndexOf("/")); From c9d4712565ba53a43bffb840369775e285e08d8f Mon Sep 17 00:00:00 2001 From: Sainan Date: Thu, 20 Jun 2024 11:48:12 +0200 Subject: [PATCH 5/9] fix: miscellaneous inaccuracies (#330) Co-authored-by: Sainan --- src/models/inventoryModels/inventoryModel.ts | 23 +++++++++++--------- src/types/inventoryTypes/inventoryTypes.ts | 2 +- static/webui/script.js | 5 +---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/models/inventoryModels/inventoryModel.ts b/src/models/inventoryModels/inventoryModel.ts index 2dc26ef8..aed24800 100644 --- a/src/models/inventoryModels/inventoryModel.ts +++ b/src/models/inventoryModels/inventoryModel.ts @@ -161,14 +161,17 @@ const ItemConfigSchema = new Schema( facial: colorSchema, syancol: colorSchema, Upgrades: [String], - Songs: [ - { - m: String, - b: String, - p: String, - s: String - } - ], + Songs: { + type: [ + { + m: String, + b: String, + p: String, + s: String + } + ], + default: undefined + }, Name: String, AbilityOverride: abilityOverrideSchema, PvpUpgrades: [String], @@ -888,7 +891,7 @@ const inventorySchema = new Schema( ChallengesFixVersion: Number, PlayedParkourTutorial: Boolean, SubscribedToEmailsPersonalized: Number, - LastInventorySync: Schema.Types.Mixed, + LastInventorySync: Schema.Types.Mixed, // this should be Schema.Types.ObjectId, but older inventories may break with that. ActiveLandscapeTraps: [Schema.Types.Mixed], RepVotes: [Schema.Types.Mixed], LeagueTickets: [Schema.Types.Mixed], @@ -914,7 +917,7 @@ const inventorySchema = new Schema( //Grustag three DeathSquadable: Boolean }, - { timestamps: { createdAt: "Created", updatedAt: "LastInventorySync" } } + { timestamps: { createdAt: "Created" } } ); inventorySchema.set("toJSON", { diff --git a/src/types/inventoryTypes/inventoryTypes.ts b/src/types/inventoryTypes/inventoryTypes.ts index d538a7a2..1a201888 100644 --- a/src/types/inventoryTypes/inventoryTypes.ts +++ b/src/types/inventoryTypes/inventoryTypes.ts @@ -170,7 +170,7 @@ export interface IInventoryResponse { SpectreLoadouts: ISpectreLoadout[]; SentinelWeapons: IEquipmentDatabase[]; Sentinels: IEquipmentDatabase[]; - EmailItems: ITypeXPItem[]; + EmailItems: ITypeCount[]; CompletedSyndicates: string[]; FocusXP: IFocusXP; Wishlist: string[]; diff --git a/static/webui/script.js b/static/webui/script.js index bc1e8758..0090d427 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -109,10 +109,7 @@ window.itemListPromise = new Promise(resolve => { items.forEach(item => { if (item.uniqueName in data.badItems) { item.name += " (Imposter)"; - } else if ( - item.uniqueName.substr(0, 18) != "/Lotus/Types/Game/" && - item.uniqueName.substr(0, 18) != "/Lotus/StoreItems/" - ) { + } else if (item.uniqueName.substr(0, 18) != "/Lotus/Types/Game/") { const option = document.createElement("option"); option.setAttribute("data-key", item.uniqueName); option.value = item.name; From f0bb281f550d5ba66bbd4fa5abeedbccb072643e Mon Sep 17 00:00:00 2001 From: Sainan Date: Thu, 20 Jun 2024 13:05:07 +0200 Subject: [PATCH 6/9] feat: implement incarnon genesis installation, challenges & skill tree (#333) --- src/controllers/api/evolveWeaponController.ts | 42 +++++++++++++++++++ .../api/setWeaponSkillTreeController.ts | 24 +++++++++++ src/controllers/api/upgradesController.ts | 8 ++-- src/models/inventoryModels/inventoryModel.ts | 14 ++++++- src/routes/api.ts | 4 ++ src/services/inventoryService.ts | 16 +++++++ .../inventoryTypes/commonInventoryTypes.ts | 7 ++++ src/types/inventoryTypes/inventoryTypes.ts | 8 +++- src/types/requestTypes.ts | 2 + 9 files changed, 118 insertions(+), 7 deletions(-) create mode 100644 src/controllers/api/evolveWeaponController.ts create mode 100644 src/controllers/api/setWeaponSkillTreeController.ts diff --git a/src/controllers/api/evolveWeaponController.ts b/src/controllers/api/evolveWeaponController.ts new file mode 100644 index 00000000..fea82844 --- /dev/null +++ b/src/controllers/api/evolveWeaponController.ts @@ -0,0 +1,42 @@ +import { RequestHandler } from "express"; +import { getAccountIdForRequest } from "@/src/services/loginService"; +import { getInventory } from "@/src/services/inventoryService"; +import { getJSONfromString } from "@/src/helpers/stringHelpers"; +import { WeaponTypeInternal } from "@/src/services/itemDataService"; +import { EquipmentFeatures } from "@/src/types/inventoryTypes/commonInventoryTypes"; + +// eslint-disable-next-line @typescript-eslint/no-misused-promises +export const evolveWeaponController: RequestHandler = async (req, res) => { + const accountId = await getAccountIdForRequest(req); + const inventory = await getInventory(accountId); + const payload = getJSONfromString(req.body.toString()) as IEvolveWeaponRequest; + console.assert(payload.Action == "EWA_INSTALL"); + + // TODO: We should remove the Genesis item & its resources, but currently we don't know these "recipes". + + const item = inventory[payload.Category].find(item => item._id.toString() == (req.query.ItemId as string))!; + item.Features ??= 0; + item.Features |= EquipmentFeatures.INCARNON_GENESIS; + + item.SkillTree = "0"; + + inventory.EvolutionProgress ??= []; + if (!inventory.EvolutionProgress.find(entry => entry.ItemType == payload.EvoType)) { + inventory.EvolutionProgress.push({ + Progress: 0, + Rank: 1, + ItemType: payload.EvoType + }); + } + + await inventory.save(); + res.end(); +}; + +interface IEvolveWeaponRequest { + Action: "EWA_INSTALL"; + Category: WeaponTypeInternal; + Recipe: string; // e.g. "/Lotus/Types/Items/MiscItems/IncarnonAdapters/UnlockerBlueprints/DespairIncarnonBlueprint" + UninstallRecipe: ""; + EvoType: string; // e.g. "/Lotus/Weapons/Tenno/ThrowingWeapons/StalkerKunai" +} diff --git a/src/controllers/api/setWeaponSkillTreeController.ts b/src/controllers/api/setWeaponSkillTreeController.ts new file mode 100644 index 00000000..b3b0be6f --- /dev/null +++ b/src/controllers/api/setWeaponSkillTreeController.ts @@ -0,0 +1,24 @@ +import { RequestHandler } from "express"; +import { getAccountIdForRequest } from "@/src/services/loginService"; +import { getInventory } from "@/src/services/inventoryService"; +import { getJSONfromString } from "@/src/helpers/stringHelpers"; +import { WeaponTypeInternal } from "@/src/services/itemDataService"; + +// eslint-disable-next-line @typescript-eslint/no-misused-promises +export const setWeaponSkillTreeController: RequestHandler = async (req, res) => { + const accountId = await getAccountIdForRequest(req); + const inventory = await getInventory(accountId); + const payload = getJSONfromString(req.body.toString()) as ISetWeaponSkillTreeRequest; + + const item = inventory[req.query.Category as WeaponTypeInternal].find( + item => item._id.toString() == (req.query.ItemId as string) + )!; + item.SkillTree = payload.SkillTree; + + await inventory.save(); + res.end(); +}; + +interface ISetWeaponSkillTreeRequest { + SkillTree: string; +} diff --git a/src/controllers/api/upgradesController.ts b/src/controllers/api/upgradesController.ts index e2f7f052..9d89da70 100644 --- a/src/controllers/api/upgradesController.ts +++ b/src/controllers/api/upgradesController.ts @@ -1,6 +1,6 @@ import { RequestHandler } from "express"; import { IUpgradesRequest } from "@/src/types/requestTypes"; -import { FocusSchool, IEquipmentDatabase } from "@/src/types/inventoryTypes/commonInventoryTypes"; +import { FocusSchool, IEquipmentDatabase, EquipmentFeatures } from "@/src/types/inventoryTypes/commonInventoryTypes"; import { IMiscItem, TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes"; import { getAccountIdForRequest } from "@/src/services/loginService"; import { addMiscItems, getInventory, updateCurrency } from "@/src/services/inventoryService"; @@ -32,7 +32,7 @@ export const upgradesController: RequestHandler = async (req, res) => { for (const item of inventory[payload.ItemCategory as TEquipmentKey] as IEquipmentDatabase[]) { if (item._id.toString() == payload.ItemId.$oid) { item.Features ??= 0; - item.Features |= 1; + item.Features |= EquipmentFeatures.DOUBLE_CAPACITY; break; } } @@ -42,7 +42,7 @@ export const upgradesController: RequestHandler = async (req, res) => { for (const item of inventory[payload.ItemCategory as TEquipmentKey] as IEquipmentDatabase[]) { if (item._id.toString() == payload.ItemId.$oid) { item.Features ??= 0; - item.Features |= 2; + item.Features |= EquipmentFeatures.UTILITY_SLOT; break; } } @@ -53,7 +53,7 @@ export const upgradesController: RequestHandler = async (req, res) => { for (const item of inventory[payload.ItemCategory as TEquipmentKey] as IEquipmentDatabase[]) { if (item._id.toString() == payload.ItemId.$oid) { item.Features ??= 0; - item.Features |= 32; + item.Features |= EquipmentFeatures.ARCANE_SLOT; break; } } diff --git a/src/models/inventoryModels/inventoryModel.ts b/src/models/inventoryModels/inventoryModel.ts index aed24800..4ef0d856 100644 --- a/src/models/inventoryModels/inventoryModel.ts +++ b/src/models/inventoryModels/inventoryModel.ts @@ -35,7 +35,8 @@ import { ITauntHistory, IPeriodicMissionCompletionDatabase, IPeriodicMissionCompletionResponse, - ILoreFragmentScan + ILoreFragmentScan, + IEvolutionProgress } from "../../types/inventoryTypes/inventoryTypes"; import { IOid } from "../../types/commonTypes"; import { @@ -562,6 +563,15 @@ const loreFragmentScansSchema = new Schema( { _id: false } ); +const evolutionProgressSchema = new Schema( + { + Progress: Number, + Rank: Number, + ItemType: String + }, + { _id: false } +); + const inventorySchema = new Schema( { accountOwnerId: Schema.Types.ObjectId, @@ -881,7 +891,7 @@ const inventorySchema = new Schema( //Progress+Rank+ItemType(ZarimanPumpShotgun) //https://warframe.fandom.com/wiki/Incarnon - EvolutionProgress: [Schema.Types.Mixed], + EvolutionProgress: { type: [evolutionProgressSchema], default: undefined }, //Unknown and system DuviriInfo: DuviriInfoSchema, diff --git a/src/routes/api.ts b/src/routes/api.ts index 15192fe8..bf7440de 100644 --- a/src/routes/api.ts +++ b/src/routes/api.ts @@ -7,6 +7,7 @@ import { createGuildController } from "@/src/controllers/api/createGuildControll import { deleteSessionController } from "@/src/controllers/api/deleteSessionController"; import { dojoController } from "@/src/controllers/api/dojoController"; import { dronesController } from "@/src/controllers/api/dronesController"; +import { evolveWeaponController } from "@/src/controllers/api/evolveWeaponController"; import { findSessionsController } from "@/src/controllers/api/findSessionsController"; import { focusController } from "@/src/controllers/api/focusController"; import { genericUpdateController } from "@/src/controllers/api/genericUpdateController"; @@ -47,6 +48,7 @@ import { setActiveShipController } from "@/src/controllers/api/setActiveShipCont import { setBootLocationController } from "@/src/controllers/api/setBootLocationController"; import { setShipCustomizationsController } from "@/src/controllers/api/setShipCustomizationsController"; import { setSupportedSyndicateController } from "@/src/controllers/api/setSupportedSyndicateController"; +import { setWeaponSkillTreeController } from "../controllers/api/setWeaponSkillTreeController"; import { shipDecorationsController } from "@/src/controllers/api/shipDecorationsController"; import { startDojoRecipeController } from "@/src/controllers/api/startDojoRecipeController"; import { startRecipeController } from "@/src/controllers/api/startRecipeController"; @@ -97,6 +99,7 @@ apiRouter.post("/addFriendImage.php", addFriendImageController); apiRouter.post("/artifacts.php", artifactsController); apiRouter.post("/claimCompletedRecipe.php", claimCompletedRecipeController); apiRouter.post("/createGuild.php", createGuildController); +apiRouter.post("/evolveWeapon.php", evolveWeaponController); apiRouter.post("/findSessions.php", findSessionsController); apiRouter.post("/focus.php", focusController); apiRouter.post("/genericUpdate.php", genericUpdateController); @@ -115,6 +118,7 @@ apiRouter.post("/rerollRandomMod.php", rerollRandomModController); apiRouter.post("/saveLoadout.php", saveLoadoutController); apiRouter.post("/sell.php", sellController); apiRouter.post("/setShipCustomizations.php", setShipCustomizationsController); +apiRouter.post("/setWeaponSkillTree.php", setWeaponSkillTreeController); apiRouter.post("/shipDecorations.php", shipDecorationsController); apiRouter.post("/startDojoRecipe.php", startDojoRecipeController); apiRouter.post("/startRecipe.php", startRecipeController); diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 36bda69e..b29a5241 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -629,6 +629,22 @@ export const missionInventoryUpdate = async (data: IMissionInventoryUpdateReques // Gear XP gearKeys.forEach(key => addGearExpByCategory(inventory, data[key], key)); + // Incarnon Challenges + if (data.EvolutionProgress) { + for (const evoProgress of data.EvolutionProgress) { + const entry = inventory.EvolutionProgress + ? inventory.EvolutionProgress.find(entry => entry.ItemType == evoProgress.ItemType) + : undefined; + if (entry) { + entry.Progress = evoProgress.Progress; + entry.Rank = evoProgress.Rank; + } else { + inventory.EvolutionProgress ??= []; + inventory.EvolutionProgress.push(evoProgress); + } + } + } + // other addMods(inventory, RawUpgrades); addMiscItems(inventory, MiscItems); diff --git a/src/types/inventoryTypes/commonInventoryTypes.ts b/src/types/inventoryTypes/commonInventoryTypes.ts index aadc1b62..2c434311 100644 --- a/src/types/inventoryTypes/commonInventoryTypes.ts +++ b/src/types/inventoryTypes/commonInventoryTypes.ts @@ -82,6 +82,13 @@ export interface IEquipmentClient extends Omit { ItemId: IOid; } +export enum EquipmentFeatures { + DOUBLE_CAPACITY = 1, + UTILITY_SLOT = 2, + ARCANE_SLOT = 32, + INCARNON_GENESIS = 512 +} + export interface IEquipmentDatabase { ItemType: string; ItemName?: string; diff --git a/src/types/inventoryTypes/inventoryTypes.ts b/src/types/inventoryTypes/inventoryTypes.ts index 1a201888..1555799b 100644 --- a/src/types/inventoryTypes/inventoryTypes.ts +++ b/src/types/inventoryTypes/inventoryTypes.ts @@ -246,7 +246,7 @@ export interface IInventoryResponse { LastInventorySync: IOid; NextRefill: IMongoDate; ActiveLandscapeTraps: any[]; - EvolutionProgress: any[]; + EvolutionProgress?: IEvolutionProgress[]; RepVotes: any[]; LeagueTickets: any[]; Quests: any[]; @@ -867,3 +867,9 @@ export interface IWebFlags { Anniversary2021: boolean; HitDownloadBtn: IMongoDate; } + +export interface IEvolutionProgress { + Progress: number; + Rank: number; + ItemType: string; +} diff --git a/src/types/requestTypes.ts b/src/types/requestTypes.ts index 6dc35b76..ce7ea1e0 100644 --- a/src/types/requestTypes.ts +++ b/src/types/requestTypes.ts @@ -5,6 +5,7 @@ import { IChallengeProgress, IConsumable, ICrewShipSalvagedWeaponSkin, + IEvolutionProgress, IMiscItem, IMission, IRawUpgrade, @@ -53,6 +54,7 @@ export interface IMissionInventoryUpdateRequest { RewardInfo?: IMissionInventoryUpdateRequestRewardInfo; FusionPoints?: number; Missions?: IMission; + EvolutionProgress?: IEvolutionProgress[]; } export interface IMissionInventoryUpdateRequestRewardInfo { From 7c47c9f1e42cff84156faa92c1aab86e35a7c2e8 Mon Sep 17 00:00:00 2001 From: Sainan Date: Thu, 20 Jun 2024 13:29:48 +0200 Subject: [PATCH 7/9] fix: not being able to talk to Nakak in Cetus (#336) --- .../api/getVendorInfoController.ts | 7 + src/routes/api.ts | 2 + static/fixed_responses/getVendorInfo.json | 301 ++++++++++++++++++ 3 files changed, 310 insertions(+) create mode 100644 src/controllers/api/getVendorInfoController.ts create mode 100644 static/fixed_responses/getVendorInfo.json diff --git a/src/controllers/api/getVendorInfoController.ts b/src/controllers/api/getVendorInfoController.ts new file mode 100644 index 00000000..cd442318 --- /dev/null +++ b/src/controllers/api/getVendorInfoController.ts @@ -0,0 +1,7 @@ +import { RequestHandler } from "express"; +import getVendorInfoResponse from "@/static/fixed_responses/getVendorInfo.json"; + +export const getVendorInfoController: RequestHandler = (req, res) => { + console.assert(req.query.vendor == "/Lotus/Types/Game/VendorManifests/Ostron/MaskSalesmanManifest"); + res.json(getVendorInfoResponse); +}; diff --git a/src/routes/api.ts b/src/routes/api.ts index bf7440de..8bdddd78 100644 --- a/src/routes/api.ts +++ b/src/routes/api.ts @@ -21,6 +21,7 @@ import { getGuildLogController } from "../controllers/api/getGuildLogController" import { getIgnoredUsersController } from "@/src/controllers/api/getIgnoredUsersController"; import { getNewRewardSeedController } from "@/src/controllers/api/getNewRewardSeedController"; import { getShipController } from "@/src/controllers/api/getShipController"; +import { getVendorInfoController } from "@/src/controllers/api/getVendorInfoController"; import { guildTechController } from "../controllers/api/guildTechController"; import { hostSessionController } from "@/src/controllers/api/hostSessionController"; import { hubController } from "@/src/controllers/api/hubController"; @@ -77,6 +78,7 @@ apiRouter.get("/getGuildLog.php", getGuildLogController); apiRouter.get("/getIgnoredUsers.php", getIgnoredUsersController); apiRouter.get("/getNewRewardSeed.php", getNewRewardSeedController); apiRouter.get("/getShip.php", getShipController); +apiRouter.get("/getVendorInfo.php", getVendorInfoController); apiRouter.get("/hub", hubController); apiRouter.get("/hubInstances", hubInstancesController); apiRouter.get("/inbox.php", inboxController); diff --git a/static/fixed_responses/getVendorInfo.json b/static/fixed_responses/getVendorInfo.json new file mode 100644 index 00000000..85aa7eac --- /dev/null +++ b/static/fixed_responses/getVendorInfo.json @@ -0,0 +1,301 @@ +{ + "VendorInfo": { + "_id": { + "$oid": "598a090d9a4a313746fd1f24" + }, + "TypeName": "/Lotus/Types/Game/VendorManifests/Ostron/MaskSalesmanManifest", + "ItemManifest": [ + { + "StoreItem": "/Lotus/StoreItems/Upgrades/Skins/Ostron/RevenantMask", + "ItemPrices": [ + { + "ItemCount": 1, + "ItemType": "/Lotus/Types/Gameplay/Eidolon/Resources/CetusWispItem", + "ProductCategory": "MiscItems" + } + ], + "Bin": "BIN_0", + "QuantityMultiplier": 1, + "Expiry": { + "$date": { + "$numberLong": "9999999000000" + } + }, + "AllowMultipurchase": true, + "Id": { + "$oid": "63ed01ef4c37f93d0b797674" + } + }, + { + "StoreItem": "/Lotus/StoreItems/Types/Items/ShipDecos/Plushies/PlushyThumper", + "ItemPrices": [ + { + "ItemCount": 2, + "ItemType": "/Lotus/Types/Gameplay/Eidolon/Resources/CetusWispItem", + "ProductCategory": "MiscItems" + }, + { + "ItemType": "/Lotus/Types/Items/Fish/Eidolon/FishParts/BothUncommonFishBPartItem", + "ItemCount": 10, + "ProductCategory": "MiscItems" + }, + { + "ItemType": "/Lotus/Types/Gameplay/Eidolon/Resources/NistlebrushItem", + "ItemCount": 10, + "ProductCategory": "MiscItems" + }, + { + "ItemType": "/Lotus/Types/Items/Gems/Eidolon/CommonOreAAlloyAItem", + "ItemCount": 32, + "ProductCategory": "MiscItems" + } + ], + "Bin": "BIN_0", + "QuantityMultiplier": 1, + "Expiry": { + "$date": { + "$numberLong": "9999999000000" + } + }, + "AllowMultipurchase": true, + "Id": { + "$oid": "63ed01ef4c37f93d0b797675" + } + }, + { + "StoreItem": "/Lotus/StoreItems/Types/Items/ShipDecos/Plushies/PlushyThumperMedium", + "ItemPrices": [ + { + "ItemCount": 4, + "ItemType": "/Lotus/Types/Gameplay/Eidolon/Resources/CetusWispItem", + "ProductCategory": "MiscItems" + }, + { + "ItemType": "/Lotus/Types/Items/Gems/Eidolon/CommonGemBCutAItem", + "ItemCount": 24, + "ProductCategory": "MiscItems" + }, + { + "ItemType": "/Lotus/Types/Items/Fish/Eidolon/FishParts/BothUncommonFishAPartItem", + "ItemCount": 18, + "ProductCategory": "MiscItems" + }, + { + "ItemType": "/Lotus/Types/Items/Fish/Eidolon/FishParts/BothUncommonFishBPartItem", + "ItemCount": 27, + "ProductCategory": "MiscItems" + } + ], + "Bin": "BIN_1", + "QuantityMultiplier": 1, + "Expiry": { + "$date": { + "$numberLong": "9999999000000" + } + }, + "AllowMultipurchase": true, + "Id": { + "$oid": "63ed01ef4c37f93d0b797676" + } + }, + { + "StoreItem": "/Lotus/StoreItems/Types/Items/ShipDecos/Plushies/PlushyThumperLarge", + "ItemPrices": [ + { + "ItemCount": 6, + "ItemType": "/Lotus/Types/Gameplay/Eidolon/Resources/CetusWispItem", + "ProductCategory": "MiscItems" + }, + { + "ItemType": "/Lotus/Types/Items/Gems/Eidolon/CommonGemACutAItem", + "ItemCount": 35, + "ProductCategory": "MiscItems" + }, + { + "ItemType": "/Lotus/Types/Items/Fish/Eidolon/FishParts/BothCommonFishAPartItem", + "ItemCount": 95, + "ProductCategory": "MiscItems" + }, + { + "ItemType": "/Lotus/Types/Gameplay/Eidolon/Resources/NistlebrushItem", + "ItemCount": 60, + "ProductCategory": "MiscItems" + } + ], + "Bin": "BIN_0", + "QuantityMultiplier": 1, + "Expiry": { + "$date": { + "$numberLong": "9999999000000" + } + }, + "AllowMultipurchase": true, + "Id": { + "$oid": "63ed01ef4c37f93d0b797677" + } + }, + { + "StoreItem": "/Lotus/StoreItems/Types/Recipes/SynthicatorRecipes/FlareBlueBlueprint", + "ItemPrices": [ + { + "ItemType": "/Lotus/Types/Items/Fish/Eidolon/FishParts/BothUncommonFishBPartItem", + "ItemCount": 10, + "ProductCategory": "MiscItems" + }, + { + "ItemType": "/Lotus/Types/Items/Fish/Eidolon/FishParts/DayCommonFishCPartItem", + "ItemCount": 10, + "ProductCategory": "MiscItems" + } + ], + "Bin": "BIN_0", + "QuantityMultiplier": 1, + "Expiry": { + "$date": { + "$numberLong": "9999999000000" + } + }, + "AllowMultipurchase": true, + "Id": { + "$oid": "6651291214e90115b91b50a1" + } + }, + { + "StoreItem": "/Lotus/StoreItems/Types/Recipes/SynthicatorRecipes/FlareRedBlueprint", + "ItemPrices": [ + { + "ItemType": "/Lotus/Types/Items/Gems/Eidolon/CommonOreAAlloyAItem", + "ItemCount": 37, + "ProductCategory": "MiscItems" + }, + { + "ItemType": "/Lotus/Types/Items/Fish/Eidolon/FishParts/BothUncommonFishAPartItem", + "ItemCount": 7, + "ProductCategory": "MiscItems" + } + ], + "Bin": "BIN_0", + "QuantityMultiplier": 1, + "Expiry": { + "$date": { + "$numberLong": "9999999000000" + } + }, + "AllowMultipurchase": true, + "Id": { + "$oid": "6651291214e90115b91b50a2" + } + }, + { + "StoreItem": "/Lotus/StoreItems/Upgrades/Skins/Ostron/VoltMask", + "ItemPrices": [ + { + "ItemType": "/Lotus/Types/Items/Gems/Eidolon/CommonOreBAlloyBItem", + "ItemCount": 34, + "ProductCategory": "MiscItems" + }, + { + "ItemType": "/Lotus/Types/Gameplay/Eidolon/Resources/GrokdrulItem", + "ItemCount": 17, + "ProductCategory": "MiscItems" + } + ], + "Bin": "BIN_0", + "QuantityMultiplier": 1, + "Expiry": { + "$date": { + "$numberLong": "9999999000000" + } + }, + "AllowMultipurchase": true, + "Id": { + "$oid": "6651291214e90115b91b50a3" + } + }, + { + "StoreItem": "/Lotus/StoreItems/Upgrades/Skins/Ostron/MagMask", + "ItemPrices": [ + { + "ItemType": "/Lotus/Types/Items/Fish/Eidolon/FishParts/DayCommonFishBPartItem", + "ItemCount": 16, + "ProductCategory": "MiscItems" + }, + { + "ItemType": "/Lotus/Types/Gameplay/Eidolon/Resources/ForestRodentPartItem", + "ItemCount": 5, + "ProductCategory": "MiscItems" + } + ], + "Bin": "BIN_0", + "QuantityMultiplier": 1, + "Expiry": { + "$date": { + "$numberLong": "9999999000000" + } + }, + "AllowMultipurchase": true, + "Id": { + "$oid": "6651291214e90115b91b50a4" + } + }, + { + "StoreItem": "/Lotus/StoreItems/Upgrades/Skins/Ostron/ExcaliburMask", + "ItemPrices": [ + { + "ItemType": "/Lotus/Types/Gameplay/Eidolon/Resources/BirdOfPreyPartItem", + "ItemCount": 5, + "ProductCategory": "MiscItems" + }, + { + "ItemType": "/Lotus/Types/Gameplay/Eidolon/Resources/GrokdrulItem", + "ItemCount": 20, + "ProductCategory": "MiscItems" + } + ], + "Bin": "BIN_0", + "QuantityMultiplier": 1, + "Expiry": { + "$date": { + "$numberLong": "9999999000000" + } + }, + "AllowMultipurchase": true, + "Id": { + "$oid": "6651291214e90115b91b50a5" + } + }, + { + "StoreItem": "/Lotus/StoreItems/Upgrades/Skins/Ostron/GrineerMask", + "ItemPrices": [ + { + "ItemType": "/Lotus/Types/Items/Fish/Eidolon/FishParts/DayCommonFishBPartItem", + "ItemCount": 20, + "ProductCategory": "MiscItems" + }, + { + "ItemType": "/Lotus/Types/Items/Gems/Eidolon/CommonOreAAlloyAItem", + "ItemCount": 31, + "ProductCategory": "MiscItems" + } + ], + "Bin": "BIN_1", + "QuantityMultiplier": 1, + "Expiry": { + "$date": { + "$numberLong": "9999999000000" + } + }, + "AllowMultipurchase": true, + "Id": { + "$oid": "6651291214e90115b91b50a6" + } + } + ], + "PropertyTextHash": "6AACA376DA34B35B5C16F1B40DBC017D", + "Expiry": { + "$date": { + "$numberLong": "9999999000000" + } + } + } +} From 5597db67615e32d2852d70278d42fa34322f4178 Mon Sep 17 00:00:00 2001 From: Sainan Date: Thu, 20 Jun 2024 16:35:24 +0200 Subject: [PATCH 8/9] fix: not being able to buy incarnon bundles (#337) --- src/services/inventoryService.ts | 22 +++++++++-- src/services/purchaseService.ts | 66 +++++++++++++++++++++++++------- src/types/purchaseTypes.ts | 20 +--------- 3 files changed, 72 insertions(+), 36 deletions(-) diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index b29a5241..efd291cc 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -2,7 +2,7 @@ import { Inventory } from "@/src/models/inventoryModels/inventoryModel"; import new_inventory from "@/static/fixed_responses/postTutorialInventory.json"; import { config } from "@/src/services/configService"; import { Types } from "mongoose"; -import { SlotNames } from "@/src/types/purchaseTypes"; +import { SlotNames, IInventoryChanges } from "@/src/types/purchaseTypes"; import { IChallengeProgress, IConsumable, @@ -26,7 +26,7 @@ import { logger } from "@/src/utils/logger"; import { WeaponTypeInternal, getWeaponType, getExalted } from "@/src/services/itemDataService"; import { ISyndicateSacrifice, ISyndicateSacrificeResponse } from "../types/syndicateTypes"; import { IEquipmentClient } from "../types/inventoryTypes/commonInventoryTypes"; -import { ExportRecipes } from "warframe-public-export-plus"; +import { ExportRecipes, ExportResources } from "warframe-public-export-plus"; export const createInventory = async ( accountOwnerId: Types.ObjectId, @@ -70,7 +70,7 @@ export const addItem = async ( accountId: string, typeName: string, quantity: number = 1 -): Promise<{ InventoryChanges: object }> => { +): Promise<{ InventoryChanges: IInventoryChanges }> => { // Strict typing if (typeName in ExportRecipes) { const inventory = await getInventory(accountId); @@ -88,6 +88,22 @@ export const addItem = async ( } }; } + if (typeName in ExportResources) { + const inventory = await getInventory(accountId); + const miscItemChanges = [ + { + ItemType: typeName, + ItemCount: quantity + } satisfies IMiscItem + ]; + addMiscItems(inventory, miscItemChanges); + await inventory.save(); + return { + InventoryChanges: { + MiscItems: miscItemChanges + } + }; + } // Path-based duck typing switch (typeName.substr(1).split("/")[1]) { diff --git a/src/services/purchaseService.ts b/src/services/purchaseService.ts index 0f96055c..9fb4a675 100644 --- a/src/services/purchaseService.ts +++ b/src/services/purchaseService.ts @@ -1,7 +1,7 @@ import { parseSlotPurchaseName } from "@/src/helpers/purchaseHelpers"; import { getSubstringFromKeyword } from "@/src/helpers/stringHelpers"; import { addItem, addBooster, updateCurrency, updateSlots } from "@/src/services/inventoryService"; -import { IPurchaseRequest, SlotPurchase } from "@/src/types/purchaseTypes"; +import { IPurchaseRequest, SlotPurchase, IInventoryChanges, IBinChanges } from "@/src/types/purchaseTypes"; import { logger } from "@/src/utils/logger"; import { ExportBundles, TRarity } from "warframe-public-export-plus"; @@ -46,12 +46,37 @@ export const handlePurchase = async (purchaseRequest: IPurchaseRequest, accountI return purchaseResponse; }; +const addInventoryChanges = (InventoryChanges: IInventoryChanges, delta: IInventoryChanges): void => { + for (const key in delta) { + if (!(key in InventoryChanges)) { + InventoryChanges[key] = delta[key]; + } else if (Array.isArray(delta[key])) { + const left = InventoryChanges[key] as object[]; + const right = delta[key] as object[]; + for (const item of right) { + left.push(item); + } + } else { + console.assert(key.substring(-3) == "Bin"); + const left = InventoryChanges[key] as IBinChanges; + const right = delta[key] as IBinChanges; + left.count += right.count; + left.platinum += right.platinum; + left.Slots += right.Slots; + if (right.Extra) { + left.Extra ??= 0; + left.Extra += right.Extra; + } + } + } +}; + const handleStoreItemAcquisition = async ( storeItemName: string, accountId: string, quantity: number, durability: TRarity -): Promise<{ InventoryChanges: object }> => { +): Promise<{ InventoryChanges: IInventoryChanges }> => { let purchaseResponse = { InventoryChanges: {} }; @@ -60,15 +85,17 @@ const handleStoreItemAcquisition = async ( const bundle = ExportBundles[storeItemName]; logger.debug("acquiring bundle", bundle); for (const component of bundle.components) { - purchaseResponse = { - ...purchaseResponse, - ...(await handleStoreItemAcquisition( - component.typeName, - accountId, - component.purchaseQuantity, - component.durability - )) - }; + addInventoryChanges( + purchaseResponse.InventoryChanges, + ( + await handleStoreItemAcquisition( + component.typeName, + accountId, + component.purchaseQuantity, + component.durability + ) + ).InventoryChanges + ); } } else { const storeCategory = getStoreItemCategory(storeItemName); @@ -106,7 +133,10 @@ export const slotPurchaseNameToSlotName: SlotPurchase = { // // new slot above base = extra + 1 and slots +1 // // new frame = slots -1 // // number of frames = extra - slots + 2 -const handleSlotPurchase = async (slotPurchaseNameFull: string, accountId: string) => { +const handleSlotPurchase = async ( + slotPurchaseNameFull: string, + accountId: string +): Promise<{ InventoryChanges: IInventoryChanges }> => { logger.debug(`slot name ${slotPurchaseNameFull}`); const slotPurchaseName = parseSlotPurchaseName( slotPurchaseNameFull.substring(slotPurchaseNameFull.lastIndexOf("/") + 1) @@ -133,7 +163,11 @@ const handleSlotPurchase = async (slotPurchaseNameFull: string, accountId: strin }; //TODO: change to getInventory, apply changes then save at the end -const handleTypesPurchase = async (typesName: string, accountId: string, quantity: number) => { +const handleTypesPurchase = async ( + typesName: string, + accountId: string, + quantity: number +): Promise<{ InventoryChanges: IInventoryChanges }> => { const typeCategory = getStoreItemTypesCategory(typesName); logger.debug(`type category ${typeCategory}`); switch (typeCategory) { @@ -158,7 +192,11 @@ const boosterDuration: Record = { LEGENDARY: 90 * 86400 }; -const handleBoostersPurchase = async (boosterStoreName: string, accountId: string, durability: TRarity) => { +const handleBoostersPurchase = async ( + boosterStoreName: string, + accountId: string, + durability: TRarity +): Promise<{ InventoryChanges: IInventoryChanges }> => { const ItemType = boosterStoreName.replace("StoreItem", ""); if (!boosterCollection.find(x => x == ItemType)) { logger.error(`unknown booster type: ${ItemType}`); diff --git a/src/types/purchaseTypes.ts b/src/types/purchaseTypes.ts index db143470..0d04114e 100644 --- a/src/types/purchaseTypes.ts +++ b/src/types/purchaseTypes.ts @@ -1,6 +1,3 @@ -import { IFlavourItem } from "@/src/types/inventoryTypes/inventoryTypes"; -import { IEquipmentClient } from "./inventoryTypes/commonInventoryTypes"; - export interface IPurchaseRequest { PurchaseParams: IPurchaseParams; buildLabel: string; @@ -17,22 +14,7 @@ export interface IPurchaseParams { ExpectedPrice: number; } -export interface IPurchaseResponse { - InventoryChanges: { - SuitBin?: IBinChanges; - WeaponBin?: IBinChanges; - MechBin?: IBinChanges; - MechSuits?: IEquipmentClient[]; - Suits?: IEquipmentClient[]; - LongGuns?: IEquipmentClient[]; - Pistols?: IEquipmentClient[]; - Melee?: IEquipmentClient[]; - PremiumCredits?: number; - PremiumCreditsFree?: number; - RegularCredits?: number; - FlavourItems?: IFlavourItem[]; - }; -} +export type IInventoryChanges = Record; export type IBinChanges = { count: number; From c415fdd9ffe7d6ed046775aa80f1592fd5258b0c Mon Sep 17 00:00:00 2001 From: Sainan Date: Thu, 20 Jun 2024 21:22:01 +0200 Subject: [PATCH 9/9] feat(webui): acquiring gear items via "Add Items" (#340) --- .../custom/getItemListsController.ts | 18 +++++++++++++++--- static/webui/script.js | 11 ++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/controllers/custom/getItemListsController.ts b/src/controllers/custom/getItemListsController.ts index 574ec8d7..1f9417bf 100644 --- a/src/controllers/custom/getItemListsController.ts +++ b/src/controllers/custom/getItemListsController.ts @@ -1,7 +1,13 @@ import { RequestHandler } from "express"; import { MinItem, items, getEnglishString } from "@/src/services/itemDataService"; import badItems from "@/static/json/exclude-mods.json"; -import { ExportArcanes, ExportResources, ExportWarframes, ExportWeapons } from "warframe-public-export-plus"; +import { + ExportArcanes, + ExportGear, + ExportResources, + ExportWarframes, + ExportWeapons +} from "warframe-public-export-plus"; interface ListedItem { uniqueName: string; @@ -31,7 +37,7 @@ const getItemListsController: RequestHandler = (_req, res) => { }); } else if (!item.excludeFromCodex) { miscitems.push({ - uniqueName, + uniqueName: "MiscItems:" + uniqueName, name: getEnglishString(item.name) }); } @@ -39,7 +45,13 @@ const getItemListsController: RequestHandler = (_req, res) => { } for (const [uniqueName, item] of Object.entries(ExportResources)) { miscitems.push({ - uniqueName, + uniqueName: "MiscItems:" + uniqueName, + name: getEnglishString(item.name) + }); + } + for (const [uniqueName, item] of Object.entries(ExportGear)) { + miscitems.push({ + uniqueName: "Consumables:" + uniqueName, name: getEnglishString(item.name) }); } diff --git a/static/webui/script.js b/static/webui/script.js index 0090d427..f7d79962 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -512,17 +512,18 @@ function disposeOfItems(category, type, count) { } function doAcquireMiscItems() { - const uniqueName = getKey(document.getElementById("miscitem-type")); - if (!uniqueName) { + const data = getKey(document.getElementById("miscitem-type")); + if (!data) { $("#miscitem-type").addClass("is-invalid").focus(); return; } + const [category, uniqueName] = data.split(":"); revalidateAuthz(() => { $.post({ url: "/api/missionInventoryUpdate.php?" + window.authz, contentType: "text/plain", data: JSON.stringify({ - MiscItems: [ + [category]: [ { ItemType: uniqueName, ItemCount: parseInt($("#miscitem-count").val()) @@ -535,8 +536,8 @@ function doAcquireMiscItems() { }); } -$("#miscitem-name").on("input", () => { - $("#miscitem-name").removeClass("is-invalid"); +$("#miscitem-type").on("input", () => { + $("#miscitem-type").removeClass("is-invalid"); }); function doAcquireRiven() {