Skip to content

Commit

Permalink
Run the formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
oestrich committed May 6, 2019
1 parent e15ff42 commit 5ea747c
Show file tree
Hide file tree
Showing 15 changed files with 52 additions and 24 deletions.
2 changes: 1 addition & 1 deletion lib/engine/command/router.ex
Expand Up @@ -3,7 +3,7 @@ defmodule Engine.Command.Router do
Parse player input and match against known patterns
"""

@callback parse(String.t()) :: {:ok, {String.t, map()}} | {:error, :unknown}
@callback parse(String.t()) :: {:ok, {String.t(), map()}} | {:error, :unknown}

@callback commands() :: [String.t()]

Expand Down
2 changes: 1 addition & 1 deletion lib/engine/command/router_macro.ex
Expand Up @@ -32,7 +32,7 @@ defmodule Engine.Command.RouterMacro do
Engine.Command.Router.parse(@patterns, text)
end

defoverridable [parse: 1, receive: 2]
defoverridable parse: 1, receive: 2
end
end

Expand Down
10 changes: 9 additions & 1 deletion lib/engine/conn.ex
Expand Up @@ -9,7 +9,15 @@ defmodule Engine.Conn do
Struct for tracking data being processed in a command or action
"""

defstruct [:foreman, :character, :params, :assigns, messages: [], private: %Engine.Conn.Private{}, lines: []]
defstruct [
:foreman,
:character,
:params,
:assigns,
messages: [],
private: %Engine.Conn.Private{},
lines: []
]
end

defmodule Engine.Conn.Event do
Expand Down
5 changes: 4 additions & 1 deletion lib/engine/grapevine.ex
Expand Up @@ -21,7 +21,10 @@ defmodule Engine.Grapevine do
redirect_uri: "urn:ietf:wg:oauth:2.0:oob"
}

response = HTTPoison.post(host() <> "oauth/token", Jason.encode!(params), [{"Content-Type", "application/json"}])
response =
HTTPoison.post(host() <> "oauth/token", Jason.encode!(params), [
{"Content-Type", "application/json"}
])

case response do
{:ok, %{status_code: 200, body: body}} ->
Expand Down
2 changes: 1 addition & 1 deletion lib/engine/help.ex
Expand Up @@ -66,7 +66,7 @@ defmodule Engine.Help do
end

def fetch_doc({command, path, function}) do
case Code.fetch_docs(command) do
case Code.fetch_docs(command) do
{:docs_v1, 2, :elixir, "text/markdown", _, _, functions} ->
{path, fetch_function_doc(function, functions)}

Expand Down
1 change: 1 addition & 0 deletions lib/engine/listener.ex
Expand Up @@ -67,6 +67,7 @@ defmodule Engine.Listener do

defp set_listener(state, listener) do
state = Map.put(state, :listener, listener)

case Application.get_env(:spigot, :listener)[:tls] do
true ->
{:noreply, state, {:continue, :listen_tls}}
Expand Down
1 change: 1 addition & 0 deletions lib/engine/sessions/auth.ex
Expand Up @@ -74,6 +74,7 @@ defmodule Engine.Sessions.Auth do
redirect_uri: "urn:ietf:wg:oauth:2.0:oob"
}
}

send(state.foreman, {:send, event})
end

Expand Down
1 change: 0 additions & 1 deletion lib/engine/sessions/options.ex
Expand Up @@ -94,4 +94,3 @@ defmodule Engine.Sessions.Options do

defp process_option(state, _option), do: {:noreply, state}
end

2 changes: 1 addition & 1 deletion lib/engine/sink.ex
Expand Up @@ -7,7 +7,7 @@ defmodule Engine.Sink do
Enum.map(actions, fn action ->
quote do
def handle_info(action = %unquote(module){action: unquote(action)}, state) do
process_action(state, action, &unquote(module).unquote(action)/2)
process_action(state, action, &(unquote(module).unquote(action) / 2))
end
end
end)
Expand Down
20 changes: 18 additions & 2 deletions lib/spigot/character.ex
@@ -1,3 +1,19 @@
defmodule Spigot.Character.Vitals do
@moduledoc """
Struct for character vitals such as health
"""

@derive Jason.Encoder
defstruct [
:health_points,
:max_health_points,
:skill_points,
:max_skill_points,
:endurance_points,
:max_endurance_points
]
end

defmodule Spigot.Character do
@moduledoc """
Session Character
Expand Down Expand Up @@ -46,15 +62,15 @@ defmodule Spigot.Character do
foreman: opts[:foreman],
combat: false,
character: %__MODULE__{
name: opts[:name],
name: opts[:name]
},
vitals: %Vitals{
health_points: 40,
max_health_points: 55,
skill_points: 35,
max_skill_points: 55,
endurance_points: 45,
max_endurance_points: 55,
max_endurance_points: 55
}
}

Expand Down
12 changes: 0 additions & 12 deletions lib/spigot/character/vitals.ex

This file was deleted.

4 changes: 3 additions & 1 deletion lib/spigot/core/views/say_view.ex
Expand Up @@ -2,7 +2,9 @@ defmodule Spigot.Core.SayView do
use Spigot, :view

def render("text", %{name: name, text: text}) do
~s(#{IO.ANSI.yellow()}#{name}#{IO.ANSI.reset()} says, #{IO.ANSI.green()}"#{text}"\n#{IO.ANSI.reset()})
~s(#{IO.ANSI.yellow()}#{name}#{IO.ANSI.reset()} says, #{IO.ANSI.green()}"#{text}"\n#{
IO.ANSI.reset()
})
end

def render("text", %{text: text}) do
Expand Down
4 changes: 3 additions & 1 deletion lib/spigot/grapevine/views/chat_view.ex
Expand Up @@ -2,7 +2,9 @@ defmodule Spigot.Grapevine.ChatView do
use Spigot, :view

def render("text", %{channel: channel, name: name, text: text}) do
~s([#{channel}] #{IO.ANSI.yellow()}#{name}#{IO.ANSI.reset()} says, #{IO.ANSI.green()}"#{text}"\n#{IO.ANSI.reset()})
~s([#{channel}] #{IO.ANSI.yellow()}#{name}#{IO.ANSI.reset()} says, #{IO.ANSI.green()}"#{text}"\n#{
IO.ANSI.reset()
})
end

def render("text", %{channel: channel, text: text}) do
Expand Down
9 changes: 8 additions & 1 deletion lib/spigot/routers.ex
Expand Up @@ -5,11 +5,15 @@ defmodule Spigot.Routers do

@routers [
Spigot.Core.Router,
Spigot.Grapevine.Router,
Spigot.Grapevine.Router
]

@doc false
def routers(), do: @routers

@doc """
Take a conn and execute a command if found
"""
def call(conn, command_text) do
case parse(command_text) do
{:error, :unknown} ->
Expand All @@ -21,6 +25,9 @@ defmodule Spigot.Routers do
end
end

@doc """
Parse through routers to find a matching command
"""
def parse(command_text) do
value =
Enum.find_value(routers(), fn router ->
Expand Down
1 change: 1 addition & 0 deletions verify.sh
@@ -1,5 +1,6 @@
set -e

mix format --check-formatted
mix compile --force --warnings-as-errors
mix test
mix credo

0 comments on commit 5ea747c

Please sign in to comment.