返回提交历史
Added
src/controllers/api/modularWeaponCraftingController.ts
+55
-0
Modified
src/controllers/custom/getItemListsController.ts
+3
-1
Modified
src/models/inventoryModels/inventoryModel.ts
+1
-0
Modified
src/routes/api.ts
+2
-0
Modified
src/services/inventoryService.ts
+9
-6
Modified
static/webui/script.js
+5
-1
XFEstudio/XFESpaceNinjaServer
feat: modular weapon crafting (#317)
aec6a964
代码差异
6 个文件
+75
-8
@@ -0,0 +1,55 @@
1
import { RequestHandler } from "express";
2
import { getAccountIdForRequest } from "@/src/services/loginService";
3
import { getJSONfromString } from "@/src/helpers/stringHelpers";
4
import { WeaponTypeInternal } from "@/src/services/itemDataService";
5
import { getInventory, updateCurrency, addWeapon, addMiscItems } from "@/src/services/inventoryService";
6
7
const modularWeaponTypes: Record<string, WeaponTypeInternal> = {
8
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryBeam": "LongGuns",
9
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondary": "Pistols",
10
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryBeam": "Pistols",
11
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryShotgun": "Pistols",
12
"/Lotus/Weapons/Ostron/Melee/LotusModularWeapon": "Melee",
13
"/Lotus/Weapons/Sentients/OperatorAmplifiers/OperatorAmpWeapon": "OperatorAmps"
14
};
15
16
interface IModularCraftRequest {
17
WeaponType: string;
18
Parts: string[];
19
}
20
21
export const modularWeaponCraftingController: RequestHandler = async (req, res) => {
22
const accountId = await getAccountIdForRequest(req);
23
const data: IModularCraftRequest = getJSONfromString(req.body.toString());
24
if (!(data.WeaponType in modularWeaponTypes)) {
25
throw new Error(`unknown modular weapon type: ${data.WeaponType}`);
26
}
27
const category = modularWeaponTypes[data.WeaponType];
28
29
// Give weapon
30
const weapon = await addWeapon(category, data.WeaponType, accountId, data.Parts);
31
32
// Remove 4000 credits
33
const currencyChanges = await updateCurrency(4000, false, accountId);
34
35
// Remove parts
36
const miscItemChanges = [];
37
for (const part of data.Parts) {
38
miscItemChanges.push({
39
ItemType: part,
40
ItemCount: -1
41
});
42
}
43
const inventory = await getInventory(accountId);
44
addMiscItems(inventory, miscItemChanges);
45
await inventory.save();
46
47
// Tell client what we did
48
res.json({
49
InventoryChanges: {
50
...currencyChanges,
51
[category]: [weapon],
52
MiscItems: miscItemChanges
53
}
54
});
55
};
@@ -43,7 +43,9 @@ const getItemListsController: RequestHandler = (_req, res) => {
43
43
item.category == "Misc" ||
44
44
item.category == "Resources" ||
45
45
item.category == "Fish" ||
46
((item as any).productCategory == "Pistols" && (item as MinWeapon).totalDamage == 0)
46
((item as any).productCategory == "Pistols" &&
47
(item as MinWeapon).totalDamage == 0 &&
48
!item.excludeFromCodex) // exclude Zaw Strike PvP variant
47
49
)
48
50
),
49
51
mods,
@@ -921,6 +921,7 @@ type InventoryDocumentProps = {
921
921
LongGuns: Types.DocumentArray<IEquipmentDatabase>;
922
922
Pistols: Types.DocumentArray<IEquipmentDatabase>;
923
923
Melee: Types.DocumentArray<IEquipmentDatabase>;
924
OperatorAmps: Types.DocumentArray<IEquipmentDatabase>;
924
925
FlavourItems: Types.DocumentArray<IFlavourItem>;
925
926
RawUpgrades: Types.DocumentArray<IRawUpgrade>;
926
927
Upgrades: Types.DocumentArray<ICrewShipSalvagedWeaponSkin>;
@@ -56,6 +56,7 @@ import { syndicateSacrificeController } from "../controllers/api/syndicateSacrif
56
56
import { startDojoRecipeController } from "@/src/controllers/api/startDojoRecipeController";
57
57
import { queueDojoComponentDestructionController } from "@/src/controllers/api/queueDojoComponentDestructionController";
58
58
import { nameWeaponController } from "@/src/controllers/api/nameWeaponController";
59
import { modularWeaponCraftingController } from "@/src/controllers/api/modularWeaponCraftingController";
59
60
60
61
const apiRouter = express.Router();
61
62
@@ -122,5 +123,6 @@ apiRouter.post("/guildTech.php", guildTechController);
122
123
apiRouter.post("/syndicateSacrifice.php", syndicateSacrificeController);
123
124
apiRouter.post("/startDojoRecipe.php", startDojoRecipeController);
124
125
apiRouter.post("/nameWeapon.php", nameWeaponController);
126
apiRouter.post("/modularWeaponCrafting.php", modularWeaponCraftingController);
125
127
126
128
export { apiRouter };
@@ -386,20 +386,23 @@ export const syndicateSacrifice = async (
386
386
export const addWeapon = async (
387
387
weaponType: WeaponTypeInternal,
388
388
weaponName: string,
389
accountId: string
389
accountId: string,
390
modularParts: string[] | undefined = undefined
390
391
): Promise<IEquipmentClient> => {
391
392
const inventory = await getInventory(accountId);
392
393
393
394
let weaponIndex;
394
395
switch (weaponType) {
395
396
case "LongGuns":
396
weaponIndex = inventory.LongGuns.push({ ItemType: weaponName, Configs: [], XP: 0 });
397
break;
398
397
case "Pistols":
399
weaponIndex = inventory.Pistols.push({ ItemType: weaponName, Configs: [], XP: 0 });
400
break;
401
398
case "Melee":
402
weaponIndex = inventory.Melee.push({ ItemType: weaponName, Configs: [], XP: 0 });
399
case "OperatorAmps":
400
weaponIndex = inventory[weaponType].push({
401
ItemType: weaponName,
402
Configs: [],
403
XP: 0,
404
ModularParts: modularParts
405
});
403
406
break;
404
407
default:
405
408
throw new Error("unknown weapon type: " + weaponType);
@@ -96,6 +96,10 @@ window.itemListPromise = new Promise(resolve => {
96
96
"/Lotus/Weapons/Tenno/Rifle/LotusRifle": { name: "Rifle" },
97
97
"/Lotus/Weapons/Tenno/Shotgun/LotusShotgun": { name: "Shotgun" },
98
98
// Modular weapons
99
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryBeam": { name: "Kitgun" },
100
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondary": { name: "Kitgun" },
101
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryBeam": { name: "Kitgun" },
102
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryShotgun": { name: "Kitgun" },
99
103
"/Lotus/Weapons/Ostron/Melee/LotusModularWeapon": { name: "Zaw" },
100
104
// Missing in data sources
101
105
"/Lotus/Upgrades/CosmeticEnhancers/Peculiars/CyoteMod": { name: "Traumatic Peculiar" }
@@ -524,7 +528,7 @@ function doAcquireMiscItems() {
524
528
MiscItems: [
525
529
{
526
530
ItemType: uniqueName,
527
ItemCount: $("#miscitem-count").val()
531
ItemCount: parseInt($("#miscitem-count").val())
528
532
}
529
533
]
530
534
})