-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.py
31 lines (27 loc) · 1.14 KB
/
game.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
import world
from player import Player
def play():
world.load_tiles()
player = Player()
#These lines load the starting room and display the text
room = world.tile_exists(player.location_x, player.location_y)
print(room.intro_text())
while player.is_alive() and not player.victory:
room = world.tile_exists(player.location_x, player.location_y)
room.modify_player(player)
# Check again since the room could have changed the player's state
if player.is_alive() and not player.victory:
print("Choose an action:\n")
available_actions = room.available_actions()
for action in available_actions:
print(action)
action_input = input('Action: ')
for action in available_actions:
if action_input == action.hotkey:
player.do_action(action, **action.kwargs)
break
if not player.is_alive():
print("--------------------------------------------------")
print("The enemy has defeated you. Maybe you need a stroner weapon. Try again.")
if __name__ == "__main__":
play()