def run_online(self, iserveur: StateOnline):

        controlle_main = OnlineControlleur(iserveur, self.var.get(), self.root)

        controlle_main.onlinec_game(self.root)

        while controlle_main.control is None and controlle_main.val > 0:
            pass

        if controlle_main.control is not None:

            self.root.destroy()
            mainFrame = Tk()
            mainFrame.title(Constants.GAME_TITLE)
            mainFrame.resizable(width=Constants.RESIZE_FRAME,
                                height=Constants.RESIZE_FRAME)
            mainFrame.minsize(Constants.FRAME_WIDTH, Constants.FRAME_HEIGHT)

            controller_main = MainController(mainFrame, Grid.grid_by_ten())
            controlle_main.control.adapt(controller_main.mainFrame)
            controller_main.game_controller = controlle_main.control
            end_controleur = EndController()
            end_controleur.add_observer(controller_main)
            controller_main.game_controller.set_end_controller(end_controleur)
            controller_main.game_controller.game.set_player(
                controller_main.player)

            controller_main.run()
        def load_grid(agent, grid):
            # On charge la grille coté client voir avec cyril
            # gride: Grid = Grid.rebulde(grid)

            texte = grid.split('time=')
            gride: Grid = Grid.rebulde(texte[0])
            self.time = int(texte[1])
            self.change_to_game(gride)
        def connect(agent, status):

            grid: Grid
            if self.typegame == 1:
                grid = Grid.grid_by_ten()
            else:
                grid = Grid.grid_by_twenty()
            if self.is_alone:
                self.is_alone = False
                if status == StateOnline.JOIN.name and self.state_online == StateOnline.CREATE:
                    # create grid voir avec Cyril
                    # On evoie la grille
                    self.agent.send_msg(
                        f'grid={grid.__str__()}time={self.time.__str__()}')
                    # time={self.time.__str__()}
                    self.change_to_game(grid)
                elif status == StateOnline.CREATE.name and self.state_online == StateOnline.JOIN:
                    self.agent.send_msg(f'connect={StateOnline.JOIN.name}')
    def runGame(self):

        if self.var.get() == 2:
            self.start_to_game(Grid.grid_by_twenty())
        else:
            self.start_to_game(Grid.grid_by_ten())
示例#5
0
 def gride_creator(self, val: int):
     return Grid.grid_by_ten() if val == 1 else Grid.grid_by_twenty()
    def game_master(self):
        return self.__player[0]

    def set_player(self, player):
        self.__player.append(player)
        player2 = Player(1, "adversair")
        self.__player.append(player2)

    def statugame(self):
        if self.__player[0].score > self.__player[1].score:
            return "vous avez gagné"
        elif self.__player[0].score == self.__player[1].score:
            return "égalité"
        else:
            return "vous avez perdu "


if __name__ == '__main__':
    print("On test la classe game2jpueur")
    player1 = HumanPlayer(69, "test")
    player2 = HumanPlayer(6, "drogue")
    board = Grid.grid_by_ten()
    game = GameTwoPlayer(board, player1, player2, 10)
    while not game.isclear():
        print(game.board)
        print("au tour du joueur : ")
        x = input("On veut quel ligne ?")
        y = input("On veut quel colonne ?")
        game.move(Position(int(x), int(y)))
        game.play()