auto trade and auto bandit
This commit is contained in:
@@ -313,6 +313,75 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Bandit Camp Panel -->
|
||||
<div class="panel">
|
||||
<h2>🏕️ Αυτόματο Bandit Camp</h2>
|
||||
<p style="font-size:0.85rem;color:#888;margin-bottom:1rem;">
|
||||
Το bot επιτίθεται αυτόματα στο στρατόπεδο ληστών και διεκδικεί αμοιβές.<br>
|
||||
Ελέγχει κάθε <strong>12–22 λεπτά</strong> (τυχαίο) — ανθρώπινος ρυθμός.
|
||||
</p>
|
||||
|
||||
<div class="toggle-row" style="margin-bottom:1rem;">
|
||||
<span class="toggle-label">Αυτόματη Επίθεση</span>
|
||||
<label class="toggle">
|
||||
<input type="checkbox" id="bootcamp-enabled">
|
||||
<span class="slider"></span>
|
||||
</label>
|
||||
<span style="color:#888;font-size:0.85rem;" id="bootcamp-hint">Ανενεργό</span>
|
||||
</div>
|
||||
|
||||
<div class="toggle-row" style="margin-bottom:1.5rem;">
|
||||
<span class="toggle-label">Συμπ. Αμυντικές Μονάδες (Σπαθ/Τοξ)</span>
|
||||
<label class="toggle">
|
||||
<input type="checkbox" id="bootcamp-use-def">
|
||||
<span class="slider"></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button class="save-btn" onclick="saveBotSettings()">💾 Αποθήκευση</button>
|
||||
<span class="save-status" id="bot-save-status">✓ Αποθηκεύτηκε</span>
|
||||
|
||||
<h3 style="margin-top:1.5rem;font-size:0.9rem;color:#aaa;">📋 Ιστορικό</h3>
|
||||
<div id="bootcamp-log" style="background:#0a1520;border:1px solid #1a3040;border-radius:8px;padding:10px;max-height:180px;overflow-y:auto;font-size:0.78rem;font-family:monospace;color:#8ab4d0;">
|
||||
<span style="color:#444;">Αναμονή δεδομένων...</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Rural Trade Panel -->
|
||||
<div class="panel">
|
||||
<h2>🔄 Αυτόματο Trade Χωριών</h2>
|
||||
<p style="font-size:0.85rem;color:#888;margin-bottom:1rem;">
|
||||
Ενεργοποιείται <strong>μόνο όταν μια κατασκευή κολλάει λόγω πόρων</strong>.<br>
|
||||
Ψάχνει χωριά στο νησί που προσφέρουν τον ελλείποντα πόρο και κάνει trade.<br>
|
||||
Ελέγχει κάθε <strong>25–45 λεπτά</strong> (τυχαίο).
|
||||
</p>
|
||||
|
||||
<div class="toggle-row" style="margin-bottom:1rem;">
|
||||
<span class="toggle-label">Αυτόματο Trade</span>
|
||||
<label class="toggle">
|
||||
<input type="checkbox" id="rural-trade-enabled">
|
||||
<span class="slider"></span>
|
||||
</label>
|
||||
<span style="color:#888;font-size:0.85rem;" id="rural-trade-hint">Ανενεργό</span>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom:0.75rem;font-size:0.85rem;color:#888;">Ελάχιστο Ratio Trade (τιμή χωριού):</div>
|
||||
<div class="option-grid" style="margin-bottom:1.5rem;">
|
||||
<button class="option-btn" data-ratio="1" onclick="selectRatio(1)"><span class="opt-time">0.25</span><span class="opt-name">Ελάχ.</span></button>
|
||||
<button class="option-btn" data-ratio="2" onclick="selectRatio(2)"><span class="opt-time">0.50</span><span class="opt-name">Χαμηλό</span></button>
|
||||
<button class="option-btn selected" data-ratio="3" onclick="selectRatio(3)"><span class="opt-time">0.75</span><span class="opt-name">Κανον.</span></button>
|
||||
<button class="option-btn" data-ratio="4" onclick="selectRatio(4)"><span class="opt-time">1.00</span><span class="opt-name">Υψηλό</span></button>
|
||||
<button class="option-btn" data-ratio="5" onclick="selectRatio(5)"><span class="opt-time">1.25</span><span class="opt-name">Μέγιστο</span></button>
|
||||
</div>
|
||||
|
||||
<button class="save-btn" onclick="saveBotSettings()">💾 Αποθήκευση</button>
|
||||
|
||||
<h3 style="margin-top:1.5rem;font-size:0.9rem;color:#aaa;">📋 Ιστορικό</h3>
|
||||
<div id="rural-trade-log" style="background:#0a1520;border:1px solid #1a3040;border-radius:8px;padding:10px;max-height:180px;overflow-y:auto;font-size:0.78rem;font-family:monospace;color:#8ab4d0;">
|
||||
<span style="color:#444;">Αναμονή δεδομένων...</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Farm Status Table -->
|
||||
<div class="panel">
|
||||
<h2>🏘️ Κατάσταση Χωριών</h2>
|
||||
@@ -334,6 +403,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
const PLAYER_ID = '{{ player_id }}';
|
||||
let selectedOption = 1;
|
||||
@@ -539,14 +609,92 @@
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
// ── Bot Settings (Bootcamp + Rural Trade) ─────────────────────
|
||||
let selectedRatio = 3;
|
||||
|
||||
function selectRatio(n) {
|
||||
selectedRatio = n;
|
||||
document.querySelectorAll('[data-ratio]').forEach(b => {
|
||||
b.classList.toggle('selected', parseInt(b.dataset.ratio) === n);
|
||||
});
|
||||
}
|
||||
|
||||
function loadBotSettings() {
|
||||
fetch(`/dashboard/bot-settings?player_id=${PLAYER_ID}`)
|
||||
.then(r => r.json())
|
||||
.then(cfg => {
|
||||
document.getElementById('bootcamp-enabled').checked = !!cfg.bootcamp_enabled;
|
||||
document.getElementById('bootcamp-hint').textContent = cfg.bootcamp_enabled ? '🟢 Ενεργό' : 'Ανενεργό';
|
||||
document.getElementById('bootcamp-use-def').checked = !!cfg.bootcamp_use_def;
|
||||
document.getElementById('rural-trade-enabled').checked = !!cfg.rural_trade_enabled;
|
||||
document.getElementById('rural-trade-hint').textContent = cfg.rural_trade_enabled ? '🟢 Ενεργό' : 'Ανενεργό';
|
||||
selectRatio(cfg.rural_trade_ratio || 3);
|
||||
});
|
||||
}
|
||||
|
||||
function saveBotSettings() {
|
||||
fetch('/dashboard/bot-settings', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
player_id: PLAYER_ID,
|
||||
bootcamp_enabled: document.getElementById('bootcamp-enabled').checked,
|
||||
bootcamp_use_def: document.getElementById('bootcamp-use-def').checked,
|
||||
rural_trade_enabled: document.getElementById('rural-trade-enabled').checked,
|
||||
rural_trade_ratio: selectedRatio
|
||||
})
|
||||
}).then(r => r.json()).then(() => {
|
||||
// Update hints
|
||||
document.getElementById('bootcamp-hint').textContent =
|
||||
document.getElementById('bootcamp-enabled').checked ? '🟢 Ενεργό' : 'Ανενεργό';
|
||||
document.getElementById('rural-trade-hint').textContent =
|
||||
document.getElementById('rural-trade-enabled').checked ? '🟢 Ενεργό' : 'Ανενεργό';
|
||||
const s = document.getElementById('bot-save-status');
|
||||
s.classList.add('visible');
|
||||
setTimeout(() => s.classList.remove('visible'), 2500);
|
||||
});
|
||||
}
|
||||
|
||||
// Wire toggle hints live
|
||||
document.getElementById('bootcamp-enabled').addEventListener('change', function() {
|
||||
document.getElementById('bootcamp-hint').textContent = this.checked ? '🟢 Ενεργό' : 'Ανενεργό';
|
||||
});
|
||||
document.getElementById('rural-trade-enabled').addEventListener('change', function() {
|
||||
document.getElementById('rural-trade-hint').textContent = this.checked ? '🟢 Ενεργό' : 'Ανενεργό';
|
||||
});
|
||||
|
||||
// ── Bot Logs ───────────────────────────────────────────────────
|
||||
function renderBotLog(containerId, entries) {
|
||||
const el = document.getElementById(containerId);
|
||||
if (!entries || entries.length === 0) {
|
||||
el.innerHTML = '<span style="color:#444;">Δεν υπάρχουν εγγραφές ακόμη.</span>';
|
||||
return;
|
||||
}
|
||||
el.innerHTML = entries.map(e => {
|
||||
const t = new Date(e.created_at + 'Z').toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false });
|
||||
return `<div><span style="color:#3a6a8a;">[${t}]</span> ${e.message}</div>`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function loadBotLogs() {
|
||||
fetch(`/dashboard/bot-logs?player_id=${PLAYER_ID}&feature=bootcamp`)
|
||||
.then(r => r.json()).then(data => renderBotLog('bootcamp-log', data));
|
||||
fetch(`/dashboard/bot-logs?player_id=${PLAYER_ID}&feature=rural_trade`)
|
||||
.then(r => r.json()).then(data => renderBotLog('rural-trade-log', data));
|
||||
}
|
||||
|
||||
// -- Boot --
|
||||
loadSettings();
|
||||
loadBotSettings();
|
||||
loadFarmData();
|
||||
loadBotLogs();
|
||||
checkOnline();
|
||||
checkWarehouseStatus();
|
||||
setInterval(loadFarmData, 15000);
|
||||
setInterval(checkOnline, 20000);
|
||||
setInterval(loadFarmData, 15000);
|
||||
setInterval(loadBotLogs, 15000);
|
||||
setInterval(checkOnline, 20000);
|
||||
setInterval(checkWarehouseStatus, 20000);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user