Skip to content

Commit

Permalink
Use display_name property of Variant instead of variant_display_name()
Browse files Browse the repository at this point in the history
  • Loading branch information
gbtami committed Jan 12, 2025
1 parent 7e4264b commit 8705757
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 14 deletions.
3 changes: 1 addition & 2 deletions server/bug/game_bug.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
CASUAL,
RATED,
IMPORTED,
variant_display_name,
MAX_CHAT_LINES,
POCKET_PATTERN,
)
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions server/compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion server/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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":
Expand Down
3 changes: 1 addition & 2 deletions server/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
IMPORTED,
HIGHSCORE_MIN_GAMES,
MAX_HIGHSCORE_ITEM_LIMIT,
variant_display_name,
MAX_CHAT_LINES,
TYPE_CHECKING,
)
Expand Down Expand Up @@ -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,
)
Expand Down
7 changes: 3 additions & 4 deletions server/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
ARENA,
CATEGORIES,
GRANDS,
variant_display_name,
SCHEDULE_MAX_DAYS,
TYPE_CHECKING,
DAILY,
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions server/tournament.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
T_FINISHED,
T_ARCHIVED,
SHIELD,
variant_display_name,
MAX_CHAT_LINES,
)
from game import Game
Expand Down Expand Up @@ -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,
)

Expand Down
7 changes: 4 additions & 3 deletions server/tournaments.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
ARENA,
RR,
SWISS,
variant_display_name,
T_STARTED,
T_CREATED,
T_ABORTED,
Expand Down Expand Up @@ -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"])
Expand All @@ -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"
Expand Down

0 comments on commit 8705757

Please sign in to comment.