diff --git a/NOTE.md b/NOTE.md index 1d38d79..3838bf9 100644 --- a/NOTE.md +++ b/NOTE.md @@ -1,6 +1,4 @@ A faire : -- Ecran de victoire -- Etat de la partie (en attente de l'autre joueur, ...) - Ecran de configuration de la partie - Nom dans les options - Faire marcher le tchat diff --git a/source/gui/scene/Game.py b/source/gui/scene/Game.py index 994013c..9c5a508 100644 --- a/source/gui/scene/Game.py +++ b/source/gui/scene/Game.py @@ -58,6 +58,10 @@ class Game(Scene): def board_ally_ready(widget): self.boat_ready_ally = True + + self.me_ready() + if self.boat_ready_enemy: self.refresh_turn_text() + PacketBoatPlaced().send_connection(connection) self.grid_ally.add_listener("on_all_boats_placed", board_ally_ready) @@ -195,6 +199,19 @@ class Game(Scene): label_batch=self.batch_label, ) + self.label_state = self.add_widget( + widget.Text, + + x=0.5, y=0.15, + + anchor_x="center", + + text="Placer vos bateaux", + font_size=20, + + batch=self.batch_label + ) + self.board_ally = core.Board(rows=8, columns=8) self.board_enemy = core.Board(rows=8, columns=8) @@ -212,6 +229,12 @@ class Game(Scene): self._boat_broken_enemy += 1 self.score_enemy.text = str(self._boat_broken_enemy) + def me_ready(self): + self.label_state.text = "L'adversaire place ses bateaux" + + def refresh_turn_text(self): + self.label_state.text = "Placer vos bombes" if self.my_turn else "L'adversaire place ses bombes" + def game_end(self, won: bool): self.window.add_scene(Result, won=won) diff --git a/source/gui/scene/Result.py b/source/gui/scene/Result.py index 8031c54..88e4ada 100644 --- a/source/gui/scene/Result.py +++ b/source/gui/scene/Result.py @@ -20,6 +20,9 @@ class Result(Scene): image=texture.Result.Style1.victory if won else texture.Result.Style1.defeat ) + # TODO: rendre l'image transparente + # TODO: empecher les intéractions + from source.gui.scene import MainMenu pyglet.clock.schedule_once(lambda dt: self.window.set_scene(MainMenu), 5.0) diff --git a/source/network/game_network.py b/source/network/game_network.py index 5369275..073ea12 100644 --- a/source/network/game_network.py +++ b/source/network/game_network.py @@ -36,7 +36,8 @@ def game_network(thread: "StoppableThread", window: "Window", connection: socket case packet.PacketBoatPlaced: game_scene.boat_ready_enemy = True - print("adversaire à posé ses bateaux") + if game_scene.boat_ready_ally: + in_pyglet_context(game_scene.refresh_turn_text) case packet.PacketBombPlaced: try: @@ -55,6 +56,7 @@ def game_network(thread: "StoppableThread", window: "Window", connection: socket in_pyglet_context(game_scene.boat_broken_enemy) game_scene.my_turn = not (touched or (bomb_state is BombState.ERROR)) + in_pyglet_context(game_scene.refresh_turn_text) if bomb_state is BombState.WON: in_pyglet_context(game_scene.game_end, won=False) @@ -68,6 +70,7 @@ def game_network(thread: "StoppableThread", window: "Window", connection: socket touched = data.bomb_state in [BombState.TOUCHED, BombState.SUNKEN, BombState.WON] game_scene.my_turn = touched + in_pyglet_context(game_scene.refresh_turn_text) if touched: in_pyglet_context(game_scene.boat_broken_ally)