2026-02-27 12:01:02 +01:00
|
|
|
|
from nicegui import ui, app
|
2026-03-02 16:17:50 +01:00
|
|
|
|
from gui import gui_style
|
2026-03-04 16:08:45 +01:00
|
|
|
|
from data import data_api
|
2026-03-12 09:34:22 +01:00
|
|
|
|
from gui.info_text import info_system
|
2026-02-27 12:01:02 +01:00
|
|
|
|
|
2026-03-03 15:49:40 +01:00
|
|
|
|
def setup_routes():
|
2026-03-08 16:23:39 +01:00
|
|
|
|
@ui.page('/statistic/{systemname}', dark=True)
|
2026-03-16 16:04:08 +01:00
|
|
|
|
def gamesystem_statistic_page(systemname: str):
|
2026-02-27 12:01:02 +01:00
|
|
|
|
|
|
|
|
|
|
if not app.storage.user.get('authenticated', False):
|
|
|
|
|
|
ui.navigate.to('/')
|
|
|
|
|
|
return
|
|
|
|
|
|
|
2026-03-02 16:17:50 +01:00
|
|
|
|
gui_style.apply_design()
|
2026-03-04 16:08:45 +01:00
|
|
|
|
|
|
|
|
|
|
player_id = app.storage.user.get('db_id')
|
2026-03-16 16:04:08 +01:00
|
|
|
|
all_stats = data_api.get_player_statistics(player_id)
|
|
|
|
|
|
|
|
|
|
|
|
# Passendes System anhand des Namens (case-insensitive) herausfiltern
|
|
|
|
|
|
system_stat = next(
|
|
|
|
|
|
(s for s in all_stats if s["gamesystem_name"].lower() == systemname.lower()),
|
|
|
|
|
|
None
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if system_stat:
|
|
|
|
|
|
# None-Werte absichern
|
|
|
|
|
|
mmr = system_stat["mmr"] or 0
|
|
|
|
|
|
games = system_stat["games_in_system"] or 0
|
|
|
|
|
|
points = system_stat["points"] or 0
|
|
|
|
|
|
avv_points = system_stat.get("avv_points") or "-"
|
|
|
|
|
|
last_played_raw = system_stat.get("last_played")
|
|
|
|
|
|
last_played = str(last_played_raw)[:10] if last_played_raw else "-"
|
2026-03-04 16:08:45 +01:00
|
|
|
|
|
|
|
|
|
|
with ui.header().classes('items-center justify-between bg-zinc-900 p-4 shadow-lg'):
|
2026-03-12 09:34:22 +01:00
|
|
|
|
ui.button(icon="arrow_back", on_click=lambda: ui.navigate.to('/')).props("round")
|
2026-03-04 16:08:45 +01:00
|
|
|
|
ui.button("Spiel eintragen", on_click=lambda: ui.navigate.to(f'/add-match/{systemname}'))
|
2026-03-16 16:04:08 +01:00
|
|
|
|
|
2026-03-12 15:23:09 +01:00
|
|
|
|
with ui.column().classes('w-full items-center justify-center mt-10'):
|
|
|
|
|
|
ui.label(f'Deine Statistik in {systemname}').classes('text-3xl justify-center font-bold text-normaltext')
|
2026-03-04 16:08:45 +01:00
|
|
|
|
|
2026-03-16 16:04:08 +01:00
|
|
|
|
# --- BLOCK 1 (MMR & Rang | Rangliste) ---
|
2026-03-06 12:01:58 +01:00
|
|
|
|
leaderboard_data = data_api.get_leaderboard(systemname)
|
|
|
|
|
|
table_rows = []
|
|
|
|
|
|
my_rank = "-"
|
|
|
|
|
|
|
|
|
|
|
|
for index, player in enumerate(leaderboard_data):
|
|
|
|
|
|
current_rank = index + 1
|
|
|
|
|
|
if player['id'] == player_id:
|
|
|
|
|
|
my_rank = current_rank
|
|
|
|
|
|
table_rows.append({
|
|
|
|
|
|
'rank': current_rank,
|
2026-03-16 16:04:08 +01:00
|
|
|
|
'trend': '➖',
|
2026-03-08 20:56:54 +01:00
|
|
|
|
'name': f"{player['display_name']} 'aka' {player['discord_name']}",
|
2026-03-06 12:01:58 +01:00
|
|
|
|
'mmr': player['mmr']
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
table_columns = [
|
2026-03-16 16:04:08 +01:00
|
|
|
|
{'name': 'rank', 'label': '#', 'field': 'rank', 'align': 'left'},
|
|
|
|
|
|
{'name': 'trend', 'label': 'Trend', 'field': 'trend', 'align': 'center'},
|
|
|
|
|
|
{'name': 'name', 'label': 'Spieler', 'field': 'name', 'align': 'left'},
|
|
|
|
|
|
{'name': 'mmr', 'label': 'MMR', 'field': 'mmr', 'align': 'left'},
|
2026-03-06 12:01:58 +01:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
with ui.element('div').classes("w-full grid grid-cols-1 lg:grid-cols-3 gap-4 mt-4"):
|
|
|
|
|
|
with ui.column().classes("w-full gap-4"):
|
|
|
|
|
|
with ui.card().classes("w-full items-center justify-center text-center"):
|
2026-03-11 20:43:30 +01:00
|
|
|
|
with ui.row().classes("w-full items-center text-center"):
|
2026-03-12 15:23:09 +01:00
|
|
|
|
ui.label("MMR Punkte: ").classes('justify-center text-2xl font-bold text-normaltext')
|
2026-03-11 20:43:30 +01:00
|
|
|
|
ui.space()
|
2026-03-12 09:34:22 +01:00
|
|
|
|
info_system.create_info_button("mmr_info")
|
2026-03-16 16:04:08 +01:00
|
|
|
|
ui.label(str(mmr)).classes('text-4xl font-bold text-accent')
|
2026-03-04 16:08:45 +01:00
|
|
|
|
|
2026-03-06 12:01:58 +01:00
|
|
|
|
with ui.card().classes("w-full items-center justify-center text-center"):
|
2026-03-22 20:39:45 +01:00
|
|
|
|
with ui.row().classes("w-full items-center text-center"):
|
|
|
|
|
|
ui.label("Rang: ").classes('justify-center text-2xl font-bold text-normaltext')
|
|
|
|
|
|
ui.space()
|
|
|
|
|
|
info_system.create_info_button("rang_info")
|
2026-03-06 12:01:58 +01:00
|
|
|
|
ui.label(str(my_rank)).classes('text-4xl font-bold text-blue-100')
|
|
|
|
|
|
|
|
|
|
|
|
with ui.card().classes("w-full lg:col-span-2"):
|
|
|
|
|
|
ui.label("Liga Rangliste").classes("text-xl font-bold text-white mb-2")
|
|
|
|
|
|
ui.table(columns=table_columns, rows=table_rows, row_key='rank').classes('w-full bg-zinc-900 text-white')
|
|
|
|
|
|
|
2026-03-04 16:08:45 +01:00
|
|
|
|
# --- BLOCK 2 (5 Karten) ---
|
|
|
|
|
|
with ui.card().classes("w-full"):
|
|
|
|
|
|
with ui.element('div').classes("w-full grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"):
|
|
|
|
|
|
|
|
|
|
|
|
with ui.card().classes("items-center justify-center text-center"):
|
|
|
|
|
|
ui.label("Spiele: ").classes('text-2xl font-bold')
|
2026-03-16 16:04:08 +01:00
|
|
|
|
ui.label(str(games)).classes('text-4xl font-bold text-blue-100')
|
2026-03-04 16:08:45 +01:00
|
|
|
|
|
|
|
|
|
|
with ui.card().classes("items-center justify-center text-center"):
|
|
|
|
|
|
ui.label("Ø Punkte pro Spiel: ").classes('text-2xl font-bold')
|
2026-03-16 16:04:08 +01:00
|
|
|
|
ui.label(str(avv_points)).classes('text-4xl font-bold text-blue-100')
|
2026-03-04 16:08:45 +01:00
|
|
|
|
|
|
|
|
|
|
with ui.card().classes("items-center justify-center text-center"):
|
|
|
|
|
|
ui.label("Win-Rate: ").classes('text-2xl font-bold')
|
|
|
|
|
|
ui.label("-").classes('text-4xl font-bold text-blue-100')
|
|
|
|
|
|
|
|
|
|
|
|
with ui.card().classes("items-center justify-center text-center"):
|
|
|
|
|
|
ui.label("Letztes Spiel am: ").classes('text-2xl font-bold')
|
|
|
|
|
|
ui.label(last_played).classes('text-4xl font-bold text-blue-100')
|
|
|
|
|
|
|
|
|
|
|
|
with ui.card().classes("items-center justify-center text-center"):
|
|
|
|
|
|
ui.label("Win-Streak: ").classes('text-2xl font-bold')
|
|
|
|
|
|
ui.label("-").classes('text-4xl font-bold text-blue-100')
|
|
|
|
|
|
|
|
|
|
|
|
# --- BLOCK 3 (3 Karten) ---
|
|
|
|
|
|
with ui.card().classes("w-full"):
|
|
|
|
|
|
with ui.element('div').classes("w-full grid grid-cols-1 md:grid-cols-3 lg:grid-cols-3 gap-4"):
|
|
|
|
|
|
|
|
|
|
|
|
with ui.card().classes("items-center justify-center text-center"):
|
|
|
|
|
|
ui.label("Dein Nemesis: ").classes('text-2xl font-bold')
|
|
|
|
|
|
ui.label("-").classes('text-4xl font-bold text-blue-100')
|
|
|
|
|
|
|
|
|
|
|
|
with ui.card().classes("items-center justify-center text-center"):
|
|
|
|
|
|
ui.label("Meisten Spiele mit: ").classes('text-2xl font-bold')
|
|
|
|
|
|
ui.label("-").classes('text-4xl font-bold text-blue-100')
|
|
|
|
|
|
|
|
|
|
|
|
with ui.card().classes("items-center justify-center text-center"):
|
|
|
|
|
|
ui.label("Dein 'Prügelknabe': ").classes('text-2xl font-bold')
|
|
|
|
|
|
ui.label("-").classes('text-4xl font-bold text-blue-100')
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
2026-03-16 16:04:08 +01:00
|
|
|
|
with ui.column().classes('w-full items-center justify-center mt-10'):
|
|
|
|
|
|
ui.label(f'Keine Statistik für "{systemname}" gefunden.').classes('text-red-500 text-xl mt-4')
|