View Source Kalevala.Event.Movement.Request (kalevala v0.1.0)

Character requesting to move from their current room in a exit_name

A move request transitions through several stages before commiting or aborting.

The character requests the room to move in a exit_name.

%Kalevala.Event{
  topic: Kalevala.Event.Movement.Request,
  data: %Kalevala.Event.Movement.Request{
    character: character,
    exit_name: "north"
  }
}

The room process sends a voting event to the Zone after determining that there is a valid exit in this exit_name.

%Kalevala.Event{
  topic: Kalevala.Event.Movement.Voting,
  data: %Kalevala.Event.Movement.Voting{
    character: character,
    from: start_room_id,
    to: end_room_id,
    exit_name: "north"
  }
}

The zone then asks the to and from room if they are OK with the character moving. Each room will be GenServer.called to block and keep this synchronous. The room movement/2 callback will be called for each room, so they can vote on the movement. Return the event with aborted: true to reject movement.

Kalevala.Event.Movement.Commit - After both room's agree that the player can move, the zone sends this event to the character.

%Kalevala.Event{
  topic: Kalevala.Event.Movement.Commit,
  data: %Movement.Commit{
    character: character,
    from: start_room_id,
    to: end_room_id,
    exit_name: "north"
  }
}

Kalevala.Event.Movement.Abort - If either room rejects the movement, the zone will respond with an abort.

%Kalevala.Event{
  topic: Kalevala.Event.Movement.Abort,
  data: %Kalevala.Event.Movement.Abort{
    character: character,
    from: start_room_id,
    to: end_room_id,
    exit_name: "north",
    reason: :door_locked
  }
}

%Kalevala.Event{
  topic: Kalevala.Event.Movement.Abort,
  data: %Kalevala.Event.Movement.Abort{
    character: character,
    from: start_room_id,
    exit_name: "north",
    reason: :no_exit
  }
}

On a commit, the player leaves the old room, and enters the new one.

%Kalevala.Event{
  topic: Kalevala.Event.Movement,
  data: %Kalevala.Event.Movement{
    character: character,
    direction: :to,
    reason: "Player enters from the south."
  }
}

%Kalevala.Event{
  topic: Kalevala.Event.Movement,
  data: %Kalevala.Event.Movement{
    character: character,
    direction: :from,
    reason: "Player leaves to the north."
  }
}

Link to this section Summary

Types

t()

Signal that a character wishes to move to another location

Link to this section Types

@type t() :: %Kalevala.Event.Movement.Request{
  character: term(),
  exit_name: term(),
  metadata: term()
}

Signal that a character wishes to move to another location

  • character is the character moving
  • exit is the exit_name of the exit the player wants to move