various fixes totest

This commit is contained in:
2026-05-03 13:50:37 +03:00
parent eb31072c87
commit 11f30f4c6a
7 changed files with 199 additions and 115 deletions

View File

@@ -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()