From d63bd0a9b2260872efd391d2ec0be1947dca57c7 Mon Sep 17 00:00:00 2001 From: Kodi Craft Date: Wed, 4 Sep 2024 11:24:04 +0200 Subject: [PATCH] Actually listen to the joinable? function --- apps/amethyst/lib/apps/game_coordinator.ex | 2 +- apps/example_game/lib/example/game.ex | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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