返回提交历史
Added
src/controllers/api/nameWeaponController.ts
+27
-0
Modified
src/controllers/api/upgradesController.ts
+8
-8
Modified
src/routes/api.ts
+2
-0
Modified
src/types/inventoryTypes/inventoryTypes.ts
+1
-1
Modified
static/webui/script.js
+64
-32
Modified
static/webui/style.css
+7
-0
XFEstudio/XFESpaceNinjaServer
feat: custom item names (#307)
b3794821
代码差异
6 个文件
+109
-41
@@ -0,0 +1,27 @@
1
import { RequestHandler } from "express";
2
import { getAccountIdForRequest } from "@/src/services/loginService";
3
import { getInventory, updateCurrency } from "@/src/services/inventoryService";
4
import { getJSONfromString } from "@/src/helpers/stringHelpers";
5
import { TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
6
7
interface INameWeaponRequest {
8
ItemName: string;
9
}
10
11
export const nameWeaponController: RequestHandler = async (req, res) => {
12
const accountId = await getAccountIdForRequest(req);
13
const inventory = await getInventory(accountId);
14
const body = getJSONfromString(req.body.toString()) as INameWeaponRequest;
15
const item = inventory[req.query.Category as string as TEquipmentKey].find(
16
item => item._id.toString() == (req.query.ItemId as string)
17
)!;
18
if (body.ItemName != "") {
19
item.ItemName = body.ItemName;
20
} else {
21
item.ItemName = undefined;
22
}
23
await inventory.save();
24
res.json({
25
InventoryChanges: await updateCurrency("webui" in req.query ? 0 : 15, true, accountId)
26
});
27
};
@@ -1,7 +1,7 @@
1
1
import { RequestHandler } from "express";
2
2
import { IUpgradesRequest } from "@/src/types/requestTypes";
3
3
import { FocusSchool, IEquipmentDatabase } from "@/src/types/inventoryTypes/commonInventoryTypes";
4
import { IMiscItem, IEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
4
import { IMiscItem, TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
5
5
import { getAccountIdForRequest } from "@/src/services/loginService";
6
6
import { addMiscItems, getInventory, updateCurrency } from "@/src/services/inventoryService";
7
7
@@ -28,7 +28,7 @@ export const upgradesController: RequestHandler = async (req, res) => {
28
28
switch (operation.UpgradeRequirement) {
29
29
case "/Lotus/Types/Items/MiscItems/OrokinReactor":
30
30
case "/Lotus/Types/Items/MiscItems/OrokinCatalyst":
31
for (const item of inventory[payload.ItemCategory as IEquipmentKey] as IEquipmentDatabase[]) {
31
for (const item of inventory[payload.ItemCategory as TEquipmentKey] as IEquipmentDatabase[]) {
32
32
if (item._id.toString() == payload.ItemId.$oid) {
33
33
item.Features ??= 0;
34
34
item.Features |= 1;
@@ -38,7 +38,7 @@ export const upgradesController: RequestHandler = async (req, res) => {
38
38
break;
39
39
case "/Lotus/Types/Items/MiscItems/UtilityUnlocker":
40
40
case "/Lotus/Types/Items/MiscItems/WeaponUtilityUnlocker":
41
for (const item of inventory[payload.ItemCategory as IEquipmentKey] as IEquipmentDatabase[]) {
41
for (const item of inventory[payload.ItemCategory as TEquipmentKey] as IEquipmentDatabase[]) {
42
42
if (item._id.toString() == payload.ItemId.$oid) {
43
43
item.Features ??= 0;
44
44
item.Features |= 2;
@@ -49,7 +49,7 @@ export const upgradesController: RequestHandler = async (req, res) => {
49
49
case "/Lotus/Types/Items/MiscItems/WeaponPrimaryArcaneUnlocker":
50
50
case "/Lotus/Types/Items/MiscItems/WeaponSecondaryArcaneUnlocker":
51
51
case "/Lotus/Types/Items/MiscItems/WeaponMeleeArcaneUnlocker":
52
for (const item of inventory[payload.ItemCategory as IEquipmentKey] as IEquipmentDatabase[]) {
52
for (const item of inventory[payload.ItemCategory as TEquipmentKey] as IEquipmentDatabase[]) {
53
53
if (item._id.toString() == payload.ItemId.$oid) {
54
54
item.Features ??= 0;
55
55
item.Features |= 32;
@@ -61,7 +61,7 @@ export const upgradesController: RequestHandler = async (req, res) => {
61
61
case "/Lotus/Types/Items/MiscItems/FormaUmbra":
62
62
case "/Lotus/Types/Items/MiscItems/FormaAura":
63
63
case "/Lotus/Types/Items/MiscItems/FormaStance":
64
for (const item of inventory[payload.ItemCategory as IEquipmentKey] as IEquipmentDatabase[]) {
64
for (const item of inventory[payload.ItemCategory as TEquipmentKey] as IEquipmentDatabase[]) {
65
65
if (item._id.toString() == payload.ItemId.$oid) {
66
66
item.XP = 0;
67
67
setSlotPolarity(item, operation.PolarizeSlot, operation.PolarizeValue);
@@ -72,7 +72,7 @@ export const upgradesController: RequestHandler = async (req, res) => {
72
72
}
73
73
break;
74
74
case "/Lotus/Types/Items/MiscItems/ModSlotUnlocker":
75
for (const item of inventory[payload.ItemCategory as IEquipmentKey] as IEquipmentDatabase[]) {
75
for (const item of inventory[payload.ItemCategory as TEquipmentKey] as IEquipmentDatabase[]) {
76
76
if (item._id.toString() == payload.ItemId.$oid) {
77
77
item.ModSlotPurchases ??= 0;
78
78
item.ModSlotPurchases += 1;
@@ -87,7 +87,7 @@ export const upgradesController: RequestHandler = async (req, res) => {
87
87
}
88
88
break;
89
89
case "/Lotus/Types/Items/MiscItems/CustomizationSlotUnlocker":
90
for (const item of inventory[payload.ItemCategory as IEquipmentKey] as IEquipmentDatabase[]) {
90
for (const item of inventory[payload.ItemCategory as TEquipmentKey] as IEquipmentDatabase[]) {
91
91
if (item._id.toString() == payload.ItemId.$oid) {
92
92
item.CustomizationSlotPurchases ??= 0;
93
93
item.CustomizationSlotPurchases += 1;
@@ -103,7 +103,7 @@ export const upgradesController: RequestHandler = async (req, res) => {
103
103
break;
104
104
case "":
105
105
console.assert(operation.OperationType == "UOT_SWAP_POLARITY");
106
for (const item of inventory[payload.ItemCategory as IEquipmentKey] as IEquipmentDatabase[]) {
106
for (const item of inventory[payload.ItemCategory as TEquipmentKey] as IEquipmentDatabase[]) {
107
107
if (item._id.toString() == payload.ItemId.$oid) {
108
108
for (let i = 0; i != operation.PolarityRemap.length; ++i) {
109
109
if (operation.PolarityRemap[i].Slot != i) {
@@ -55,6 +55,7 @@ import { getGuildDojoController } from "@/src/controllers/api/getGuildDojoContro
55
55
import { syndicateSacrificeController } from "../controllers/api/syndicateSacrificeController";
56
56
import { startDojoRecipeController } from "@/src/controllers/api/startDojoRecipeController";
57
57
import { queueDojoComponentDestructionController } from "@/src/controllers/api/queueDojoComponentDestructionController";
58
import { nameWeaponController } from "@/src/controllers/api/nameWeaponController";
58
59
59
60
const apiRouter = express.Router();
60
61
@@ -120,5 +121,6 @@ apiRouter.post("/upgrades.php", upgradesController);
120
121
apiRouter.post("/guildTech.php", guildTechController);
121
122
apiRouter.post("/syndicateSacrifice.php", syndicateSacrificeController);
122
123
apiRouter.post("/startDojoRecipe.php", startDojoRecipeController);
124
apiRouter.post("/nameWeapon.php", nameWeaponController);
123
125
124
126
export { apiRouter };
@@ -59,7 +59,7 @@ export interface ITypeCount {
59
59
ItemCount: number;
60
60
}
61
61
62
export type IEquipmentKey =
62
export type TEquipmentKey =
63
63
| "Suits"
64
64
| "LongGuns"
65
65
| "Pistols"
@@ -132,6 +132,9 @@ function updateInventory() {
132
132
{
133
133
const td = document.createElement("td");
134
134
td.textContent = itemMap[item.ItemType]?.name ?? item.ItemType;
135
if (item.ItemName) {
136
td.textContent = item.ItemName + " (" + td.textContent + ")";
137
}
135
138
tr.appendChild(td);
136
139
}
137
140
{
@@ -144,12 +147,21 @@ function updateInventory() {
144
147
event.preventDefault();
145
148
addGearExp("Suits", item.ItemId.$oid, 1_600_000 - item.XP);
146
149
};
147
a.textContent = "Make Rank 30";
150
a.title = "Make Rank 30";
151
a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M214.6 41.4c-12.5-12.5-32.8-12.5-45.3 0l-160 160c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L160 141.2V448c0 17.7 14.3 32 32 32s32-14.3 32-32V141.2L329.4 246.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-160-160z"/></svg>`;
152
td.appendChild(a);
153
}
154
{
155
const a = document.createElement("a");
156
a.href = "#";
157
a.onclick = function (event) {
158
event.preventDefault();
159
const name = prompt("Enter new custom name:");
160
renameGear("Suits", item.ItemId.$oid, name);
161
};
162
a.title = "Rename";
163
a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M0 80V229.5c0 17 6.7 33.3 18.7 45.3l176 176c25 25 65.5 25 90.5 0L418.7 317.3c25-25 25-65.5 0-90.5l-176-176c-12-12-28.3-18.7-45.3-18.7H48C21.5 32 0 53.5 0 80zm112 32a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>`;
148
164
td.appendChild(a);
149
150
const span = document.createElement("span");
151
span.innerHTML = " · ";
152
td.appendChild(span);
153
165
}
154
166
{
155
167
const a = document.createElement("a");
@@ -158,7 +170,8 @@ function updateInventory() {
158
170
event.preventDefault();
159
171
disposeOfGear("Suits", item.ItemId.$oid);
160
172
};
161
a.textContent = "Remove";
173
a.title = "Remove";
174
a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M135.2 17.7L128 32H32C14.3 32 0 46.3 0 64S14.3 96 32 96H416c17.7 0 32-14.3 32-32s-14.3-32-32-32H320l-7.2-14.3C307.4 6.8 296.3 0 284.2 0H163.8c-12.1 0-23.2 6.8-28.6 17.7zM416 128H32L53.2 467c1.6 25.3 22.6 45 47.9 45H346.9c25.3 0 46.3-19.7 47.9-45L416 128z"/></svg>`;
162
175
td.appendChild(a);
163
176
}
164
177
tr.appendChild(td);
@@ -173,6 +186,9 @@ function updateInventory() {
173
186
{
174
187
const td = document.createElement("td");
175
188
td.textContent = itemMap[item.ItemType]?.name ?? item.ItemType;
189
if (item.ItemName) {
190
td.textContent = item.ItemName + " (" + td.textContent + ")";
191
}
176
192
tr.appendChild(td);
177
193
}
178
194
{
@@ -185,12 +201,21 @@ function updateInventory() {
185
201
event.preventDefault();
186
202
addGearExp(category, item.ItemId.$oid, 800_000 - item.XP);
187
203
};
188
a.textContent = "Make Rank 30";
204
a.title = "Make Rank 30";
205
a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M214.6 41.4c-12.5-12.5-32.8-12.5-45.3 0l-160 160c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L160 141.2V448c0 17.7 14.3 32 32 32s32-14.3 32-32V141.2L329.4 246.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-160-160z"/></svg>`;
206
td.appendChild(a);
207
}
208
{
209
const a = document.createElement("a");
210
a.href = "#";
211
a.onclick = function (event) {
212
event.preventDefault();
213
const name = prompt("Enter new custom name:");
214
renameGear(category, item.ItemId.$oid, name);
215
};
216
a.title = "Rename";
217
a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M0 80V229.5c0 17 6.7 33.3 18.7 45.3l176 176c25 25 65.5 25 90.5 0L418.7 317.3c25-25 25-65.5 0-90.5l-176-176c-12-12-28.3-18.7-45.3-18.7H48C21.5 32 0 53.5 0 80zm112 32a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>`;
189
218
td.appendChild(a);
190
191
const span = document.createElement("span");
192
span.innerHTML = " · ";
193
td.appendChild(span);
194
219
}
195
220
{
196
221
const a = document.createElement("a");
@@ -199,7 +224,8 @@ function updateInventory() {
199
224
event.preventDefault();
200
225
disposeOfGear(category, item.ItemId.$oid);
201
226
};
202
a.textContent = "Remove";
227
a.title = "Remove";
228
a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M135.2 17.7L128 32H32C14.3 32 0 46.3 0 64S14.3 96 32 96H416c17.7 0 32-14.3 32-32s-14.3-32-32-32H320l-7.2-14.3C307.4 6.8 296.3 0 284.2 0H163.8c-12.1 0-23.2 6.8-28.6 17.7zM416 128H32L53.2 467c1.6 25.3 22.6 45 47.9 45H346.9c25.3 0 46.3-19.7 47.9-45L416 128z"/></svg>`;
203
229
td.appendChild(a);
204
230
}
205
231
tr.appendChild(td);
@@ -241,14 +267,10 @@ function updateInventory() {
241
267
})
242
268
);
243
269
a.target = "_blank";
244
a.textContent = "View Stats";
270
a.title = "View Stats";
271
a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M160 80c0-26.5 21.5-48 48-48h32c26.5 0 48 21.5 48 48V432c0 26.5-21.5 48-48 48H208c-26.5 0-48-21.5-48-48V80zM0 272c0-26.5 21.5-48 48-48H80c26.5 0 48 21.5 48 48V432c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V272zM368 96h32c26.5 0 48 21.5 48 48V432c0 26.5-21.5 48-48 48H368c-26.5 0-48-21.5-48-48V144c0-26.5 21.5-48 48-48z"/></svg>`;
245
272
td.appendChild(a);
246
273
}
247
{
248
const span = document.createElement("span");
249
span.innerHTML = " · ";
250
td.appendChild(span);
251
}
252
274
{
253
275
const a = document.createElement("a");
254
276
a.href = "#";
@@ -256,7 +278,8 @@ function updateInventory() {
256
278
event.preventDefault();
257
279
disposeOfGear("Upgrades", item.ItemId.$oid);
258
280
};
259
a.textContent = "Remove";
281
a.title = "Remove";
282
a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M135.2 17.7L128 32H32C14.3 32 0 46.3 0 64S14.3 96 32 96H416c17.7 0 32-14.3 32-32s-14.3-32-32-32H320l-7.2-14.3C307.4 6.8 296.3 0 284.2 0H163.8c-12.1 0-23.2 6.8-28.6 17.7zM416 128H32L53.2 467c1.6 25.3 22.6 45 47.9 45H346.9c25.3 0 46.3-19.7 47.9-45L416 128z"/></svg>`;
260
283
td.appendChild(a);
261
284
}
262
285
tr.appendChild(td);
@@ -282,12 +305,9 @@ function updateInventory() {
282
305
event.preventDefault();
283
306
setFingerprint(item.ItemType, item.ItemId, { lvl: maxRank });
284
307
};
285
a.textContent = "Max Rank";
308
a.title = "Max Rank";
309
a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M214.6 41.4c-12.5-12.5-32.8-12.5-45.3 0l-160 160c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L160 141.2V448c0 17.7 14.3 32 32 32s32-14.3 32-32V141.2L329.4 246.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-160-160z"/></svg>`;
286
310
td.appendChild(a);
287
288
const span = document.createElement("span");
289
span.innerHTML = " · ";
290
td.appendChild(span);
291
311
}
292
312
{
293
313
const a = document.createElement("a");
@@ -296,7 +316,8 @@ function updateInventory() {
296
316
event.preventDefault();
297
317
disposeOfGear("Upgrades", item.ItemId.$oid);
298
318
};
299
a.textContent = "Remove";
319
a.title = "Remove";
320
a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M135.2 17.7L128 32H32C14.3 32 0 46.3 0 64S14.3 96 32 96H416c17.7 0 32-14.3 32-32s-14.3-32-32-32H320l-7.2-14.3C307.4 6.8 296.3 0 284.2 0H163.8c-12.1 0-23.2 6.8-28.6 17.7zM416 128H32L53.2 467c1.6 25.3 22.6 45 47.9 45H346.9c25.3 0 46.3-19.7 47.9-45L416 128z"/></svg>`;
300
321
td.appendChild(a);
301
322
}
302
323
tr.appendChild(td);
@@ -327,14 +348,10 @@ function updateInventory() {
327
348
event.preventDefault();
328
349
setFingerprint(item.ItemType, item.LastAdded, { lvl: maxRank });
329
350
};
330
a.textContent = "Max Rank";
351
a.title = "Max Rank";
352
a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M214.6 41.4c-12.5-12.5-32.8-12.5-45.3 0l-160 160c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L160 141.2V448c0 17.7 14.3 32 32 32s32-14.3 32-32V141.2L329.4 246.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-160-160z"/></svg>`;
331
353
td.appendChild(a);
332
354
}
333
{
334
const span = document.createElement("span");
335
span.innerHTML = " · ";
336
td.appendChild(span);
337
}
338
355
{
339
356
const a = document.createElement("a");
340
357
a.href = "#";
@@ -342,7 +359,8 @@ function updateInventory() {
342
359
event.preventDefault();
343
360
disposeOfItems("Upgrades", item.ItemType, item.ItemCount);
344
361
};
345
a.textContent = "Remove";
362
a.title = "Remove";
363
a.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M135.2 17.7L128 32H32C14.3 32 0 46.3 0 64S14.3 96 32 96H416c17.7 0 32-14.3 32-32s-14.3-32-32-32H320l-7.2-14.3C307.4 6.8 296.3 0 284.2 0H163.8c-12.1 0-23.2 6.8-28.6 17.7zM416 128H32L53.2 467c1.6 25.3 22.6 45 47.9 45H346.9c25.3 0 46.3-19.7 47.9-45L416 128z"/></svg>`;
346
364
td.appendChild(a);
347
365
}
348
366
tr.appendChild(td);
@@ -432,6 +450,20 @@ function addGearExp(category, oid, xp) {
432
450
});
433
451
}
434
452
453
function renameGear(category, oid, name) {
454
revalidateAuthz(() => {
455
$.post({
456
url: "/api/nameWeapon.php?" + window.authz + "&Category=" + category + "&ItemId=" + oid + "&webui=1",
457
contentType: "text/plain",
458
data: JSON.stringify({
459
ItemName: name
460
})
461
}).done(function () {
462
updateInventory();
463
});
464
});
465
}
466
435
467
function disposeOfGear(category, oid) {
436
468
const data = {
437
469
SellCurrency: "SC_RegularCredits",
@@ -20,3 +20,10 @@ body:not(.logged-in) .nav-item.dropdown,
20
20
body:not(.logged-in) #refresh-note {
21
21
display: none;
22
22
}
23
24
td.text-end > a > svg {
25
fill: currentColor;
26
height: 1em;
27
margin-left: 0.5em;
28
margin-bottom: 4px; /* to centre the icon */
29
}