From 3652623caf9c012aaf41ec097e707df31a69b8c1 Mon Sep 17 00:00:00 2001 From: Hauke Platte Date: Thu, 7 Mar 2024 13:59:26 +0100 Subject: [PATCH] fix(network): fixed lobby handover to flayfield --- UI/field_frame.py | 6 +++--- UI/gamefield.py | 2 +- UI/multi.py | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/UI/field_frame.py b/UI/field_frame.py index faa56bd..472f95a 100644 --- a/UI/field_frame.py +++ b/UI/field_frame.py @@ -51,7 +51,7 @@ def _display_widgets(self): class field_controller(): def __init__(self, view, players): self.view = view - sub_controller = gamefield_controller(self.view.gamefield) + self.sub_controller = gamefield_controller(self.view.gamefield) for player_lbl, player in zip(self.view.player, players): player_lbl.set(player.display_name, player_type.unknown) self._bind() @@ -71,10 +71,10 @@ def error(self, *args): msg.display() class Field(base_frame): - def __init__(self, master, *args, start_player, start_symbol, opponent, opponent_symbol, **kwargs): + def __init__(self, master, *args, starting_player, starting_player_symbol, opponent, opponent_symbol, **kwargs): super().__init__(master) self._create_widgets() - self.controller = field_controller(self, tuple(start_player, opponent)) + self.controller = field_controller(self, [starting_player, opponent]) self._display_widgets() #self.bind("<>", self.controller.sub_controller.turn) #self.bind("<>", self.controller.end) diff --git a/UI/gamefield.py b/UI/gamefield.py index 9659fb0..570bd7f 100644 --- a/UI/gamefield.py +++ b/UI/gamefield.py @@ -27,7 +27,7 @@ def __init__(self, view: gamefield): def _bind(self): for position, button in self.view.fields.items(): - button.config(command=lambda e=position: self._game_input(self, e)) + button.config(command=lambda e=position: self._game_input(e)) def draw_field(self, matrix=None, position=None, value=None): #either matrix as a 3x3 list or position and value need to be provided if matrix != None: diff --git a/UI/multi.py b/UI/multi.py index dcfd96e..646639b 100644 --- a/UI/multi.py +++ b/UI/multi.py @@ -49,7 +49,7 @@ def _display_widgets(self,): def _update_lobby(self): queue = self.master.in_queue.get() - #print(queue) + self.playerlist = [] for player in queue['player']: self.playerlist.append([tk.Label(self, text=player.display_name), tk.Button(self, text='Kick', command=lambda uuid=player.uuid, *args: self.master.out_queue.put({'message_type': 'lobby/kick', 'args' : {'player_to_kick_index': uuid}}))]) @@ -64,8 +64,9 @@ def _update_lobby(self): player[1].grid(sticky=tk.E+tk.W+tk.N+tk.S, column=4, row=4+i) - def _start_game(self, event): + def _start_game(self): queue = self.master.in_queue.get() + print(queue) self.master.show(Field, **queue) def on_destroy(self):