Skip to content
Browse files

Added win% Closes #10

  • Loading branch information...
1 parent 705cc47 commit bf84029e68eef145cb6157722a5ae08f508f8a2e @johnzimmerman committed Mar 14, 2012
Showing with 12 additions and 2 deletions.
  1. +12 −2 foosbot.py
View
14 foosbot.py
@@ -250,7 +250,12 @@ def handle_message(self, sender, message):
stats = '-- FoosBot Team Records --\n\n'
for row in result:
- stats += '%s and %s (%s-%s)\n' % row
+ wins = float(row[2])
+ games_played = float(wins + row[3])
+ win_percentage = '%.3f' % (wins / games_played)
+ win_percentage = str(win_percentage)[1:] if float(win_percentage) < 1 else str(win_percentage)
+ row = row + (win_percentage, )
+ stats += '%s and %s %s-%s (%s)\n' % row
reply = stats
@@ -264,7 +269,12 @@ def handle_message(self, sender, message):
stats = '-- FoosBot Player Records --\n\n'
for row in result:
- stats += '%s (%s-%s)\n' % row
+ wins = float(row[1])
+ games_played = float(wins + row[2])
+ win_percentage = '%.3f' % (wins / games_played)
+ win_percentage = str(win_percentage)[1:] if float(win_percentage) < 1 else str(win_percentage)
+ row = row + (win_percentage, )
+ stats += '%s %s-%s (%s)\n' % row
reply = stats

0 comments on commit bf84029

Please sign in to comment.
Something went wrong with that request. Please try again.