Add "Account" cheats, with "Unlock All Focus Schools"

This commit is contained in:
Sainan 2024-06-26 05:19:28 +02:00
parent 07af880897
commit eb9b8d5209
2 changed files with 61 additions and 2 deletions

View File

@ -157,7 +157,7 @@
</div>
<div data-route="/webui/cheats, /webui/settings" data-title="Cheats | OpenWF WebUI">
<div class="row">
<div class="col-lg-6">
<div class="col-lg-4">
<div class="card mb-4">
<h5 class="card-header">Server</h5>
<form class="card-body" onsubmit="doChangeSettings();return false;">
@ -223,7 +223,15 @@
</form>
</div>
</div>
<div class="col-lg-6">
<div class="col-lg-4">
<div class="card mb-4">
<h5 class="card-header">Account</h5>
<div class="card-body">
<button class="btn btn-primary" onclick="doUnlockAllFocusSchools();">Unlock All Focus Schools</button>
</div>
</div>
</div>
<div class="col-lg-4">
<div class="card mb-4">
<h5 class="card-header">Client</h5>
<div id="client-cheats-nok" class="card-body">

View File

@ -726,3 +726,54 @@ fetch("http://localhost:61558/ping", { mode: "no-cors" }).then(() => {
fetch("http://localhost:61558/fov_override?" + this.value);
};
});
function doUnlockAllFocusSchools() {
revalidateAuthz(() => {
$.get("/api/inventory.php?" + window.authz + "&xpBasedLevelCapDisabled=1").done(async (data) => {
const missingFocusUpgrades = {
"/Lotus/Upgrades/Focus/Attack/AttackFocusAbility": true,
"/Lotus/Upgrades/Focus/Tactic/TacticFocusAbility": true,
"/Lotus/Upgrades/Focus/Ward/WardFocusAbility": true,
"/Lotus/Upgrades/Focus/Defense/DefenseFocusAbility": true,
"/Lotus/Upgrades/Focus/Power/PowerFocusAbility": true,
};
if (data.FocusUpgrades) {
for (const focusUpgrade of data.FocusUpgrades) {
if (focusUpgrade.ItemType in missingFocusUpgrades) {
delete missingFocusUpgrades[focusUpgrade.ItemType];
}
}
}
for (const upgradeType of Object.keys(missingFocusUpgrades)) {
await unlockFocusSchool(upgradeType);
}
if (Object.keys(missingFocusUpgrades).length == 0) {
alert("All focus schools are already unlocked.");
} else {
alert("Unlocked " + Object.keys(missingFocusUpgrades).length + " new focus schools! An inventory update will be needed for the changes to be reflected in-game. Visiting the navigation should be the easiest way to trigger that.");
}
});
});
}
function unlockFocusSchool(upgradeType) {
return new Promise(resolve => {
// Deselect current FocusAbility so we will be able to unlock the way for free
$.post({
url: "/api/focus.php?" + window.authz + "&op=5",
contentType: "text/plain",
data: "{}"
}).done(function () {
// Unlock the way now
$.post({
url: "/api/focus.php?" + window.authz + "&op=2",
contentType: "text/plain",
data: JSON.stringify({
FocusType: upgradeType
})
}).done(function() {
resolve();
});
});
});
}