-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller.py
43 lines (36 loc) · 1.11 KB
/
controller.py
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
class GameController:
def __init__(self):
self.aiPoints = 0
self.humanPoints = 0
self.aiTurn = True
self.GameEnded = False
def getAiPoints(self):
return int(self.aiPoints)
def setAiPoints(self, points):
self.aiPoints += points
def getHumanPoints(self):
return int(self.humanPoints)
def setHumanPoints(self, points):
self.humanPoints += points
def play(self, ai, human):
if self.GameEnded:
return
if self.aiTurn:
if ai == human:
self.aiTurn = False
else:
self.setAiPoints(ai)
else:
if ai == human:
self.GameEnded = True
else:
self.setHumanPoints(human)
if self.aiPoints < self.humanPoints:
self.GameEnded = True
def getWinner(self):
if self.aiPoints > self.humanPoints:
return ["AI WON", (255, 0, 0)]
elif self.aiPoints < self.humanPoints:
return ["YOU WON", (0, 0, 255)]
else:
return ["Tie", (0, 255, 0)]