diff --git a/apps/bot_manager/lib/game_socket_handler.ex b/apps/bot_manager/lib/game_socket_handler.ex index e493cde23..07f989347 100644 --- a/apps/bot_manager/lib/game_socket_handler.ex +++ b/apps/bot_manager/lib/game_socket_handler.ex @@ -71,22 +71,17 @@ defmodule BotManager.GameSocketHandler do def handle_info(:perform_action, state) do Process.send_after(self(), :perform_action, @action_delay_ms) - send_current_action(state) + {:ok, update_block_attack_state(state)} + end - state = - case state.current_action do - {:attack, _} -> - Map.put(state, :attack_blocked, true) - Process.send_after(self(), :unblock_attack, Enum.random(2000..4000)) - - _ -> - state - end - - {:ok, state} + defp update_block_attack_state(%{current_action: {:attack, _}} = state) do + Process.send_after(self(), :unblock_attack, Enum.random(2000..4000)) + Map.put(state, :attack_blocked, true) end + defp update_block_attack_state(state), do: state + def handle_cast({:send, {_type, _msg} = frame}, state) do {:reply, frame, state} end