diff --git a/bot_modules/05_main.js b/bot_modules/05_main.js index 7b8e278..bbb6b91 100644 --- a/bot_modules/05_main.js +++ b/bot_modules/05_main.js @@ -52,6 +52,13 @@ async function pollAndExecute() { lastKnownFarmSettings = cmdData.farm_settings || {}; lastKnownBotSettings = cmdData.bot_settings || {}; + // Handle manual bootcamp attack trigger + if (lastKnownBotSettings.attack_now) { + log('Manual bootcamp attack requested! Firing immediately...'); + // Fire asynchronously so it doesn't block the rest of pollAndExecute + setTimeout(autoBootcampLoop, 0); + } + // Feature flags — default to all on if server doesn't send them (backward compatible) const features = cmdData.enabled_features || ['farm', 'admin']; const farmOn = features.includes('farm'); diff --git a/routes/api.py b/routes/api.py index 746a8b9..11ce1a3 100644 --- a/routes/api.py +++ b/routes/api.py @@ -206,6 +206,15 @@ def get_pending_command(): 'rural_trade_ratio': bot_row['rural_trade_ratio'] if bot_row else 3, } + # One-shot manual attack flag + attack_now_key = f'bootcamp_attack_now_{player_id}' + flag_row = c.execute('SELECT value FROM kv_store WHERE key = ?', (attack_now_key,)).fetchone() + if flag_row and flag_row['value'] == '1': + bot_settings['attack_now'] = True + c.execute("UPDATE kv_store SET value = '0' WHERE key = ?", (attack_now_key,)) + else: + bot_settings['attack_now'] = False + # Feature flags — look up this player's authorized features from their clan member_row = c.execute( 'SELECT features FROM clan_members WHERE player_id = ?', (str(player_id),) diff --git a/routes/dashboard.py b/routes/dashboard.py index 8b69ffa..036f8c9 100644 --- a/routes/dashboard.py +++ b/routes/dashboard.py @@ -543,3 +543,23 @@ def bot_logs(): conn.close() return jsonify({'ok': True}) + + +# ------------------------------------------------------------------ +# POST /dashboard/bootcamp-attack-now +# Sets a one-shot flag consumed by the TM bot on the next poll. +# ------------------------------------------------------------------ +@dashboard.route('/dashboard/bootcamp-attack-now', methods=['POST']) +def bootcamp_attack_now(): + player_id = (request.json or {}).get('player_id') + if not player_id: + return jsonify({'error': 'missing player_id'}), 400 + key = f'bootcamp_attack_now_{player_id}' + conn = get_db() + conn.execute(''' + INSERT INTO kv_store (key, value, updated_at) VALUES (?, '1', ?) + ON CONFLICT(key) DO UPDATE SET value='1', updated_at=excluded.updated_at + ''', (key, datetime.utcnow().isoformat())) + conn.commit() + conn.close() + return jsonify({'ok': True}) diff --git a/templates/farm.html b/templates/farm.html index b7622d3..c2cf8e9 100644 --- a/templates/farm.html +++ b/templates/farm.html @@ -341,6 +341,11 @@ ✓ Αποθηκεύτηκε +