MJ: attack coordinator update / various fixes . captcha and back button and jitterloop 2 secs

This commit is contained in:
2026-05-03 12:40:20 +03:00
parent 47381a9304
commit eb31072c87
16 changed files with 1492 additions and 31 deletions

View File

@@ -35,7 +35,17 @@ def index():
''', (clan_id,)).fetchall()
captcha_rows = conn.execute("SELECT key, value FROM kv_store WHERE key LIKE 'captcha_active_%'").fetchall()
active_captchas = {r['key'].replace('captcha_active_', ''): True for r in captcha_rows if r['value'] == '1'}
# Key format is captcha_active_{player_id}_{world_id} — build a (player_id, world_id) → bool map
active_captchas = {}
for r in captcha_rows:
if r['value'] != '1':
continue
parts = r['key'].replace('captcha_active_', '').split('_', 1)
if len(parts) == 2:
active_captchas[(parts[0], parts[1])] = True
else:
# Legacy key (player_id only) — keep working
active_captchas[(parts[0], '')] = True
conn.close()
players = []
@@ -50,14 +60,20 @@ def index():
except Exception:
pass
wid = r['world_id'] or ''
captcha_active = (
active_captchas.get((r['player_id'], wid), False) or
active_captchas.get((r['player_id'], ''), False) # legacy fallback
)
players.append({
'player': r['player'],
'player_id': r['player_id'],
'world_id': r['world_id'] or 'Unknown',
'world_id': wid or 'Unknown',
'is_online': is_online,
'captcha_active': active_captchas.get(r['player_id'], False)
'captcha_active': captcha_active
})
return render_template('index.html', players=players, no_clan=False)
@@ -81,6 +97,11 @@ def player_farm(player_id, world_id):
def player_tracker(player_id, world_id):
return render_template('tracker.html', player_id=player_id, world_id=world_id)
@dashboard.route('/player/<player_id>/<world_id>/attack-planner')
@login_required
def player_attack_planner(player_id, world_id):
return render_template('attack_planner.html', player_id=player_id, world_id=world_id)
# ------------------------------------------------------------------
# GET /dashboard/farm-settings — returns current farm config
@@ -330,16 +351,26 @@ def client_status():
# ------------------------------------------------------------------
@dashboard.route('/dashboard/captcha-status', methods=['GET'])
def captcha_status():
player_id = request.args.get('player_id')
player_id = request.args.get('player_id', '').strip()
world_id = request.args.get('world_id', '').strip()
conn = get_db()
# Try world-specific key first, fall back to legacy player-only key
key = f'captcha_active_{player_id}_{world_id}' if world_id else f'captcha_active_{player_id}'
row = conn.execute(
"SELECT value FROM kv_store WHERE key = ?", (f'captcha_active_{player_id}', )
"SELECT value FROM kv_store WHERE key = ?", (key,)
).fetchone()
if not row and world_id:
# Legacy fallback
row = conn.execute(
"SELECT value FROM kv_store WHERE key = ?",
(f'captcha_active_{player_id}',)
).fetchone()
conn.close()
active = bool(row and row['value'] == '1')
return jsonify({'captcha_active': active})
# ------------------------------------------------------------------
# GET /dashboard/commands/queue
# Returns pending+executing BUILD commands for a specific town,