Skip to content

Commit

Permalink
Fix credo moving code to new function
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico-Sanchez committed Nov 1, 2024
1 parent 7b31b62 commit 7f213be
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions apps/arena/lib/arena/game/effect.ex
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,7 @@ defmodule Arena.Game.Effect do
send(self(), {:damage_done, owner_id, real_damage})

Entities.take_damage(entity, real_damage, owner_id)
|> update_in([:aditional_info, :effects], fn effects ->
Enum.map(effects, fn current_effect ->
if current_effect.id == effect.id do
Map.put(current_effect, :player_owner_id, owner_id)
else
current_effect
end
end)
end)
|> add_player_owner_of_effect_to_entity(effect.id, owner_id)
end
end

Expand Down Expand Up @@ -301,6 +293,18 @@ defmodule Arena.Game.Effect do
end
end

defp add_player_owner_of_effect_to_entity(entity, effect_id, owner_id) do
update_in(entity, [:aditional_info, :effects], fn effects ->
Enum.map(effects, fn current_effect ->
if current_effect.id == effect_id do
Map.put(current_effect, :player_owner_id, owner_id)
else
current_effect
end
end)
end)
end

defp add_effect_to_entity(game_state, entity, effect, owner_id, start_action_removal_in_ms) do
now = System.monotonic_time(:millisecond)

Expand Down

0 comments on commit 7f213be

Please sign in to comment.