forked from OpenWF/SpaceNinjaServer
		
	feat(webui): "add maxed" for mods (#2387)
Closes #2382 Reviewed-on: OpenWF/SpaceNinjaServer#2387 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									aa6191f033
								
							
						
					
					
						commit
						8c85cdcd1d
					
				@ -7,7 +7,7 @@ export const addItemsController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
    const requests = req.body as IAddItemRequest[];
 | 
					    const requests = req.body as IAddItemRequest[];
 | 
				
			||||||
    const inventory = await getInventory(accountId);
 | 
					    const inventory = await getInventory(accountId);
 | 
				
			||||||
    for (const request of requests) {
 | 
					    for (const request of requests) {
 | 
				
			||||||
        await addItem(inventory, request.ItemType, request.ItemCount, true, undefined, undefined, true);
 | 
					        await addItem(inventory, request.ItemType, request.ItemCount, true, undefined, request.Fingerprint, true);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    await inventory.save();
 | 
					    await inventory.save();
 | 
				
			||||||
    res.end();
 | 
					    res.end();
 | 
				
			||||||
@ -16,4 +16,5 @@ export const addItemsController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
interface IAddItemRequest {
 | 
					interface IAddItemRequest {
 | 
				
			||||||
    ItemType: string;
 | 
					    ItemType: string;
 | 
				
			||||||
    ItemCount: number;
 | 
					    ItemCount: number;
 | 
				
			||||||
 | 
					    Fingerprint?: string;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -483,6 +483,16 @@ export const addItem = async (
 | 
				
			|||||||
        return addCustomization(inventory, typeName);
 | 
					        return addCustomization(inventory, typeName);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (typeName in ExportUpgrades || typeName in ExportArcanes) {
 | 
					    if (typeName in ExportUpgrades || typeName in ExportArcanes) {
 | 
				
			||||||
 | 
					        if (targetFingerprint) {
 | 
				
			||||||
 | 
					            if (quantity != 1) {
 | 
				
			||||||
 | 
					                logger.warn(`adding 1 of ${typeName} ${targetFingerprint} even tho quantity ${quantity} was requested`);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            inventory.Upgrades.push({
 | 
				
			||||||
 | 
					                ItemType: typeName,
 | 
				
			||||||
 | 
					                UpgradeFingerprint: targetFingerprint
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            return {}; // there's not exactly a common "InventoryChanges" format for these
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        const changes = [
 | 
					        const changes = [
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                ItemType: typeName,
 | 
					                ItemType: typeName,
 | 
				
			||||||
 | 
				
			|||||||
@ -527,6 +527,7 @@
 | 
				
			|||||||
                                <form class="input-group mb-3" onsubmit="doAcquireMod();return false;">
 | 
					                                <form class="input-group mb-3" onsubmit="doAcquireMod();return false;">
 | 
				
			||||||
                                    <input class="form-control" id="mod-count" type="number" value="1"/>
 | 
					                                    <input class="form-control" id="mod-count" type="number" value="1"/>
 | 
				
			||||||
                                    <input class="form-control w-50" id="mod-to-acquire" list="datalist-mods" />
 | 
					                                    <input class="form-control w-50" id="mod-to-acquire" list="datalist-mods" />
 | 
				
			||||||
 | 
					                                    <button class="btn btn-success" onclick="window.maxed=true" type="submit" data-loc="mods_addMax"></button>
 | 
				
			||||||
                                    <button class="btn btn-primary" type="submit" data-loc="general_addButton"></button>
 | 
					                                    <button class="btn btn-primary" type="submit" data-loc="general_addButton"></button>
 | 
				
			||||||
                                </form>
 | 
					                                </form>
 | 
				
			||||||
                                <table class="table table-hover w-100">
 | 
					                                <table class="table table-hover w-100">
 | 
				
			||||||
 | 
				
			|||||||
@ -1873,6 +1873,8 @@ function setFingerprint(ItemType, ItemId, fingerprint) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function doAcquireMod() {
 | 
					function doAcquireMod() {
 | 
				
			||||||
 | 
					    const maxed = !!window.maxed;
 | 
				
			||||||
 | 
					    window.maxed = false;
 | 
				
			||||||
    const uniqueName = getKey(document.getElementById("mod-to-acquire"));
 | 
					    const uniqueName = getKey(document.getElementById("mod-to-acquire"));
 | 
				
			||||||
    if (!uniqueName) {
 | 
					    if (!uniqueName) {
 | 
				
			||||||
        $("#mod-to-acquire").addClass("is-invalid").focus();
 | 
					        $("#mod-to-acquire").addClass("is-invalid").focus();
 | 
				
			||||||
@ -1880,14 +1882,15 @@ function doAcquireMod() {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    const count = parseInt($("#mod-count").val());
 | 
					    const count = parseInt($("#mod-count").val());
 | 
				
			||||||
    if (count != 0) {
 | 
					    if (count != 0) {
 | 
				
			||||||
        revalidateAuthz().then(() => {
 | 
					        Promise.all([window.itemListPromise, revalidateAuthz()]).then(([itemList]) => {
 | 
				
			||||||
            $.post({
 | 
					            $.post({
 | 
				
			||||||
                url: "/custom/addItems?" + window.authz,
 | 
					                url: "/custom/addItems?" + window.authz,
 | 
				
			||||||
                contentType: "application/json",
 | 
					                contentType: "application/json",
 | 
				
			||||||
                data: JSON.stringify([
 | 
					                data: JSON.stringify([
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        ItemType: uniqueName,
 | 
					                        ItemType: uniqueName,
 | 
				
			||||||
                        ItemCount: count
 | 
					                        ItemCount: count,
 | 
				
			||||||
 | 
					                        Fingerprint: maxed ? JSON.stringify({ lvl: itemList[uniqueName].fusionLimit ?? 5 }) : undefined
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                ])
 | 
					                ])
 | 
				
			||||||
            }).done(function () {
 | 
					            }).done(function () {
 | 
				
			||||||
@ -1902,6 +1905,11 @@ function doAcquireMod() {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function doAcquireModMax() {
 | 
				
			||||||
 | 
					    const uniqueName = getKey(document.getElementById("mod-to-acquire"));
 | 
				
			||||||
 | 
					    alert("doAcquireModMax: " + uniqueName);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const uiConfigs = [...$(".config-form input[id], .config-form select[id]")].map(x => x.id);
 | 
					const uiConfigs = [...$(".config-form input[id], .config-form select[id]")].map(x => x.id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
for (const id of uiConfigs) {
 | 
					for (const id of uiConfigs) {
 | 
				
			||||||
 | 
				
			|||||||
@ -127,6 +127,7 @@ dict = {
 | 
				
			|||||||
    mods_fingerprintHelp: `Benötigst du Hilfe mit dem Fingerabdruck?`,
 | 
					    mods_fingerprintHelp: `Benötigst du Hilfe mit dem Fingerabdruck?`,
 | 
				
			||||||
    mods_rivens: `Rivens`,
 | 
					    mods_rivens: `Rivens`,
 | 
				
			||||||
    mods_mods: `Mods`,
 | 
					    mods_mods: `Mods`,
 | 
				
			||||||
 | 
					    mods_addMax: `[UNTRANSLATED] Add Maxed`,
 | 
				
			||||||
    mods_addMissingUnrankedMods: `Fehlende Mods ohne Rang hinzufügen`,
 | 
					    mods_addMissingUnrankedMods: `Fehlende Mods ohne Rang hinzufügen`,
 | 
				
			||||||
    mods_removeUnranked: `Mods ohne Rang entfernen`,
 | 
					    mods_removeUnranked: `Mods ohne Rang entfernen`,
 | 
				
			||||||
    mods_addMissingMaxRankMods: `Fehlende Mods mit Max. Rang hinzufügen`,
 | 
					    mods_addMissingMaxRankMods: `Fehlende Mods mit Max. Rang hinzufügen`,
 | 
				
			||||||
 | 
				
			|||||||
@ -126,6 +126,7 @@ dict = {
 | 
				
			|||||||
    mods_fingerprintHelp: `Need help with the fingerprint?`,
 | 
					    mods_fingerprintHelp: `Need help with the fingerprint?`,
 | 
				
			||||||
    mods_rivens: `Rivens`,
 | 
					    mods_rivens: `Rivens`,
 | 
				
			||||||
    mods_mods: `Mods`,
 | 
					    mods_mods: `Mods`,
 | 
				
			||||||
 | 
					    mods_addMax: `Add Maxed`,
 | 
				
			||||||
    mods_addMissingUnrankedMods: `Add Missing Unranked Mods`,
 | 
					    mods_addMissingUnrankedMods: `Add Missing Unranked Mods`,
 | 
				
			||||||
    mods_removeUnranked: `Remove Unranked Mods`,
 | 
					    mods_removeUnranked: `Remove Unranked Mods`,
 | 
				
			||||||
    mods_addMissingMaxRankMods: `Add Missing Max Rank Mods`,
 | 
					    mods_addMissingMaxRankMods: `Add Missing Max Rank Mods`,
 | 
				
			||||||
 | 
				
			|||||||
@ -127,6 +127,7 @@ dict = {
 | 
				
			|||||||
    mods_fingerprintHelp: `¿Necesitas ayuda con la huella digital?`,
 | 
					    mods_fingerprintHelp: `¿Necesitas ayuda con la huella digital?`,
 | 
				
			||||||
    mods_rivens: `Agrietados`,
 | 
					    mods_rivens: `Agrietados`,
 | 
				
			||||||
    mods_mods: `Mods`,
 | 
					    mods_mods: `Mods`,
 | 
				
			||||||
 | 
					    mods_addMax: `[UNTRANSLATED] Add Maxed`,
 | 
				
			||||||
    mods_addMissingUnrankedMods: `Agregar mods sin rango faltantes`,
 | 
					    mods_addMissingUnrankedMods: `Agregar mods sin rango faltantes`,
 | 
				
			||||||
    mods_removeUnranked: `Quitar mods sin rango`,
 | 
					    mods_removeUnranked: `Quitar mods sin rango`,
 | 
				
			||||||
    mods_addMissingMaxRankMods: `Agregar mods de rango máximo faltantes`,
 | 
					    mods_addMissingMaxRankMods: `Agregar mods de rango máximo faltantes`,
 | 
				
			||||||
 | 
				
			|||||||
@ -127,6 +127,7 @@ dict = {
 | 
				
			|||||||
    mods_fingerprintHelp: `Besoin d'aide pour l'empreinte ?`,
 | 
					    mods_fingerprintHelp: `Besoin d'aide pour l'empreinte ?`,
 | 
				
			||||||
    mods_rivens: `Rivens`,
 | 
					    mods_rivens: `Rivens`,
 | 
				
			||||||
    mods_mods: `Mods`,
 | 
					    mods_mods: `Mods`,
 | 
				
			||||||
 | 
					    mods_addMax: `[UNTRANSLATED] Add Maxed`,
 | 
				
			||||||
    mods_addMissingUnrankedMods: `Ajouter les mods sans rang manquants`,
 | 
					    mods_addMissingUnrankedMods: `Ajouter les mods sans rang manquants`,
 | 
				
			||||||
    mods_removeUnranked: `Retirer les mods sans rang`,
 | 
					    mods_removeUnranked: `Retirer les mods sans rang`,
 | 
				
			||||||
    mods_addMissingMaxRankMods: `Ajouter les mods niveau max manquants`,
 | 
					    mods_addMissingMaxRankMods: `Ajouter les mods niveau max manquants`,
 | 
				
			||||||
 | 
				
			|||||||
@ -127,6 +127,7 @@ dict = {
 | 
				
			|||||||
    mods_fingerprintHelp: `Нужна помощь с отпечатком?`,
 | 
					    mods_fingerprintHelp: `Нужна помощь с отпечатком?`,
 | 
				
			||||||
    mods_rivens: `Моды Разлома`,
 | 
					    mods_rivens: `Моды Разлома`,
 | 
				
			||||||
    mods_mods: `Моды`,
 | 
					    mods_mods: `Моды`,
 | 
				
			||||||
 | 
					    mods_addMax: `[UNTRANSLATED] Add Maxed`,
 | 
				
			||||||
    mods_addMissingUnrankedMods: `Добавить недостающие моды без ранга`,
 | 
					    mods_addMissingUnrankedMods: `Добавить недостающие моды без ранга`,
 | 
				
			||||||
    mods_removeUnranked: `Удалить моды без ранга`,
 | 
					    mods_removeUnranked: `Удалить моды без ранга`,
 | 
				
			||||||
    mods_addMissingMaxRankMods: `Добавить недостающие моды максимального ранга`,
 | 
					    mods_addMissingMaxRankMods: `Добавить недостающие моды максимального ранга`,
 | 
				
			||||||
 | 
				
			|||||||
@ -127,6 +127,7 @@ dict = {
 | 
				
			|||||||
    mods_fingerprintHelp: `需要印记相关的帮助?`,
 | 
					    mods_fingerprintHelp: `需要印记相关的帮助?`,
 | 
				
			||||||
    mods_rivens: `裂罅MOD`,
 | 
					    mods_rivens: `裂罅MOD`,
 | 
				
			||||||
    mods_mods: `Mods`,
 | 
					    mods_mods: `Mods`,
 | 
				
			||||||
 | 
					    mods_addMax: `[UNTRANSLATED] Add Maxed`,
 | 
				
			||||||
    mods_addMissingUnrankedMods: `添加所有缺失的Mods`,
 | 
					    mods_addMissingUnrankedMods: `添加所有缺失的Mods`,
 | 
				
			||||||
    mods_removeUnranked: `删除所有未升级的Mods`,
 | 
					    mods_removeUnranked: `删除所有未升级的Mods`,
 | 
				
			||||||
    mods_addMissingMaxRankMods: `添加所有缺失的满级Mods`,
 | 
					    mods_addMissingMaxRankMods: `添加所有缺失的满级Mods`,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user