small changes
This commit is contained in:
parent
106c8bb5e3
commit
3ce6ff75f8
|
|
@ -174,6 +174,36 @@ def get_player_statistics(player_id):
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def get_player_statistic(player_id, system_id):
|
||||||
|
connection = sqlite3.connect(DB_PATH)
|
||||||
|
connection.row_factory = sqlite3.Row
|
||||||
|
cursor = connection.cursor()
|
||||||
|
|
||||||
|
query = """
|
||||||
|
SELECT
|
||||||
|
sys.id AS gamesystem_id,
|
||||||
|
sys.name AS gamesystem_name,
|
||||||
|
sys.*,
|
||||||
|
stat.mmr,
|
||||||
|
stat.games_in_system,
|
||||||
|
stat.points,
|
||||||
|
stat.avv_points,
|
||||||
|
stat.last_played,
|
||||||
|
stat.win_rate,
|
||||||
|
stat.trend,
|
||||||
|
stat.tyrann_id,
|
||||||
|
stat.pushover_id,
|
||||||
|
stat.nemesis_id
|
||||||
|
FROM gamesystems sys
|
||||||
|
LEFT JOIN player_game_statistic stat
|
||||||
|
ON sys.id = stat.gamesystem_id AND stat.player_id = ?
|
||||||
|
WHERE sys.id = ?
|
||||||
|
"""
|
||||||
|
cursor.execute(query, (player_id, system_id))
|
||||||
|
row = cursor.fetchone()
|
||||||
|
connection.close()
|
||||||
|
|
||||||
|
return dict(row) if row else None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
25
match_calculations/achievments/achievments.py
Normal file
25
match_calculations/achievments/achievments.py
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
from data import data_api
|
||||||
|
from wood import logger
|
||||||
|
import sqlite3
|
||||||
|
|
||||||
|
|
||||||
|
def check_player_achievments(player_id):
|
||||||
|
# Schauen ob der Spieler sich nach dem Match (function wird aufgerufen NACHDEM ein Match berechnet wurde) sich ein Achievment verdient hat.
|
||||||
|
game_stats = data_api.get_player_statistic(player_id, system_id)
|
||||||
|
|
||||||
|
# Checken ob die Gamestats da sind und geladen sind.
|
||||||
|
if not game_stats:
|
||||||
|
logger.log(f"no game_stats could be loaded for PlayerID {player_id}.")
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
if game_stats["mmr"] is None:
|
||||||
|
logger.log(f"PlayerID {player_id} has no game statistics AFTER match got calculated.")
|
||||||
|
return
|
||||||
|
|
||||||
|
played_games_achievment(player_id)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def played_games_achievment(player_id):
|
||||||
|
return
|
||||||
|
|
@ -3,6 +3,7 @@ from match_calculations import calculation
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from wood import logger
|
from wood import logger
|
||||||
|
from match_calculations.achievments import achievments
|
||||||
|
|
||||||
|
|
||||||
point_inflation = 1 # => entspricht %
|
point_inflation = 1 # => entspricht %
|
||||||
|
|
@ -96,6 +97,9 @@ def calculate_match (match_id):
|
||||||
logger.log(f"Match{match_id}: Winner {data_api.get_player_name(winner_id)}: Base {w_base} + Khorne({w_khorne}) + Slaanesh({slaanesh}) + Tzeentch({tzeentch}) = {calc_results[winner_id]["total"]}")
|
logger.log(f"Match{match_id}: Winner {data_api.get_player_name(winner_id)}: Base {w_base} + Khorne({w_khorne}) + Slaanesh({slaanesh}) + Tzeentch({tzeentch}) = {calc_results[winner_id]["total"]}")
|
||||||
logger.log(f"Match{match_id}: Looser {data_api.get_player_name(looser_id)}: -Base({l_base}) + Khorne({l_khorne}) - Slaanesh({slaanesh}) - Tzeentch({tzeentch}) = {calc_results[looser_id]["total"]}")
|
logger.log(f"Match{match_id}: Looser {data_api.get_player_name(looser_id)}: -Base({l_base}) + Khorne({l_khorne}) - Slaanesh({slaanesh}) - Tzeentch({tzeentch}) = {calc_results[looser_id]["total"]}")
|
||||||
data_api.save_calculated_match(calc_results)
|
data_api.save_calculated_match(calc_results)
|
||||||
|
achievments.check_player_achievments(winner_id, system_id)
|
||||||
|
achievments.check_player_achievments(looser_id, system_id)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def determine_draw_diff(sys_id):
|
def determine_draw_diff(sys_id):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user