diff --git a/apps/amethyst/lib/apps/game_coordinator.ex b/apps/amethyst/lib/apps/game_coordinator.ex index cfa3698..d9b3ad6 100644 --- a/apps/amethyst/lib/apps/game_coordinator.ex +++ b/apps/amethyst/lib/apps/game_coordinator.ex @@ -96,7 +96,7 @@ defmodule Amethyst.GameCoordinator do end defp _find(type, state) do - case state.games |> Enum.find(fn {_, game} -> game.mod == type end) do + case state.games |> Enum.find(fn {_, game} -> game.mod == type && game[:mod].joinable?(game[:refs]) end) do nil -> {nil, state} {_, game} -> {game, state} end diff --git a/apps/example_game/lib/example/game.ex b/apps/example_game/lib/example/game.ex index 9e7af55..78df9f7 100644 --- a/apps/example_game/lib/example/game.ex +++ b/apps/example_game/lib/example/game.ex @@ -20,4 +20,9 @@ defmodule Example.Game do Logger.info("Player at #{inspect(from)} moved to #{x}, #{y}, #{z}") :ok end + + @impl true + def joinable?(refs) do + true + end end