-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgameplay.py
45 lines (34 loc) · 1.24 KB
/
gameplay.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
"""rock == rock
paper == paper
scissors == scissors
rock #User input : scissors #Computer throw
scissors : paper
paper : rock
if UserThrow == ComputerThrow #In the case that your choice ties with the computer
return "tie"
elif ComputerThrow is in our beatable #In the case that your choice beats the computer
return "you win!"
elif #In the case that your choice loses to the computer
return "womp womp"
"""
import typing
import random
# def playerThrow(gameDict:typing.Dict[str, typing.List[str]]) -> str:
# throws = list(gameDict.keys())
# playerThrow = input("Choose your weapon!")
# return playerThrow
def getComputerThrow(gameDict:typing.Dict[str, typing.List[str]]) -> str:
throws = list(gameDict.keys())
computerThrow = random.choice(throws)
return computerThrow
def findWinner(gameDict:typing.Dict[str, typing.List[str]], computerThrow:str, playerThrow:str) -> str:
if playerThrow == computerThrow:
return "tie"
if computerThrow not in gameDict:
print("Computer threw an invalid option")
if playerThrow not in gameDict:
print("Player threw an invalid option")
if computerThrow in gameDict[playerThrow]:
return "player wins"
else:
return "computer wins"