def move_other_storage(self, wn, x_turt, o_turt, cs_turt): """Moves everything from otherStoragePile to otherPlayingPile""" if self.otherPlayingPile.size() == 0: while self.otherStoragePile.size() != 0: # removes all the cards from the storage pile and puts it into the playing hand d = self.otherStoragePile.dequeue() self.otherPlayingPile.push(d) if self.otherStoragePile.size() == 0: return self.otherPlayingPile else: x_turt.clear() Display.other_card_number(self, wn, x_turt, self.otherPlayingPile.size()) # updates computer playing pile number Display.replace_other_card(self, wn, cs_turt) # moves computer storage to playing pile o_turt.clear() Display.other_storage_number(self, wn, o_turt, self.otherStoragePile.size()) # updates computer storage pile number cs_turt.clear() return self.otherPlayingPile
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
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