示例#1
0
 def adjacent_moves(self):
     moves = []
     if dungeon.room_exists(self.x + 1, self.y):
         moves.append(actions.MoveRight())
     if dungeon.room_exists(self.x - 1, self.y):
         moves.append(actions.MoveLeft())
     if dungeon.room_exists(self.x, self.y - 1):
         moves.append(actions.MoveUp())
     if dungeon.room_exists(self.x, self.y + 1):
         moves.append(actions.MoveDown())
     return moves
示例#2
0
文件: game.py 项目: mcnuggz/PythonRPG
def play():
	dungeon.load_rooms()
	player = Player()
	room = dungeon.room_exists(player.location_x, player.location_y)
	print(room.intro_text())
	while player.is_alive() and not player.victory:
		room = dungeon.room_exists(player.location_x, player.location_y)
		room.modify_player(player)
		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
示例#3
0
 def move(self, dx, dy):
     self.location_x += dx
     self.location_y += dy
     print(dungeon.room_exists(self.location_x, self.location_y).intro_text())