new market

This commit is contained in:
2026-04-25 16:01:15 +03:00
parent 8a64a7b4fc
commit a143345831
6 changed files with 282 additions and 8 deletions

View File

@@ -129,6 +129,24 @@ def get_farm_data():
return jsonify(farms_summary)
# ------------------------------------------------------------------
# GET /dashboard/market-data
# Returns the latest market scan data for a player.
# ------------------------------------------------------------------
@dashboard.route('/dashboard/market-data', methods=['GET'])
def get_market_data():
player_id = request.args.get('player_id')
conn = get_db()
row = conn.execute(
"SELECT value, updated_at FROM kv_store WHERE key = ?", (f'market_data_{player_id}', )
).fetchone()
conn.close()
if row:
return jsonify({'data': json.loads(row['value']), 'updated_at': row['updated_at']})
return jsonify({'data': None, 'updated_at': None})
# ------------------------------------------------------------------
# GET /dashboard/towns
# Returns all known towns with their latest state snapshot.
@@ -266,8 +284,8 @@ def create_command():
return jsonify({'error': f'missing field: {field}'}), 400
cmd_type = data['type']
if cmd_type not in ('build', 'recruit', 'market_offer', 'farm_loot', 'farm_upgrade', 'research'):
return jsonify({'error': 'type must be build, recruit, market_offer, farm_loot, farm_upgrade, or research'}), 400
if cmd_type not in ('build', 'recruit', 'market_offer', 'farm_loot', 'farm_upgrade', 'research', 'scan_market', 'accept_market_offer'):
return jsonify({'error': 'type must be build, recruit, market_offer, farm_loot, farm_upgrade, research, scan_market, or accept_market_offer'}), 400
# Reject if the Tampermonkey client is offline (no state push in last 150 s)
conn = get_db()