diff options
Diffstat (limited to 'app_types')
-rw-r--r-- | app_types/__init__.py | 16 |
1 files changed, 16 insertions, 0 deletions
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 |