Пример #1
0
 def move_my_storage(self, wn, u_turt, t_turt, s_turt):
     """Moves everything from myStoragePile to myPlayingPile"""
     if self.myPlayingPile.size() == 0:
         while self.myStoragePile.size() != 0:                   # removes all the cards from the storage pile and puts it into the playing hand
             c = self.myStoragePile.dequeue()
             self.myPlayingPile.push(c)
         if self.myStoragePile.size()== 0:
             return self.myPlayingPile
         else:
             u_turt.clear()
             Display.user_card_number(self, wn, u_turt, self.myPlayingPile.size())   # updated user card number
             Display.replace_card(self, wn, s_turt)                              # moves the storage to the playing pile
             t_turt.clear()
             Display.user_storage_number(self, wn, t_turt, self.myStoragePile.size())    # updates storage pile number
             s_turt.clear()
             return self.myPlayingPile
Пример #2
0
    def deal(self, wn, turt, u_turt, x_turt):
        """Deals out 25 cards from to each player's playing pile from shuffled dealers pile """
        Display.draw_board(self, wn, turt)              # initializes board
        Display.write_text(self, wn, turt)              # initiates user and computer
        for i in range(1):                             # deals out 25 cards to player 1
            my_card = self.dealingPile.pop()
            self.myPlayingPile.push(my_card)
        Display.user_playing(self, wn, turt)            # draws user playing pile
        u_turt.clear()
        Display.user_card_number(self, wn, u_turt, self.myPlayingPile.size())       # prints number of cards

        for i in range(1):                             # deals out 25 cards to the computer
            other_card = self.dealingPile.pop()
            self.otherPlayingPile.push(other_card)
            Display.comp_playing(self, wn, turt)            # draws computer playing pile
        x_turt.clear()
        Display.other_card_number(self, wn, x_turt, self.otherPlayingPile.size())   # prints the number of cards
        return self.otherPlayingPile, self.myPlayingPile         # returns the storage for each hand
Пример #3
0
    def compare_other(self, wn, u_turt, x_turt):
        """Gives the cards to whichever layer had the highest played number"""
        b = self.myCurrent.top()
        a = self.otherCurrent.top()

        if b > a:
            a = self.myCurrent.pop()                        # removes card and places it in the lootpile
            self.lootPile.push(a)
            x = self.otherCurrent.pop()
            self.lootPile.push(x)
            while self.war.size() != 0:                     # removes cards inside the war stack and places it in the lootpile
                p = self.war.pop()
                self.lootPile.push(p)
            u_turt.clear()
            Display.user_card_number(self, wn, u_turt, self.myPlayingPile.size())       # displays number of cards remaining for user
            x_turt.clear()
            Display.other_card_number(self, wn, x_turt, self.otherPlayingPile.size())
            print("You won the cards.")
            return self.lootPile
        elif b < a:
            b = self.myCurrent.pop()
            self.lootPile.push(b)
            c = self.otherCurrent.pop()                    # removes card and places it in the lootpile
            self.lootPile.push(c)
            while self.war.size() != 0:
                h = self.war.pop()
                self.lootPile.push(h)
            u_turt.clear()
            Display.user_card_number(self, wn, u_turt, self.myPlayingPile.size())
            x_turt.clear()
            Display.other_card_number(self, wn, x_turt, self.otherPlayingPile.size())   # displays number of cards remaining for computer
            print("Computer won the cards.")
            return self.lootPile                            # returns the lootpile
        elif b == a:
            b = self.myCurrent.pop()                        # puts the player's current card and the computer's current card in a stack if they are the same
            self.war.push(b)
            c = self.otherCurrent.pop()
            self.war.push(c)
            while self.war.size() != 0:
                x = self.war.pop()
                self.lootPile.push(x)
            u_turt.clear()
            Display.user_card_number(self, wn, u_turt, self.myPlayingPile.size())
            x_turt.clear()
            Display.other_card_number(self, wn, x_turt, self.otherPlayingPile.size())
            return self.lootPile