-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
102 lines (90 loc) · 2.63 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
96
97
98
99
100
101
102
from click.termui import clear, pause
from src.game.player import Player
from src.utils.data import fake
from src.utils.ui import fore, intro, welcome, shop_menu, player_menu, game_menu
def display_intro():
print(fore.GREEN + intro)
def display_welcome():
print(fore.YELLOW + welcome)
def display_menu():
print(
fore.YELLOW + f"""
Available action:
(1) Explore
(2) Eat
(3) Rest
"""
)
def display_status(player):
print(
fore.GREEN + f"""
Your Status:
{player.name} Level {player.level}
XP: {player.xp}/100 Coins: {player.coins}
HP: {player.health} EP: {player.energy}
Hunger: {player.hunger} Thirst: {player.thirst}
"""
)
def display_inventory(player):
print(fore.GREEN + f"""
Your Inventory:
Foods:
{player.foods_inventory}
Items:
{player.items_inventory}
""")
def shop(player):
clear()
print(fore.YELLOW + shop_menu)
item = str(input(fore.MAGENTA + f"{player.name} want to buy: "))
player.shop(item)
def next_turn(player, check_survive=True):
if check_survive:
player.check_survive()
pause()
main(player)
else:
pause()
main(player)
def main(player):
clear()
display_welcome()
choice = str(input(fore.MAGENTA + "Your choice: "))
if choice == '1':
player.explore()
next_turn(player)
elif choice == '2':
food = str(input(fore.MAGENTA + "Food name: "))
player.eat(food)
player.drink()
next_turn(player)
elif choice == '3':
hours = int(input(fore.MAGENTA + "Rest for (hour): "))
player.rest(hours)
next_turn(player)
elif choice == 'status':
display_status(player)
next_turn(player, check_survive=False)
elif choice == 'help':
display_menu()
next_turn(player, check_survive=False)
elif choice == 'inventory':
display_inventory(player)
next_turn(player, check_survive=False)
elif choice == 'exit':
return
else:
print(fore.RED + "Invalid choice!")
next_turn(player, check_survive=False)
if __name__ == "__main__":
try:
display_intro()
player_name = str(input(fore.MAGENTA + "Enter your name: "))
if not player_name:
player_name = fake.first_name()
player = Player(player_name)
else:
player = Player(player_name)
main(player)
except KeyboardInterrupt:
print("\nProgram closed.")