From e68ef52292d59730ea21ff9eba53014dc096c2c4 Mon Sep 17 00:00:00 2001 From: c0de Date: Thu, 10 Nov 2022 21:02:20 -0600 Subject: [PATCH] Add calculation for the difference score --- GhostBallBot/game/guess.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/GhostBallBot/game/guess.py b/GhostBallBot/game/guess.py index 1d8195d..69ed2af 100644 --- a/GhostBallBot/game/guess.py +++ b/GhostBallBot/game/guess.py @@ -74,7 +74,27 @@ class ProcessGuess: return self.difference def get_difference_score(self): + """ + Calculate points for the player based on how close + they are (within range of 0-500) to the pitch_value + """ + + if self.difference == 0: + self.difference_score = 15 + elif self.difference > 0 and self.difference < 21: + self.difference_score = 8 + elif self.difference > 20 and self.difference < 51: + self.difference_score = 5 + elif self.difference > 50 and self.difference < 101: + self.difference_score = 3 + elif self.difference > 100 and self.difference < 151: + self.difference_score = 2 + elif self.difference > 150 and self.difference < 201: + self.difference_score = 1 + elif self.difference > 200 and self.difference < 495: self.difference_score = 0 + else: + self.difference_score = -5 self.update_player_total_points() return self.difference_score