From 7eb9450e142fae4e6c10a0c6d231a506f20dc87b Mon Sep 17 00:00:00 2001 From: Joshua Augustinus Date: Tue, 6 Aug 2024 17:37:03 +1000 Subject: [PATCH] Restrict algo to mods --- lib/teiserver/battle/libs/balance_lib.ex | 4 +++- .../battle/balance_lib_internal_test.exs | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/teiserver/battle/libs/balance_lib.ex b/lib/teiserver/battle/libs/balance_lib.ex index 7cc87ce10..79a04ad6c 100644 --- a/lib/teiserver/battle/libs/balance_lib.ex +++ b/lib/teiserver/battle/libs/balance_lib.ex @@ -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 diff --git a/test/teiserver/battle/balance_lib_internal_test.exs b/test/teiserver/battle/balance_lib_internal_test.exs index ea0c1be4a..5a1596762 100644 --- a/test/teiserver/battle/balance_lib_internal_test.exs +++ b/test/teiserver/battle/balance_lib_internal_test.exs @@ -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}")