-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.py
68 lines (57 loc) · 2.24 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
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
import world, tiles
from player import Player
from helpa import helpa
from parse_translate import parse_translate # natural languiage to game speak
for x in range(100):
print "\n"
def action_parser(action_input, available_actions, player, room):
for action in available_actions:
if action_input == action.hotkey:
player.do_action(action, **action.kwargs)
break
else:
commands = action_input.split()
if commands[0] == "examine" and player.inventory is not None:
for item in player.inventory:
# if commands[1] in item.description:
if commands[1] in item.shortnames:
player.describe_an_item(item)
if commands[0] == "npc" and isinstance(room, (tiles.NPCRoom)):
print room.describe_npc()
# player.describe_npc("CFO")
if commands[0] == "help":
print "\tfetching help"
helpa()
# else:
# print "\tNot Found!!!"
def play():
world.load_tiles()
# pcs = npcs()
player = Player()
room = world.tile_exists(player.location_x, player.location_y)
# print(room.tile_name())
# print vars(room)
print room.room_name()
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()
room.exits_text()
# print exits
# for action in available_actions:
# print(action)
# print " "
action_input = raw_input('\tWhat would you like to do? :')
action_input = parse_translate(action_input)
# print action_input
action_parser(action_input, available_actions, player, room)
# for action in available_actions:
# if action_input == action.hotkey:
# player.do_action(action, **action.kwargs)
# break
if __name__ == "__main__":
play()