Example #1
0
    def createGame(self, rows=9):
        l, s = Layout(self), self.s
        self.setSize(l.XM+11*l.XS, l.YM+4*l.YS+12*l.YOFFSET)

        x, y = l.XM, l.YM
        s.talon = WasteTalonStack(x, y, self, max_rounds=1)
        l.createText(s.talon, 's')
        x += l.XS
        s.waste = WasteStack(x, y, self)
        l.createText(s.waste, 's')

        y = l.YM
        for i in range(2):
            x = l.XM+2.5*l.XS
            for j in range(8):
                s.foundations.append(
                    SS_FoundationStack(x, y, self, suit=j % 4, max_move=1))
                x += l.XS
            y += l.YS
        x, y = l.XM, l.YM+2*l.YS
        stack = ReserveStack(x, y, self, max_cards=8)
        s.reserves.append(stack)
        stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, l.YOFFSET
        l.createText(stack, 'n')

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

        l.defaultStackGroups()
Example #2
0
    def createGame(self, playcards=20, rows=8, reserves=1):

        decks = self.gameinfo.decks
        l, s = Layout(self), self.s
        self.setSize(l.XM+(reserves+0.5+rows)*l.XS,
                     l.YM+max(2*l.YS+7*l.YOFFSET, l.YS+playcards*l.YOFFSET))

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

        x, y = l.XM, l.YM
        for i in range(reserves):
            stack = ReserveStack(x, y, self, max_cards=UNLIMITED_CARDS)
            stack.CARD_YOFFSET = l.YOFFSET
            s.reserves.append(stack)
            x += l.XS

        x, y = l.XM + (reserves+0.5+(rows-decks*4)/2.0)*l.XS, l.YM
        for i in range(4):
            s.foundations.append(RK_FoundationStack(x, y, self, suit=ANY_SUIT))
            x += l.XS

        x, y = l.XM+(reserves+0.5)*l.XS, l.YM+l.YS
        for i in range(rows):
            s.rows.append(BasicRowStack(x, y, self, base_rank=NO_RANK))
            x += l.XS

        l.defaultStackGroups()
Example #3
0
    def createGame(self):

        # create layout
        l, s = Layout(self), self.s

        # set window
        self.setSize(l.XM+10.5*l.XS, l.YM+2*l.YS+20*l.YOFFSET)

        # create stacks
        x, y = l.XM, l.YM+l.YS//2
        for i in (0, 1):
            stack = ReserveStack(x, y, self, max_cards=4)
            s.reserves.append(stack)
            stack.CARD_YOFFSET = l.YOFFSET
            l.createText(stack, 'n')
            x += l.XS

        x, y = l.XM+2.5*l.XS, l.YM
        for i in range(8):
            s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2))
            x += l.XS

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

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

        # define stack-groups
        l.defaultStackGroups()
Example #4
0
    def createGame(self):

        # create layout
        l, s = Layout(self), self.s

        # set window
        self.setSize(l.XM+8*l.XS, l.YM+5*l.YS)

        # create stacks
        x, y = l.XM, l.YM
        for i in range(8):
            s.foundations.append(SS_FoundationStack(x, y, self,
                                                    suit=i//2, max_cards=10))
            x += l.XS

        y = l.YM+l.YS
        for i in range(3):
            x = l.XM
            for j in range(8):
                # stack = SS_RowStack(x, y, self, max_move=1)
                stack = ReserveStack(x, y, self)
                stack.CARD_YOFFSET = 0
                s.rows.append(stack)
                x += l.XS
            y += l.YS

        x, y = self.width-l.XS, self.height-l.YS
        s.talon = DealRowTalonStack(x, y, self)
        l.createText(s.talon, 'sw')

        # define stack-groups
        l.defaultStackGroups()
Example #5
0
    def createGame(self, rows=5, playcards=16):
        l, s = Layout(self), self.s

        decks = self.gameinfo.decks
        max_rows = max(2+decks*4, 2+rows)
        w, h = l.XM+max_rows*l.XS, l.YM+l.YS+playcards*l.YOFFSET
        self.setSize(w, h)

        x, y = l.XM, l.YM
        s.talon = DealRowTalonStack(x, y, self)
        l.createText(s.talon, 'ne')

        x += (max_rows-decks*4)*l.XS
        for i in range(decks*4):
            s.foundations.append(Spider_SS_Foundation(x, y, self))
            x += l.XS

        x, y = l.XM, l.YM+l.YS
        stack = ReserveStack(x, y, self, max_cards=UNLIMITED_CARDS)
        stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, l.YOFFSET
        s.reserves.append(stack)
        l.createText(stack, 'ne')

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

        l.defaultStackGroups()
Example #6
0
 def prepareView(self):
     ReserveStack.prepareView(self)
     if not self.is_visible or self.game.preview > 1:
         return
     images = self.game.app.images
     x, y = self.x + images.CARDW//2, self.y + images.CARDH//2
     self.texts.misc = MfxCanvasText(
         self.game.canvas, x, y,
         anchor="center",
         font=self.game.app.getFont("canvas_default"))
Example #7
0
    def createGame(self):

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

        y = l.YM
        for i in range(5):
            x = l.XM+(8-i)*l.XS//2
            for j in range(i+1):
                s.rows.append(ReserveStack(x, y, self))
                x += l.XS
            y += l.YS

        suit = 0
        for xx, yy in ((1.5, 1.5),
                       (1,   2.5),
                       (6.5, 1.5),
                       (7,   2.5)):
            x, y = l.XM+xx*l.XS, l.YM+yy*l.YS
            s.foundations.append(SS_FoundationStack(x, y, self, suit))
            suit += 1

        x, y = l.XM, l.YM
        s.talon = WasteTalonStack(x, y, self, max_rounds=1)
        l.createText(s.talon, 's')
        x += l.XS
        s.waste = WasteStack(x, y, self)
        l.createText(s.waste, 's')

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

        # set window
        self.setSize(l.XM + 9 * l.XS, l.YM + 4 * l.YS)

        # create stacks
        for i in range(4):
            for j in range(5):
                x, y = l.XM + (j + 3) * l.XS, l.YM + i * l.YS
                s.rows.append(ReserveStack(x, y, self))
        for i in range(4):
            dx, dy = ((2, 1), (8, 1), (2, 2), (8, 2))[i]
            x, y = l.XM + dx * l.XS, l.YM + dy * l.YS
            s.foundations.append(self.Foundation_Class(x, y, self, i))
        x, y = l.XM, l.YM
        s.talon = WasteTalonStack(x, y, self, max_rounds=1)
        l.createText(s.talon, "se")
        y = y + l.YS
        s.waste = WasteStack(x, y, self)
        l.createText(s.waste, "se")

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

        # set window
        self.setSize(l.XM + 10*l.XS, l.YM + 5*l.YS)

        # create stacks
        for i in range(3):
            for j in range(10):
                x, y, = l.XM + j*l.XS, l.YM + (i+1)*l.YS
                s.rows.append(
                    SiebenBisAs_RowStack(
                        x, y, self, max_accept=1, max_cards=1))
        for i in range(2):
            x, y, = l.XM + (i+4)*l.XS, l.YM
            s.reserves.append(ReserveStack(x, y, self, max_accept=0))
        for i in range(4):
            x, y, = l.XM + (i+3)*l.XS, l.YM + 4*l.YS
            s.foundations.append(
                SiebenBisAs_Foundation(
                    x, y, self, i, base_rank=6, mod=13,
                    max_move=0, max_cards=8))
        s.talon = InitialDealTalonStack(l.XM, self.height-l.YS, self)

        # define stack-groups
        l.defaultStackGroups()
Example #10
0
    def createGame(self, rows=8, reserves=4, playcards=6):
        l, s = Layout(self), self.s
        self.setSize(l.XM + rows * l.XS,
                     l.YM + 3 * l.YS + playcards * l.YOFFSET)

        dx = (self.width - l.XM - (reserves + 1) * l.XS) // 3
        x, y = l.XM + dx, l.YM
        for i in range(reserves):
            s.reserves.append(ReserveStack(x, y, self))
            x += l.XS
        x += dx
        max_cards = 52 * self.gameinfo.decks
        s.foundations.append(
            RK_FoundationStack(x,
                               y,
                               self,
                               base_rank=ANY_RANK,
                               mod=13,
                               max_cards=max_cards))
        l.createText(s.foundations[0], 'ne')
        x, y = l.XM, l.YM + l.YS
        for i in range(rows):
            s.rows.append(BasicRowStack(x, y, self))
            x += l.XS
        s.talon = InitialDealTalonStack(l.XM, self.height - l.YS, self)

        l.defaultAll()
Example #11
0
    def createGame(self, rows=8, reserves=8):
        # create layout
        l, s = Layout(self), self.s

        # set window
        # (piles up to 16 cards are playable without
        # overlap in default window size)
        h = max(2 * l.YS, l.YS + (16 - 1) * l.YOFFSET)
        maxrows = max(rows, reserves)
        self.setSize(l.XM + maxrows * l.XS, l.YM + l.YS + h + l.YS)

        # create stacks
        x, y = l.XM + (maxrows - 4) * l.XS / 2, l.YM
        for i in range(4):
            s.foundations.append(SS_FoundationStack(x, y, self, i))
            x = x + l.XS
        x, y = l.XM + (maxrows - rows) * l.XS / 2, y + l.YS
        for i in range(rows):
            s.rows.append(self.RowStack_Class(x, y, self))
            x = x + l.XS
        x, y = l.XM + (maxrows - reserves) * l.XS / 2, self.height - l.YS
        for i in range(reserves):
            s.reserves.append(ReserveStack(x, y, self))
            x = x + l.XS
        self.setRegion(s.reserves, (-999, y - l.CH / 2, 999999, 999999))
        s.talon = InitialDealTalonStack(l.XM, l.YM, self)

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

        # set window
        # (piles up to 20 cards are playable in default window size)
        h = max(3 * l.YS, 20 * l.YOFFSET)
        self.setSize(l.XM + 10 * l.XS, l.YM + l.YS + h)

        # create stacks
        x, y = l.XM, l.YM
        for i in range(4):
            s.reserves.append(ReserveStack(x + (i + 3) * l.XS, y, self))
        for suit in range(4):
            i = (9, 0, 1, 8)[suit]
            s.foundations.append(
                SS_FoundationStack(x + i * l.XS, y, self, suit))
        x, y = l.XM, l.YM + l.YS
        for i in range(10):
            s.rows.append(self.RowStack_Class(x, y, self))
            x = x + l.XS
        self.setRegion(s.rows, (-999, y - l.CH / 2, 999999, 999999))
        s.talon = InitialDealTalonStack(l.XM, self.height - l.YS, self)

        # define stack-groups
        self.sg.openstacks = s.foundations + s.rows + s.reserves
        self.sg.talonstacks = [s.talon]
        self.sg.dropstacks = s.rows + s.reserves
        self.sg.reservestacks = s.reserves
Example #13
0
    def createGame(self):

        # create layout
        l, s = Layout(self), self.s

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

        # create stacks
        s.talon = self.Talon_Class(l.XM, h - l.YS, self)
        x, y = 3 * l.XM + 6 * l.XS, l.YM
        for i in range(4):
            s.foundations.append(
                self.Foundation_Class(x, y, self, suit=i, mod=13,
                                      max_cards=26))
            x += l.XS
        x, y = 2 * l.XM, l.YM + l.YS + l.YM
        for i in range(10):
            s.rows.append(self.RowStack_Class(x, y, self))
            x += l.XS
        x, y = l.XM, l.YM
        for i in range(6):
            s.reserves.append(ReserveStack(x, y, self))
            x += l.XS
        # default
        l.defaultAll()
Example #14
0
    def createGame(self, rows=13, reserves=10, playcards=20):

        # create layout
        l, s = Layout(self), self.s

        # set window
        decks = self.gameinfo.decks
        max_rows = max(decks * 4, rows, reserves)
        w, h = l.XM + max_rows * l.XS, l.YM + 3 * l.YS + playcards * l.YOFFSET
        self.setSize(w, h)

        # create stacks
        s.talon = self.Talon_Class(l.XM, h - l.YS, self)

        x, y = l.XM + (max_rows - decks * 4) * l.XS // 2, l.YM
        for j in range(4):
            for i in range(decks):
                s.foundations.append(self.Foundation_Class(x, y, self, suit=j))
                x += l.XS
        x, y = l.XM + (max_rows - reserves) * l.XS // 2, l.YM + l.YS
        for i in range(reserves):
            s.reserves.append(ReserveStack(x, y, self))
            x += l.XS
        x, y = l.XM + (max_rows - rows) * l.XS // 2, l.YM + 2 * l.YS
        for i in range(rows):
            s.rows.append(self.RowStack_Class(x, y, self))
            x += l.XS

        # default
        l.defaultAll()
Example #15
0
    def createGame(self, rows=8, reserves=4, playcards=15):

        decks = self.gameinfo.decks

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

        x, y = l.XM, l.YM
        for i in range(reserves):
            s.reserves.append(ReserveStack(x, y, self))
            x += l.XS

        x = self.width - 2*l.XS
        s.foundations.append(FourByFour_Foundation(x, y, self,
                             suit=ANY_SUIT, base_rank=ACE, max_cards=52*decks,
                             max_accept=1, max_move=0))
        stack = s.foundations[0]
        tx, ty, ta, tf = l.getTextAttr(stack, 'ne')
        font = self.app.getFont('canvas_default')
        stack.texts.misc = MfxCanvasText(self.canvas, tx, ty,
                                         anchor=ta, font=font)

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

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

        l.defaultStackGroups()
Example #16
0
 def createGame(self):
     # create layout
     l, s = Layout(self), self.s
     self.setSize(l.XM + 8 * l.XS, l.YM + 2 * l.YS + 12 * l.YOFFSET)
     # create stacks
     x, y = l.XM, self.height - l.YS
     s.talon = InitialDealTalonStack(x, y, self)
     x, y = l.XM + l.XS, l.YM
     for i in range(2):
         s.reserves.append(ReserveStack(x, y, self))
         x += l.XS
     x += 2 * l.XS
     for i in range(2):
         s.foundations.append(
             AC_FoundationStack(x,
                                y,
                                self,
                                suit=ANY_SUIT,
                                max_cards=26,
                                mod=13,
                                max_move=0))
         x += l.XS
     x, y = l.XM, l.YM + l.YS
     for i in range(8):
         s.rows.append(AC_RowStack(x, y, self))
         x += l.XS
     # default
     l.defaultAll()
Example #17
0
    def createGame(self):
        l, s = Layout(self), self.s
        self.setSize(l.XM + 11 * l.XS,
                     2 * l.YM + max(2 * l.YS + 12 * l.YOFFSET, 5 * l.YS))

        x, y, = l.XM + 1.5 * l.XS, l.YM
        for i in range(8):
            s.foundations.append(SS_FoundationStack(x, y, self, suit=i % 4))
            x += l.XS
        x, y = l.XM + 1.5 * l.XS, 2 * l.YM + l.YS
        for i in range(8):
            s.reserves.append(
                BasicRowStack(x, y, self, max_move=1, max_accept=0))
            x += l.XS
        x, y = l.XM, 2 * l.YM + l.YS
        for i in range(4):
            stack = Saxony_Reserve(x, y, self, max_move=1)
            self.s.rows.append(stack)
            stack.CARD_YOFFSET = 0
            y += l.YS
        x, y = self.width - l.XS, 2 * l.YM + l.YS
        for i in range(4):
            self.s.reserves.append(ReserveStack(x, y, self))
            y += l.YS
        s.talon = Saxony_Talon(l.XM, l.YM, self)
        l.createText(s.talon, "ne")

        l.defaultStackGroups()
Example #18
0
    def createGame(self, rows=10):
        l, s = Layout(self), self.s
        # set size so that at least 2/3 of a card is visible with 15 cards
        h = l.CH * 2 / 3 + (15 - 1) * l.YOFFSET
        h = l.YS + max(h, 3 * l.YS)
        self.setSize(l.XM + rows * l.XS, l.YM + h)

        x, y = l.XM + (rows - 8) * l.XS, l.YM
        for i in range(4):
            s.foundations.append(Braid_Foundation(x, y, self, suit=i))
            x += l.XS
        tx, ty, ta, tf = l.getTextAttr(s.foundations[-1], "se")
        font = self.app.getFont("canvas_default")
        self.texts.info = MfxCanvasText(self.canvas,
                                        tx,
                                        ty,
                                        anchor=ta,
                                        font=font)
        x += 2 * l.XS
        stack = ReserveStack(x, y, self, max_cards=UNLIMITED_CARDS)
        s.reserves.append(stack)
        l.createText(stack, 'se')
        x, y = l.XM, l.YM + l.YS
        for i in range(rows):
            s.rows.append(TheLittleCorporal_RowStack(x, y, self, mod=13))
            x += l.XS

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

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

        # set window
        self.setSize(l.XM + 8 * l.XS, l.YM + 4 * l.YS)

        # create stacks
        x, y, = l.XM, l.YM
        for i in range(8):
            s.foundations.append(self.Foundation_Class(x, y, self, ANY_SUIT))
            x += l.XS
        x, y, = l.XM, y + l.YS
        for i in range(8):
            s.reserves.append(ReserveStack(x, y, self, max_accept=0))
            x += l.XS
        x, y = l.XM + 3 * l.XS, l.YM + 3 * l.YS
        s.talon = WasteTalonStack(x, y, self, max_rounds=1)
        l.createText(s.talon, "sw")
        x += l.XS
        s.waste = WasteStack(x, y, self)
        l.createText(s.waste, "se")

        # define stack-groups
        l.defaultStackGroups()
Example #20
0
    def createGame(self):
        l, s = Layout(self), self.s

        self.setSize(l.XM+12*l.XS, l.YM+max(4.5*l.YS, 2*l.YS+12*l.YOFFSET))

        x, y = l.XM, l.YM
        s.talon = WasteTalonStack(x, y, self, max_rounds=1)
        l.createText(s.talon, 's')
        x += l.XS
        s.waste = WasteStack(x, y, self)
        l.createText(s.waste, 's')
        x += 2*l.XS
        for i in range(8):
            s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2))
            x += l.XS
        x, y = l.XM, l.YM+l.YS*3//2
        for i in range(3):
            s.reserves.append(ReserveStack(x, y, self))
            y += l.YS
        x, y = l.XM+2*l.XS, l.YM+l.YS
        for i in range(10):
            s.rows.append(SS_RowStack(x, y, self, max_move=1))
            x += l.XS

        l.defaultStackGroups()
Example #21
0
    def createGame(self, **layout):
        l, s = Layout(self), self.s
        kwdefault(layout,
                  rows=self.Rows,
                  reserves=self.Reserves,
                  texts=0,
                  playcards=22)
        self.Layout_Method(l, **layout)
        self.setSize(l.size[0], l.size[1])

        # Create stacks
        s.talon = self.Talon_Class(l.s.talon.x, l.s.talon.y, self)
        for r in l.s.foundations:
            s.foundations.append(
                self.Foundation_Class(r.x,
                                      r.y,
                                      self,
                                      suit=ANY_SUIT,
                                      base_rank=r.suit))
        for r in l.s.rows:
            s.rows.append(
                self.RowStack_Class(r.x,
                                    r.y,
                                    self,
                                    base_rank=self.BaseRank,
                                    yoffset=l.YOFFSET))
        for r in l.s.reserves:
            s.reserves.append(ReserveStack(r.x, r.y, self))
        l.defaultAll()
Example #22
0
 def createGame(self, rows=6, texts=True):
     l, s = Layout(self), self.s
     max_rows = max(8, rows)
     self.setSize(l.XM + max_rows * l.XS, l.YM + 2 * l.YS + 13 * l.YOFFSET)
     x, y = l.XM + l.XS * (max_rows - 4) // 2, l.YM
     for i in range(4):
         s.reserves.append(ReserveStack(x, y, self))
         x += l.XS
     x = l.XM + (max_rows - 1) * l.XS
     s.foundations.append(
         AbstractFoundationStack(x,
                                 y,
                                 self,
                                 suit=ANY_SUIT,
                                 max_cards=52,
                                 max_accept=0))
     l.createText(s.foundations[0], 'nw')
     x, y = l.XM + l.XS * (max_rows - rows) // 2, l.YM + l.YS
     for i in range(rows):
         s.rows.append(UD_AC_RowStack(x, y, self, mod=13))
         x += l.XS
     s.talon = self.Talon_Class(l.XM, l.YM, self)
     if texts:
         l.createText(s.talon, 'ne')
     l.defaultStackGroups()
    def createGame(self, rows=8, playcards=12, texts=False):
        # create layout
        l, s = Layout(self), self.s

        # set window
        self.setSize(l.XM+max(9, rows)*l.XS, l.YM+3*l.YS+playcards*l.YOFFSET)

        # extra settings
        self.base_cards = None

        # create stacks
        for i in range(8):
            x, y, = l.XM + i*l.XS, l.YM
            s.reserves.append(ReserveStack(x, y, self, max_accept=0))
        for i in range(8):
            x, y, = l.XM + i*l.XS, l.YM + l.YS
            s.foundations.append(
                Interregnum_Foundation(x, y, self, mod=13, max_move=0))
        for i in range(rows):
            x, y, = l.XM + (2*i+8-rows)*l.XS//2, l.YM + 2*l.YS
            s.rows.append(self.RowStack_Class(x, y, self))
        s.talon = self.Talon_Class(self.width-l.XS, self.height-l.YS, self)
        if texts:
            l.createRoundText(s.talon, 'nn')
        else:
            l.createText(s.talon, "n")

        # define stack-groups
        l.defaultStackGroups()
Example #24
0
    def createGame(self, max_rounds=2):

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

        y = l.YM
        for i in range(2):
            x = l.XM
            for j in range(4):
                s.foundations.append(SS_FoundationStack(x, y, self,
                                     suit=j, base_rank=6, max_cards=7))
                x += l.XS
            y += l.YS
        for i in range(2):
            x = l.XM
            for j in range(4):
                s.foundations.append(SS_FoundationStack(x, y, self, suit=j,
                                     base_rank=5, dir=-1, max_cards=6))
                x += l.XS
            y += l.YS
        y = l.YM
        for i in range(3):
            x = l.XM+5*l.XS
            for j in range(3):
                s.rows.append(ReserveStack(x, y, self))
                x += l.XS
            y += l.YS
        x, y = l.XM+5*l.XS, l.YM+3*l.YS
        s.talon = WasteTalonStack(x, y, self, max_rounds=1)
        l.createText(s.talon, 'sw')
        x += l.XS
        s.waste = WasteStack(x, y, self)
        l.createText(s.waste, 'se')

        l.defaultStackGroups()
Example #25
0
 def canMoveCards(self, cards):
     if not ReserveStack.canMoveCards(self, cards):
         return False
     if not self.game.s.waste.cards:
         return False
     c = self.game.s.waste.cards[-1]
     return c.face_up and cards[0].suit == c.suit and \
         cards[0].rank == c.rank
Example #26
0
 def clickHandler(self, event):
     if (not self.cards
             and self.game.s.talon.cards and self.game.isValidPlay(
                 self.id,
                 self.game.s.talon.getCard().rank + 1)):
         self.game.s.talon.playMoveMove(1, self)
         return 1
     return ReserveStack.clickHandler(self, event)
Example #27
0
 def acceptsCards(self, from_stack, cards):
     if not ReserveStack.acceptsCards(self, from_stack, cards):
         return False
     if from_stack not in self.game.s.rows:
         return False
     if self.game.draw_done or not from_stack._canDrawCard():
         return False
     return True
Example #28
0
 def acceptsCards(self, from_stack, cards):
     if not ReserveStack.acceptsCards(self, from_stack, cards):
         return False
     if from_stack not in self.game.s.rows:
         return False
     if self.game.draw_done or not from_stack._canDrawCard():
         return False
     return True
Example #29
0
 def acceptsCards(self, from_stack, cards):
     if not ReserveStack.acceptsCards(self, from_stack, cards):
         return False
     # must be neighbours
     if not self.game.isNeighbour(from_stack, self):
         return False
     # must be able to move our card to the foundations or reserves
     return self._getDropStack() is not None
Example #30
0
    def createGame(self, reserves=6):
        # create layout
        l, s = Layout(self), self.s

        # set window
        w, h = 3*l.XM+5*l.XS, l.YM+4*l.YS+l.TEXT_HEIGHT+l.TEXT_MARGIN
        self.setSize(w, h)

        # create stacks
        lay = ((0, 0, 0, 1, 13),
               (2, 0, 0, 1, 13),
               (0, 1, 1, 1, 13),
               (2, 1, 1, 1, 13),
               (1, 1, 2, 0, 1),
               (1, 2, 2, 1, 13),
               (0, 2, 3, 1, 13),
               (2, 2, 3, 1, 13),
               (1, 0, 2, 1, 12),
               )
        for i, j, suit, max_accept, max_cards in lay:
            x, y = 2*l.XM+l.XS+i*l.XS, l.YM+j*l.YS
            stack = SS_FoundationStack(
                x, y, self, suit=suit,
                max_move=0, max_accept=max_accept, max_cards=max_cards, mod=13)
            s.foundations.append(stack)

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

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

        x, y = 2*l.XM+1.5*l.XS, l.YM+3*l.YS
        s.talon = WasteTalonStack(x, y, self, max_rounds=3)
        l.createText(s.talon, "s")
        l.createRoundText(self.s.talon, 'sss')
        x += l.XS
        s.waste = WasteStack(x, y, self)
        l.createText(s.waste, "s")

        # define stack-groups
        l.defaultStackGroups()
Example #31
0
 def acceptsCards(self, from_stack, cards):
     if not ReserveStack.acceptsCards(self, from_stack, cards):
         return False
     # must be neighbours
     if not self.game.isNeighbour(from_stack, self):
         return False
     # must be able to move our card to the foundations or reserves
     return self._getDropStack() is not None
Example #32
0
 def canMoveCards(self, cards):
     if not ReserveStack.canMoveCards(self, cards):
         return False
     if not self.game.s.waste.cards:
         return False
     c = self.game.s.waste.cards[-1]
     return c.face_up and cards[0].suit == c.suit and \
         cards[0].rank == c.rank
Example #33
0
    def createGame(self):
        l, s = Layout(self), self.s
        self.setSize(l.XM+9*l.XS, l.YM+6*l.YS)

        # vertical rows
        x = l.XM+l.XS
        for i in (0, 1):
            y = l.YM+l.YS
            for j in range(4):
                stack = ReserveStack(x, y, self, base_suit=i)
                stack.getBottomImage = stack._getSuitBottomImage
                s.rows.append(stack)
                y += l.YS
            x += 6*l.XS
        # horizontal rows
        y = l.YM+l.YS
        for i in (2, 3):
            x = l.XM+2.5*l.XS
            for j in range(4):
                stack = ReserveStack(x, y, self, base_suit=i)
                stack.getBottomImage = stack._getSuitBottomImage
                s.rows.append(stack)
                x += l.XS
            y += 3*l.YS
        # foundations
        decks = self.gameinfo.decks
        for k in range(decks):
            suit = 0
            for i, j in ((0, 3-decks*0.5+k),
                         (8, 3-decks*0.5+k),
                         (4.5-decks*0.5+k, 0),
                         (4.5-decks*0.5+k, 5)):
                x, y = l.XM+i*l.XS, l.YM+j*l.YS
                s.foundations.append(SS_FoundationStack(x, y, self,
                                     suit=suit, max_move=0))
                suit += 1
        # talon & waste
        x, y = l.XM+3.5*l.XS, l.YM+2.5*l.YS
        s.talon = WasteTalonStack(x, y, self, max_rounds=2)
        l.createText(s.talon, 's')
        l.createRoundText(self.s.talon, 'nn')
        x += l.XS
        s.waste = WasteStack(x, y, self)
        l.createText(s.waste, 's')

        l.defaultStackGroups()
Example #34
0
 def canMoveCards(self, cards):
     if not ReserveStack.canMoveCards(self, cards):
         return False
     rows = self.game.s.rows
     index = list(self.game.s.reserves).index(self)
     if rows[2*index].cards or rows[2*index+1].cards:
         return False
     return True
Example #35
0
 def canMoveCards(self, cards):
     if not ReserveStack.canMoveCards(self, cards):
         return False
     rows = self.game.s.rows
     index = list(self.game.s.reserves).index(self)
     if rows[2 * index].cards or rows[2 * index + 1].cards:
         return False
     return True
Example #36
0
 def clickHandler(self, event):
     game = self.game
     for row in game.s.rows:
         if len(row.cards) < 1:
             return ReserveStack.clickHandler(self, event)
     self.game.emptyStack = self.id
     self.game.playSample("drop", priority=200)
     self.playMoveMove(1, self.game.s.foundations[0])
     return True
Example #37
0
 def acceptsCards(self, from_stack, cards):
     if not ReserveStack.acceptsCards(self, from_stack, cards):
         return False
     c = cards[0]
     if c.rank not in self.ACCEPTED_CARDS:
         return False
     for s in self.game.s.reserves:
         if s.cards and s.cards[0].rank == c.rank:
             return False
     return True
Example #38
0
 def acceptsCards(self, from_stack, cards):
     if not ReserveStack.acceptsCards(self, from_stack, cards):
         return False
     c = cards[0]
     if c.rank not in self.ACCEPTED_CARDS:
         return False
     for s in self.game.s.reserves:
         if s.cards and s.cards[0].rank == c.rank:
             return False
     return True
Example #39
0
    def createGame(self):
        l, s = Layout(self), self.s

        # Set window size
        h = max(3 * l.YS, 20 * l.YOFFSET)
        self.setSize(l.XM + 12 * l.XS, l.YM + l.YS + h)

        # Create foundations
        x = l.XM + l.XS * 3.5
        y = l.YM
        s.foundations.append(SS_FoundationStack(x, y, self, 0, max_cards=14))
        x = x + l.XS
        s.foundations.append(SS_FoundationStack(x, y, self, 1, max_cards=14))
        x = x + l.XS
        s.foundations.append(SS_FoundationStack(x, y, self, 4, max_cards=22))
        x = x + l.XS
        s.foundations.append(SS_FoundationStack(x, y, self, 2, max_cards=14))
        x = x + l.XS
        s.foundations.append(SS_FoundationStack(x, y, self, 3, max_cards=14))

        # Create reserves
        x = l.XM
        for i in range(3):
            s.reserves.append(ReserveStack(x, y, self))
            x = x + l.XS
        x = x + l.XS * 6
        for i in range(3):
            s.reserves.append(ReserveStack(x, y, self))
            x = x + l.XS

        # Create rows
        x = l.XM
        y = l.YM + l.YS * 1.1
        for i in range(12):
            s.rows.append(Skiz_RowStack(x, y, self))
            x = x + l.XS
        self.setRegion(s.rows, (-999, int(y), 999999, 999999))

        # Create talon
        s.talon = InitialDealTalonStack(l.XM, self.height-l.YS, self)

        # Define stack groups
        l.defaultStackGroups()
Example #40
0
    def createGame(self, playcards=13, reserves=0, texts=False):
        # create layout
        l, s = Layout(self), self.s

        # set window
        # (set size so that at least 13 cards are fully playable)
        w = max(3 * l.XS, l.XS + (playcards - 1) * l.XOFFSET)
        x0 = l.XM
        x1 = x0 + w + 2 * l.XM
        x2 = x1 + l.XS + 2 * l.XM
        x3 = x2 + w + l.XM
        h = l.YM + (4 + int(reserves != 0)) * l.YS + int(texts) * l.TEXT_HEIGHT
        self.setSize(x3, h)

        # create stacks
        y = l.YM
        if reserves:
            x = x1 - int(l.XS * (reserves - 1) / 2)
            for i in range(reserves):
                s.reserves.append(ReserveStack(x, y, self))
                x += l.XS
            y += l.YS
        x = x1
        for i in range(4):
            s.foundations.append(
                self.Foundation_Class(x, y, self, suit=i, max_move=0))
            y += l.YS
        if texts:
            tx, ty, ta, tf = l.getTextAttr(None, "ss")
            tx, ty = x + tx, y - l.YS + ty
            font = self.app.getFont("canvas_default")
            self.texts.info = MfxCanvasText(self.canvas,
                                            tx,
                                            ty,
                                            anchor=ta,
                                            font=font)
        for x in (x0, x2):
            y = l.YM + l.YS * int(reserves != 0)
            for i in range(4):
                stack = self.RowStack_Class(x, y, self)
                stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0
                s.rows.append(stack)
                y += l.YS
        x, y = self.width - l.XS, self.height - l.YS
        s.talon = InitialDealTalonStack(x, y, self)
        if reserves:
            l.setRegion(
                s.rows[:4],
                (-999, l.YM + l.YS - l.CH // 2, x1 - l.CW // 2, 999999))
        else:
            l.setRegion(s.rows[:4], (-999, -999, x1 - l.CW // 2, 999999))

        # default
        l.defaultAll()
Example #41
0
    def createGame(self):

        # create layout
        l, s = Layout(self), self.s

        # set window
        self.setSize(l.XM + 10 * l.XS,
                     max(l.YM + l.YS + 20 * l.YOFFSET, 2 * l.YM + 5 * l.YS))

        # create stacks
        x, y, = l.XM + 2 * l.XS, l.YM
        for i in range(4):
            s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
            x = x + l.XS
        for i in range(4):
            s.foundations.append(
                SS_FoundationStack(x, y, self, suit=i, base_rank=KING, dir=-1))
            x = x + l.XS
        x, y = l.XM + 2 * l.XS, 2 * l.YM + l.YS
        for i in range(6):
            stack = BasicRowStack(x, y, self, max_move=1, max_accept=0)
            s.rows.append(stack)
            if not self.ROW_YOFFSET:
                stack.CARD_YOFFSET = 0
            x = x + l.XS

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

        s.talon = Tournament_Talon(l.XM, l.YM, self, max_rounds=3)
        l.createText(s.talon, "se")
        l.createRoundText(s.talon, 'ne')

        # define stack-groups
        l.defaultStackGroups()
Example #42
0
    def createGame(self):
        l, s = Layout(self), self.s

        # Set window size
        self.setSize(l.XM + l.XS * self.WIDTH, l.YM * 3 + l.YS * self.HEIGHT)

        # Create foundations
        x = self.width // 2 + l.XM // 2 - l.XS * 3
        y = l.YM
        for j in range(2):
            for i in range(6):
                s.foundations.append(
                    Hanafuda_SS_FoundationStack(
                        x, y, self, i + (j * 6),
                        max_cards=4, max_accept=1, base_rank=3))
                x = x + l.XS
            x = self.width // 2 + l.XM // 2 - l.XS * 3
            y = y + l.YS

        # Create flower beds
        x = l.XM
        y = l.YM * 2 + l.YS * 2
        for j in range(self.YROWS):
            for i in range(self.XROWS):
                row = self.RowStack_Class(
                    x, y, self, yoffset=0, max_accept=self.MAX_MOVE,
                    max_move=self.MAX_MOVE, max_cards=self.MAX_CARDS,
                    base_rank=0)
                row.CARD_XOFFSET = l.CW // 2
                s.rows.append(row)
                x = x + self.width // self.XROWS
            x = l.XM
            y = y + l.YS
        self.setRegion(s.rows, (l.XM, l.YS * 2, 999999, y))

        # Create pool
        x = self.width // 2 + l.XM // 2 - (l.XS * self.XRESERVES) // 2
        for j in range(self.YRESERVES):
            for i in range(self.XRESERVES):
                s.reserves.append(
                    ReserveStack(x, y, self, max_accept=self.MAX_RESERVE))
                x = x + l.XS
            x = self.width // 2 + l.XM // 2 - l.XS * (self.XRESERVES // 2)
            y = y + l.YS
        if s.reserves:
            self.setRegion(
                s.reserves, (l.XM, l.YS * (2 + self.YROWS), 999999, 999999))

        # Create talon
        s.talon = InitialDealTalonStack(l.XM, l.YM, self)

        # Define stack-groups
        l.defaultStackGroups()
Example #43
0
    def createGame(self, rows=8, reserves=6, playcards=12):
        # create layout
        l, s = Layout(self), self.s

        # set window
        decks = self.gameinfo.decks
        foundations = decks*4
        max_rows = max(foundations, rows)
        w, h = l.XM+(max_rows+1)*l.XS, l.YM+3*l.YS+playcards*l.YOFFSET
        self.setSize(w, h)

        # create stacks
        x, y = l.XM+l.XS+(max_rows-foundations)*l.XS//2, l.YM
        for fclass in self.Foundation_Classes:
            for i in range(4):
                s.foundations.append(fclass(x, y, self, suit=i))
                x += l.XS

        x, y = l.XM+l.XS+(max_rows-rows)*l.XS//2, l.YM+l.YS
        for i in range(rows):
            s.rows.append(self.RowStack_Class(x, y, self,
                                              max_move=1, max_accept=1))
            x += l.XS
        self.setRegion(s.rows, (-999, y-l.CH//2, 999999, h-l.YS-l.CH//2))

        d = (w-reserves*l.XS)//reserves
        x, y = l.XM, h-l.YS
        for i in range(reserves):
            stack = ReserveStack(x, y, self)
            stack.CARD_XOFFSET, stack.CARD_YOFFSET = 2, 0
            s.reserves.append(stack)
            x += l.XS+d

        s.talon = self.Talon_Class(l.XM, l.YM, self)
        l.createText(s.talon, "s")

        # define stack-groups
        l.defaultStackGroups()
Example #44
0
 def acceptsCards(self, from_stack, cards):
     if not ReserveStack.acceptsCards(self, from_stack, cards):
         return False
     r_ranks = []
     for r in self.game.s.reserves:
         if r.cards:
             r_ranks.append(r.cards[0].rank)
     if not r_ranks:
         return True
     r_ranks.append(cards[0].rank)
     r_ranks.sort()
     if len(r_ranks) == 2:
         return r_ranks[1]-r_ranks[0] in (1, 12)
     for i in range(3):
         j, k = (i+1) % 3, (i+2) % 3
         if ((r_ranks[i]+1) % 13 == r_ranks[j] and
                 (r_ranks[j]+1) % 13 == r_ranks[k]):
             return True
     return False
Example #45
0
 def canMoveCards(self, cards):
     if self.game.s.rows[8].cards and self.game.s.rows[9].cards:
         return False
     return ReserveStack.canMoveCards(self, cards)
Example #46
0
 def acceptsCards(self, from_stack, cards):
     if not ReserveStack.acceptsCards(self, from_stack, cards):
         return False
     return len(self.cards) == 0
Example #47
0
 def canMoveCards(self, cards):
     if self.game.s.rows[self.id-2].cards:
         return False
     return ReserveStack.canMoveCards(self, cards)
Example #48
0
 def acceptsCards(self, from_stack, cards):
     if (from_stack is self.game.s.braidstrong or
             from_stack is self.game.s.braidweak or
             from_stack in self.game.s.rows):
         return 0
     return ReserveStack.acceptsCards(self, from_stack, cards)
Example #49
0
 def acceptsCards(self, from_stack, cards):
     return (ReserveStack.acceptsCards(self, from_stack, cards) and
             self.game.s.talon.cards)
Example #50
0
 def copyModel(self, clone):
     ReserveStack.copyModel(self, clone)
     clone.pos = self.pos
Example #51
0
 def acceptsCards(self, from_stack, cards):
     if not ReserveStack.acceptsCards(self, from_stack, cards):
         return 0
     return self._getMiddleStack(from_stack) is not None
Example #52
0
 def moveMove(self, ncards, to_stack, frames=-1, shadow=-1):
     if to_stack is not self.game.s.foundations[0]:
         self._dropPairMove(ncards, to_stack, frames=-1, shadow=shadow)
     else:
         ReserveStack.moveMove(
             self, ncards, to_stack, frames=frames, shadow=shadow)
Example #53
0
 def acceptsCards(self, from_stack, cards):
     if not ReserveStack.acceptsCards(self, from_stack, cards):
         return False
     # must be neighbours
     return self.game.isNeighbour(from_stack, self)
Example #54
0
 def acceptsCards(self, from_stack, cards):
     if not ReserveStack.acceptsCards(self, from_stack, cards):
         return 0
     # Only take Wizards
     return cards[0].suit == 4
Example #55
0
 def acceptsCards(self, from_stack, cards):
     if not ReserveStack.acceptsCards(self, from_stack, cards):
         return False
     # this stack accepts one card from the Waste pile
     return from_stack is self.game.s.waste
Example #56
0
 def acceptsCards(self, from_stack, cards):
     #         if from_stack.id >= 8:
     #             # from_stack must be a Napoleon_RowStack
     #             return False
     return ReserveStack.acceptsCards(self, from_stack, cards)
Example #57
0
 def clickHandler(self, event):
     if not self.cards:
         self.game.s.talon.playMoveMove(1, self)
         return 1
     return ReserveStack.clickHandler(self, event)
Example #58
0
 def acceptsCards(self, from_stack, cards):
     if not ReserveStack.acceptsCards(self, from_stack, cards):
         return False
     if from_stack in self.game.s.rows:
         return False
     return True
Example #59
0
 def acceptsCards(self, from_stack, cards):
     if not ReserveStack.acceptsCards(self, from_stack, cards):
         return False
     return from_stack is self.game.s.talon
Example #60
0
 def acceptsCards(self, from_stack, cards):
     if from_stack is self.game.s.braid or from_stack in self.game.s.rows:
         return False
     return ReserveStack.acceptsCards(self, from_stack, cards)