Ejemplo n.º 1
0
 def isGameWon(self):
     if self.s.talon.cards:
         return 0
     for row in self.s.rows:
         if not isSameSuitSequence(row.cards, dir=1):
             return 0
     return 1
Ejemplo n.º 2
0
 def fillStack(self, stack):
     for r in self.s.rows:
         if len(r.cards) >= 13 and isSameSuitSequence(r.cards[-13:]):
             old_state = self.enterState(self.S_FILL)
             self.playSample("drop", priority=200)
             self.moveMove(13, r, self.s.foundations[0])
             self.leaveState(old_state)
Ejemplo n.º 3
0
 def isGameWon(self):
     for s in self.s.rows:
         if len(s.cards) == 0:
             continue
         if len(s.cards) != 13 or not isSameSuitSequence(s.cards):
             return False
     return True
Ejemplo n.º 4
0
 def isGameWon(self):
     if self.s.talon.cards:
         return 0
     for row in self.s.rows:
         if not isSameSuitSequence(row.cards, dir=1):
             return 0
     return 1
Ejemplo n.º 5
0
 def isGameWon(self):
     if len(self.s.talon.cards):
         return 0
     for s in self.s.rows:
         if len(s.cards) != 12 or not isSameSuitSequence(s.cards):
             return 0
     return 1
Ejemplo n.º 6
0
 def fillStack(self, stack):
     for r in self.s.rows:
         if len(r.cards) >= 13 and isSameSuitSequence(r.cards[-13:]):
             old_state = self.enterState(self.S_FILL)
             self.playSample("drop", priority=200)
             self.moveMove(13, r, self.s.foundations[0])
             self.leaveState(old_state)
Ejemplo n.º 7
0
 def isGameWon(self):
     if len(self.s.talon.cards):
         return 0
     for s in self.s.rows:
         if len(s.cards) != 12 or not isSameSuitSequence(s.cards):
             return 0
     return 1
Ejemplo n.º 8
0
 def canDropCards(self, stacks):
     pile, stack, rank = self.getPile(), stacks[0], 0
     if stack.cards:
         rank = (stack.cards[-1].rank + 1) % 12
     if (not pile or len(pile) <= 11 - rank or
             not isSameSuitSequence(pile[-(12 - rank):]) or
             not stack.acceptsCards(self, pile[-1:])):
         return (None, 0)
     return (stack, 1)
Ejemplo n.º 9
0
 def canDropCards(self, stacks):
     pile, stack, rank = self.getPile(), stacks[0], 0
     if stack.cards:
         rank = (stack.cards[-1].rank + 1) % 12
     if (not pile or len(pile) <= 11 - rank
             or not isSameSuitSequence(pile[-(12 - rank):])
             or not stack.acceptsCards(self, pile[-1:])):
         return (None, 0)
     return (stack, 1)
Ejemplo n.º 10
0
 def acceptsCards(self, from_stack, cards):
     if not UD_SS_RowStack.acceptsCards(self, from_stack, cards):
         return False
     if not (from_stack in self.game.s.reserves
             or from_stack in self.game.s.rows):
         return False
     if len(self.cards) > 1:
         cs = self.cards + cards
         if not (isSameSuitSequence(cs, dir=1)
                 or isSameSuitSequence(cs, dir=-1)):
             return False
     if from_stack in self.game.s.reserves:
         if hasattr(self.cap, 'column') and \
                self.cap.column != from_stack.cap.column:
             return False
         if hasattr(self.cap, 'row') and \
                 self.cap.row != from_stack.cap.row:
             return False
     return True
Ejemplo n.º 11
0
 def isGameWon(self):
     cardsPlayed = False
     for s in self.s.rows:
         if s.cards:
             if len(s.cards) != 13 or not isSameSuitSequence(s.cards):
                 return False
             cardsPlayed = True
     if not cardsPlayed:
         return False
     return True
Ejemplo n.º 12
0
 def acceptsCards(self, from_stack, cards):
     if not UD_SS_RowStack.acceptsCards(self, from_stack, cards):
         return False
     if not (from_stack in self.game.s.reserves or
             from_stack in self.game.s.rows):
         return False
     if len(self.cards) > 1:
         cs = self.cards+cards
         if not (isSameSuitSequence(cs, dir=1) or
                 isSameSuitSequence(cs, dir=-1)):
             return False
     if from_stack in self.game.s.reserves:
         if hasattr(self.cap, 'column') and \
                self.cap.column != from_stack.cap.column:
             return False
         if hasattr(self.cap, 'row') and \
                 self.cap.row != from_stack.cap.row:
             return False
     return True
Ejemplo n.º 13
0
 def isGameWon(self):
     if len(self.s.foundations[0].cards) != 13:
         return False
     for s in self.s.rows:
         if len(s.cards) == 0:
             continue
         if len(s.cards) != 13:
             return False
         if not isSameSuitSequence(s.cards):
             return False
     return True
