Ejemplo n.º 1
0
    def createGame(self):
        l, s = Layout(self), self.s
        self.setSize(l.XM+8*l.XS, l.YM+4*l.YS)

        x0, y0 = l.XM+2*l.XS, l.YM
        rank = 0
        font = self.app.getFont("canvas_default")

        for xx, yy in ((3.5, 0.15),
                       (4.5, 0.5),
                       (5,   1.5),
                       (4.5, 2.5),
                       (3.5, 2.85),
                       (2.5, 3),
                       (1.5, 2.85),
                       (0.5, 2.5),
                       (0,   1.5),
                       (0.5, 0.5),
                       (1.5, 0.15),
                       (2.5, 0),
                       (2.5, 1.5),
                       ):
            x = int(x0 + xx*l.XS)
            y = int(y0 + yy*l.YS)
            stack = AC_FoundationStack(
                    x, y, self, suit=ANY_SUIT,
                    dir=0, max_cards=4, base_rank=rank, max_move=0)
            stack.getBottomImage = stack._getReserveBottomImage
            s.foundations.append(stack)
            if self.preview <= 1:
                label = RANKS[rank][0]
                if label == "1":
                    label = "10"
                stack.texts.misc = MfxCanvasText(self.canvas,
                                                 x + l.CW // 2,
                                                 y + l.CH // 2,
                                                 anchor="center",
                                                 font=font)
                stack.texts.misc.config(text=label)
            rank += 1

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

        l.defaultStackGroups()
Ejemplo n.º 2
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()
Ejemplo n.º 3
0
 def acceptsCards(self, from_stack, cards):
     if not AC_FoundationStack.acceptsCards(self, from_stack, cards):
         return False
     if from_stack is self.game.s.waste or \
             from_stack in self.game.s.reserves:
         return False
     return True
Ejemplo n.º 4
0
 def acceptsCards(self, from_stack, cards):
     if not AC_FoundationStack.acceptsCards(self, from_stack, cards):
         return False
     if from_stack is self.game.s.waste or \
             from_stack in self.game.s.reserves:
         return False
     return True
Ejemplo n.º 5
0
 def acceptsCards(self, from_stack, cards):
     if self.game.getState() == 0:
         if len(cards) != 1 or not cards[0].face_up:
             return False
         if cards[0].suit != self.cap.base_suit:
             return False
         return from_stack in self.game.s.rows
     return AC_FoundationStack.acceptsCards(self, from_stack, cards)
Ejemplo n.º 6
0
 def acceptsCards(self, from_stack, cards):
     if self.game.getState() == 0:
         if len(cards) != 1 or not cards[0].face_up:
             return False
         if cards[0].suit != self.cap.base_suit:
             return False
         return from_stack in self.game.s.rows
     return AC_FoundationStack.acceptsCards(self, from_stack, cards)
Ejemplo n.º 7
0
    def acceptsCards(self, from_stack, cards):
        num_cards = len(self.cards)
        for i in range(13):
            check_seq = self.game.s.rows[i].cards
            if len(check_seq) > num_cards:
                if check_seq[num_cards].suit != cards[0].suit:
                    return False

        return AC_FoundationStack.acceptsCards(self, from_stack, cards)
Ejemplo n.º 8
0
    def createGame(self):
        l, s = Layout(self), self.s
        self.setSize(l.XM + 8 * l.XS, l.YM + 4 * l.YS)

        x0, y0 = l.XM + 2 * l.XS, l.YM
        rank = 0
        for xx, yy in (
            (3.5, 0.15),
            (4.5, 0.5),
            (5, 1.5),
            (4.5, 2.5),
            (3.5, 2.85),
            (2.5, 3),
            (1.5, 2.85),
            (0.5, 2.5),
            (0, 1.5),
            (0.5, 0.5),
            (1.5, 0.15),
            (2.5, 0),
            (2.5, 1.5),
        ):
            x = int(x0 + xx * l.XS)
            y = int(y0 + yy * l.YS)
            s.foundations.append(
                AC_FoundationStack(x,
                                   y,
                                   self,
                                   suit=ANY_SUIT,
                                   dir=0,
                                   max_cards=4,
                                   base_rank=rank,
                                   max_move=0))
            rank += 1

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

        l.defaultStackGroups()
Ejemplo n.º 9
0
    def createGame(self):

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

        x0 = l.XM + 1.5 * l.XS
        for k in (0, 1):
            suit = 0
            for i, j in ((1, 0), (0, 0.5), (2, 0.5), (1, 1)):
                x, y = x0 + i * l.XS, l.YM + j * l.YS
                s.foundations.append(AC_FoundationStack(x, y, self, suit=suit))
                suit += 1
            x0 += 3.5 * l.XS

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

        x, y = l.XM + 3.75 * l.XS, l.YM + 2 * l.YS
        for i in (0, 1):
            stack = KingAC_RowStack(x, y, self, max_move=1)
            stack.getBottomImage = stack._getReserveBottomImage
            s.rows.append(stack)
            stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, 0
            x += l.XS
        x, y = l.XM + 2.75 * l.XS, l.YM + 3 * l.YS
        for i in range(4):
            stack = BasicRowStack(x, y, self)
            s.reserves.append(stack)
            stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, 0
            l.createText(stack, 's')
            x += l.XS

        l.defaultStackGroups()
Ejemplo n.º 10
0
 def getBaseCard(self):
     if self.game.getState() == 0:
         return _('Base card - %s.') % _('any card')
     return AC_FoundationStack.getBaseCard(self)
Ejemplo n.º 11
0
 def __init__(self, x, y, game, suit, **cap):
     kwdefault(cap, mod=13, min_cards=1, max_move=0)
     AC_FoundationStack.__init__(self, x, y, game, suit, **cap)
Ejemplo n.º 12
0
 def getBaseCard(self):
     if self.game.getState() == 0:
         return _('Base card - %s.') % _('any card')
     return AC_FoundationStack.getBaseCard(self)
Ejemplo n.º 13
0
 def __init__(self, x, y, game, suit, **cap):
     kwdefault(cap, mod=13, min_cards=1, max_move=0)
     AC_FoundationStack.__init__(self, x, y, game, suit, **cap)
Ejemplo n.º 14
0
 def acceptsCards(self, from_stack, cards):
     if self.cards and not self.game.inSuitSequence(self.cards[-1],
                                                    cards[0]):
         return False
     return AC_FoundationStack.acceptsCards(self, from_stack, cards)