-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper.py
55 lines (52 loc) · 1.16 KB
/
helper.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
import random, time
from draw import *
"""
Displays the current status of two Player objects.
----------
user : Player object
bot : Player object
"""
def status(user, bot):
print ("\n" + "-" * 40)
user.status()
bot.status()
print ("-" * 40)
draw_update(user, bot)
"""
Allows the user to select a move from available options, and executes move against the second Player object.
----------
user : Player object
bot : Player object
"""
def user_move(user, bot):
print ("Choose a move:")
for m in user.moves:
print (m)
answer = input(">")
if answer in user.moves:
print (user.name, ":", answer)
move = user.moves[answer]
move(bot)
move_user()
else:
print ("Invalid")
user_move(user, bot)
time.sleep(1)
status(user, bot)
"""
Selects a random move for the bot Player to use against the user Player.
----------
user : Player object
bot : Player object
"""
def bot_move(user, bot):
print ("Computer's turn...")
time.sleep(1)
print("")
move_name = random.choice(list(bot.moves.keys()))
move = bot.moves[move_name]
print (bot.name, ":", move_name)
move(user)
move_bot()
time.sleep(1)
status(user, bot)