Exemple #1
0
    def bind(self, *args, **kwargs):
        """
        Function to send name to server
        """

        msg = construct_message("Bind", args=self.name)
        send(msg, self.server)
Exemple #2
0
    def action(self, *args, **kwargs):
        """
        Ask user a command for the robot
        """

        cmd = input("{}, What move do you want to do?\r\n".format(self.name))
        msg = construct_message("Action", args=cmd)
        send(msg, self.server)
Exemple #3
0
    def ask_for_action(self, player):
        """
        Ask the current player an action
        :param player: name of the player to send the message to
        """

        for name, link in self.players.items():
            if name == player:
                msg = construct_message("Action")
            else:
                msg = construct_message(
                    "Wait", args="Waiting for {} to play...".format(player))

            send(msg, link)

        if self.wait_action.is_set():
            self.wait_action.clear()
Exemple #4
0
    def refresh_maps(self):
        """
        Send update maze map to all player
        """

        msg = construct_message("Refresh", args=self.maze.map)

        for player_socket in self.players.values():
            send(msg, player_socket)
Exemple #5
0
    def cmd_usage(self, player):
        """
        Send robot instructions to player
         :param : name of the player
        """

        instruction = self.maze.cmd_usage()
        msg = construct_message("Usage", args=instruction)
        send(msg, self.players[player])
Exemple #6
0
    def introduction(self):
        """
        Send introduction message to all players
        """

        welcome = self.initialisation_string()
        for name, link in self.players.items():
            new_welcome = welcome + "You are robot {}!\n\r".format(
                self.maze.players[name])
            msg = construct_message("Intro", args=new_welcome)
            send(msg, link)