Compare commits
No commits in common. "8077b9e4b6d281fa156ed42dbed36316125155b4" and "6d12d908775bcf3e4ba8f282d594dc9c3a4b28e1" have entirely different histories.
8077b9e4b6
...
6d12d90877
@ -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 = {
|
||||||
|
@ -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,76 +15,34 @@ export const modularWeaponSaleController: RequestHandler = async (req, res) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.query.op == "SyncAll") {
|
const today: number = Math.trunc(Date.now() / 86400000);
|
||||||
|
const kitgunIsPrimary: boolean = (today & 1) != 0;
|
||||||
res.json({
|
res.json({
|
||||||
SaleInfos: getSaleInfos(partTypeToParts, Math.trunc(Date.now() / 86400000))
|
SaleInfos: [
|
||||||
});
|
|
||||||
} else if (req.query.op == "Purchase") {
|
|
||||||
const accountId = await getAccountIdForRequest(req);
|
|
||||||
const inventory = await getInventory(accountId);
|
|
||||||
const payload = getJSONfromString<IModularWeaponPurchaseRequest>(String(req.body));
|
|
||||||
const weaponInfo = getSaleInfos(partTypeToParts, payload.Revision).find(x => x.Name == payload.SaleName)!
|
|
||||||
.Weapons[payload.ItemIndex];
|
|
||||||
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),
|
|
||||||
...updateCurrency(inventory, weaponInfo.PremiumPrice, true)
|
|
||||||
};
|
|
||||||
await inventory.save();
|
|
||||||
res.json({
|
|
||||||
InventoryChanges: inventoryChanges
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
throw new Error(`unknown modularWeaponSale op: ${String(req.query.op)}`);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const getSaleInfos = (partTypeToParts: Record<string, string[]>, day: number): IModularWeaponSaleInfo[] => {
|
|
||||||
const kitgunIsPrimary: boolean = (day & 1) != 0;
|
|
||||||
return [
|
|
||||||
getModularWeaponSale(
|
getModularWeaponSale(
|
||||||
partTypeToParts,
|
partTypeToParts,
|
||||||
day,
|
today,
|
||||||
"Ostron",
|
"Ostron",
|
||||||
["LWPT_HILT", "LWPT_BLADE", "LWPT_HILT_WEIGHT"],
|
["LWPT_HILT", "LWPT_BLADE", "LWPT_HILT_WEIGHT"],
|
||||||
() => "/Lotus/Weapons/Ostron/Melee/LotusModularWeapon"
|
() => "/Lotus/Weapons/Ostron/Melee/LotusModularWeapon"
|
||||||
),
|
),
|
||||||
getModularWeaponSale(
|
getModularWeaponSale(
|
||||||
partTypeToParts,
|
partTypeToParts,
|
||||||
day,
|
today,
|
||||||
"SolarisUnitedHoverboard",
|
"SolarisUnitedHoverboard",
|
||||||
["LWPT_HB_DECK", "LWPT_HB_ENGINE", "LWPT_HB_FRONT", "LWPT_HB_JET"],
|
["LWPT_HB_DECK", "LWPT_HB_ENGINE", "LWPT_HB_FRONT", "LWPT_HB_JET"],
|
||||||
() => "/Lotus/Types/Vehicles/Hoverboard/HoverboardSuit"
|
() => "/Lotus/Types/Vehicles/Hoverboard/HoverboardSuit"
|
||||||
),
|
),
|
||||||
getModularWeaponSale(
|
getModularWeaponSale(
|
||||||
partTypeToParts,
|
partTypeToParts,
|
||||||
day,
|
today,
|
||||||
"SolarisUnitedMoaPet",
|
"SolarisUnitedMoaPet",
|
||||||
["LWPT_MOA_LEG", "LWPT_MOA_HEAD", "LWPT_MOA_ENGINE", "LWPT_MOA_PAYLOAD"],
|
["LWPT_MOA_LEG", "LWPT_MOA_HEAD", "LWPT_MOA_ENGINE", "LWPT_MOA_PAYLOAD"],
|
||||||
() => "/Lotus/Types/Friendly/Pets/MoaPets/MoaPetPowerSuit"
|
() => "/Lotus/Types/Friendly/Pets/MoaPets/MoaPetPowerSuit"
|
||||||
),
|
),
|
||||||
getModularWeaponSale(
|
getModularWeaponSale(
|
||||||
partTypeToParts,
|
partTypeToParts,
|
||||||
day,
|
today,
|
||||||
"SolarisUnitedKitGun",
|
"SolarisUnitedKitGun",
|
||||||
[
|
[
|
||||||
kitgunIsPrimary ? "LWPT_GUN_PRIMARY_HANDLE" : "LWPT_GUN_SECONDARY_HANDLE",
|
kitgunIsPrimary ? "LWPT_GUN_PRIMARY_HANDLE" : "LWPT_GUN_SECONDARY_HANDLE",
|
||||||
@ -122,7 +67,8 @@ const getSaleInfos = (partTypeToParts: Record<string, string[]>, day: number): I
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
];
|
]
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
@ -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"
|
|
||||||
};
|
|
@ -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);
|
||||||
|
@ -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;
|
|
||||||
};
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user