feat(webui): add necramechs #834

Merged
Sainan merged 1 commits from necramechs into main 2025-01-20 03:21:51 -08:00
4 changed files with 48 additions and 18 deletions

View File

@ -1,5 +1,5 @@
import { getAccountIdForRequest } from "@/src/services/loginService";
import { addEquipment, addPowerSuit, getInventory, updateSlots } from "@/src/services/inventoryService";
import { addEquipment, addPowerSuit, addMechSuit, getInventory, updateSlots } from "@/src/services/inventoryService";
import { SlotNames } from "@/src/types/purchaseTypes";
import { InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
import { RequestHandler } from "express";
@ -9,14 +9,17 @@ export const addItemsController: RequestHandler = async (req, res) => {
const requests = req.body as IAddItemRequest[];
const inventory = await getInventory(accountId);
for (const request of requests) {
updateSlots(inventory, productCategoryToSlotName[request.type], 0, 1);
switch (request.type) {
case ItemType.Suits:
updateSlots(inventory, productCategoryToSlotName[request.type], 0, 1);
addPowerSuit(inventory, request.internalName);
break;
case ItemType.MechSuits:
addMechSuit(inventory, request.internalName);
break;
default:
updateSlots(inventory, productCategoryToSlotName[request.type], 0, 1);
addEquipment(inventory, request.type, request.internalName);
break;
}
@ -34,7 +37,8 @@ const productCategoryToSlotName: Record<ItemType, SlotNames> = {
SpaceGuns: InventorySlot.SPACESUITS,
SpaceMelee: InventorySlot.SPACESUITS,
Sentinels: InventorySlot.SENTINELS,
SentinelWeapons: InventorySlot.SENTINELS
SentinelWeapons: InventorySlot.SENTINELS,
MechSuits: InventorySlot.MECHSUITS
};
enum ItemType {
@ -46,7 +50,8 @@ enum ItemType {
SpaceGuns = "SpaceGuns",
SpaceMelee = "SpaceMelee",
SentinelWeapons = "SentinelWeapons",
Sentinels = "Sentinels"
Sentinels = "Sentinels",
MechSuits = "MechSuits"
}
interface IAddItemRequest {

View File

@ -22,6 +22,7 @@ interface ListedItem {
const getItemListsController: RequestHandler = (req, response) => {
const lang = getDict(typeof req.query.lang == "string" ? req.query.lang : "en");
const res: Record<string, ListedItem[]> = {};
res.Suits = [];
res.LongGuns = [];
res.Melee = [];
res.ModularParts = [];
@ -31,10 +32,14 @@ const getItemListsController: RequestHandler = (req, response) => {
res.SpaceGuns = [];
res.SpaceMelee = [];
res.SpaceSuits = [];
res.Suits = [];
res.MechSuits = [];
res.miscitems = [];
for (const [uniqueName, item] of Object.entries(ExportWarframes)) {
if (item.productCategory == "Suits" || item.productCategory == "SpaceSuits") {
if (
item.productCategory == "Suits" ||
item.productCategory == "SpaceSuits" ||
item.productCategory == "MechSuits"
) {
res[item.productCategory].push({
uniqueName,
name: getString(item.name, lang),

View File

@ -201,14 +201,14 @@
</div>
<div class="col-lg-6">
<div class="card mb-3" style="height: 400px;">
<h5 class="card-header">Sentinel Weapons</h5>
<h5 class="card-header">Necramechs</h5>
<div class="card-body overflow-auto">
<form class="input-group mb-3" onsubmit="doAcquireEquipment('SentinelWeapons');return false;">
<input class="form-control" id="acquire-type-SentinelWeapons" list="datalist-SentinelWeapons" />
<form class="input-group mb-3" onsubmit="doAcquireEquipment('MechSuits');return false;">
<input class="form-control" id="acquire-type-MechSuits" list="datalist-MechSuits" />
<button class="btn btn-primary" type="submit">Add</button>
</form>
<table class="table table-hover w-100">
<tbody id="SentinelWeapons-list"></tbody>
<tbody id="MechSuits-list"></tbody>
</table>
</div>
</div>
@ -229,6 +229,20 @@
</div>
</div>
</div>
<div class="col-lg-6">
<div class="card mb-3" style="height: 400px;">
<h5 class="card-header">Sentinel Weapons</h5>
<div class="card-body overflow-auto">
<form class="input-group mb-3" onsubmit="doAcquireEquipment('SentinelWeapons');return false;">
<input class="form-control" id="acquire-type-SentinelWeapons" list="datalist-SentinelWeapons" />
<button class="btn btn-primary" type="submit">Add</button>
</form>
<table class="table table-hover w-100">
<tbody id="SentinelWeapons-list"></tbody>
</table>
</div>
</div>
</div>
</div>
<div class="row g-3">
<div class="col-lg-6">
@ -505,6 +519,7 @@
<datalist id="datalist-SentinelWeapons"></datalist>
<datalist id="datalist-Sentinels"></datalist>
<datalist id="datalist-ModularParts"></datalist>
<datalist id="datalist-MechSuits"></datalist>
<datalist id="datalist-miscitems"></datalist>
<datalist id="datalist-mods">
<option data-key="/Lotus/Upgrades/Mods/Fusers/LegendaryModFuser" value="Legendary Core"></option>

View File

@ -205,7 +205,8 @@ function updateInventory() {
"SpaceMelee",
"SentinelWeapons",
"Hoverboards",
"OperatorAmps"
"OperatorAmps",
"MechSuits"
].forEach(category => {
document.getElementById(category + "-list").innerHTML = "";
data[category].forEach(item => {
@ -230,14 +231,18 @@ function updateInventory() {
const td = document.createElement("td");
td.classList = "text-end";
const maxXP =
category === "Suits" ||
category === "SpaceSuits" ||
category === "Sentinels" ||
category === "Hoverboards"
category == "Suits" ||
category == "SpaceSuits" ||
category == "Sentinels" ||
category == "Hoverboards" ||
category == "MechSuits"
? 1_600_000
: 800_000;
if (item.XP < maxXP) {
if (
item.XP < maxXP &&
category != "MechSuits" // missionInventoryUpdate currently doesn't handle this category
) {
const a = document.createElement("a");
a.href = "#";
a.onclick = function (event) {
@ -260,7 +265,7 @@ function updateInventory() {
}
}
};
a.title = "Make Rank 30";
a.title = "Max Rank";
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>`;
td.appendChild(a);
}