Skip to content

Commit

Permalink
fix: deathmatch position in game tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
tvillegas98 committed Dec 17, 2024
1 parent c9b6f41 commit 3b0ee5a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apps/arena/lib/arena/game_tracker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ defmodule Arena.GameTracker do
| {:heal, player_id(), non_neg_integer()}
| {:kill_by_zone, player_id()}
| {:select_bounty, player_id(), bounty_quest_id()}
| {:deathmatch_position, player_id(), pos_integer()}

@spec push_event(pid(), event()) :: :ok
def push_event(match_pid, event) do
Expand Down Expand Up @@ -136,6 +137,11 @@ defmodule Arena.GameTracker do
|> put_in([:position_on_death], data.position_on_death - 1)
end

defp update_data(data, {:deathmatch_position, player_id, position}) do
data
|> put_in([:players, player_id, :position], position)
end

defp update_data(data, {:damage_taken, player_id, amount}) do
update_in(data, [:players, player_id, :damage_taken], fn damage_taken -> damage_taken + amount end)
end
Expand Down
1 change: 1 addition & 0 deletions apps/arena/lib/arena/game_updater.ex
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ defmodule Arena.GameUpdater do
teams_with_kills
|> Enum.reduce(game_state, fn {team, position}, game_state_acc ->
Enum.reduce(team.players, game_state_acc, fn player, game_state_acc ->
GameTracker.push_event(self(), {:deathmatch_position, player.id, position})
put_player_position(game_state_acc, player.id, position)
end)
end)
Expand Down

0 comments on commit 3b0ee5a

Please sign in to comment.