various fixes totest
This commit is contained in:
@@ -29,17 +29,17 @@ def _get_clan_from_request():
|
||||
# ------------------------------------------------------------------
|
||||
# Helper — auto-register a player_id under a clan on first push.
|
||||
# ------------------------------------------------------------------
|
||||
def _auto_register_member(clan_id, player_id, player_name):
|
||||
def _auto_register_member(clan_id, player_id, player_name, world_id=''):
|
||||
conn = get_db()
|
||||
conn.execute('''
|
||||
INSERT OR IGNORE INTO clan_members (clan_id, player_id, player_name)
|
||||
VALUES (?, ?, ?)
|
||||
''', (clan_id, str(player_id), player_name or ''))
|
||||
# Update name in case it changed
|
||||
INSERT OR IGNORE INTO clan_members (clan_id, player_id, player_name, world_id)
|
||||
VALUES (?, ?, ?, ?)
|
||||
''', (clan_id, str(player_id), player_name or '', world_id or ''))
|
||||
# Update name and world on every push (they can change)
|
||||
conn.execute('''
|
||||
UPDATE clan_members SET player_name = ?
|
||||
UPDATE clan_members SET player_name = ?, world_id = ?
|
||||
WHERE clan_id = ? AND player_id = ?
|
||||
''', (player_name or '', clan_id, str(player_id)))
|
||||
''', (player_name or '', world_id or '', clan_id, str(player_id)))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
@@ -63,7 +63,7 @@ def receive_state():
|
||||
# Auto-register this player to the clan that matches the key (if any)
|
||||
clan = _get_clan_from_request()
|
||||
if clan:
|
||||
_auto_register_member(clan['id'], player_id, player)
|
||||
_auto_register_member(clan['id'], player_id, player, world_id)
|
||||
|
||||
conn = get_db()
|
||||
c = conn.cursor()
|
||||
|
||||
@@ -126,7 +126,7 @@ def options():
|
||||
members = []
|
||||
if clan:
|
||||
rows = conn.execute(
|
||||
'''SELECT cm.id, cm.player_id, cm.player_name, cm.joined_at, cm.features,
|
||||
'''SELECT cm.id, cm.player_id, cm.player_name, cm.world_id, cm.joined_at, cm.features,
|
||||
ts.updated_at
|
||||
FROM clan_members cm
|
||||
LEFT JOIN town_state ts ON ts.player_id = cm.player_id
|
||||
@@ -147,14 +147,15 @@ def options():
|
||||
except Exception:
|
||||
pass
|
||||
members.append({
|
||||
'id': row['id'],
|
||||
'player_id': row['player_id'],
|
||||
'player_name': row['player_name'] or 'Άγνωστος',
|
||||
'joined_at': row['joined_at'][:10] if row['joined_at'] else '',
|
||||
'is_online': is_online,
|
||||
'feat_farm': 'farm' in (row['features'] or 'farm,admin'),
|
||||
'feat_admin': 'admin' in (row['features'] or 'farm,admin'),
|
||||
'feat_atk_planner': 'attack_planner' in (row['features'] or ''),
|
||||
'id': row['id'],
|
||||
'player_id': row['player_id'],
|
||||
'player_name': row['player_name'] or 'Άγνωστος',
|
||||
'world_id': row['world_id'] or '–',
|
||||
'joined_at': row['joined_at'][:10] if row['joined_at'] else '',
|
||||
'is_online': is_online,
|
||||
'feat_farm': 'farm' in (row['features'] or 'farm,admin'),
|
||||
'feat_admin': 'admin' in (row['features'] or 'farm,admin'),
|
||||
'feat_atk_planner': 'attack_planner' in (row['features'] or ''),
|
||||
'feat_atk_planner_admin': 'attack_planner_admin' in (row['features'] or ''),
|
||||
})
|
||||
|
||||
|
||||
@@ -100,7 +100,19 @@ def player_tracker(player_id, world_id):
|
||||
@dashboard.route('/player/<player_id>/<world_id>/attack-planner')
|
||||
@login_required
|
||||
def player_attack_planner(player_id, world_id):
|
||||
return render_template('attack_planner.html', player_id=player_id, world_id=world_id)
|
||||
clan_key = ''
|
||||
if current_user.clan_id:
|
||||
conn = get_db()
|
||||
clan = conn.execute(
|
||||
'SELECT clan_key FROM clans WHERE id = ?', (current_user.clan_id,)
|
||||
).fetchone()
|
||||
conn.close()
|
||||
if clan:
|
||||
clan_key = clan['clan_key']
|
||||
return render_template('attack_planner.html',
|
||||
player_id=player_id,
|
||||
world_id=world_id,
|
||||
clan_key=clan_key)
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user