MJ: attack coordinator update / various fixes . captcha and back button and jitterloop 2 secs
This commit is contained in:
@@ -98,17 +98,30 @@ def receive_state():
|
||||
datetime.utcnow().isoformat()
|
||||
))
|
||||
conn.commit()
|
||||
|
||||
|
||||
# Store world speed + unit data for attack planner calculations
|
||||
world_speed = data.get('world_speed')
|
||||
unit_speeds = data.get('unit_speeds')
|
||||
if world_id and world_speed is not None and unit_speeds:
|
||||
world_data = json.dumps({'world_speed': world_speed, 'unit_speeds': unit_speeds})
|
||||
c.execute('''
|
||||
INSERT INTO kv_store (key, value, updated_at)
|
||||
VALUES (?, ?, ?)
|
||||
ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at
|
||||
''', (f'world_data_{world_id}', world_data, datetime.utcnow().isoformat()))
|
||||
conn.commit()
|
||||
|
||||
try:
|
||||
evaluate_blueprints(conn)
|
||||
conn.commit()
|
||||
except Exception as e:
|
||||
print("Error evaluating blueprints:", e)
|
||||
|
||||
|
||||
conn.close()
|
||||
return jsonify({'ok': True, 'towns_updated': len(towns)})
|
||||
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# GET /api/commands/pending
|
||||
# Tampermonkey polls this to get the next command to execute.
|
||||
@@ -390,12 +403,14 @@ def command_result(cmd_id):
|
||||
@api.route('/api/captcha/alert', methods=['POST'])
|
||||
def captcha_alert():
|
||||
player_id = request.args.get('player_id')
|
||||
world_id = request.args.get('world_id', '').strip()
|
||||
if not player_id:
|
||||
return jsonify({'error': 'no player_id provided'}), 400
|
||||
|
||||
data = request.get_json(silent=True) or {}
|
||||
detected = bool(data.get('detected', False))
|
||||
kv_key = f'captcha_active_{player_id}'
|
||||
# Key is world-specific so captcha in world A doesn't affect world B
|
||||
kv_key = f'captcha_active_{player_id}_{world_id}' if world_id else f'captcha_active_{player_id}'
|
||||
|
||||
conn = get_db()
|
||||
conn.execute('''
|
||||
@@ -409,6 +424,7 @@ def captcha_alert():
|
||||
conn.close()
|
||||
return jsonify({'ok': True})
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# POST /api/market_data
|
||||
# Tampermonkey uploads the market scan data.
|
||||
|
||||
Reference in New Issue
Block a user