Skip to content

Commit

Permalink
Restrict algo to mods
Browse files Browse the repository at this point in the history
  • Loading branch information
jauggy committed Aug 6, 2024
1 parent e3cf0ab commit 7eb9450
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/teiserver/battle/libs/balance_lib.ex
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ defmodule Teiserver.Battle.BalanceLib do
if(is_moderator) do
Teiserver.Battle.BalanceLib.algorithm_modules() |> Map.keys()
else
Teiserver.Battle.BalanceLib.algorithm_modules() |> Map.delete("force_party") |> Map.keys()
Teiserver.Battle.BalanceLib.algorithm_modules()
|> Map.drop(["force_party", "brute_force"])
|> Map.keys()
end
end

Expand Down
17 changes: 17 additions & 0 deletions test/teiserver/battle/balance_lib_internal_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,23 @@ defmodule Teiserver.Battle.BalanceLibInternalTest do
assert BalanceLib.balanced_teams_has_parties?(team_groups)
end

test "Allowed algorithms" do
is_moderator = true
result = BalanceLib.get_allowed_algorithms(is_moderator)

assert result == [
"brute_force",
"cheeky_switcher_smart",
"force_party",
"loser_picks",
"split_one_chevs"
]

is_moderator = false
result = BalanceLib.get_allowed_algorithms(is_moderator)
assert result == ["cheeky_switcher_smart", "loser_picks", "split_one_chevs"]
end

defp create_test_users do
Enum.map(1..5, fn k ->
Teiserver.TeiserverTestLib.new_user("User_#{k}")
Expand Down

0 comments on commit 7eb9450

Please sign in to comment.