Ejemplo n.º 14
0
 def isGameWon(self):
     if len(self.s.foundations[0].cards) != 13:
         return False
     for s in self.s.rows:
         if len(s.cards) == 0:
             continue
         if len(s.cards) != 13:
             return False
         if not isSameSuitSequence(s.cards):
             return False
     return True
Ejemplo n.º 15
0
 def acceptsCards(self, from_stack, cards):
     if not (from_stack in self.game.s.rows and
             AbstractFoundationStack.acceptsCards(self, from_stack, cards)):
         return 0
     pile, rank, suit = from_stack.getPile(), 0, 0
     if self.cards:
         rank = (self.cards[-1].rank + 1) % 12
         suit = self.cards[-1].suit + (rank == 0)
     if (not pile or len(pile) <= 11 - rank
             or not isSameSuitSequence(pile[-(12 - rank):])):
         return 0
     return cards[0].suit == suit and cards[0].rank == rank
Ejemplo n.º 16
0
 def acceptsCards(self, from_stack, cards):
     if not (from_stack in self.game.s.rows and
             AbstractFoundationStack.acceptsCards(self, from_stack, cards)):
         return 0
     pile, rank, suit = from_stack.getPile(), 0, 0
     if self.cards:
         rank = (self.cards[-1].rank + 1) % 12
         suit = self.cards[-1].suit + (rank == 0)
     if (not pile or len(pile) <= 11 - rank or
             not isSameSuitSequence(pile[-(12 - rank):])):
         return 0
     return cards[0].suit == suit and cards[0].rank == rank
Ejemplo n.º 17
0
 def canDropCards(self, stacks):
     cards = self.cards
     if not cards:
         return (None, 0)
     dcards = None
     if cards[-1].rank == ACE:
         if len(cards) < 4:
             return (None, 0)
         if isSameColorSequence(cards[-4:], dir=0):
             dcards = cards[-4:]
     else:
         if len(cards) < 6:
             return (None, 0)
         if isSameSuitSequence(cards, dir=-2):
             dcards = cards[-6:]
     if not dcards:
         return (None, 0)
     for s in stacks:
         if s is not self and s.acceptsCards(self, dcards):
             return (s, len(dcards))
     return (None, 0)
Ejemplo n.º 18
0
 def isGameWon(self):
     rows = [s for s in self.s.rows if s.cards]
     if len(rows) != 48:
         return False  # no cards dealt yet
     i = 0
     if 1:
         # allow wrap around: search first Ace
         while rows[i].cards[-1].rank != ACE:
             i = i + 1
         rows = rows + rows
     # now check for 4 sequences
     for j in (i + 0, i + 12, i + 24, i + 36):
         r1 = rows[j]
         r2 = rows[j + 11]
         if (r2.id - r1.id) % 54 != 11:
             # found a space within the sequence
             return False
         if r1.cards[-1].rank != ACE or r2.cards[-1].rank != QUEEN:
             return False
         pile = getPileFromStacks(rows[j:j + 12])
         if not pile or not isSameSuitSequence(pile, dir=1):
             return False
     return True
Ejemplo n.º 19
0
 def isGameWon(self):
     rows = [s for s in self.s.rows if s.cards]
     if len(rows) != 48:
         return False            # no cards dealt yet
     i = 0
     if 1:
         # allow wrap around: search first Ace
         while rows[i].cards[-1].rank != ACE:
             i = i + 1
         rows = rows + rows
     # now check for 4 sequences
     for j in (i+0, i+12, i+24, i+36):
         r1 = rows[j]
         r2 = rows[j+11]
         if (r2.id - r1.id) % 54 != 11:
             # found a space within the sequence
             return False
         if r1.cards[-1].rank != ACE or r2.cards[-1].rank != QUEEN:
             return False
         pile = getPileFromStacks(rows[j:j+12])
         if not pile or not isSameSuitSequence(pile, dir=1):
             return False
     return True
Ejemplo n.º 20
0
 def canMoveCards(self, cards):
     return isSameSuitSequence(cards) or isRankSequence(cards, dir=0)
Ejemplo n.º 21
0
 def canMoveCards(self, cards):
     if cards[0].rank == ACE:
         return isSameColorSequence(cards, dir=0)
     elif cards[-1].rank == ACE:
         return False                # 5-3-ace
     return isSameSuitSequence(cards, dir=-2)
Ejemplo n.º 22
0
 def isGameWon(self):
     for s in self.s.rows:
         if s.cards:
             if len(s.cards) != 13 or not isSameSuitSequence(s.cards):
                 return False
     return True
Ejemplo n.º 23
0
 def canMoveCards(self, cards):
     return isSameSuitSequence(cards) or isRankSequence(cards, dir=0)