defmodule BwcWeb.Roster do
  import Plug.Conn

  def init(opts), do: opts

  def call(conn, _opts) do
    import Logger

    {:ok, player} =
      conn
      |> get_session(:username)
      |> case do
        nil -> {:ok, "Nobody"}
        username -> Bwc.get_or_create_player(username)
      end
    Logger.debug(player)
    assign(conn, :current_player, player)
  end
end
