character/targeted
combat/ticked
room/entered
room/heard
state/ticked
commands/emote
commands/move
commands/say
commands/skill
commands/target
defmodule Data.Events do
@type action :: String.t()
@type options_mapping :: map()
@callback type() :: String.t()
@callback allowed_actions?() :: [action()]
@callback options :: options_mapping()
def mapping() do
%{
"room/entered" => Data.Events.RoomEntered,
"room/heard" => Data.Events.RoomHeard,
}
end
end
defmodule Data.Events.Actions do
@callback type() :: String.t()
@callback options :: options_mapping()
def mapping() do
%{
"communications/say" => Data.Events.Actions.Communications.Say,
"commications/emote" => Data.Events.Actions.Communications.Emote,
}
end
end
{
"type": "room/entered",
"options": {},
"actions": []
}
defmodule Data.Events.RoomEntered do
defstruct [:type, :options, :actions]
@behaviour Data.Events
@impl true
def type(), do: "room/entered"
@impl true
def allowed_actions?() do
[
"communications/emote",
"communications/say"
]
end
@impl true
def options(), do: []
end
defmodule Data.Events.RoomHeard do
defstruct [:type, :options, :actions]
@behaviour Data.Events
@impl true
def type(), do: "room/heard"
@impl true
def allowed_actions?(), do: ["communications/say", "communications/emote"]
@impl true
def options(), do: [regex: :string]
end
defmodule Data.Events.CombatTick do
defstruct [:type, :actions]
@behaviour Data.Events
@impl true
def allowed_actions?(), do: ["target/effects"]
@impl true
def options(), do: []
end
{
"type": "communications/say",
"delay": 0,
"options": {}
}
defmodule Data.Events.Actions.Communications.Say do
defstruct [:type, :delay, :options]
@behaviour Data.Events.Actions
@impl true
def type(), do: "communications/say"
@impl true
def options(), do: [message: :string, messages: {:array, :string}]
end
defmodule Data.Events.Actions.Target.Effects do
defstruct [:type, :delay, :options]
@behaviour Data.Events.Actions
@impl true
def type(), do: "target/effects"
@impl true
def options(), do: [text: :string, weight: :integer, effects: {:array, :effect}]
end
What I want them to look like:
{
"type": "tick",
"options": {
"random_delay": 50,
"minimum_delay": 15
},
"actions": [
{
"type": "channels/emote",
"options": {
"message": "moves about the store"
}
},
{
"type": "channels/emote",
"delay": 1,
"options": {
"message": "moves about the store",
"status_key": "moving",
"status_line": "[name] is moving around the store",
"status_listen": "[name] is whistling"
}
}
]
}
{
"type": "room/entered",
"actions": [
{
"type": "communications/emote",
"delay": 0.5,
"options": {
"message": "[name] glances up from reading his paper",
}
},
{
"type": "communications/say",
"delay": 0.75,
"options": {
"message": "Welcome!"
}
},
{
"type": "communications/say",
"delay": 0.75,
"options": {
"message": "How can I help you?"
}
}
]
}
{
"type": "room/heard",
"options": {
"regex": "hello"
},
"actions": [
{
"type": "communications/say",
"delay": 0.5,
"options": {
"message": "Welcome!"
}
},
]
}
{
"type": "combat/tick",
"actions": [
{
"type": "target/effects",
"delay": 0.5,
"options": {
"text": "{user} slashes at you.",
"weight": 10,
"effects": [
{
"kind": "damage",
"type": "slashing",
"amount": 10
}
]
}
}
]
}