|
|
|
@@ -36,6 +36,7 @@ function removeActionDescription() { |
|
|
|
} |
|
|
|
|
|
|
|
function moveToRoom(src, exit, dest, state) { |
|
|
|
const from = state.world[state.player.location]; |
|
|
|
const room = state.world[dest]; |
|
|
|
|
|
|
|
if (exit.hooks) { |
|
|
|
@@ -54,13 +55,22 @@ function moveToRoom(src, exit, dest, state) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
state.world[dest].move(state.world[dest], state); |
|
|
|
if (from && from.exit) |
|
|
|
from.exit(state.world[dest], state); |
|
|
|
|
|
|
|
if (room.move) |
|
|
|
room.move(state.world[dest], state); |
|
|
|
|
|
|
|
if (room.enter) |
|
|
|
room.enter(state.world[dest], state); |
|
|
|
|
|
|
|
state.player.location = dest; |
|
|
|
|
|
|
|
refresh(); |
|
|
|
} |
|
|
|
|
|
|
|
function goToRoom(dest, state) { |
|
|
|
const from = state.world[state.player.location]; |
|
|
|
const room = state.world[dest]; |
|
|
|
|
|
|
|
if (room.hooks) { |
|
|
|
@@ -71,17 +81,23 @@ function goToRoom(dest, state) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (from && from.exit) |
|
|
|
from.exit(state.world[dest], state); |
|
|
|
|
|
|
|
if (room.enter) |
|
|
|
room.enter(state.world[dest], state); |
|
|
|
|
|
|
|
state.player.location = dest; |
|
|
|
|
|
|
|
refresh(); |
|
|
|
} |
|
|
|
|
|
|
|
function updateRoom(state) { |
|
|
|
const name = state.player.location |
|
|
|
const name = state.player.location; |
|
|
|
const room = state.world[name]; |
|
|
|
|
|
|
|
if (!state.player.rooms[name.id]) { |
|
|
|
state.player.rooms[name.id] = {}; |
|
|
|
if (!state.player.rooms[room.id]) { |
|
|
|
state.player.rooms[room.id] = {}; |
|
|
|
} |
|
|
|
|
|
|
|
const areaName = document.querySelector("#area-name"); |
|
|
|
|