feat(webui): add client cheats and new account cheat "Unlock All Focus Schools" #406
@ -157,7 +157,7 @@
 | 
				
			|||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
            <div data-route="/webui/cheats, /webui/settings" data-title="Cheats | OpenWF WebUI">
 | 
					            <div data-route="/webui/cheats, /webui/settings" data-title="Cheats | OpenWF WebUI">
 | 
				
			||||||
                <div class="row">
 | 
					                <div class="row">
 | 
				
			||||||
                    <div class="col-lg-6">
 | 
					                    <div class="col-lg-4">
 | 
				
			||||||
                        <div class="card mb-4">
 | 
					                        <div class="card mb-4">
 | 
				
			||||||
                            <h5 class="card-header">Server</h5>
 | 
					                            <h5 class="card-header">Server</h5>
 | 
				
			||||||
                            <form class="card-body" onsubmit="doChangeSettings();return false;">
 | 
					                            <form class="card-body" onsubmit="doChangeSettings();return false;">
 | 
				
			||||||
@ -223,7 +223,15 @@
 | 
				
			|||||||
                            </form>
 | 
					                            </form>
 | 
				
			||||||
                        </div>
 | 
					                        </div>
 | 
				
			||||||
                    </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">
 | 
					                        <div class="card mb-4">
 | 
				
			||||||
                            <h5 class="card-header">Client</h5>
 | 
					                            <h5 class="card-header">Client</h5>
 | 
				
			||||||
                            <div id="client-cheats-nok" class="card-body">
 | 
					                            <div id="client-cheats-nok" class="card-body">
 | 
				
			||||||
 | 
				
			|||||||
@ -726,3 +726,54 @@ fetch("http://localhost:61558/ping", { mode: "no-cors" }).then(() => {
 | 
				
			|||||||
        fetch("http://localhost:61558/fov_override?" + this.value);
 | 
					        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();
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	
in general I noticed you like using the do prefix, however I think it doesn't add to the function name.
Just something I personally would change.
I use this prefix for functions that are invoked from the UI as opposed to internal functions. I think it somewhat clarifies expectations.