Only add missing mods
This commit is contained in:
parent
8c6300d4e2
commit
c2f4176a74
@ -321,7 +321,7 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p><button class="btn btn-primary" onclick="doUnlockAllFocusSchools();">Unlock All Focus Schools</button></p>
|
<p><button class="btn btn-primary" onclick="doUnlockAllFocusSchools();">Unlock All Focus Schools</button></p>
|
||||||
<p><button class="btn btn-primary" onclick="doHelminthUnlockAll();">Fully Level Up Helminth</button></p>
|
<p><button class="btn btn-primary" onclick="doHelminthUnlockAll();">Fully Level Up Helminth</button></p>
|
||||||
<button class="btn btn-primary" onclick="doAddAllMods();">Add All Mods</button>
|
<button class="btn btn-primary" onclick="doAddAllMods();">Add Missing Mods</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1078,32 +1078,39 @@ function doHelminthUnlockAll() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function doAddAllMods() {
|
function doAddAllMods() {
|
||||||
const mods = [];
|
let modsAll = new Set();
|
||||||
for (const child of document.getElementById("datalist-mods").children) {
|
for (const child of document.getElementById("datalist-mods").children) {
|
||||||
mods.push(child.getAttribute("data-key"));
|
modsAll.add(child.getAttribute("data-key"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Batch to avoid PayloadTooLargeError
|
const req = $.get("/api/inventory.php?" + window.authz + "&xpBasedLevelCapDisabled=1");
|
||||||
const batchSize = 500;
|
req.done(data => {
|
||||||
const batches = [];
|
for (const modOwned of data.RawUpgrades) {
|
||||||
for (let i = 0; i < mods.length; i += batchSize) {
|
if (modOwned.ItemCount ?? 1 > 0) {
|
||||||
batches.push(mods.slice(i, i + batchSize));
|
modsAll.delete(modOwned.ItemType);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
batches.forEach(batch => {
|
modsAll = Array.from(modsAll);
|
||||||
revalidateAuthz(() => {
|
const batches = [];
|
||||||
$.post({
|
for (let i = 0; i < modsAll.length; i += 1000) {
|
||||||
url: "/api/missionInventoryUpdate.php?" + window.authz,
|
batches.push(modsAll.slice(i, i + 1000));
|
||||||
contentType: "text/plain",
|
}
|
||||||
data: JSON.stringify({
|
batches.forEach(batch => {
|
||||||
RawUpgrades: batch.map(mod => ({
|
revalidateAuthz(() => {
|
||||||
ItemType: mod,
|
$.post({
|
||||||
ItemCount: 21 // Needed to fully upgrade certain arcanes
|
url: "/api/missionInventoryUpdate.php?" + window.authz,
|
||||||
}))
|
contentType: "text/plain",
|
||||||
})
|
data: JSON.stringify({
|
||||||
}).done(function () {
|
RawUpgrades: batch.map(mod => ({
|
||||||
document.getElementById("mod-to-acquire").value = "";
|
ItemType: mod,
|
||||||
updateInventory();
|
ItemCount: 21 // To fully upgrade certain arcanes
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
}).done(function () {
|
||||||
|
document.getElementById("mod-to-acquire").value = "";
|
||||||
|
updateInventory();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user