Skip to content

Commit

Permalink
Check if killer is alive before giving powerup (#948)
Browse files Browse the repository at this point in the history
  • Loading branch information
AminArria authored Sep 11, 2024
1 parent 4f3436b commit 300a84a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions apps/arena/lib/arena/game_updater.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1610,13 +1610,13 @@ defmodule Arena.GameUpdater do
defp grant_power_up_to_killer(game_state, _game_config, nil = _killer, _victim), do: game_state

defp grant_power_up_to_killer(game_state, game_config, killer, victim) do
amount_of_power_ups =
get_amount_of_power_ups(victim, game_config.game.power_ups_per_kill)

updated_killer = Player.power_up_boost(killer, amount_of_power_ups, game_config)

players = Map.get(game_state, :players) |> Map.put(killer.id, updated_killer)
Map.put(game_state, :players, players)
if Player.alive?(killer) do
amount_of_power_ups = get_amount_of_power_ups(victim, game_config.game.power_ups_per_kill)
updated_killer = Player.power_up_boost(killer, amount_of_power_ups, game_config)
put_in(game_state, [:players, killer.id], updated_killer)
else
game_state
end
end

defp get_amount_of_power_ups(%{aditional_info: %{power_ups: power_ups}}, power_ups_per_kill) do
Expand Down

0 comments on commit 300a84a

Please sign in to comment.