This repository was archived by the owner on Jul 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
95 lines (74 loc) · 2.16 KB
/
main.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
from Animal import setUpAnimalCards, get_animals_list
from Planet import setUpPlanetCards, get_planets_list
from random import choice
from time import sleep
from os import system
gameOptions = ["animals", "planets"]
print(gameOptions)
deckAnswer = input("What type of deck would you prefer?")
# while answer is invalid, ask for new input
while deckAnswer not in gameOptions:
deckAnswer = input("type valid option:")
# setting up game
gameList = []
if deckAnswer == "animals":
setUpAnimalCards()
gameList = get_animals_list()
elif deckAnswer == "planets":
setUpPlanetCards()
gameList = get_planets_list()
print("welcome to card battles")
print("")
print("CARDS:")
for oneCard in gameList:
print(oneCard.name)
playAgainOptions = ["y", "yes", "yup", "sure", "ye", "yea"]
playAgain = "y"
userScore = 0
botScore = 0
# game loop
while playAgain in playAgainOptions:
userChoice = choice(gameList)
print("")
print("\nYour card is...", userChoice.name)
userChoice.print_stats()
gameList.remove(userChoice)
botChoice = choice(gameList)
print("\nComputer's card is...???")
print("\nChoose a stat:")
print(userChoice.options)
answer = input()
while answer not in userChoice.options:
answer = input("type valid option:")
user_stat = userChoice.get_value(answer)
bot_stat = botChoice.get_value(answer)
print("comparing " + answer + "...")
sleep(1)
print(userChoice.name + " " + str(user_stat))
print(botChoice.name + " " + str(bot_stat))
# check which is bigger
if user_stat > bot_stat:
print("You Win!")
userScore += 1
elif user_stat == bot_stat:
print("Tied!")
else:
print("Bot Wins!")
botScore += 1
print("Current user score: " + str(userScore))
print("Current bot score: " + str(botScore))
sleep(2)
playAgain = input("Would you like to play again?")
playAgain.lower().strip()
# clears screen
system("clear")
print("Game Over!")
print("Final user score: " + str(userScore))
print("Final bot score: " + str(botScore))
print("")
if userScore > botScore:
print("you beat the machine!")
elif userScore == botScore:
print("you both tied!")
else:
print("the machine is victorious")