diff --git a/lib/teiserver/battle/balance/respect_avoids.ex b/lib/teiserver/battle/balance/respect_avoids.ex index 73371ddcd..d51c54ed2 100644 --- a/lib/teiserver/battle/balance/respect_avoids.ex +++ b/lib/teiserver/battle/balance/respect_avoids.ex @@ -53,7 +53,7 @@ defmodule Teiserver.Battle.Balance.RespectAvoids do players = flatten_members(expanded_group) parties = get_parties(expanded_group) - noobs = get_noobs(players) |> sort_noobs() + noobs = get_solo_noobs(players) |> sort_noobs() experienced_players = get_experienced_players(players, noobs) experienced_player_ids = experienced_players |> Enum.map(fn x -> x.id end) players_in_parties_count = parties |> List.flatten() |> Enum.count() @@ -140,7 +140,7 @@ defmodule Teiserver.Battle.Balance.RespectAvoids do ] true -> - "New players: None" + "Solo new players: None" end logs = @@ -514,10 +514,10 @@ defmodule Teiserver.Battle.Balance.RespectAvoids do end # Noobs have high uncertainty and chev 1,2,3 - @spec get_noobs([RA.player()]) :: any() - def get_noobs(players) do + @spec get_solo_noobs([RA.player()]) :: any() + def get_solo_noobs(players) do Enum.filter(players, fn player -> - is_newish_player?(player.rank, player.uncertainty) + is_newish_player?(player.rank, player.uncertainty) && !player.in_party? end) end diff --git a/lib/teiserver_web/live/battles/match/show.ex b/lib/teiserver_web/live/battles/match/show.ex index 2e5c35267..01917f920 100644 --- a/lib/teiserver_web/live/battles/match/show.ex +++ b/lib/teiserver_web/live/battles/match/show.ex @@ -93,7 +93,7 @@ defmodule TeiserverWeb.Battle.MatchLive.Show do match_id: match.id ] ) - |> Map.new(fn log -> {log.user_id, log} end) + |> Map.new(fn log -> {log.user_id, get_prematch_log(log)} end) # Creates a map where the party_id refers to an integer # but only includes parties with 2 or more members @@ -185,6 +185,14 @@ defmodule TeiserverWeb.Battle.MatchLive.Show do end) |> Enum.sort_by(fn v -> v end, &<=/2) + balanced_members = + Enum.map(members, fn x -> + team_id = get_team_id(x.user_id, past_balance.team_players) + Map.put(x, :team_id, team_id) + end) + |> Enum.sort_by(fn m -> rating_logs[m.user.id].value["rating_value"] end, &>=/2) + |> Enum.sort_by(fn m -> m.team_id end, &<=/2) + game_id = cond do match.game_id -> match.game_id @@ -202,6 +210,7 @@ defmodule TeiserverWeb.Battle.MatchLive.Show do |> assign(:match, match) |> assign(:match_name, match_name) |> assign(:members, members) + |> assign(:balanced_members, balanced_members) |> assign(:rating_logs, rating_logs) |> assign(:parties, parties) |> assign(:past_balance, past_balance) @@ -224,6 +233,33 @@ defmodule TeiserverWeb.Battle.MatchLive.Show do end end + # Adjust the logs so that we use the prematch values of rating/uncertainty + # Prematch values are more relevant to understanding balance logs + defp get_prematch_log(log) do + %{ + "rating_value" => rating_value, + "uncertainty" => uncertainty, + "rating_value_change" => rating_value_change, + "uncertainty_change" => uncertainty_change + } = log.value + + old_rating = rating_value - rating_value_change + old_uncertainty = uncertainty - uncertainty_change + + Map.put(log, :rating_value, old_rating) + |> Map.put(:uncertainty, old_uncertainty) + end + + def get_team_id(player_id, team_players) do + {team_id, _players} = + Enum.find(team_players, fn {_k, player_ids} -> + Enum.any?(player_ids, fn x -> x == player_id end) + end) + + # team_id should start at 0 even though first key is 1 + team_id - 1 + end + defp generate_new_balance_data(match, algorithm) do # For the section "If balance we made using current ratings", do not fuzz ratings # This means the rating used is exactly equal to what is stored in database diff --git a/lib/teiserver_web/live/battles/match/show.html.heex b/lib/teiserver_web/live/battles/match/show.html.heex index 7543d7f62..2ebe41ead 100644 --- a/lib/teiserver_web/live/battles/match/show.html.heex +++ b/lib/teiserver_web/live/battles/match/show.html.heex @@ -303,27 +303,80 @@
Name & Party | +Team | +Rating | +Uncertainty | +||
---|---|---|---|---|---|
+ <%= m.user.name %> + | + <%= if party_colour do %> +
+ |
+ <% else %>
+ + + | + <% end %> +<%= m.team_id + 1 %> | ++ <%= if rating != nil do %> + <%= rating.value["rating_value"] |> round(2) %> + <% end %> + | ++ <%= if rating != nil do %> + <%= rating.value["uncertainty"] |> round(2) %> + <% end %> + | +