Exemplo n.º 1
0
 def acceptsCards(self, from_stack, cards):
     if not RK_FoundationStack.acceptsCards(self, from_stack, cards):
         return False
     if from_stack not in self.game.s.rows:
         return False
     row_id = self.id + 8
     return len(self.game.allstacks[row_id].cards) > 0
Exemplo n.º 2
0
 def acceptsCards(self, from_stack, cards):
     if not RK_FoundationStack.acceptsCards(self, from_stack, cards):
         return False
     if self.cards:
         return True
     if self.game.s.reserves[0].cards:
         c = self.game.s.reserves[0].cards[-1]
         return (c.rank+1) % 13 == cards[-1].rank
     return True
Exemplo n.º 3
0
 def acceptsCards(self, from_stack, cards):
     if not RK_FoundationStack.acceptsCards(self, from_stack, cards):
         return False
     if self.cards:
         return True
     if self.game.s.reserves[0].cards:
         c = self.game.s.reserves[0].cards[-1]
         return (c.rank+1) % 13 == cards[-1].rank
     return True
Exemplo n.º 4
0
 def acceptsCards(self, from_stack, cards):
     if not RK_FoundationStack.acceptsCards(self, from_stack, cards):
         return False
     if len(self.cards) == 12:
         # the final card must come from the reserve above the foundation
         return from_stack.id == self.id - 8
     else:
         # card must come from rows
         return from_stack in self.game.s.rows
Exemplo n.º 5
0
 def acceptsCards(self, from_stack, cards):
     if not RK_FoundationStack.acceptsCards(self, from_stack, cards):
         return False
     if len(self.cards) == 12:
         # the final card must come from the reserve above the foundation
         return from_stack.id == self.id - 8
     else:
         # card must come from rows
         return from_stack in self.game.s.rows
Exemplo n.º 6
0
 def acceptsCards(self, from_stack, cards):
     if not RK_FoundationStack.acceptsCards(self, from_stack, cards):
         return False
     c = cards[0]
     if c.rank in (4, 5):
         i = list(self.game.s.foundations).index(self) % 8
         r = self.game.s.rows[i]
         if not r.cards:
             return False
     return True
Exemplo n.º 7
0
 def acceptsCards(self, from_stack, cards):
     if not RK_FoundationStack.acceptsCards(self, from_stack, cards):
         return False
     if from_stack in self.game.s.rows:
         ri = list(self.game.s.rows).index(from_stack)
         fi = list(self.game.s.foundations).index(self)
         if ri < 4:
             return ri == fi
         if ri == 4:
             return True
         return ri-1 == fi
     return False
Exemplo n.º 8
0
 def acceptsCards(self, from_stack, cards):
     if not RK_FoundationStack.acceptsCards(self, from_stack, cards):
         return False
     if from_stack in self.game.s.rows:
         ri = list(self.game.s.rows).index(from_stack)
         fi = list(self.game.s.foundations).index(self)
         if ri < 4:
             return ri == fi
         if ri == 4:
             return True
         return ri-1 == fi
     return False
Exemplo n.º 9
0
 def acceptsCards(self, from_stack, cards):
     if not RK_FoundationStack.acceptsCards(self, from_stack, cards):
         return False
     # check the suit
     num_cards = len(self.cards)
     for f in self.game.s.foundations:
         if len(f.cards) > num_cards:
             suit = f.cards[num_cards].suit
             break
     else:
         return True
     return cards[0].suit == suit
Exemplo n.º 10
0
 def acceptsCards(self, from_stack, cards):
     if not RK_FoundationStack.acceptsCards(self, from_stack, cards):
         return False
     # check the suit
     num_cards = len(self.cards)
     for f in self.game.s.foundations:
         if len(f.cards) > num_cards:
             suit = f.cards[num_cards].suit
             break
     else:
         return True
     return cards[0].suit == suit
Exemplo n.º 11
0
 def acceptsCards(self, from_stack, cards):
     if (not self.cards):
         if (self.id > 0 and not self.game.s
                 .foundations[self.id - 1].cards):
             return False
         if self.id == 0:
             return cards[0].rank == KING
         else:
             return cards[0].rank == (self.game.s
                                      .foundations[self.id - 1]
                                      .cards[0].rank - 1) % 13
     if not RK_FoundationStack.acceptsCards(self, from_stack, cards):
         return False
     return True
Exemplo n.º 12
0
    def acceptsCards(self, from_stack, cards):
        if len(cards) > 1:
            return False

        if len(self.cards) > 0:
            return (self.cards[-1].suit == cards[0].suit and
                    RK_FoundationStack.acceptsCards(self, from_stack, cards))

        foundations = self.game.s.foundations
        for i in range(4):
            if (foundations[i].cards and
                    foundations[i].cards[0].suit == cards[0].suit):
                return False
        if cards[0].rank != self.cap.base_rank:
            return False
        return True
Exemplo n.º 13
0
    def acceptsCards(self, from_stack, cards):
        if len(self.cards) > 0:
            return (self.cards[-1].suit == cards[0].suit
                    and RK_FoundationStack.acceptsCards(
                        self, from_stack, cards))

        foundations = self.game.s.foundations

        # Checking each rule for starting a new foundation:
        # Only the next foundation can be built to.
        if self.id > 0 and len(foundations[self.id - 1].cards) == 0:
            return False
        # The suit must match the foundation directly to the left.
        if (self.id > 3
                and foundations[self.id - 4].cards[0].suit != cards[0].suit):
            return False
        # Two foundations in the same column can't have the same suit.
        if self.id <= 3:
            for i in range(4):
                if (foundations[i].cards
                        and foundations[i].cards[0].suit == cards[0].suit):
                    return False
        # Only the lowest available card of a suit can start a foundation.
        for row in self.game.s.rows:
            if (row.cards and row.cards[-1].suit == cards[0].suit
                    and row.cards[-1].rank < cards[0].rank):
                return False
        # Can't start a foundation with a card that can be played on an
        # existing foundation.
        for foundation in foundations:
            if (foundation.cards and foundation.cards[-1].suit == cards[0].suit
                    and (foundation.cards[-1].rank == cards[0].rank - 1 or
                         (foundation.cards[-1].rank == KING
                          and cards[0].rank == ACE))):
                return False
        return True
Exemplo n.º 14
0
 def acceptsCards(self, from_stack, cards):
     if not RK_FoundationStack.acceptsCards(self, from_stack, cards):
         return False
     if (self.id > 0 and not self.game.s.foundations[self.id - 1].cards):
         return False
     return True