fix 1
This commit is contained in:
@@ -480,6 +480,11 @@
|
||||
const isLocked = status === 0;
|
||||
const action = isLocked ? 'unlock' : 'upgrade';
|
||||
|
||||
const requestedAction = cmd.payload?.action_type;
|
||||
if (requestedAction && requestedAction !== action) {
|
||||
skipped++; continue;
|
||||
}
|
||||
|
||||
log(`Farm ${action}: farm_id=${farm.attributes.id} level=${level} town=${town_id}`);
|
||||
try {
|
||||
uw.gpAjax.ajaxPost('frontend_bridge', 'execute', {
|
||||
|
||||
@@ -292,8 +292,13 @@
|
||||
<input type="number" id="kp-threshold" class="input-field" value="0" min="0" step="10">
|
||||
</div>
|
||||
|
||||
<button class="save-btn" id="upgrade-btn" onclick="triggerUpgrade()">🚀 Ξεκλείδωμα & Αναβάθμιση Τώρα</button>
|
||||
<div style="display: flex; gap: 1rem;">
|
||||
<button class="save-btn" id="unlock-btn" onclick="triggerUpgrade('unlock')" style="flex: 1; background: linear-gradient(135deg, #7a5c2a, #cca04a);">🔓 Μόνο Ξεκλείδωμα</button>
|
||||
<button class="save-btn" id="upgrade-btn" onclick="triggerUpgrade('upgrade')" style="flex: 1;">🚀 Μόνο Αναβάθμιση</button>
|
||||
</div>
|
||||
<div style="margin-top: 10px;">
|
||||
<span class="save-status" id="upgrade-status">Εντολή εστάλη!</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Farm Status Table -->
|
||||
@@ -426,17 +431,30 @@
|
||||
|
||||
// -- Live Sync --
|
||||
function requestSync() {
|
||||
const btn = document.querySelector('.sync-btn');
|
||||
const originalText = btn.innerText;
|
||||
btn.innerText = '⏳ Syncing...';
|
||||
btn.disabled = true;
|
||||
|
||||
fetch(`/api/sync-request?player_id=${PLAYER_ID}`, { method: 'POST' })
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
// Will get a fast state update
|
||||
setTimeout(loadFarmData, 1500);
|
||||
setTimeout(() => {
|
||||
loadFarmData();
|
||||
btn.innerText = originalText;
|
||||
btn.disabled = false;
|
||||
}, 1500);
|
||||
});
|
||||
}
|
||||
|
||||
// -- Trigger Upgrade --
|
||||
function triggerUpgrade() {
|
||||
// -- Trigger Upgrade / Unlock --
|
||||
function triggerUpgrade(actionType) {
|
||||
const threshold = document.getElementById('kp-threshold').value;
|
||||
const btn = actionType === 'unlock' ? document.getElementById('unlock-btn') : document.getElementById('upgrade-btn');
|
||||
const originalText = btn.innerText;
|
||||
btn.innerText = '⏳ Αποστολή...';
|
||||
btn.disabled = true;
|
||||
|
||||
fetch('/dashboard/commands', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@@ -444,11 +462,13 @@
|
||||
player_id: PLAYER_ID,
|
||||
town_id: 0,
|
||||
type: 'farm_upgrade',
|
||||
payload: { threshold: threshold }
|
||||
payload: { threshold: threshold, action_type: actionType }
|
||||
})
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(() => {
|
||||
btn.innerText = originalText;
|
||||
btn.disabled = false;
|
||||
const s = document.getElementById('upgrade-status');
|
||||
s.classList.add('visible');
|
||||
setTimeout(() => s.classList.remove('visible'), 3000);
|
||||
|
||||
Reference in New Issue
Block a user