-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
52 lines (45 loc) · 1.54 KB
/
main.py
File metadata and controls
52 lines (45 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from elo import Elo
from db import Database
class Main():
def __init__(self):
self.db = Database()
def commands(self):
print()
print("1 - add a player")
print("2 - count elo")
print("3 - print elos")
print("0 - quit")
print()
def give_command(self, command):
if command == 1:
self.db.add_player()
if command == 2:
name = input("name: ")
elo = self.db.find_player_elo(name)[0]
total_cups = int(input("number of cups in game:"))
opponent_elo = float(input("opponent average elo: "))
cups_drank = int(input("cups you drank: "))
new = input("first game (y/n) ")
if new == "y":
count = Elo(elo, opponent_elo, cups_drank, True, total_cups)
else:
count = Elo(elo, opponent_elo, cups_drank, False, total_cups)
new_elo = count.count()
total_games = self.db.palyers[name][1] + 1
total_cups = self.db.palyers[name][1] + cups_drank
self.db.palyers[name] = [elo, total_games, total_cups]
return new_elo
if command == 3:
for key, val in self.db.palyers.items():
print(f"{key}: {val[0]}")
if __name__=="__main__":
main = Main()
while True:
main.commands()
command = int(input("command: "))
print()
if command == 0:
print("bye")
break
else:
main.give_command(command)