Skip to content

Commit

Permalink
Update based on Lexon review
Browse files Browse the repository at this point in the history
  • Loading branch information
jauggy committed Jun 5, 2024
1 parent ca7e921 commit 0451c91
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
4 changes: 2 additions & 2 deletions lib/teiserver/coordinator/consul_commands.ex
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ defmodule Teiserver.Coordinator.ConsulCommands do
["Parties:" | party_list]
end

play_level_bounds = LobbyRestrictions.get_rating_bounds_text(state)
play_rank_bounds = LobbyRestrictions.get_rank_bounds_text(state)
play_level_bounds = LobbyRestrictions.get_rating_bounds_for_title(state)
play_rank_bounds = LobbyRestrictions.get_rank_bounds_for_title(state)

welcome_message =
if state.welcome_message do
Expand Down
26 changes: 11 additions & 15 deletions lib/teiserver/lobby/libs/lobby_restrictions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule Teiserver.Lobby.LobbyRestrictions do
@moduledoc """
Helper methods for lobby policies
"""
alias Teiserver.CacheUser
alias Teiserver.{CacheUser, Config}
require Logger
alias Teiserver.Battle.BalanceLib
alias Teiserver.Battle
Expand All @@ -15,8 +15,8 @@ defmodule Teiserver.Lobby.LobbyRestrictions do
def rating_upper_bound, do: @rating_upper_bound

def get_lobby_restrictions_welcome_text(state) do
play_level_bounds = get_rating_bounds_text(state)
play_rank_bounds = get_rank_bounds_text(state)
play_level_bounds = get_rating_bounds_for_title(state)
play_rank_bounds = get_rank_bounds_for_title(state)

cond do
play_level_bounds == nil && play_rank_bounds == nil ->
Expand All @@ -28,14 +28,6 @@ defmodule Teiserver.Lobby.LobbyRestrictions do
end
end

def get_rating_bounds_text(state) do
get_rating_bounds_for_title(state)
end

def get_rank_bounds_text(state) do
get_rank_bounds_for_title(state)
end

def get_rank_bounds_for_title(consul_state) when consul_state == nil do
nil
end
Expand Down Expand Up @@ -127,14 +119,18 @@ defmodule Teiserver.Lobby.LobbyRestrictions do
]
end

defp allow_bypass_rank_check?(user) do
method = Config.get_site_config_cache("profile.Rank method")
# When using Role method for ranks,
# contributors auto pass since their ranks are not defined on playtime. To be fixed seperately.
method == "Role" && CacheUser.is_contributor?(user)
end

@spec check_rank_to_play(any(), any()) :: :ok | {:error, iodata()}
def check_rank_to_play(user, consul_state) do
state = consul_state

# Contributors auto pass since their ranks are not defined on playtime. To be fixed seperately.
is_contributor? = CacheUser.is_contributor?(user)

if is_contributor? do
if allow_bypass_rank_check?(user) do
:ok
else
cond do
Expand Down

0 comments on commit 0451c91

Please sign in to comment.