From c2cd62908b41fecb956c9c14cbfe1b0029127460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sta=C5=84czak-Marikin?= Date: Tue, 16 Apr 2024 06:42:49 +0200 Subject: [PATCH] Make minimal game duration to treat game as ranked configurable, lower default 180 -> 90 Fixes #214. Relevant discussion in https://discord.com/channels/549281623154229250/855772061095559179/1210540660604538951 --- lib/teiserver/game/libs/match_rating_lib.ex | 4 ++-- lib/teiserver/libs/teiserver_configs.ex | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/teiserver/game/libs/match_rating_lib.ex b/lib/teiserver/game/libs/match_rating_lib.ex index 81526b117..483c475f5 100644 --- a/lib/teiserver/game/libs/match_rating_lib.ex +++ b/lib/teiserver/game/libs/match_rating_lib.ex @@ -4,7 +4,7 @@ defmodule Teiserver.Game.MatchRatingLib do to balance matches. For that use Teiserver.Battle.BalanceLib. """ - alias Teiserver.{Account, Coordinator, Game, Battle} + alias Teiserver.{Account, Coordinator, Config, Game, Battle,} alias Teiserver.Data.Types, as: T alias Teiserver.Repo alias Teiserver.Battle.{BalanceLib, MatchLib} @@ -71,7 +71,7 @@ defmodule Teiserver.Game.MatchRatingLib do match.team_count < 2 -> {:error, :not_enough_teams} - match.game_duration < 180 -> + match.game_duration < Config.get_site_config_cache("matchmaking.Time to treat game as ranked") -> {:error, :too_short} Map.get(match.tags, "game/modoptions/ranked_game", "1") == "0" -> diff --git a/lib/teiserver/libs/teiserver_configs.ex b/lib/teiserver/libs/teiserver_configs.ex index d9e107237..e0e0b86b5 100644 --- a/lib/teiserver/libs/teiserver_configs.ex +++ b/lib/teiserver/libs/teiserver_configs.ex @@ -36,6 +36,16 @@ defmodule Teiserver.TeiserverConfigs do value_label: "Require ready check" }) + add_site_config_type(%{ + key: "matchmaking.Time to treat game as ranked", + section: "Matchmaking", + type: "integer", + permissions: ["Server"], + description: "Games shorter than this time in seconds will not be treated as ranked.", + default: 90, + value_label: "Require ready check" + }) + add_site_config_type(%{ key: "bots.Flag", section: "Bots",