-
Notifications
You must be signed in to change notification settings - Fork 0
/
human_player.py
51 lines (38 loc) · 1.48 KB
/
human_player.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
from player import Player
from strings import INVALID_INPUT_WARNING
from colorama import Fore
yellow = Fore.YELLOW
class HumanPlayer(Player):
def solve_puzzle(self):
return input("\n Type the answer to solve the word puzzle: ").upper()
def choose_option(self, options):
# This is used both for the intro and the regular game play options
while True:
choice = input(f"\n {self.name}, please choose an option: ")
# Validate choice
if choice not in options:
print(f"{yellow}{INVALID_INPUT_WARNING}")
continue
# Return choice
return choice
def guess_a_consonant(self, letters):
while True:
guess = input(
"\n Which consonant would you like to guess?: ").upper()
# Validate consonant
if guess not in letters.consonants:
print(
f" {yellow}That letter is not in the list of remaining consonants.")
continue
# Return consonant
return guess
def guess_a_vowel(self, letters):
while True:
guess = input("\n Which vowel would you like to guess?: ").upper()
# Validate vowel
if guess not in letters.vowels:
print(
f" {yellow}That letter is not in the list of remaining vowels.")
continue
# Return vowel
return guess