Compare commits

..

No commits in common. "8077b9e4b6d281fa156ed42dbed36316125155b4" and "6d12d908775bcf3e4ba8f282d594dc9c3a4b28e1" have entirely different histories.

5 changed files with 76 additions and 153 deletions

View File

@ -1,6 +1,7 @@
import { RequestHandler } from "express"; import { RequestHandler } from "express";
import { getAccountIdForRequest } from "@/src/services/loginService"; import { getAccountIdForRequest } from "@/src/services/loginService";
import { getJSONfromString } from "@/src/helpers/stringHelpers"; import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
import { import {
getInventory, getInventory,
updateCurrency, updateCurrency,
@ -10,9 +11,26 @@ import {
occupySlot, occupySlot,
productCategoryToInventoryBin productCategoryToInventoryBin
} from "@/src/services/inventoryService"; } from "@/src/services/inventoryService";
import { ExportWeapons } from "warframe-public-export-plus";
import { IInventoryChanges } from "@/src/types/purchaseTypes"; import { IInventoryChanges } from "@/src/types/purchaseTypes";
import { getDefaultUpgrades } from "@/src/services/itemDataService";
import { modularWeaponTypes } from "@/src/helpers/modularWeaponHelper"; const modularWeaponTypes: Record<string, TEquipmentKey> = {
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimary": "LongGuns",
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryBeam": "LongGuns",
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryLauncher": "LongGuns",
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryShotgun": "LongGuns",
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimarySniper": "LongGuns",
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondary": "Pistols",
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryBeam": "Pistols",
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryShotgun": "Pistols",
"/Lotus/Weapons/Ostron/Melee/LotusModularWeapon": "Melee",
"/Lotus/Weapons/Sentients/OperatorAmplifiers/OperatorAmpWeapon": "OperatorAmps",
"/Lotus/Types/Vehicles/Hoverboard/HoverboardSuit": "Hoverboards",
"/Lotus/Types/Friendly/Pets/MoaPets/MoaPetPowerSuit": "MoaPets",
"/Lotus/Types/Friendly/Pets/ZanukaPets/ZanukaPetAPowerSuit": "MoaPets",
"/Lotus/Types/Friendly/Pets/ZanukaPets/ZanukaPetBPowerSuit": "MoaPets",
"/Lotus/Types/Friendly/Pets/ZanukaPets/ZanukaPetCPowerSuit": "MoaPets"
};
interface IModularCraftRequest { interface IModularCraftRequest {
WeaponType: string; WeaponType: string;
@ -28,7 +46,8 @@ export const modularWeaponCraftingController: RequestHandler = async (req, res)
const category = modularWeaponTypes[data.WeaponType]; const category = modularWeaponTypes[data.WeaponType];
const inventory = await getInventory(accountId); const inventory = await getInventory(accountId);
const configs = applyDefaultUpgrades(inventory, getDefaultUpgrades(data.Parts)); // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const configs = applyDefaultUpgrades(inventory, ExportWeapons[data.Parts[0]]?.defaultUpgrades);
// Give weapon // Give weapon
const inventoryChanges: IInventoryChanges = { const inventoryChanges: IInventoryChanges = {

View File

@ -3,22 +3,9 @@ import { ExportWeapons } from "warframe-public-export-plus";
import { IMongoDate } from "@/src/types/commonTypes"; import { IMongoDate } from "@/src/types/commonTypes";
import { toMongoDate } from "@/src/helpers/inventoryHelpers"; import { toMongoDate } from "@/src/helpers/inventoryHelpers";
import { CRng } from "@/src/services/rngService"; import { CRng } from "@/src/services/rngService";
import { ArtifactPolarity, EquipmentFeatures } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import {
addEquipment,
applyDefaultUpgrades,
getInventory,
occupySlot,
productCategoryToInventoryBin,
updateCurrency
} from "@/src/services/inventoryService";
import { getDefaultUpgrades } from "@/src/services/itemDataService";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { modularWeaponTypes } from "@/src/helpers/modularWeaponHelper";
import { IInventoryChanges } from "@/src/types/purchaseTypes";
export const modularWeaponSaleController: RequestHandler = async (req, res) => { // op=SyncAll
export const modularWeaponSaleController: RequestHandler = (_req, res) => {
const partTypeToParts: Record<string, string[]> = {}; const partTypeToParts: Record<string, string[]> = {};
for (const [uniqueName, data] of Object.entries(ExportWeapons)) { for (const [uniqueName, data] of Object.entries(ExportWeapons)) {
if (data.partType) { if (data.partType) {
@ -28,101 +15,60 @@ export const modularWeaponSaleController: RequestHandler = async (req, res) => {
} }
} }
if (req.query.op == "SyncAll") { const today: number = Math.trunc(Date.now() / 86400000);
res.json({ const kitgunIsPrimary: boolean = (today & 1) != 0;
SaleInfos: getSaleInfos(partTypeToParts, Math.trunc(Date.now() / 86400000)) res.json({
}); SaleInfos: [
} else if (req.query.op == "Purchase") { getModularWeaponSale(
const accountId = await getAccountIdForRequest(req); partTypeToParts,
const inventory = await getInventory(accountId); today,
const payload = getJSONfromString<IModularWeaponPurchaseRequest>(String(req.body)); "Ostron",
const weaponInfo = getSaleInfos(partTypeToParts, payload.Revision).find(x => x.Name == payload.SaleName)! ["LWPT_HILT", "LWPT_BLADE", "LWPT_HILT_WEIGHT"],
.Weapons[payload.ItemIndex]; () => "/Lotus/Weapons/Ostron/Melee/LotusModularWeapon"
const category = modularWeaponTypes[weaponInfo.ItemType];
const configs = applyDefaultUpgrades(inventory, getDefaultUpgrades(weaponInfo.ModularParts));
const inventoryChanges: IInventoryChanges = {
...addEquipment(
inventory,
category,
weaponInfo.ItemType,
weaponInfo.ModularParts,
{},
{
Features: EquipmentFeatures.DOUBLE_CAPACITY | EquipmentFeatures.GILDED,
ItemName: payload.ItemName,
Configs: configs,
Polarity: [
{
Slot: payload.PolarizeSlot,
Value: payload.PolarizeValue
}
]
}
), ),
...occupySlot(inventory, productCategoryToInventoryBin(category)!, true), getModularWeaponSale(
...updateCurrency(inventory, weaponInfo.PremiumPrice, true) partTypeToParts,
}; today,
await inventory.save(); "SolarisUnitedHoverboard",
res.json({ ["LWPT_HB_DECK", "LWPT_HB_ENGINE", "LWPT_HB_FRONT", "LWPT_HB_JET"],
InventoryChanges: inventoryChanges () => "/Lotus/Types/Vehicles/Hoverboard/HoverboardSuit"
}); ),
} else { getModularWeaponSale(
throw new Error(`unknown modularWeaponSale op: ${String(req.query.op)}`); partTypeToParts,
} today,
}; "SolarisUnitedMoaPet",
["LWPT_MOA_LEG", "LWPT_MOA_HEAD", "LWPT_MOA_ENGINE", "LWPT_MOA_PAYLOAD"],
const getSaleInfos = (partTypeToParts: Record<string, string[]>, day: number): IModularWeaponSaleInfo[] => { () => "/Lotus/Types/Friendly/Pets/MoaPets/MoaPetPowerSuit"
const kitgunIsPrimary: boolean = (day & 1) != 0; ),
return [ getModularWeaponSale(
getModularWeaponSale( partTypeToParts,
partTypeToParts, today,
day, "SolarisUnitedKitGun",
"Ostron", [
["LWPT_HILT", "LWPT_BLADE", "LWPT_HILT_WEIGHT"], kitgunIsPrimary ? "LWPT_GUN_PRIMARY_HANDLE" : "LWPT_GUN_SECONDARY_HANDLE",
() => "/Lotus/Weapons/Ostron/Melee/LotusModularWeapon" "LWPT_GUN_BARREL",
), "LWPT_GUN_CLIP"
getModularWeaponSale( ],
partTypeToParts, (parts: string[]) => {
day, const barrel = parts[1];
"SolarisUnitedHoverboard", const gunType = ExportWeapons[barrel].gunType!;
["LWPT_HB_DECK", "LWPT_HB_ENGINE", "LWPT_HB_FRONT", "LWPT_HB_JET"], if (kitgunIsPrimary) {
() => "/Lotus/Types/Vehicles/Hoverboard/HoverboardSuit" return {
), GT_RIFLE: "/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimary",
getModularWeaponSale( GT_SHOTGUN: "/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryShotgun",
partTypeToParts, GT_BEAM: "/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryBeam"
day, }[gunType];
"SolarisUnitedMoaPet", } else {
["LWPT_MOA_LEG", "LWPT_MOA_HEAD", "LWPT_MOA_ENGINE", "LWPT_MOA_PAYLOAD"], return {
() => "/Lotus/Types/Friendly/Pets/MoaPets/MoaPetPowerSuit" GT_RIFLE: "/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondary",
), GT_SHOTGUN: "/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryShotgun",
getModularWeaponSale( GT_BEAM: "/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryBeam"
partTypeToParts, }[gunType];
day, }
"SolarisUnitedKitGun",
[
kitgunIsPrimary ? "LWPT_GUN_PRIMARY_HANDLE" : "LWPT_GUN_SECONDARY_HANDLE",
"LWPT_GUN_BARREL",
"LWPT_GUN_CLIP"
],
(parts: string[]) => {
const barrel = parts[1];
const gunType = ExportWeapons[barrel].gunType!;
if (kitgunIsPrimary) {
return {
GT_RIFLE: "/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimary",
GT_SHOTGUN: "/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryShotgun",
GT_BEAM: "/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryBeam"
}[gunType];
} else {
return {
GT_RIFLE: "/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondary",
GT_SHOTGUN: "/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryShotgun",
GT_BEAM: "/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryBeam"
}[gunType];
} }
} )
) ]
]; });
}; };
const priceFactor: Record<string, number> = { const priceFactor: Record<string, number> = {
@ -175,12 +121,3 @@ interface IModularWeaponSaleItem {
PremiumPrice: number; PremiumPrice: number;
ModularParts: string[]; ModularParts: string[];
} }
interface IModularWeaponPurchaseRequest {
SaleName: string;
ItemIndex: number;
Revision: number;
ItemName: string;
PolarizeSlot: number;
PolarizeValue: ArtifactPolarity;
}

View File

@ -1,19 +0,0 @@
import { TEquipmentKey } from "../types/inventoryTypes/inventoryTypes";
export const modularWeaponTypes: Record<string, TEquipmentKey> = {
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimary": "LongGuns",
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryBeam": "LongGuns",
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryLauncher": "LongGuns",
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryShotgun": "LongGuns",
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimarySniper": "LongGuns",
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondary": "Pistols",
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryBeam": "Pistols",
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryShotgun": "Pistols",
"/Lotus/Weapons/Ostron/Melee/LotusModularWeapon": "Melee",
"/Lotus/Weapons/Sentients/OperatorAmplifiers/OperatorAmpWeapon": "OperatorAmps",
"/Lotus/Types/Vehicles/Hoverboard/HoverboardSuit": "Hoverboards",
"/Lotus/Types/Friendly/Pets/MoaPets/MoaPetPowerSuit": "MoaPets",
"/Lotus/Types/Friendly/Pets/ZanukaPets/ZanukaPetAPowerSuit": "MoaPets",
"/Lotus/Types/Friendly/Pets/ZanukaPets/ZanukaPetBPowerSuit": "MoaPets",
"/Lotus/Types/Friendly/Pets/ZanukaPets/ZanukaPetCPowerSuit": "MoaPets"
};

View File

@ -201,7 +201,6 @@ apiRouter.post("/joinSession.php", joinSessionController);
apiRouter.post("/login.php", loginController); apiRouter.post("/login.php", loginController);
apiRouter.post("/missionInventoryUpdate.php", missionInventoryUpdateController); apiRouter.post("/missionInventoryUpdate.php", missionInventoryUpdateController);
apiRouter.post("/modularWeaponCrafting.php", modularWeaponCraftingController); apiRouter.post("/modularWeaponCrafting.php", modularWeaponCraftingController);
apiRouter.post("/modularWeaponSale.php", modularWeaponSaleController);
apiRouter.post("/nameWeapon.php", nameWeaponController); apiRouter.post("/nameWeapon.php", nameWeaponController);
apiRouter.post("/placeDecoInComponent.php", placeDecoInComponentController); apiRouter.post("/placeDecoInComponent.php", placeDecoInComponentController);
apiRouter.post("/playerSkills.php", playerSkillsController); apiRouter.post("/playerSkills.php", playerSkillsController);

View File

@ -29,7 +29,6 @@ import {
ExportSentinels, ExportSentinels,
ExportWarframes, ExportWarframes,
ExportWeapons, ExportWeapons,
IDefaultUpgrade,
IInboxMessage, IInboxMessage,
IMissionReward, IMissionReward,
IPowersuit, IPowersuit,
@ -257,15 +256,3 @@ export const toStoreItem = (type: string): string => {
export const fromStoreItem = (type: string): string => { export const fromStoreItem = (type: string): string => {
return "/Lotus/" + type.substring("/Lotus/StoreItems/".length); return "/Lotus/" + type.substring("/Lotus/StoreItems/".length);
}; };
export const getDefaultUpgrades = (parts: string[]): IDefaultUpgrade[] | undefined => {
const allDefaultUpgrades: IDefaultUpgrade[] = [];
for (const part of parts) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const defaultUpgrades = ExportWeapons[part]?.defaultUpgrades;
if (defaultUpgrades) {
allDefaultUpgrades.push(...defaultUpgrades);
}
}
return allDefaultUpgrades.length == 0 ? undefined : allDefaultUpgrades;
};