farm fix between worlds
This commit is contained in:
@@ -122,14 +122,22 @@ def set_farm_settings():
|
|||||||
@dashboard.route('/dashboard/farm-data', methods=['GET'])
|
@dashboard.route('/dashboard/farm-data', methods=['GET'])
|
||||||
def get_farm_data():
|
def get_farm_data():
|
||||||
player_id = request.args.get('player_id')
|
player_id = request.args.get('player_id')
|
||||||
|
world_id = request.args.get('world_id')
|
||||||
conn = get_db()
|
conn = get_db()
|
||||||
|
if world_id:
|
||||||
|
rows = conn.execute(
|
||||||
|
'SELECT town_id, town_name, data FROM town_state WHERE player_id = ? AND world_id = ?',
|
||||||
|
(player_id, world_id)
|
||||||
|
).fetchall()
|
||||||
|
else:
|
||||||
rows = conn.execute(
|
rows = conn.execute(
|
||||||
'SELECT town_id, town_name, data FROM town_state WHERE player_id = ?', (player_id,)
|
'SELECT town_id, town_name, data FROM town_state WHERE player_id = ?', (player_id,)
|
||||||
).fetchall()
|
).fetchall()
|
||||||
|
|
||||||
# Also fetch when the bot last farmed
|
# Also fetch when the bot last farmed (per world)
|
||||||
|
lf_key = f'last_farmed_{player_id}_{world_id}' if world_id else f'last_farmed_{player_id}'
|
||||||
lf_row = conn.execute(
|
lf_row = conn.execute(
|
||||||
"SELECT value FROM kv_store WHERE key = ?", (f'last_farmed_{player_id}',)
|
"SELECT value FROM kv_store WHERE key = ?", (lf_key,)
|
||||||
).fetchone()
|
).fetchone()
|
||||||
last_farmed_at = lf_row['value'] if lf_row else None
|
last_farmed_at = lf_row['value'] if lf_row else None
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|||||||
@@ -233,7 +233,7 @@
|
|||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="topbar">
|
<div class="topbar">
|
||||||
<a href="/player/{{ player_id }}">← Πίσω</a>
|
<a href="/player/{{ player_id }}/{{ world_id }}">← Πίσω</a>
|
||||||
<h1>🌾 Farm Manager</h1>
|
<h1>🌾 Farm Manager</h1>
|
||||||
<span class="online-dot" id="online-dot" title="Κατάσταση Script"></span>
|
<span class="online-dot" id="online-dot" title="Κατάσταση Script"></span>
|
||||||
<button class="sync-btn" onclick="requestSync()">Live Sync</button>
|
<button class="sync-btn" onclick="requestSync()">Live Sync</button>
|
||||||
@@ -411,6 +411,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
const PLAYER_ID = '{{ player_id }}';
|
const PLAYER_ID = '{{ player_id }}';
|
||||||
|
const WORLD_ID = '{{ world_id }}';
|
||||||
let selectedOption = 1;
|
let selectedOption = 1;
|
||||||
|
|
||||||
// -- Loot option buttons --
|
// -- Loot option buttons --
|
||||||
@@ -480,7 +481,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function loadFarmData() {
|
function loadFarmData() {
|
||||||
fetch(`/dashboard/farm-data?player_id=${PLAYER_ID}`)
|
fetch(`/dashboard/farm-data?player_id=${PLAYER_ID}&world_id=${WORLD_ID}`)
|
||||||
.then(r => r.json())
|
.then(r => r.json())
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
const data = resp.towns || [];
|
const data = resp.towns || [];
|
||||||
|
|||||||
Reference in New Issue
Block a user