Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Nicolas Continanza <[email protected]>
  • Loading branch information
agustinesco and ncontinanza authored Apr 17, 2024
1 parent 7349814 commit e4cb643
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions apps/bot_manager/lib/bot_state_machine.ex
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ defmodule BotManager.BotStateMachine do
|> Map.filter(fn {_player_id, player} -> Utils.player_alive?(player) end)
|> Enum.map(fn {_player_id, player} ->
player_info =
get_ditance_and_direction_to_positions(bot_player.position, player.position)
get_distance_and_direction_to_positions(bot_player.position, player.position)

Map.merge(player, player_info)
end)
end

defp get_ditance_and_direction_to_positions(base_position, end_position) do
defp get_distance_and_direction_to_positions(base_position, end_position) do
%{x: x, y: y} = Vector.sub(end_position, base_position)
distance = :math.sqrt(:math.pow(x, 2) + :math.pow(y, 2))
direction = %{x: x / distance, y: y / distance}
Expand Down
6 changes: 3 additions & 3 deletions apps/bot_manager/lib/game_socket_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ defmodule BotManager.GameSocketHandler do

def handle_connect(_conn, state) do
send(self(), :decide_action)
send(self(), :perfom_action)
send(self(), :perform_action)
{:ok, state}
end

Expand Down Expand Up @@ -62,8 +62,8 @@ defmodule BotManager.GameSocketHandler do
{:ok, Map.put(state, :current_action, action)}
end

def handle_info(:perfom_action, state) do
Process.send_after(self(), :perfom_action, @action_delay_ms)
def handle_info(:perform_action, state) do
Process.send_after(self(), :perform_action, @action_delay_ms)

send_current_action(state)

Expand Down

0 comments on commit e4cb643

Please sign in to comment.