-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tournament game service #921
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import logging | ||
|
||
from . import LadderGame | ||
from .typedefs import GameType | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class TournamentGame(LadderGame): | ||
"""Class for tournament games""" | ||
|
||
game_type = GameType.TOURNAMENT |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,8 +34,8 @@ | |
matchmaker_queue_map_pool | ||
) | ||
from server.decorators import with_logger | ||
from server.game_service import GameService | ||
from server.games import InitMode, LadderGame | ||
from server.game_service import GameService, NotConnectedError | ||
from server.games import Game, InitMode, LadderGame | ||
from server.games.ladder_game import GameClosedError | ||
from server.ladder_service.game_name import game_name | ||
from server.ladder_service.violation_service import ViolationService | ||
|
@@ -563,23 +563,23 @@ def get_player_mean(player: Player) -> float: | |
if game_options: | ||
game.gameOptions.update(game_options) | ||
|
||
mapname = re.match("maps/(.+).zip", map_path).group(1) | ||
map_name = re.match("maps/(.+).zip", map_path).group(1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we refactor the regex? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where to? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about just making use of the properties you added to the Game class? The map_file_path is already being set on line 532. map_name = game.map_name |
||
# FIXME: Database filenames contain the maps/ prefix and .zip suffix. | ||
# Really in the future, just send a better description | ||
|
||
self._logger.debug("Starting ladder game: %s", game) | ||
|
||
def make_game_options(player: Player) -> GameLaunchOptions: | ||
return GameLaunchOptions( | ||
mapname=mapname, | ||
mapname=map_name, | ||
expected_players=len(all_players), | ||
game_options=game_options, | ||
team=game.get_player_option(player.id, "Team"), | ||
faction=game.get_player_option(player.id, "Faction"), | ||
map_position=game.get_player_option(player.id, "StartSpot") | ||
) | ||
|
||
await self.launch_match(game, host, all_guests, make_game_options) | ||
await self.launch_server_made_game(game, host, all_guests, make_game_options) | ||
self._logger.debug("Ladder game launched successfully %s", game) | ||
metrics.matches.labels(queue.name, MatchLaunch.SUCCESSFUL).inc() | ||
except Exception as e: | ||
|
@@ -623,9 +623,9 @@ def make_game_options(player: Player) -> GameLaunchOptions: | |
) | ||
self.violation_service.register_violations(abandoning_players) | ||
|
||
async def launch_match( | ||
async def launch_server_made_game( | ||
self, | ||
game: LadderGame, | ||
game: Game, | ||
host: Player, | ||
guests: list[Player], | ||
make_game_options: Callable[[Player], GameLaunchOptions] | ||
|
@@ -725,8 +725,3 @@ def on_connection_lost(self, conn: "LobbyConnection") -> None: | |
async def shutdown(self): | ||
for queue in self.queues.values(): | ||
queue.shutdown() | ||
|
||
|
||
class NotConnectedError(asyncio.TimeoutError): | ||
def __init__(self, players: list[Player]): | ||
self.players = players |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need these in the base class? They only make sense for automatch games.