Skip to content

Commit

Permalink
feat(generalsio): read agent index
Browse files Browse the repository at this point in the history
Will be usefull with map generation as player indexes are used to mark
who ones given tile.
  • Loading branch information
revolko authored and strakam committed Oct 21, 2024
1 parent 32b4cc5 commit fdc1e44
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions generals/remote/generalsio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,21 @@ def join_game(self, force_start: bool = True) -> None:
if force_start:
self.emit("set_force_start", (self.queue_id, True))

agent_index = None
while True:
event = self.receive()[0]
event, *data = self.receive()
if event == "game_start":
game_data = data[0]
agent_index = game_data["playerIndex"]
break

self._start_game()
self._play_game(agent_index)

def _start_game(self) -> None:
def _play_game(self, agent_index: int) -> None:
"""
Triggered after server starts the game.
TODO: spawn a new thread in which Agent will calculate its moves
:param agent_index: The index of agent in the game
"""
winner = False
while True:
Expand Down

0 comments on commit fdc1e44

Please sign in to comment.