コード例 #1
0
 def find_in_array(self, card_played, array):
     """
         Finds a card object in a given array
     """
     for card in array:
         if card.equals(card_played):
             return card
     return None
コード例 #2
0
ファイル: game.py プロジェクト: sandmman/Hearts
 def find_in_array(self,card_played,array):
     """
         Finds a card object in a given array
     """
     for card in array:
         if card.equals(card_played):
             return card
     return None
コード例 #3
0
ファイル: game.py プロジェクト: sandmman/Hearts
    def update_game_cards(self,card_played):
        """
            Removes the most recently played cards from the deck
            and from the individual suit arrays
        """
        self.deck = [card for card in self.deck if not card.equals(card_played)]

        if card_played.suit == "Clubs":
            self.clubs.remove(self.find_in_array(card_played,self.clubs))
        elif card_played.suit == "Spades":
            self.spades.remove(self.find_in_array(card_played,self.spades))
        elif card_played.suit == "Diamonds":
            self.diamonds.remove(self.find_in_array(card_played,self.diamonds))
        else:
            self.hearts.remove(self.find_in_array(card_played,self.hearts))
コード例 #4
0
    def update_game_cards(self, card_played):
        """
            Removes the most recently played cards from the deck
            and from the individual suit arrays
        """
        self.deck = [
            card for card in self.deck if not card.equals(card_played)
        ]

        if card_played.suit == "Clubs":
            self.clubs.remove(self.find_in_array(card_played, self.clubs))
        elif card_played.suit == "Spades":
            self.spades.remove(self.find_in_array(card_played, self.spades))
        elif card_played.suit == "Diamonds":
            self.diamonds.remove(self.find_in_array(card_played,
                                                    self.diamonds))
        else:
            self.hearts.remove(self.find_in_array(card_played, self.hearts))