-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZombieGame.py
99 lines (85 loc) · 2.88 KB
/
ZombieGame.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 25 16:28:48 2021
@author: rimes
"""
from Zombies.randomZombie import randomZombie
from Zombies.inTheMomentZombie import inTheMomentZombie
from Zombies.carefulZombie import carefulZombie
from Zombies.twoBrainZombie import twoBrainZombie
from Zombies.twoShotgunZombie import twoShotgunZombie
from Zombies.userZombie import userZombie
import time
def printScores(scores, counter):
if not counter:
print("Final scores are: ")
else:
print("Scores at the end of round " + str(counter) + " are:")
for i in list(scores.keys()):
print(i.name + ": " + str(scores[i]))
time.sleep(8)
print()
if __name__ == "__main__":
randZom = randomZombie()
inMomentZom = inTheMomentZombie()
carfulZom = carefulZombie()
twoBrainZom = twoBrainZombie()
twoShotZom = twoShotgunZombie()
name = input("Please enter your Zombie name.\n")
print()
user = userZombie(name)
scores = {randZom: 0, inMomentZom : 0, carfulZom : 0, twoBrainZom : 0,
twoShotZom : 0, user : 0}
maxScore = 0
winner = None
counter = 1
while maxScore < 13:
for i in list(scores.keys()):
temp = i.takeTurn()
scores[i] += temp
print(i.name + " ended their turn with a score of " + str(temp) + ".")
if i != user:
time.sleep(8)
else:
time.sleep(2)
print()
if scores[i] > maxScore:
maxScore = scores[i]
winner = i
printScores(scores, counter)
counter += 1
print("Looks like " + winner.name + " got to 13 first. Everyone else has one more chance!")
for i in list(scores.keys()):
if i == winner:
continue
temp = i.takeTurn()
scores[i] += temp
print(i.name + " ended their turn with a score of " + str(temp) + ".")
time.sleep(8)
print()
winners = [winner]
for i in list(scores.keys()):
if scores[i] > maxScore:
maxScore = scores[i]
winners = [i]
elif scores[i] == maxScore and i not in winners:
winners.append(i)
if len(winners) > 1:
print("Looks like we have a tie!", end =" ")
for i in winners:
print(i.name, end = ", ")
print("will go again.")
maxScore = 0
winner = None
for i in winners:
temp = i.takeTurn()
scores[i] += temp
print(i.name + " ended their turn with a score of " + str(temp) + ".")
time.sleep(8)
print()
if temp > maxScore:
maxScore = scores[i]
winner = i
print("We have a winner! Congratulations " + winner.name + "!! Looks like" +
" you're the most fit zombie.")
printScores(scores, False)