From 0d210d01b012c25b9b007d8adf577fe6dd006f11 Mon Sep 17 00:00:00 2001 From: Dmitrii Morozov Date: Wed, 31 Jul 2024 18:50:24 +0200 Subject: Added KD and WP stats --- app_types/__init__.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'app_types') diff --git a/app_types/__init__.py b/app_types/__init__.py index 436dc59..66f16c5 100644 --- a/app_types/__init__.py +++ b/app_types/__init__.py @@ -20,6 +20,22 @@ class UserStats: wins: int minutesplayed: int + def get_kd(self): + try: + kd = self.kills / (self.matches_played - self.wins) + except ZeroDivisionError: + kd = 0 + return float(format(kd, '.2f')) + + def get_winpercentage(self): + try: + winper = (self.wins * 100) / self.matches_played + except ZeroDivisionError: + winper = 0 + if winper > 100: + winper = 100 + return float(format(winper, '.2f')) + class User: id: str -- cgit v1.2.3