Skip to content

Commit

Permalink
Cleanup and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
L-e-x-o-n committed Jun 9, 2024
1 parent b2960e5 commit f2b76e7
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 126 deletions.
16 changes: 11 additions & 5 deletions lib/teiserver/battle/libs/match_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ defmodule Teiserver.Battle.MatchLib do
end
end


def list_game_types() do
[
"Duel",
Expand Down Expand Up @@ -137,10 +136,17 @@ defmodule Teiserver.Battle.MatchLib do

def make_match_name(match) do
case match.game_type do
"Duel" -> "Duel on #{match.map}"
type when type in ["Small Team", "Big Team"] -> "#{match.team_size}v#{match.team_size} on #{match.map}"
"FFA" -> "#{match.team_count} way FFA on #{match.map}"
t -> "#{t} game on #{match.map}"
"Duel" ->
"Duel on #{match.map}"

type when type in ["Small Team", "Big Team"] ->
"#{match.team_size}v#{match.team_size} on #{match.map}"

"FFA" ->
"#{match.team_count} way FFA on #{match.map}"

t ->
"#{t} game on #{match.map}"
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/teiserver/coordinator/consul_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ defmodule Teiserver.Coordinator.ConsulServer do
rating_type = MatchLib.game_type(state.host_teamsize, state.host_teamcount)

{player_rating, player_uncertainty} =
BalanceLib.get_user_rating_value_uncertainty_pair(user.id, "Big Team")
BalanceLib.get_user_rating_value_uncertainty_pair(user.id, rating_type)

player_rating = max(player_rating, 1)
avoid_status = Account.check_avoid_status(user.id, player_list)
Expand Down
7 changes: 3 additions & 4 deletions lib/teiserver/game/servers/balancer_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ defmodule Teiserver.Game.BalancerServer do
teams =
players
|> Enum.group_by(fn c -> c.team_number end)

team_size = Enum.max(Enum.map(teams, fn {_, t} -> Enum.count(t) end), fn -> 0 end)
game_type = MatchLib.game_type(team_size, team_count)

Expand Down Expand Up @@ -205,8 +206,7 @@ defmodule Teiserver.Game.BalancerServer do
player_id_list
|> Enum.map(fn userid ->
%{
userid =>
BalanceLib.get_user_rating_rank(userid, game_type, opts[:fuzz_multiplier])
userid => BalanceLib.get_user_rating_rank(userid, game_type, opts[:fuzz_multiplier])
}
end)

Expand All @@ -229,8 +229,7 @@ defmodule Teiserver.Game.BalancerServer do
players
|> Enum.map(fn %{userid: userid} ->
%{
userid =>
BalanceLib.get_user_rating_rank(userid, game_type, opts[:fuzz_multiplier])
userid => BalanceLib.get_user_rating_rank(userid, game_type, opts[:fuzz_multiplier])
}
end)

Expand Down
1 change: 0 additions & 1 deletion lib/teiserver/libs/test_lib.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
defmodule Teiserver.TeiserverTestLib do
@moduledoc false
alias Teiserver.{Client, CacheUser, Account}
alias Teiserver.Lobby.LobbyLib
alias Teiserver.Account.AccoladeLib
alias Teiserver.Protocols.TachyonLib
alias Teiserver.Coordinator.CoordinatorServer
Expand Down
101 changes: 0 additions & 101 deletions lib/teiserver/mix_tasks/team_rating.ex

This file was deleted.

20 changes: 11 additions & 9 deletions lib/teiserver_web/controllers/api/spads_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@ defmodule TeiserverWeb.API.SpadsController do
def get_rating(conn, %{
"target_id" => target_id_str,
"type" => type
}
) do

}) do
target_id = int_parse(target_id_str)
lobby = get_member_lobby(target_id)
host_ip = case lobby do
nil -> nil
_ -> Account.get_client_by_id(lobby.founder_id).ip
end

host_ip =
case lobby do
nil -> nil
_ -> Account.get_client_by_id(lobby.founder_id).ip
end

actual_type =
case type do
"Team" -> get_team_subtype(lobby)
"TeamFFA" -> "Big Team" # Team FFA uses Big Team rating
# Team FFA uses Big Team rating
"TeamFFA" -> "Big Team"
v -> v
end

Expand Down Expand Up @@ -247,7 +248,8 @@ defmodule TeiserverWeb.API.SpadsController do
end

cond do
Enum.count(teams) == 2 and max_team_size <= 5 -> "Small Team" # 2v2, 3v3, 4v4, 5v5
# 2v2, 3v3, 4v4, 5v5
Enum.count(teams) == 2 and max_team_size <= 5 -> "Small Team"
true -> "Big Team"
end
end
Expand Down
11 changes: 8 additions & 3 deletions lib/teiserver_web/live/moderation/report_user/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,14 @@ defmodule TeiserverWeb.Moderation.ReportUserLive.Index do
|> Enum.map(fn match ->
label =
case match.game_type do
type when type in ["Small Team", "Big Team"] -> "#{match.team_size} vs #{match.team_size} on #{match.map}"
"FFA" -> "#{match.team_count} way FFA on #{match.map}"
v -> v
type when type in ["Small Team", "Big Team"] ->
"#{match.team_size} vs #{match.team_size} on #{match.map}"

"FFA" ->
"#{match.team_count} way FFA on #{match.map}"

v ->
v
end

time_ago =
Expand Down
14 changes: 12 additions & 2 deletions lib/teiserver_web/templates/admin/match/search.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,18 @@
enumerable: [
%{id: "", name: "Any", icon: "fa-solid fa-square", colour: "#AA0000"},
%{id: "Duel", name: "Duel", icon: "fa-solid fa-square", colour: "#AA0000"},
%{id: "Small Team", name: "Small Team", icon: "fa-solid fa-square", colour: "#AA0000"},
%{id: "Big Team", name: "Big Team", icon: "fa-solid fa-square", colour: "#AA0000"},
%{
id: "Small Team",
name: "Small Team",
icon: "fa-solid fa-square",
colour: "#AA0000"
},
%{
id: "Big Team",
name: "Big Team",
icon: "fa-solid fa-square",
colour: "#AA0000"
},
%{id: "FFA", name: "FFA", icon: "fa-solid fa-square", colour: "#AA0000"},
%{
id: "Team FFA",
Expand Down

0 comments on commit f2b76e7

Please sign in to comment.