diff --git a/GrepolisRemoteControl.user.js b/GrepolisRemoteControl.user.js index cbe8475..4e12c8f 100644 --- a/GrepolisRemoteControl.user.js +++ b/GrepolisRemoteControl.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Grepolis Remote Control // @namespace http://tampermonkey.net/ -// @version 3.6.7 +// @version 3.5.7 // @description Polls grepo.haunter-pets.top for remote commands and executes them in-game (Multi-Player) // @author Dimitrios // @match https://*.grepolis.com/game/* @@ -814,120 +814,6 @@ } } - // Auto Bandit Camp: if enabled, attack/claim when ready - if (farmSettings.bandit_camp_enabled) { - try { - // player_id already declared above in pollAndExecute scope - const currentTownId = uw.ITowns?.getCurrentTown?.()?.id - || Object.keys(uw.ITowns?.towns || {})[0] - || null; - if (!player_id || !currentTownId) { - log(`⚔️ Bandit Camp: Missing globals — player_id=${player_id} town_id=${currentTownId}`); - } else { - // First try: MM collection (works once camp was opened in-game) - let spotData = uw.MM.getOnlyCollectionByName('PlayerAttackSpot')?.models?.[0]?.attributes || null; - - // Second try: use gpAjax with a callback — it handles auth/hash internally - if (!spotData) { - spotData = await new Promise((resolve) => { - try { - uw.gpAjax.ajaxPost('frontend_bridge', 'execute', { - model_url: `PlayerAttackSpot/${player_id}`, - action_name: 'get_own', - captcha: null, - arguments: {}, - town_id: currentTownId, - nl_init: true - }, false, { - success: function(data) { - // Response may contain the spot data directly - const d = data?.PlayerAttackSpot - || data?.data?.PlayerAttackSpot?.[player_id] - || data?.[player_id] - || data; - resolve((d && d.cooldown_at !== undefined) ? d : null); - }, - error: function() { resolve(null); } - }); - } catch(e) { resolve(null); } - }); - - // After the gpAjax call, MM might now have the model - if (!spotData) { - spotData = uw.MM.getOnlyCollectionByName('PlayerAttackSpot')?.models?.[0]?.attributes || null; - } - } - - if (!spotData) { - log('⚔️ Bandit Camp: Could not load spot data. Open the Bandit Camp window in-game once to let the game load it.'); - } else { - const nowTs = Math.floor(Date.now() / 1000); - const spotId = spotData.id || player_id; - const townId = spotData.town_id || currentTownId; - - log(`⚔️ Bandit Monitor -> Cooldown in: ${Math.max(0, spotData.cooldown_at - nowTs)}s | Reward: ${spotData.reward_available} | Level: ${spotData.level}`); - - if (spotData.reward_available) { - log('⚔️ Bandit Camp: Reward available! Waiting before claiming...'); - await sleep(randInt(8000, 24000)); - uw.gpAjax.ajaxPost('frontend_bridge', 'execute', { - model_url: `PlayerAttackSpot/${spotId}`, - action_name: 'useReward', - captcha: null, - arguments: {}, - town_id: townId, - nl_init: true - }); - log('⚔️ Bandit Camp: Reward claimed!'); - } else if (spotData.cooldown_at <= nowTs) { - let hasMovements = false; - try { - const movements = uw.MM.getOnlyCollectionByName('MovementCommand')?.models || []; - hasMovements = movements.length > 0; - } catch (e) {} - - if (!hasMovements) { - const town = uw.ITowns?.getTown?.(townId) || uw.ITowns?.towns?.[townId]; - if (town) { - const myUnits = town.units() || {}; - const allowedUnits = ['sword', 'slinger', 'archer', 'hoplite', 'rider', 'chariot', 'catapult']; - const sendUnits = {}; - let totalUnits = 0; - for (let u of allowedUnits) { - if ((myUnits[u] || 0) > 0) { - sendUnits[u] = myUnits[u]; - totalUnits += myUnits[u]; - } - } - if (totalUnits > 0) { - log(`⚔️ Bandit Camp: Attacking with ${totalUnits} units...`); - await sleep(randInt(8000, 24000)); - uw.gpAjax.ajaxPost('frontend_bridge', 'execute', { - model_url: `PlayerAttackSpot/${spotId}`, - action_name: 'attack', - captcha: null, - arguments: sendUnits, - town_id: townId, - nl_init: true - }); - log('⚔️ Bandit Camp: Attack sent!'); - } else { - log('⚔️ Bandit Camp: No units available.'); - } - } - } else { - log('⚔️ Bandit Camp: Troops still returning — waiting...'); - } - } - } - } - } catch (e) { - log(`⚔️ Bandit camp error: ${e.message}`); - } - } - - - if (cmdData.sync_requested) { log('Sync requested by server — pushing state immediately'); pushState(); diff --git a/routes/api.py b/routes/api.py index 37c912f..ac504de 100644 --- a/routes/api.py +++ b/routes/api.py @@ -104,11 +104,10 @@ def get_pending_command(): # Also return current farm settings so TM knows loot_option farm_row = c.execute( - 'SELECT enabled, bandit_camp_enabled, loot_option FROM farm_settings WHERE player_id = ?', (player_id,) + 'SELECT enabled, loot_option FROM farm_settings WHERE player_id = ?', (player_id,) ).fetchone() farm_settings = { 'enabled': bool(farm_row['enabled']) if farm_row else False, - 'bandit_camp_enabled': bool(farm_row['bandit_camp_enabled']) if farm_row else False, 'loot_option': farm_row['loot_option'] if farm_row else 1 } diff --git a/routes/dashboard.py b/routes/dashboard.py index 2a683b5..2fa433e 100644 --- a/routes/dashboard.py +++ b/routes/dashboard.py @@ -70,12 +70,12 @@ def get_farm_settings(): player_id = request.args.get('player_id') conn = get_db() row = conn.execute( - 'SELECT enabled, bandit_camp_enabled, loot_option FROM farm_settings WHERE player_id = ?', (player_id,) + 'SELECT enabled, loot_option FROM farm_settings WHERE player_id = ?', (player_id,) ).fetchone() conn.close() if row: - return jsonify({'enabled': bool(row['enabled']), 'bandit_camp_enabled': bool(row['bandit_camp_enabled']), 'loot_option': row['loot_option']}) - return jsonify({'enabled': False, 'bandit_camp_enabled': False, 'loot_option': 1}) + return jsonify({'enabled': bool(row['enabled']), 'loot_option': row['loot_option']}) + return jsonify({'enabled': False, 'loot_option': 1}) @dashboard.route('/dashboard/farm-settings', methods=['POST']) def set_farm_settings(): @@ -84,18 +84,16 @@ def set_farm_settings(): return jsonify({'error': 'missing player_id'}), 400 player_id = data['player_id'] enabled = 1 if data.get('enabled') else 0 - bandit_camp_enabled = 1 if data.get('bandit_camp_enabled') else 0 loot_option = int(data.get('loot_option', 1)) conn = get_db() conn.execute(''' - INSERT INTO farm_settings (player_id, enabled, bandit_camp_enabled, loot_option, updated_at) - VALUES (?, ?, ?, ?, ?) + INSERT INTO farm_settings (player_id, enabled, loot_option, updated_at) + VALUES (?, ?, ?, ?) ON CONFLICT(player_id) DO UPDATE SET enabled = excluded.enabled, - bandit_camp_enabled = excluded.bandit_camp_enabled, loot_option = excluded.loot_option, updated_at = excluded.updated_at - ''', (player_id, enabled, bandit_camp_enabled, loot_option, datetime.utcnow().isoformat())) + ''', (player_id, enabled, loot_option, datetime.utcnow().isoformat())) conn.commit() conn.close() return jsonify({'ok': True}) diff --git a/templates/farm.html b/templates/farm.html index 0a036f6..a0e542d 100644 --- a/templates/farm.html +++ b/templates/farm.html @@ -255,15 +255,6 @@ Ανενεργό -