From d8ba139d071ddc42c69e1b6b725970fc0106031b Mon Sep 17 00:00:00 2001 From: haunter Date: Sat, 2 May 2026 02:21:32 +0300 Subject: [PATCH] 2 bugs / farm and bandit --- bot_modules/04c_execute_bootcamp_trade.js | 24 ++++++++--------------- bot_modules/05_main.js | 6 ++++-- routes/api.py | 5 ++++- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/bot_modules/04c_execute_bootcamp_trade.js b/bot_modules/04c_execute_bootcamp_trade.js index e16fc5a..7af1666 100644 --- a/bot_modules/04c_execute_bootcamp_trade.js +++ b/bot_modules/04c_execute_bootcamp_trade.js @@ -62,13 +62,17 @@ async function autoBootcampLoop() { const isFavor = reward.power_id?.includes('favor'); const stashable = reward.stashable; - if (isInstant && !isFavor) { + const useReward = () => { uw.gpAjax.ajaxPost('frontend_bridge', 'execute', { model_url: `PlayerAttackSpot/${player_id}`, action_name: 'useReward', arguments: {} }); - await botLog(player_id, world_id, 'bootcamp', 'Διεκδίκηση αμοιβής ληστών...'); + botLog(player_id, world_id, 'bootcamp', `Reward used: ${reward.power_id}`); + }; + + if (isInstant && !isFavor) { + useReward(); } else if (stashable) { uw.gpAjax.ajaxPost('frontend_bridge', 'execute', { model_url: `PlayerAttackSpot/${player_id}`, @@ -78,22 +82,10 @@ async function autoBootcampLoop() { success: () => { botLog(player_id, world_id, 'bootcamp', `Reward stashed: ${reward.power_id}`); }, - error: () => { - uw.gpAjax.ajaxPost('frontend_bridge', 'execute', { - model_url: `PlayerAttackSpot/${player_id}`, - action_name: 'useReward', - arguments: {} - }); - botLog(player_id, world_id, 'bootcamp', 'Αποτυχία διεκδίκησης αμοιβής.'); - } + error: useReward }); } else { - uw.gpAjax.ajaxPost('frontend_bridge', 'execute', { - model_url: `PlayerAttackSpot/${player_id}`, - action_name: 'useReward', - arguments: {} - }); - await botLog(player_id, world_id, 'bootcamp', `Reward used (fallback): ${reward.power_id}`); + useReward(); } await sleep(randInt(3000, 7000)); return; // Wait for next cycle to attack diff --git a/bot_modules/05_main.js b/bot_modules/05_main.js index e60d977..778b274 100644 --- a/bot_modules/05_main.js +++ b/bot_modules/05_main.js @@ -185,7 +185,8 @@ async function autoFarmLoop() { if (allFull) { log('⚠️ Auto-farm: ALL warehouses are full (>95%) — skipping loot this cycle'); try { - await apiFetch(`${BASE_URL}/api/farm_status?player_id=${player_id}`, { + const world_id = uw.Game?.world_id || ''; + await apiFetch(`${BASE_URL}/api/farm_status?player_id=${player_id}&world_id=${world_id}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ warehouse_full: true }) @@ -200,7 +201,8 @@ async function autoFarmLoop() { await executeFarmLoot({ payload: { loot_option: farmSettings.loot_option } }); // Report success so dashboard shows last_farmed_at try { - await apiFetch(`${BASE_URL}/api/farm_status?player_id=${player_id}`, { + const world_id = uw.Game?.world_id || ''; + await apiFetch(`${BASE_URL}/api/farm_status?player_id=${player_id}&world_id=${world_id}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ warehouse_full: false }) diff --git a/routes/api.py b/routes/api.py index 6418102..7de9525 100644 --- a/routes/api.py +++ b/routes/api.py @@ -437,9 +437,12 @@ def upload_market_data(): @api.route('/api/farm_status', methods=['POST', 'GET']) def farm_status(): player_id = request.args.get('player_id') + world_id = request.args.get('world_id') if not player_id: return jsonify({'error': 'no player_id'}), 400 - kv_key = f'farm_status_{player_id}' + + player_key = f"{player_id}_{world_id}" if world_id else player_id + kv_key = f'farm_status_{player_key}' conn = get_db() if request.method == 'POST': data = request.get_json(silent=True) or {}