def grid_effect(self, event):
        if self.game.coup_valide() and self.online_controleur.my_turn:
            self.game.changeTurn(self.online_controleur.my_turn)

            self.online_controleur.turn_click(self.game.CubeArray[0])
            GameController.grid_effect(self, event)
            self.score_controller.reload_color(self.game.get_player_color())
            self.pas_to_other_turn()
 def __init__(self, parent, game, OnlineControlleur):
     GameController.__init__(self, parent, game)
     self.online_controleur = OnlineControlleur
     self.endvvue=True
     OnlineControlleur.game_controlleur=self
     self.online_controleur.exodia()
     self.time = self.game.get_time()
     if not self.online_controleur.my_turn and parent is not None :
         self.score_controller.var_time.set(Constants.MESSAGE_ADVERCE_TURN)
Beispiel #3
0
    def update(self, data) -> None:
        self.__stop()
        endcontrolleur = self.game_controller.end_controlleur

        self.game_controller = GameController(self.mainFrame,
                                              GameOnePlayer(data))
        self.game_controller.game.set_player(self.player)
        self.game_controller.set_end_controller(endcontrolleur)
        self.refresh_view()
        self.update_time()
Beispiel #4
0
 def __init__(self, mainFrame, grid):
     self.mainFrame = mainFrame
     self.player = HumanPlayer(69, "test")
     self.view = MainFrameView(self.mainFrame, self)
     self.menu_controller = MenuController(self.mainFrame, self.player)
     game = GameOnePlayer(grid)
     game.set_player(self.player)
     self.game_controller = GameController(self.mainFrame, game)
     self.menu_controller.add_observer(self)
     end_vcontroleur = EndController()
     end_vcontroleur.add_observer(self)
     self.game_controller.set_end_controller(end_vcontroleur)
     self.__main_job = None
     self.mainFrame.protocol("WM_DELETE_WINDOW", self.update_quit)
    def grd_refresh(self):

        GameController.grd_refresh(self)
 def adapt(self, parent):
     GameController.adapt(self,parent)
     if not self.online_controleur.my_turn:
         self.score_controller.var_time.set(Constants.MESSAGE_ADVERCE_TURN)
 def on_hovering_effect(self, position):
     if self.online_controleur.my_turn:
         GameController.on_hovering_effect(self, position)
Beispiel #8
0
class MainController(Observer):
    def __init__(self, mainFrame, grid):
        self.mainFrame = mainFrame
        self.player = HumanPlayer(69, "test")
        self.view = MainFrameView(self.mainFrame, self)
        self.menu_controller = MenuController(self.mainFrame, self.player)
        game = GameOnePlayer(grid)
        game.set_player(self.player)
        self.game_controller = GameController(self.mainFrame, game)
        self.menu_controller.add_observer(self)
        end_vcontroleur = EndController()
        end_vcontroleur.add_observer(self)
        self.game_controller.set_end_controller(end_vcontroleur)
        self.__main_job = None
        self.mainFrame.protocol("WM_DELETE_WINDOW", self.update_quit)

    def run(self):
        self.update_time()
        self.refresh_view()
        self.__main_job = self.mainFrame.mainloop()

    def update_time(self):
        self.game_controller.up_timer()

        self.__jobtime = self.mainFrame.after(1000, self.update_time)

    def refresh_view(self):
        self.game_controller.grd_refresh()
        self.__jobrefresh = self.mainFrame.after(100, self.refresh_view)

    def update(self, data) -> None:
        self.__stop()
        endcontrolleur = self.game_controller.end_controlleur

        self.game_controller = GameController(self.mainFrame,
                                              GameOnePlayer(data))
        self.game_controller.game.set_player(self.player)
        self.game_controller.set_end_controller(endcontrolleur)
        self.refresh_view()
        self.update_time()

    def update_obline(self, data, iserveur) -> None:

        self.__stop()
        controller_main = oc.OnlineControlleur(iserveur, data, self.mainFrame)
        controller_main.add_apelant(self)
        controller_main.online_game(self.mainFrame)

    def craft_game(self, controleur):

        endcontrolleur = self.game_controller.end_controlleur
        self.game_controller = controleur

        self.game_controller.adapt(self.mainFrame)
        self.player.score = 0
        self.game_controller.game.set_player(self.player)
        self.game_controller.set_end_controller(endcontrolleur)
        self.refresh_view()

        self.update_time()

    def update_quit(self):
        self.__stop()

        self.mainFrame.destroy()

    def __stop(self):
        if self.__jobtime is not None:
            self.mainFrame.after_cancel(self.__jobtime)
            self.__jobtime = None
        if self.__jobrefresh is not None:
            self.mainFrame.after_cancel(self.__jobrefresh)
            self.__jobrefresh = None
        self.game_controller.quit()