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

Serialize faction as string in game launch message #835

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion server/ladder_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def get_player_mean(player):
def game_options(player: Player) -> GameLaunchOptions:
return options._replace(
team=game.get_player_option(player.id, "Team"),
faction=player.faction,
faction=player.faction.name,
map_position=game.get_player_option(player.id, "StartSpot")
)

Expand Down
2 changes: 1 addition & 1 deletion server/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GameLaunchOptions(NamedTuple):

mapname: Optional[str] = None
team: Optional[int] = None
faction: Optional[int] = None
faction: Optional[str] = None
expected_players: Optional[int] = None
map_position: Optional[int] = None

Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/test_matchmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async def test_game_launch_message(lobby_server):
assert msg1["mapname"] == msg2["mapname"]
assert msg1["team"] == 2
assert msg2["team"] == 3
assert msg1["faction"] == msg2["faction"] == 1 # faction 1 is uef
assert msg1["faction"] == msg2["faction"] == "uef"
assert msg1["expected_players"] == msg2["expected_players"] == 2
assert msg1["map_position"] == 1
assert msg2["map_position"] == 2
Expand Down
9 changes: 5 additions & 4 deletions tests/integration_tests/test_teammatchmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
leaderboard_rating,
leaderboard_rating_journal
)
from server.factions import Faction
from tests.utils import fast_forward

from .conftest import connect_and_sign_in, read_until, read_until_command
Expand Down Expand Up @@ -98,7 +99,7 @@ async def test_game_matchmaking(lobby_server):
assert msg["expected_players"] == 4
assert msg["team"] in (2, 3)
assert msg["map_position"] in (1, 2, 3, 4)
assert msg["faction"] == 1
assert msg["faction"] == "uef"


@fast_forward(15)
Expand Down Expand Up @@ -143,7 +144,7 @@ async def test_game_matchmaking_multiqueue(lobby_server):
assert msg["expected_players"] == 4
assert msg["team"] in (2, 3)
assert msg["map_position"] in (1, 2, 3, 4)
assert msg["faction"] == 2
assert msg["faction"] == "aeon"


@fast_forward(10)
Expand Down Expand Up @@ -221,7 +222,7 @@ async def test_game_matchmaking_with_parties(lobby_server):
assert msg["expected_players"] == 4
assert msg["team"] in (2, 3)
assert msg["map_position"] in (1, 2, 3, 4)
assert msg["faction"] == i + 1
assert msg["faction"] == "uef" if i == 0 else "aeon" if i == 1 else "cybran" if i == 2 else "seraphim"


@fast_forward(30)
Expand Down Expand Up @@ -470,7 +471,7 @@ async def test_game_ratings(lobby_server):
proto,
[player_id, "Army", slot],
[player_id, "Color", slot],
[player_id, "Faction", msg["faction"]],
[player_id, "Faction", Faction.from_string(msg["faction"])],
[player_id, "StartSpot", slot],
[player_id, "Team", msg["team"]],
)
Expand Down