From 6a4217234bb62a9c07ab0a89abf6e7d1090f34b6 Mon Sep 17 00:00:00 2001 From: haunter Date: Fri, 24 Apr 2026 21:29:55 +0300 Subject: [PATCH] add new function farm quests --- GrepolisRemoteControl.user.js | 71 ++++++++++++++++++++++++++++++++++- db.py | 2 + routes/dashboard.py | 14 ++++--- templates/farm.html | 37 ++++++++++++++---- 4 files changed, 110 insertions(+), 14 deletions(-) diff --git a/GrepolisRemoteControl.user.js b/GrepolisRemoteControl.user.js index 4e12c8f..64562f5 100644 --- a/GrepolisRemoteControl.user.js +++ b/GrepolisRemoteControl.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Grepolis Remote Control // @namespace http://tampermonkey.net/ -// @version 3.5.7 +// @version 3.6.0 // @description Polls grepo.haunter-pets.top for remote commands and executes them in-game (Multi-Player) // @author Dimitrios // @match https://*.grepolis.com/game/* @@ -814,6 +814,75 @@ } } + // Auto Bandit Camp: if enabled, attack/claim when ready + if (farmSettings.bandit_camp_enabled) { + try { + const spotModels = uw.MM.getModels().PlayerAttackSpot; + if (spotModels) { + const spotId = Object.keys(spotModels)[0]; + if (spotId) { + const spot = spotModels[spotId]; + const nowTs = Math.floor(Date.now() / 1000); + const townId = spot.attributes.town_id; + + if (spot.attributes.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 (spot.attributes.cooldown_at <= nowTs) { + // Check if there are active movements to make sure troops are home + let hasMovements = false; + try { + const movements = uw.MM.getOnlyCollectionByName('MovementCommand')?.models || []; + hasMovements = movements.length > 0; + } catch (e) {} + + if (!hasMovements) { + // Gather troops + 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) { + sendUnits[u] = myUnits[u]; + totalUnits += myUnits[u]; + } + } + + if (totalUnits > 0) { + log(`⚔️ Bandit Camp: Cooldown over! Preparing to attack 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!'); + } + } + } + } + } + } + } catch (e) { + log(`Bandit camp error: ${e.message}`); + } + } + if (cmdData.sync_requested) { log('Sync requested by server — pushing state immediately'); pushState(); diff --git a/db.py b/db.py index 7a78bbb..f1af9c3 100644 --- a/db.py +++ b/db.py @@ -60,6 +60,7 @@ def init_db(): CREATE TABLE IF NOT EXISTS farm_settings ( player_id TEXT PRIMARY KEY, enabled INTEGER NOT NULL DEFAULT 0, + bandit_camp_enabled INTEGER NOT NULL DEFAULT 0, loot_option INTEGER NOT NULL DEFAULT 1, -- 1=5min, 2=20min, 3=90min, 4=4h updated_at TEXT NOT NULL DEFAULT (datetime('now')) ) @@ -73,6 +74,7 @@ def init_db(): 'ALTER TABLE town_state ADD COLUMN y REAL', 'ALTER TABLE town_state ADD COLUMN sea INTEGER', 'ALTER TABLE commands ADD COLUMN player_id TEXT', + 'ALTER TABLE farm_settings ADD COLUMN bandit_camp_enabled INTEGER NOT NULL DEFAULT 0', ]: try: c.execute(_col) diff --git a/routes/dashboard.py b/routes/dashboard.py index 2fa433e..2a683b5 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, loot_option FROM farm_settings WHERE player_id = ?', (player_id,) + 'SELECT enabled, bandit_camp_enabled, loot_option FROM farm_settings WHERE player_id = ?', (player_id,) ).fetchone() conn.close() if row: - return jsonify({'enabled': bool(row['enabled']), 'loot_option': row['loot_option']}) - return jsonify({'enabled': False, 'loot_option': 1}) + 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}) @dashboard.route('/dashboard/farm-settings', methods=['POST']) def set_farm_settings(): @@ -84,16 +84,18 @@ 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, loot_option, updated_at) - VALUES (?, ?, ?, ?) + INSERT INTO farm_settings (player_id, enabled, bandit_camp_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, loot_option, datetime.utcnow().isoformat())) + ''', (player_id, enabled, bandit_camp_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 a0e542d..0a036f6 100644 --- a/templates/farm.html +++ b/templates/farm.html @@ -255,6 +255,15 @@ Ανενεργό +
+ Στρατόπεδο Ληστών (Auto) + + Ανενεργό +
+
Επίπεδο Λεηλασίας: