Beispiel #1
0
 def canDropCards(self, stacks):
     if self.game.demo:
         return UD_SS_RowStack.canDropCards(self, stacks)
     for s in self.game.s.foundations:
         if s.cards:
             return UD_SS_RowStack.canDropCards(self, stacks)
     return (None, 0)
Beispiel #2
0
 def canDropCards(self, stacks):
     if self.game.demo:
         return UD_SS_RowStack.canDropCards(self, stacks)
     for s in self.game.s.foundations:
         if s.cards:
             return UD_SS_RowStack.canDropCards(self, stacks)
     return (None, 0)
Beispiel #3
0
    def createGame(self):
        # create layout
        l, s = Layout(self), self.s

        # set window
        # (set size so that at least 7 cards are fully playable)
        dx = l.XM+l.XS+7*l.XOFFSET
        w = l.XM+max(5*dx, 9*l.XS+2*l.XM)
        h = l.YM+6*l.YS
        self.setSize(w, h)

        # create stacks
        x, y = l.XM, l.YM
        s.talon = TalonStack(x, y, self)
        l.createText(s.talon, "se")
        x = max(l.XS+3*l.XM, (self.width-l.XM-8*l.XS)//2)
        for i in range(4):
            s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
            x += l.XS
        for i in range(4):
            s.foundations.append(SS_FoundationStack(x, y, self, suit=i,
                                                    base_rank=KING, dir=-1))
            x += l.XS
        y = l.YM+l.YS
        for i in range(5):
            x = l.XM
            for j in range(5):
                stack = UD_SS_RowStack(x, y, self)
                s.rows.append(stack)
                stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0
                x += dx
            y += l.YS

        # define stack-groups
        l.defaultStackGroups()
Beispiel #4
0
    def createGame(self):
        l, s = Layout(self), self.s
        playcards = 10
        w0 = l.XS + (playcards - 1) * l.XOFFSET
        w, h = l.XM + max(self.COLS * w0, 9 * l.XS), \
            l.YM + (self.ROWS + 1) * l.YS + l.TEXT_HEIGHT
        self.setSize(w, h)
        x, y = l.XM, l.YM
        s.talon = Crescent_Talon(x, y, self, max_rounds=4)
        if self.SHOW_TALON_COUNT:
            l.createText(s.talon, 'ne')
        l.createRoundText(s.talon, 's')
        x, y = w - 8 * l.XS, l.YM
        for i in range(4):
            s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
            x += l.XS
        for i in range(4):
            s.foundations.append(
                SS_FoundationStack(x, y, self, suit=i, base_rank=KING, dir=-1))
            x += l.XS
        y = l.YM + l.YS + l.TEXT_HEIGHT
        for i in range(self.ROWS):
            x = l.XM
            for j in range(self.COLS):
                stack = UD_SS_RowStack(x, y, self, base_rank=NO_RANK, mod=13)
                s.rows.append(stack)
                stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0
                x += w0
            y += l.YS
        self.s.internals.append(InvisibleStack(self))
        self.s.internals.append(InvisibleStack(self))

        l.defaultStackGroups()
Beispiel #5
0
    def createGame(self):

        l, s = Layout(self), self.s
        self.setSize(l.XM+9*l.XS, l.YM+5*l.YS)

        x, y = l.XM, l.YM
        for i in range(4):
            s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
            y += l.YS
        x, y = self.width-l.XS, l.YM
        for i in range(4):
            s.foundations.append(SS_FoundationStack(x, y, self,
                                 suit=i, base_rank=KING, dir=-1))
            y += l.YS
        x, y = (self.width-l.XS)//2, self.height-l.YS
        s.talon = DealRowTalonStack(x, y, self)
        l.createText(s.talon, 'se')
        y = l.YM
        for i in range(4):
            x = l.XM+l.XS*3//2
            for j in range(6):
                stack = UD_SS_RowStack(x, y, self, base_rank=NO_RANK)
                s.rows.append(stack)
                stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, 0
                x += l.XS
            y += l.YS

        l.defaultStackGroups()
Beispiel #6
0
    def createGame(self):
        l, s = Layout(self), self.s
        playcards = 10
        w0 = l.XS+(playcards-1)*l.XOFFSET
        w, h = l.XM+max(4*w0, 9*l.XS), l.YM+5*l.YS
        self.setSize(w, h)
        x, y = l.XM, l.YM
        s.talon = Crescent_Talon(x, y, self, max_rounds=4)
        l.createRoundText(s.talon, 'ne')
        x, y = w-8*l.XS, l.YM
        for i in range(4):
            s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
            x += l.XS
        for i in range(4):
            s.foundations.append(SS_FoundationStack(x, y, self, suit=i,
                                                    base_rank=KING, dir=-1))
            x += l.XS
        y = l.YM+l.YS
        for i in range(4):
            x = l.XM
            for j in range(4):
                stack = UD_SS_RowStack(x, y, self, base_rank=NO_RANK, mod=13)
                s.rows.append(stack)
                stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0
                x += w0
            y += l.YS
        self.s.internals.append(InvisibleStack(self))
        self.s.internals.append(InvisibleStack(self))

        l.defaultStackGroups()
Beispiel #7
0
    def createGame(self):

        l, s = Layout(self), self.s
        self.setSize(l.XM + 9 * l.XS, l.YM + 5 * l.YS)

        x, y = l.XM, l.YM
        for i in range(4):
            s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
            y += l.YS
        x, y = self.width - l.XS, l.YM
        for i in range(4):
            s.foundations.append(
                SS_FoundationStack(x, y, self, suit=i, base_rank=KING, dir=-1))
            y += l.YS
        x, y = (self.width - l.XS) // 2, self.height - l.YS
        s.talon = DealRowTalonStack(x, y, self)
        l.createText(s.talon, 'se')
        y = l.YM
        for i in range(4):
            x = l.XM + l.XS * 3 // 2
            for j in range(6):
                stack = UD_SS_RowStack(x, y, self, base_rank=NO_RANK)
                s.rows.append(stack)
                stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, 0
                x += l.XS
            y += l.YS

        l.defaultStackGroups()
Beispiel #8
0
    def createGame(self):
        # create layout
        l, s = Layout(self), self.s

        # set window
        # (set size so that at least 7 cards are fully playable)
        dx = l.XM+l.XS+7*l.XOFFSET
        w = l.XM+max(5*dx, 9*l.XS+2*l.XM)
        h = l.YM+6*l.YS
        self.setSize(w, h)

        # create stacks
        x, y = l.XM, l.YM
        s.talon = TalonStack(x, y, self)
        l.createText(s.talon, "se")
        x = max(l.XS+3*l.XM, (self.width-l.XM-8*l.XS)//2)
        for i in range(4):
            s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
            x += l.XS
        for i in range(4):
            s.foundations.append(SS_FoundationStack(x, y, self, suit=i,
                                                    base_rank=KING, dir=-1))
            x += l.XS
        y = l.YM+l.YS
        for i in range(5):
            x = l.XM
            for j in range(5):
                stack = UD_SS_RowStack(x, y, self)
                s.rows.append(stack)
                stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0
                x += dx
            y += l.YS

        # define stack-groups
        l.defaultStackGroups()
Beispiel #9
0
    def createGame(self):
        rows = 12

        l, s = Layout(self), self.s
        self.setSize(l.XM + rows * l.XS, l.YM + 3 * l.YS + 16 * l.YOFFSET)

        x, y = l.XM + (rows - 8) * l.XS / 2, l.YM
        for i in range(4):
            s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
            x += l.XS
        for i in range(4):
            s.foundations.append(
                SS_FoundationStack(x, y, self, suit=i, base_rank=KING, dir=-1))
            x += l.XS

        x, y = l.XM + l.XS / 2, l.YM + l.YS
        for i in range(rows / 2):
            s.reserves.append(BusyCards_FreeCell(x, y, self))
            x += 2 * l.XS

        x, y = l.XM, l.YM + 2 * l.YS
        for i in range(rows):
            s.rows.append(UD_SS_RowStack(x, y, self))
            x += l.XS

        x, y = l.XM, self.height - l.YS
        s.talon = InitialDealTalonStack(x, y, self)

        l.defaultStackGroups()
Beispiel #10
0
    def createGame(self):
        self.base_card = None
        # create layout
        l, s = Layout(self), self.s

        # set window
        # (set size so that at least 3 cards are fully playable)
        w = max(2 * l.XS, l.XS + 3 * l.XOFFSET)
        w = min(3 * l.XS, w)
        w = (w + 1) & ~1
        self.setSize(l.XM + 6 * w, l.YM + 4 * l.YS + l.TEXT_HEIGHT)

        dx = (self.width - 4 * l.XS) // (4 + 1)
        x, y = l.XM + dx, l.YM
        dx += l.XS
        for i in range(4):
            s.foundations.append(SS_FoundationStack(x, y, self, suit=i,
                                                    mod=13))
            x += dx

        tx, ty, ta, tf = l.getTextAttr(s.foundations[0], "s")

        self.texts.info = \
            MfxCanvasText(self.canvas, tx, ty, anchor=ta,
                          font=self.app.getFont("canvas_default"))

        y += l.TEXT_HEIGHT
        for i in range(3):
            x, y = l.XM, y + l.YS
            for j in range(5):
                stack = UD_SS_RowStack(x,
                                       y,
                                       self,
                                       max_move=1,
                                       max_accept=1,
                                       base_rank=NO_RANK,
                                       mod=13,
                                       max_cards=3)
                stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0
                s.rows.append(stack)
                x += w
            stack = UD_SS_RowStack(x,
                                   y,
                                   self,
                                   max_move=1,
                                   max_accept=1,
                                   base_rank=ANY_RANK,
                                   mod=13,
                                   max_cards=3)
            stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0
            s.rows.append(stack)

        x, y = self.width - l.XS, self.height - l.YS
        s.talon = self.Talon_Class(x, y, self)

        # define stack-groups
        l.defaultStackGroups()
        return l
Beispiel #11
0
    def createGame(self):
        # create layout
        l, s = Layout(self), self.s

        # set window
        w, h = 2 * l.XM + 8 * l.XS, max(2 * (l.YM + l.YS + 8 * l.YOFFSET),
                                        l.YM + 5 * l.YS)
        self.setSize(w, h)

        # create stacks
        x, y = l.XM, l.YM
        for i in range(6):
            s.rows.append(UD_SS_RowStack(x, y, self, base_rank=NO_RANK))
            x += l.XS
        x, y = l.XM, l.YM + l.YS + 8 * l.YOFFSET
        for i in range(6):
            s.rows.append(UD_SS_RowStack(x, y, self, base_rank=NO_RANK))
            x += l.XS
        y = l.YM
        for i in range(4):
            x = l.XM + 6 * l.XS + l.XM
            s.foundations.append(SS_FoundationStack(x, y, self, i, max_move=0))
            x += l.XS
            s.foundations.append(
                SS_FoundationStack(x,
                                   y,
                                   self,
                                   i,
                                   base_rank=KING,
                                   max_move=0,
                                   dir=-1))
            y += l.YS

        s.talon = InitialDealTalonStack(w - l.XS, h - l.YS, self)

        # default
        l.defaultAll()
Beispiel #12
0
    def createGame(self):
        # create layout
        l, s = Layout(self), self.s

        # set window
        w, h = l.XM + (8 + 2) * l.XS, l.YM + max(3 * (l.YS + 8 * l.YOFFSET),
                                                 8 * l.YS)
        self.setSize(w, h)

        # create stacks
        y = l.YM
        for i in range(3):
            x = l.XM
            for j in range(8):
                s.rows.append(UD_SS_RowStack(x, y, self, base_rank=NO_RANK))
                x += l.XS
            y += l.YS + 8 * l.YOFFSET

        y = l.YM
        for j in range(2):
            for i in range(4):
                x = l.XM + 8 * l.XS
                s.foundations.append(
                    SS_FoundationStack(x,
                                       y,
                                       self,
                                       suit=j * 2 + i / 2,
                                       max_move=0))
                x += l.XS
                s.foundations.append(
                    SS_FoundationStack(x,
                                       y,
                                       self,
                                       suit=j * 2 + i / 2,
                                       base_rank=KING,
                                       max_move=0,
                                       dir=-1))
                y += l.YS

        s.talon = InitialDealTalonStack(l.XM, h - l.YS, self)

        # default
        l.defaultAll()
Beispiel #13
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
Beispiel #14
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
Beispiel #15
0
 def acceptsCards(self, from_stack, cards):
     if not UD_SS_RowStack.acceptsCards(self, from_stack, cards):
         return False
     if from_stack in self.game.s.rows:
         return False
     return True
Beispiel #16
0
 def acceptsCards(self, from_stack, cards):
     if not UD_SS_RowStack.acceptsCards(self, from_stack, cards):
         return False
     if not self.cards:
         return cards[0].rank in (ACE, KING)
     return True
Beispiel #17
0
 def acceptsCards(self, from_stack, cards):
     if not UD_SS_RowStack.acceptsCards(self, from_stack, cards):
         return False
     return len(self.game.s.talon.cards) == 0
Beispiel #18
0
 def acceptsCards(self, from_stack, cards):
     if not UD_SS_RowStack.acceptsCards(self, from_stack, cards):
         return False
     if from_stack in self.game.s.rows:
         return False
     return True
 def acceptsCards(self, from_stack, cards):
     if not UD_SS_RowStack.acceptsCards(self, from_stack, cards):
         return False
     return len(self.game.s.talon.cards) == 0
Beispiel #20
0
 def acceptsCards(self, from_stack, cards):
     if not UD_SS_RowStack.acceptsCards(self, from_stack, cards):
         return False
     if not self.cards:
         return cards[0].rank in (ACE, KING)
     return True