diff --git a/server/bug/game_bug.py b/server/bug/game_bug.py index be0907050..95f246415 100644 --- a/server/bug/game_bug.py +++ b/server/bug/game_bug.py @@ -26,7 +26,6 @@ CASUAL, RATED, IMPORTED, - variant_display_name, MAX_CHAT_LINES, POCKET_PATTERN, ) @@ -85,7 +84,7 @@ def __init__( self.berserk_time = self.base * 1000 * 30 self.browser_title = "%s • %s+%s vs %s+%s" % ( - variant_display_name(self.variant + ("960" if self.chess960 else "")).title(), + self.server_variant.display_name.title(), self.wplayerA.username, self.bplayerB.username, self.wplayerB.username, diff --git a/server/compress.py b/server/compress.py index c5466a0af..e5dc86f41 100644 --- a/server/compress.py +++ b/server/compress.py @@ -9,6 +9,7 @@ """ # Create mappings to compress variant, result and uci/usi move lists a little +# DEPRECATED (this is in ServerVariants enum from now on) V2C_ORIG = { "ataxx": "Z", "chess": "n", diff --git a/server/const.py b/server/const.py index 275620aad..66fefa915 100644 --- a/server/const.py +++ b/server/const.py @@ -156,6 +156,7 @@ class GameStatus(IntEnum): MANCHU_R_FEN = "m1bakab1r/9/9/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/RNBAKABNR w - - 0 1" DARK_FEN = "********/********/********/********/********/********/********/******** w - - 0 1" +# DEPRECATED (this is in ServerVariants enum from now on) VARIANTS_ORIG = ( "chess", "chess960", @@ -235,6 +236,7 @@ class GameStatus(IntEnum): if PROD: VARIANTS_ORIG = tuple(e for e in VARIANTS_ORIG if e not in ["bughouse", "bughouse960"]) +# DEPRECATED (this is in ServerVariants enum from now on) VARIANT_ICONS_ORIG = { "ataxx": "☣", "makruk": "Q", @@ -412,7 +414,8 @@ class GameStatus(IntEnum): } -def variant_display_name(variant): +# DEPRECATED (this is in ServerVariants enum from now on) +def variant_display_name_orig(variant): if variant == "seirawan": return "S-CHESS" elif variant == "seirawan960": diff --git a/server/game.py b/server/game.py index bf06a361f..2983941ac 100644 --- a/server/game.py +++ b/server/game.py @@ -28,7 +28,6 @@ IMPORTED, HIGHSCORE_MIN_GAMES, MAX_HIGHSCORE_ITEM_LIMIT, - variant_display_name, MAX_CHAT_LINES, TYPE_CHECKING, ) @@ -105,7 +104,7 @@ def __init__( self.berserk_time = self.base * 1000 * 30 self.browser_title = "%s • %s vs %s" % ( - variant_display_name(self.variant + ("960" if self.chess960 else "")).title(), + self.server_variant.display_name.title(), self.wplayer.username, self.bplayer.username, ) diff --git a/server/scheduler.py b/server/scheduler.py index 6c9e7e1b2..e1d02cb07 100644 --- a/server/scheduler.py +++ b/server/scheduler.py @@ -8,7 +8,6 @@ ARENA, CATEGORIES, GRANDS, - variant_display_name, SCHEDULE_MAX_DAYS, TYPE_CHECKING, DAILY, @@ -23,6 +22,7 @@ from tournaments import new_tournament from logger import log +from variants import get_server_variant from calendar import MONDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY @@ -264,9 +264,8 @@ def new_scheduled_tournaments(already_scheduled, now=None): and (plan.freq, plan.variant, plan.is960, starts_at, plan.duration) not in already_scheduled ): - variant_name = variant_display_name( - plan.variant + ("960" if plan.is960 else "") - ).title() + server_variant = get_server_variant(plan.variant, plan.is960) + variant_name = server_variant.display_name.title() if plan.freq == SHIELD: name = "%s Shield Arena" % variant_name diff --git a/server/tournament.py b/server/tournament.py index 8df66b75e..570070c0c 100644 --- a/server/tournament.py +++ b/server/tournament.py @@ -32,7 +32,6 @@ T_FINISHED, T_ARCHIVED, SHIELD, - variant_display_name, MAX_CHAT_LINES, ) from game import Game @@ -284,7 +283,7 @@ def __init__( self.clock_task = asyncio.create_task(self.clock(), name="tournament-clock") self.browser_title = "%s Tournament • %s" % ( - variant_display_name(self.variant), + self.server_variant.display_name, self.name, ) diff --git a/server/tournaments.py b/server/tournaments.py index 9bea12f7e..59e0cff58 100644 --- a/server/tournaments.py +++ b/server/tournaments.py @@ -11,7 +11,6 @@ ARENA, RR, SWISS, - variant_display_name, T_STARTED, T_CREATED, T_ABORTED, @@ -45,6 +44,8 @@ async def create_or_update_tournament( variant = form["variant"] variant960 = variant.endswith("960") variant_name = variant[:-3] if variant960 else variant + server_variant = get_server_variant(variant_name, variant960) + rated = form.get("rated", "") == "1" and form["position"] == "" base = float(form["clockTime"]) inc = int(form["clockIncrement"]) @@ -61,10 +62,10 @@ async def create_or_update_tournament( name = form["name"] # Create meaningful tournament name in case we forget to change it :) if name == "": - name = "%s Arena" % variant_display_name(variant).title() + name = "%s Arena" % server_variant.display_name.title() if frequency == SHIELD: - name = "%s Shield Arena" % variant_display_name(variant).title() + name = "%s Shield Arena" % server_variant.display_name.title() else: description = form["description"] name = name if name.lower().endswith("arena") else name + " Arena"