Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
84 lines (53 sloc) 1.69 KB
---
syntax:
- "go <direction>"
- "enter <direction>"
logic: |
output = ''
direction = arg['direction']
location = @player.location
# If an exit exists, load destination location and issue look command
if (@locations[location].exits && @locations[location].exits[direction])
# If player is trying to move around in the dark,
# and darkness is lethal in the game, kill player
if @locations[location].dark \
and @locations[location].dark != 'safe' \
and !@player.has_lit_item
@game.over = true
return "You trip in the dark and break your neck.\n"
else
if (@locations[location].exits[direction]['condition'])
result = instance_eval(@locations[location].exits[direction]['condition'])
if (!result['success'])
return result['message']
end
if (result['message'])
output << result['message']
end
end
@state['last_location'] = location
@player.location = @locations[location].exits[direction]['destination']
return output + '>look'
end
# Otherwise check for a door
elsif @doors[direction]
door = direction
# If the door exists in the player's location, try it
if @doors[door].locations.include?(location)
# Go through door, if it's open
if @doors[door].traits['opened']
attempt_successful = @doors[door].attempt_entry(@player, @props)
if attempt_successful
return '>look'
else
return "Something won't fit through.\n"
end
else
return "It's not open.\n"
end
else
return "You can't go that way.\n"
end
else
return "You can't go that way.\n"
end