Current section
Files
Jump to
Current section
Files
lib/mjolnir/commands/walk.ex
defmodule Mjolnir.Commands.Walk do
use Mjolnir.Command
require Logger
alias Mjolnir.Components.{Location, Exits}
def call(state, [direction]) do
# pup = fetch_puppet!(state)
# room = fetch_entity!(pup.components[Location].location)
# exits = room.components[Exits].exits
# case select_exit(exits, direction) do
# nil ->
# {:not_found, state}
# exit ->
# update_component(pup, Location, fn exits ->
# exits
# end)
{:ok, state}
# end
end
# defp select_exit(exits, direction) do
# Enum.reduce(exits, [], fn {k, v}, acc ->
# {:ok, reg} = Regex.compile("^#{direction}")
# if !is_nil(exits[direction]) || String.match?(k, reg) do
# acc ++ [v]
# else
# acc
# end
# end)
# |> List.first()
# end
end