Exemple #1
0
    def capture(self, player):
        """
        Used for passed Player to gain control of Piece

        :param player: The player to gain control of this Piece.
        :type player: Player
        """
        logger.debug("Piece at (%u,%u) owned by player=%u captured by player=%u.",
                     self.x, self.y, self.player.id, player.id)
        self.player = player
        self.type = player.id
        self.capture_count = self.capture_count + 1
Exemple #2
0
    def get_next_player(self):
        """ Switches to the next available player with pieces."""
        if self.active_player is None:
            self.active_player = self.board.players[0]
        else:
            players_cycle = cycle(self.board.players)

            # Cycle to the current player.
            for temp_player in players_cycle:
                if temp_player is self.active_player:
                    break

            # Cycle to the next available player with pieces.
            for temp_player in players_cycle:
                if (self.board.does_player_have_pieces(temp_player) is False):
                    continue
                self.active_player = temp_player
                break

        logger.debug("Starting turn for player=%u.", self.active_player.id)