diff --git a/apps/arena/lib/arena/game_socket_handler.ex b/apps/arena/lib/arena/game_socket_handler.ex index 506dfdfe0..d7dbe21ff 100644 --- a/apps/arena/lib/arena/game_socket_handler.ex +++ b/apps/arena/lib/arena/game_socket_handler.ex @@ -34,6 +34,7 @@ defmodule Arena.GameSocketHandler do |> Map.put(:enable, game_status == :RUNNING) |> Map.put(:block_actions, false) |> Map.put(:game_finished, game_status == :ENDED) + |> Map.put(:player_alive, true) encoded_msg = GameEvent.encode(%GameEvent{ @@ -131,7 +132,12 @@ defmodule Arena.GameSocketHandler do @impl true def websocket_info({:player_dead, player_id}, state) do if state.player_id == player_id do - {:ok, Map.put(state, :enable, false)} + state = + state + |> Map.put(:enable, false) + |> Map.put(:player_alive, false) + + {:ok, state} else {:ok, state} end @@ -153,7 +159,7 @@ defmodule Arena.GameSocketHandler do end @impl true - def terminate(_reason, _req, %{game_finished: false} = state) do + def terminate(_reason, _req, %{game_finished: false, player_alive: true} = state) do spawn(fn -> Finch.build(:get, Utils.get_bot_connection_url(state.game_id, state.client_id)) |> Finch.request(Arena.Finch)