From c5dcd5641088d4ce22d7f649ed8a87d400708ad6 Mon Sep 17 00:00:00 2001 From: Daniel Nagel Date: Sat, 14 Mar 2026 21:12:09 +0100 Subject: [PATCH] Messy MMR+ / - in der DB. Anzeige und Berechnung stimmt was nicht. --- ...-user-c446a3b8-a6ed-40c3-a878-3069e9d230cb.json | 2 +- data/setup_database.py | 14 +++++++++++++- gui/match_history_gui.py | 8 ++++++-- match_calculations/calc_match.py | 2 +- match_calculations/calc_mmr_change.py | 8 ++++++-- 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/.nicegui/storage-user-c446a3b8-a6ed-40c3-a878-3069e9d230cb.json b/.nicegui/storage-user-c446a3b8-a6ed-40c3-a878-3069e9d230cb.json index ed7d579..90a427a 100644 --- a/.nicegui/storage-user-c446a3b8-a6ed-40c3-a878-3069e9d230cb.json +++ b/.nicegui/storage-user-c446a3b8-a6ed-40c3-a878-3069e9d230cb.json @@ -1 +1 @@ -{"authenticated":true,"discord_id":"277898241750859776","discord_name":"mrteels","db_id":1,"display_name":"Schwitzender Grot","discord_avatar_url":"https://cdn.discordapp.com/avatars/277898241750859776/7c3446bb51fafd72b1b4c21124b4994f.png"} \ No newline at end of file +{"authenticated":true,"discord_id":"277898241750859776","discord_name":"mrteels","db_id":2,"display_name":"Stolpernder Meta-Chaser","discord_avatar_url":"https://cdn.discordapp.com/avatars/277898241750859776/7c3446bb51fafd72b1b4c21124b4994f.png"} \ No newline at end of file diff --git a/data/setup_database.py b/data/setup_database.py index 3f07502..87cda8d 100644 --- a/data/setup_database.py +++ b/data/setup_database.py @@ -54,6 +54,7 @@ def init_db(): points INTEGER DEFAULT 0, avv_points INTEGER DEFAULT 0, last_played TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + trend INTEGER DEFAULT 0, FOREIGN KEY (player_id) REFERENCES players (id), FOREIGN KEY (gamesystem_id) REFERENCES gamesystems (id) ) @@ -69,8 +70,19 @@ def init_db(): player2_id INTEGER, score_player2 INTEGER, played_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + + player1_base_change INTEGER, + player1_khorne INTEGER, + player1_slaanesh INTEGER, + player1_tzeentch INTEGER, player1_mmr_change INTEGER, + + player2_base_change INTEGER, + player2_khorne INTEGER, + player2_slaanesh INTEGER, + player2_tzeentch INTEGER, player2_mmr_change INTEGER, + player2_check INTEGER DEFAULT 0, match_is_counted INTEGER DEFAULT 0, FOREIGN KEY (gamesystem_id) REFERENCES gamesystems (id), @@ -89,7 +101,7 @@ def init_db(): ) ''') - # 6. Tabelle: player_achievements (Wer hat welchen Erfolg wann bekommen? - Bewegungsdaten) + # 6. Tabelle: player_achievements. Wer hat welchen Erfolg wann bekommen cursor.execute(''' CREATE TABLE IF NOT EXISTS player_achievements ( id INTEGER PRIMARY KEY AUTOINCREMENT, diff --git a/gui/match_history_gui.py b/gui/match_history_gui.py index 4357885..1ccd79a 100644 --- a/gui/match_history_gui.py +++ b/gui/match_history_gui.py @@ -55,6 +55,8 @@ def setup_routes(): mmr_text = "0" elif my_mmr_change > 0: mmr_text = f"+{my_mmr_change}" + elif my_mmr_change < 0: + mmr_text = f"{my_mmr_change}" else: mmr_text = str(my_mmr_change) @@ -63,7 +65,8 @@ def setup_routes(): 'date': str(match['played_at'])[:10], 'system': match['gamesystem_name'], 'opponent': opponent, - 'score': f"{my_score} : {opp_score}", + 'score': f"{my_score}", + 'opp_score': f"{opp_score}", 'result': result, 'mmr': mmr_text }) @@ -72,8 +75,9 @@ def setup_routes(): columns = [ {'name': 'date', 'label': 'Datum', 'field': 'date', 'align': 'left'}, {'name': 'system', 'label': 'System', 'field': 'system', 'align': 'left'}, + {'name': 'score', 'label': 'Punkte', 'field': 'score', 'align': 'left'}, {'name': 'opponent', 'label': 'Gegner', 'field': 'opponent', 'align': 'left'}, - {'name': 'score', 'label': 'Punkte', 'field': 'score', 'align': 'center'}, + {'name': 'opp_score', 'label': 'Gegner Punkte', 'field': 'score', 'align': 'center'}, {'name': 'result', 'label': 'Ergebnis', 'field': 'result', 'align': 'left'}, {'name': 'mmr', 'label': 'MMR Änderung', 'field': 'mmr', 'align': 'right'} ] diff --git a/match_calculations/calc_match.py b/match_calculations/calc_match.py index bd46d48..06fe0f8 100644 --- a/match_calculations/calc_match.py +++ b/match_calculations/calc_match.py @@ -61,7 +61,7 @@ def calculate_match (match_id): mmr_change_winner, mmr_change_looser = calc_mmr_change.calc_mmr_change(sys_name, winner_id, looser_id, winner_score, looser_score, match_is_draw) data_api.apply_match_to_player_statistic (winner_id, sys_id, mmr_change_winner, winner_score) - data_api.apply_match_to_player_statistic (looser_id, sys_id, -mmr_change_looser, looser_score) + data_api.apply_match_to_player_statistic (looser_id, sys_id, mmr_change_looser, looser_score) # Zuordnen: Welcher Change gehört zu P1 und welcher zu P2? if winner_id == p1_id: diff --git a/match_calculations/calc_mmr_change.py b/match_calculations/calc_mmr_change.py index 4785afd..eb26f8a 100644 --- a/match_calculations/calc_mmr_change.py +++ b/match_calculations/calc_mmr_change.py @@ -59,8 +59,12 @@ def calc_mmr_change(systemname, winner_id, looser_id, winner_points, looser_poin looser_final_mmr_change = int(base_change + wrath_of_khorne(looser_id)* rust_factor) else: winner_final_mmr_change = int((base_change + wrath_of_khorne(winner_id) + sla_points) * rust_factor) - looser_final_mmr_change = int(((base_change + wrath_of_khorne(winner_id) - sla_points) * rust_factor)* point_inflation) - return winner_final_mmr_change, looser_final_mmr_change + looser_final_mmr_change = int(((base_change + wrath_of_khorne(winner_id) - sla_points) * rust_factor)* point_inflation) + + logger.log("MMR CALC", f"Winner: Base:{base_change} Khorne:{wrath_of_khorne(winner_id)} Sla:{sla_points} = {winner_final_mmr_change}") + logger.log("MMR CALC", f"Looser: Base:{base_change} Khorne:{wrath_of_khorne(winner_id)} Sla:{sla_points} = {looser_final_mmr_change}") + + return winner_final_mmr_change, (looser_final_mmr_change) # -----------------