-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbesenitsa.py
32 lines (25 loc) · 939 Bytes
/
besenitsa.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
from game.players.input_player import InputPlayer
from game.engine import *
import game.level as level
DIFFICULTIES = [level.EASY, level.MEDIUM, level.HARD, level.PESHO_BAFTATA]
def main():
print("Welcome to Besenitsa.")
d = -1
while d not in range(len(DIFFICULTIES)):
try:
d = int(input("Select level [0-3]: "))
except ValueError:
print("Please enter a valid number (0, 1, 2 or 3).")
level = DIFFICULTIES[d]
player = InputPlayer(level.failed_attempts)
engine = BesenitsaEngine(level.word, player)
outcome = GameState.ONGOING
while outcome == GameState.ONGOING:
print(f"Word: {engine.masked_word}\nFailed attempts left: {player.hp}")
outcome = engine.guess()
if outcome == GameState.LOST:
print("Sorry, you lost.")
elif outcome == GameState.WON:
print("Congrats! You won.")
if __name__ == "__main__":
main()