Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/network_client' into network_client
Browse files Browse the repository at this point in the history
  • Loading branch information
bananabr3d committed Mar 4, 2024
2 parents 00171ec + 86764f6 commit 84bab05
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class GameClient:
_lobby_status (list[str]): The status of the lobby. Contains all players in the lobby.
_game_status (list[list[int]]): The status of the game. Contains the current playfield.
_statistics: The statistics of the game. TODO
_chat_history (list[str]): The chat history of the game. Contains all messages sent in the game.
_chat_history (list[tuple[Player, str]]): The chat history of the game. Contains all messages sent in the game.
_winner (Player): The winner of the game. None if the game is not finished yet or it is a draw.
_error_history (list[str]): The error history of the game. Contains all errors that occurred for this client.
_json_schema (dict): The JSON schema that is used to validate incoming messages.
Expand Down Expand Up @@ -67,7 +67,7 @@ def __init__(self, ip:str, port:int, player:Player) -> None:
self._lobby_status: list[str] = []
self._playfield: list[list[int]] = [[0,0,0],[0,0,0],[0,0,0]]
self._statistics = None # TODO
self._chat_history: list[str] = []
self._chat_history: list[tuple[Player, str]] = []
self._winner: Player = None
self._error_history: list[str] = []

Expand Down Expand Up @@ -145,13 +145,13 @@ async def listen(self):

await self._message_handler(message_type)

def get_player_by_uuid(self, uuid:str):
def get_player_by_uuid(self, uuid:str) -> Player:
for player in self._lobby_status:
if str(player.uuid) == uuid:
return player
return None

async def _preprocess_message(self, message:str):
async def _preprocess_message(self, message:str) -> str:
message_json = json.loads(message)

try:
Expand Down
2 changes: 1 addition & 1 deletion UI/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def manually(self):

def _connect(self):
root = self.master.master
root.network_client = client_thread(self, in_queue=root.out_queue, out_queue=root.in_queue, player=root.player, ip=self.etrAddress.get())
root.network_client = client_thread(root, in_queue=root.out_queue, out_queue=root.in_queue, player=root.player, ip=self.etrAddress.get())
root.show(Join)

class Multiplayer(base_frame):
Expand Down

0 comments on commit 84bab05

Please sign in to comment.