Mj2 : modular and prepare for client options
This commit is contained in:
@@ -134,37 +134,48 @@ def get_pending_command():
|
||||
conn = get_db()
|
||||
c = conn.cursor()
|
||||
|
||||
build_cmd = _fetch_pending_of_type(c, 'build', player_id)
|
||||
recruit_cmd = _fetch_pending_of_type(c, 'recruit', player_id)
|
||||
market_cmd = _fetch_pending_of_type(c, 'market_offer', player_id)
|
||||
farm_cmd = _fetch_pending_of_type(c, 'farm_loot', player_id)
|
||||
build_cmd = _fetch_pending_of_type(c, 'build', player_id)
|
||||
recruit_cmd = _fetch_pending_of_type(c, 'recruit', player_id)
|
||||
market_cmd = _fetch_pending_of_type(c, 'market_offer', player_id)
|
||||
farm_cmd = _fetch_pending_of_type(c, 'farm_loot', player_id)
|
||||
farm_upgrade_cmd = _fetch_pending_of_type(c, 'farm_upgrade', player_id)
|
||||
research_cmd = _fetch_pending_of_type(c, 'research', player_id)
|
||||
sync_req = _check_and_reset_sync(c, player_id)
|
||||
research_cmd = _fetch_pending_of_type(c, 'research', player_id)
|
||||
sync_req = _check_and_reset_sync(c, player_id)
|
||||
|
||||
# Also return current farm settings so TM knows loot_option
|
||||
# Farm settings
|
||||
farm_row = c.execute(
|
||||
'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,
|
||||
'loot_option': farm_row['loot_option'] if farm_row else 1
|
||||
'enabled': bool(farm_row['enabled']) if farm_row else False,
|
||||
'loot_option': farm_row['loot_option'] if farm_row else 1
|
||||
}
|
||||
|
||||
# Feature flags — look up this player's authorized features from their clan
|
||||
member_row = c.execute(
|
||||
'SELECT features FROM clan_members WHERE player_id = ?', (str(player_id),)
|
||||
).fetchone()
|
||||
if member_row and member_row['features']:
|
||||
enabled_features = [f.strip() for f in member_row['features'].split(',') if f.strip()]
|
||||
else:
|
||||
enabled_features = ['farm', 'admin'] # default: all on (backward-compatible)
|
||||
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
return jsonify({
|
||||
'build': build_cmd,
|
||||
'recruit': recruit_cmd,
|
||||
'market': market_cmd,
|
||||
'research': research_cmd,
|
||||
'farm': farm_cmd,
|
||||
'farm_upgrade': farm_upgrade_cmd,
|
||||
'farm_settings': farm_settings,
|
||||
'sync_requested': sync_req
|
||||
'build': build_cmd,
|
||||
'recruit': recruit_cmd,
|
||||
'market': market_cmd,
|
||||
'research': research_cmd,
|
||||
'farm': farm_cmd,
|
||||
'farm_upgrade': farm_upgrade_cmd,
|
||||
'farm_settings': farm_settings,
|
||||
'enabled_features': enabled_features,
|
||||
'sync_requested': sync_req
|
||||
})
|
||||
|
||||
|
||||
def _check_and_reset_sync(c, player_id):
|
||||
key = f'sync_request_{player_id}'
|
||||
row = c.execute("SELECT value FROM kv_store WHERE key = ?", (key,)).fetchone()
|
||||
|
||||
Reference in New Issue
Block a user