Skip to content
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

Remove references to equilibrium #744 #764

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions server/game_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@
from .db import FAFDatabase
from .decorators import with_logger
from .games import (
CoopGame,
CustomGame,
FeaturedMod,
FeaturedModType,
Game,
GameState,
LadderGame,
ValidityState,
VisibilityState
)
Expand Down Expand Up @@ -154,15 +151,6 @@ def create_game(
"matchmaker_queue_id": matchmaker_queue_id,
}
game_args.update(kwargs)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would definitely either make game_class a required argument, or give it a sensible default. Defaulting to None just doesn't make any sense anymore.

if not game_class:
game_class = {
FeaturedModType.LADDER_1V1: LadderGame,
FeaturedModType.COOP: CoopGame,
FeaturedModType.FAF: CustomGame,
FeaturedModType.FAFBETA: CustomGame,
FeaturedModType.EQUILIBRIUM: CustomGame
}.get(game_mode, Game)
game = game_class(**game_args)

self._games[game_id] = game
Expand Down
1 change: 0 additions & 1 deletion server/games/typedefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ class FeaturedModType():
"""

COOP = "coop"
EQUILIBRIUM = "equilibrium"
FAF = "faf"
FAFBETA = "fafbeta"
LADDER_1V1 = "ladder1v1"
Expand Down
18 changes: 17 additions & 1 deletion server/lobbyconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@
from .factions import Faction
from .game_service import GameService
from .gameconnection import GameConnection
from .games import FeaturedModType, GameState, VisibilityState
from .games import (
CoopGame,
CustomGame,
FeaturedModType,
Game,
GameState,
LadderGame,
VisibilityState
)
from .geoip_service import GeoIpService
from .ice_servers.coturn import CoturnHMAC
from .ice_servers.nts import TwilioNTS
Expand Down Expand Up @@ -895,9 +903,17 @@ async def command_game_host(self, message):
if rating_max is not None:
rating_max = float(rating_max)

game_class = {
FeaturedModType.LADDER_1V1: LadderGame,
FeaturedModType.COOP: CoopGame,
FeaturedModType.FAF: CustomGame,
FeaturedModType.FAFBETA: CustomGame
}.get(game_mode, Game)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only need to check for coop here, and default to CustomGame.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use an if statement


game = self.game_service.create_game(
visibility=visibility,
game_mode=game_mode,
game_class=game_class,
host=self.player,
name=title,
mapname=mapname,
Expand Down
1 change: 0 additions & 1 deletion tests/unit_tests/test_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ async def test_validate_game_settings(game: Game, game_add_players):
mods = (
FeaturedModType.FAF,
FeaturedModType.LADDER_1V1,
FeaturedModType.EQUILIBRIUM,
"AnythingReally"
)

Expand Down
4 changes: 4 additions & 0 deletions tests/unit_tests/test_games_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ async def test_create_game(players, game_service):
game = game_service.create_game(
visibility=VisibilityState.PUBLIC,
game_mode="faf",
game_class=CustomGame,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could make this the default argument.

host=players.hosting,
name="Test",
mapname="SCMP_007",
Expand All @@ -32,6 +33,7 @@ async def test_all_games(players, game_service):
game = game_service.create_game(
visibility=VisibilityState.PUBLIC,
game_mode="faf",
game_class=CustomGame,
host=players.hosting,
name="Test",
mapname="SCMP_007",
Expand All @@ -44,6 +46,7 @@ async def test_all_games(players, game_service):
async def test_create_game_ladder1v1(players, game_service):
game = game_service.create_game(
game_mode="ladder1v1",
game_class=LadderGame,
host=players.hosting,
name="Test Ladder",
)
Expand All @@ -57,6 +60,7 @@ async def test_create_game_other_gamemode(players, game_service):
game = game_service.create_game(
visibility=VisibilityState.PUBLIC,
game_mode="labwars",
game_class=CustomGame,
host=players.hosting,
name="Test",
mapname="SCMP_007",
Expand Down
1 change: 1 addition & 0 deletions tests/unit_tests/test_lobbyconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ async def test_command_game_host_creates_game(
})
expected_call = {
"game_mode": "faf",
"game_class": CustomGame,
"name": test_game_info["title"],
"host": players.hosting,
"visibility": VisibilityState.PUBLIC,
Expand Down