예제 #1
0
 def __init__(self, x, y, game):
     RK_FoundationStack.__init__(self,
                                 x,
                                 y,
                                 game,
                                 base_rank=ACE,
                                 dir=0,
                                 max_move=0,
                                 max_cards=8)
     self.CARD_YOFFSET = min(30, self.game.app.images.CARD_YOFFSET + 10)
예제 #2
0
    def createGame(self):

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

        x, y = l.XM, l.YM
        s.talon = WasteTalonStack(x, y, self, max_rounds=3)
        l.createText(s.talon, 's')
        l.createRoundText(s.talon, 'ne', dx=l.XS)
        x += l.XS
        s.waste = WasteStack(x, y, self)
        l.createText(s.waste, 's')
        x0, y0 = l.XM + 2 * l.XS, l.YM
        k = 0
        for i, j in ((2, 0), (0, 1.5), (4, 1.5), (2, 3)):
            x, y = x0 + i * l.XS, y0 + j * l.YS
            s.foundations.append(
                RK_FoundationStack(
                    x,
                    y,
                    self,
                    # suit=ANY_SUIT,
                    base_rank=KING,
                    dir=-1,
                    max_move=0))
            k += 1
        k = 0
        for i, j in ((2, 1), (1, 1.5), (3, 1.5), (2, 2)):
            x, y = x0 + i * l.XS, y0 + j * l.YS
            s.foundations.append(
                RK_FoundationStack(
                    x,
                    y,
                    self,
                    # suit=ANY_SUIT,
                    base_rank=1,
                    max_move=0,
                    max_cards=12))
            k += 1
        k = 0
        for i, j in ((1, 0.2), (3, 0.2), (1, 2.8), (3, 2.8)):
            x, y = x0 + i * l.XS, y0 + j * l.YS
            s.foundations.append(
                IdleAces_AceFoundation(x,
                                       y,
                                       self,
                                       suit=k,
                                       max_cards=1,
                                       max_move=0))
            k += 1

        l.defaultStackGroups()
예제 #3
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
예제 #4
0
    def createGame(self):

        l, s = Layout(self), self.s

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

        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 += l.XS
        for i in range(8):
            s.foundations.append(
                SS_FoundationStack(x, y, self, suit=i % 4, max_cards=12))
            x += l.XS
        x, y = l.XM, l.YM + l.YS + l.TEXT_HEIGHT
        s.foundations.append(
            RK_FoundationStack(x,
                               y,
                               self,
                               suit=ANY_SUIT,
                               base_rank=KING,
                               dir=0,
                               max_cards=8))
        x += 3 * l.XS
        for i in range(6):
            s.rows.append(RK_RowStack(x, y, self, max_move=1))
            x += l.XS

        l.defaultStackGroups()
예제 #5
0
    def createGame(self):
        l, s = Layout(self), self.s
        self.setSize(l.XM+7*l.XS, l.YM+3*l.YS)

        for i, j in ((1, 0),
                     (2, 0),
                     (3, 0),
                     (4, 0),
                     (5, 1),
                     (3.5, 2),
                     (2.5, 2),
                     (1.5, 2),
                     (0, 1),
                     ):
            x, y = l.XM+(1+i)*l.XS, l.YM+j*l.YS
            stack = CircleNine_RowStack(x, y, self, max_accept=1,
                                        max_move=1, base_rank=NO_RANK)
            s.rows.append(stack)
            stack.CARD_YOFFSET = 0

        x, y = l.XM+3.5*l.XS, l.YM+l.YS
        stack = RK_FoundationStack(x, y, self, suit=ANY_SUIT, max_cards=52,
                                   max_move=0, mod=13, base_rank=ANY_RANK)
        s.foundations.append(stack)
        l.createText(stack, 'ne')
        x, y = l.XM, l.YM
        s.talon = Strategerie_Talon(x, y, self)
        l.createText(s.talon, 'ne')

        l.defaultStackGroups()
        self.sg.dropstacks.append(s.talon)
예제 #6
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()
예제 #7
0
    def createGame(self, rows=5, reserves=4, playcards=15):
        # create layout
        l, s = Layout(self), self.s

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

        # create stacks
        x, y = l.XM, l.YM
        for i in range(4):
            for j in range(2):
                s.foundations.append(
                    RK_FoundationStack(x, y, self, suit=ANY_SUIT))
                x += l.XS
        x, y = l.XM + (8 - rows) * l.XS // 2, l.YM + l.YS
        for i in range(rows):
            s.rows.append(Gloaming_RowStack(x, y, self, max_accept=1))
            x += l.XS

        x, y = l.XM + (8 - reserves - 1) * l.XS // 2, self.height - l.YS
        for i in range(reserves):
            s.reserves.append(OpenStack(x, y, self, max_accept=0))
            x += l.XS

        s.talon = TalonStack(x, y, self)
        l.createText(s.talon, 'n')

        # define stack-groups
        l.defaultStackGroups()
예제 #8
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()
예제 #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
        x, y, = l.XM + 3 * l.XS, l.YM
        for i in range(4):
            s.foundations.append(RK_FoundationStack(x, y, self, max_move=0))
            x += l.XS
        for i in range(2):
            y = l.YM + (i * 2 + 3) * l.YS / 2
            for j in range(4):
                x = l.XM + (j * 5) * l.XS / 2
                stack = RK_RowStack(x, y, self, base_rank=NO_RANK, max_move=1)
                stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0
                s.rows.append(stack)
        x, y, = l.XM + 3 * l.XS, l.YM + 4 * l.YS
        s.talon = Bristol_Talon(x, y, self)
        l.createText(s.talon, "sw")
        x += l.XS
        for i in range(3):
            stack = WasteStack(x, y, self)
            l.createText(stack, 'n')
            s.reserves.append(stack)
            x += l.XS

        # define stack-groups
        self.sg.openstacks = s.foundations + s.rows
        self.sg.talonstacks = [s.talon]
        self.sg.dropstacks = s.rows + s.reserves
예제 #10
0
    def createGame(self, rows=8):
        # create layout
        layout, s = Layout(self), self.s

        # set window
        playcards = 12
        self.setSize(
            layout.XM+rows*layout.XS,
            layout.YM+3*layout.YS+playcards*layout.YOFFSET)

        # create stacks
        x, y = layout.XM + (rows-1)*layout.XS//2, layout.YM
        stack = RK_FoundationStack(x, y, self, base_rank=ANY_RANK,
                                   max_cards=52, mod=13)
        s.foundations.append(stack)
        layout.createText(stack, 'ne')

        x, y = layout.XM, layout.YM+layout.YS
        for i in range(rows):
            s.rows.append(RK_RowStack(x, y, self, base_rank=NO_RANK, mod=13))
            x += layout.XS

        x, y = layout.XM, self.height-layout.YS
        s.talon = TalonStack(x, y, self)
        layout.createText(s.talon, 'se')

        # define stack-groups
        layout.defaultStackGroups()
예제 #11
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
예제 #12
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
예제 #13
0
파일: golf.py 프로젝트: shlomif/PySolFC
 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
예제 #14
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
예제 #15
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
예제 #16
0
    def createGame(self, rows=4, max_rounds=1, num_deal=1):
        # create layout
        l, s = Layout(self), self.s

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

        # create stacks
        x, y = l.XM, l.YM
        for i in range(2):
            stack = OpenStack(x, y, self)
            stack.CARD_XOFFSET = l.XOFFSET
            l.createText(stack, "sw")
            s.reserves.append(stack)
            x += 4.5 * l.XS

        x, y = l.XM, y + l.YS
        for i in range(4):
            s.foundations.append(
                RK_FoundationStack(x, y, self, suit=i, base_rank=ACE, dir=1))
            x = x + l.XS
        x = x + (l.XS / 2)
        for i in range(4):
            s.foundations.append(
                RK_FoundationStack(x, y, self, suit=i, base_rank=KING, dir=-1))
            x = x + l.XS
        x, y = l.XM + l.XS, y + l.YS
        s.talon = WasteTalonStack(x,
                                  y,
                                  self,
                                  max_rounds=max_rounds,
                                  num_deal=num_deal)
        l.createText(s.talon, "sw")
        x = x + l.XS
        s.waste = WasteStack(x, y, self)
        l.createText(s.waste, "se", text_format="%D")
        x += 2.5 * l.XS
        for i in range(rows):
            s.rows.append(AcesAndKings_RowStack(x, y, self, max_accept=1))
            x = x + l.XS

        # define stack-groups
        l.defaultStackGroups()
예제 #17
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
예제 #18
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
예제 #19
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
예제 #20
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
예제 #21
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
예제 #22
0
파일: numerica.py 프로젝트: joeraz/PySolFC
    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
예제 #23
0
 def createGame(self, **layout):
     # create layout
     l, s = Layout(self), self.s
     l.freeCellLayout(rows=4, reserves=4, texts=1)
     self.setSize(l.size[0], l.size[1])
     # create stacks
     s.talon = Strategerie_Talon(l.s.talon.x, l.s.talon.y, self)
     for r in l.s.foundations:
         s.foundations.append(RK_FoundationStack(r.x, r.y, self))
     for r in l.s.rows:
         s.rows.append(Strategerie_RowStack(r.x, r.y, self,
                                            max_accept=UNLIMITED_ACCEPTS))
     for r in l.s.reserves:
         s.reserves.append(Strategerie_ReserveStack(r.x, r.y, self))
     # default
     l.defaultAll()
     self.sg.dropstacks.append(s.talon)
예제 #24
0
    def createGame(self):
        # 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 + 13 * l.XOFFSET)
        self.setSize(l.XM + 2 * w + 2 * l.XS, l.YM + 5 * l.YS + l.TEXT_HEIGHT)

        # create stacks
        x, y = l.XM, l.YM + 4 * l.YS
        s.talon = InitialDealTalonStack(x, y, self)
        x, y = l.XM + w - l.XS, self.height - l.YS
        for i in range(4):
            stack = OpenStack(x, y, self, max_accept=0)
            s.reserves.append(stack)
            l.createText(stack, 'n')
            x += l.XS

        x = l.XM + w
        for x in (l.XM + w, l.XM + w + l.XS):
            y = l.YM
            for i in range(4):
                s.foundations.append(RK_FoundationStack(x, y, self,
                                                        max_move=0))
                y += l.YS

        for x in (l.XM, l.XM + w + 2 * l.XS):
            y = l.YM
            for i in range(4):
                stack = RK_RowStack(x,
                                    y,
                                    self,
                                    max_move=1,
                                    max_accept=1,
                                    base_rank=ANY_RANK)
                stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0
                s.rows.append(stack)
                y += l.YS
        l.setRegion(s.rows[:4],
                    (-999, -999, w - l.CW // 2, l.YM + 4 * l.YS - l.CH // 2))

        # define stack-groups
        l.defaultStackGroups()
        # set regions
        l.defaultRegions()
예제 #25
0
    def createGame(self):
        l, s = Layout(self), self.s
        self.setSize(l.XM + 7.5 * l.XS, l.YM + 3.8 * l.YS)

        x0, y0 = l.XM, l.YM
        for xx, yy in (
            (4, 0.4),
            (3, 0.2),
            (2, 0.0),
            (1, 0.2),
            (0, 0.7),
            (1, 1.2),
            (2, 1.4),
            (3, 1.6),
            (4, 2.0),
            (3, 2.6),
            (2, 2.8),
            (1, 2.6),
            (0, 2.4),
        ):
            x, y = x0 + xx * l.XS, y0 + yy * l.YS
            s.foundations.append(
                RK_FoundationStack(x,
                                   y,
                                   self,
                                   suit=ANY_SUIT,
                                   max_cards=8,
                                   mod=13,
                                   max_move=0))

        x, y = l.XM + 5.5 * l.XS, l.YM + 2 * l.YS
        for i in (0, 1):
            stack = Calculation_RowStack(x, y, self, max_move=1, max_accept=1)
            stack.CARD_YOFFSET = 0
            s.rows.append(stack)
            l.createText(stack, 's')
            x += l.XS
        x, y = l.XM + 5.5 * l.XS, l.YM + l.YS
        s.talon = WasteTalonStack(x, y, self, max_rounds=1)
        l.createText(s.talon, 'nw')
        x += l.XS
        s.waste = WasteStack(x, y, self, max_cards=1)

        l.defaultStackGroups()
예제 #26
0
    def createGame(self, rows=8):
        # create layout
        l, s = Layout(self), self.s

        # set size
        self.setSize(l.XM + (rows+2)*l.XS, l.YM + 5*l.YS)

        #
        playcards = 4*l.YS // l.YOFFSET
        xoffset, yoffset = [], []
        for i in range(playcards):
            xoffset.append(0)
            yoffset.append(l.YOFFSET)
        for i in range(104-playcards):
            xoffset.append(l.XOFFSET)
            yoffset.append(0)

        # create stacks
        x, y = l.XM, l.YM
        for i in range(rows):
            stack = RK_RowStack(x, y, self)
            stack.CARD_XOFFSET = xoffset
            stack.CARD_YOFFSET = yoffset
            s.rows.append(stack)
            x += l.XS
        x, y = l.XM + rows*l.XS, l.YM
        for suit in range(4):
            for i in range(2):
                s.foundations.append(RK_FoundationStack(x+i*l.XS, y, self,
                                                        suit=suit))
            y += l.YS
        self.setRegion(self.s.foundations,
                       (x - l.CW // 2, -999, 999999, y), priority=1)
        x, y = self.width-3*l.XS//2, self.height-l.YS
        s.talon = InitialDealTalonStack(x, y, self)

        # define stack-groups
        l.defaultStackGroups()
예제 #27
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
예제 #28
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
예제 #29
0
 def __init__(self, x, y, game):
     RK_FoundationStack.__init__(
         self, x, y, game, base_rank=ACE, dir=0, max_move=0, max_cards=8)
     self.CARD_YOFFSET = min(30, self.game.app.images.CARD_YOFFSET + 10)
예제 #30
0
 def getBottomImage(self):
     if self.cap.base_rank == ACE:
         return self.game.app.images.getLetter(ACE)
     return RK_FoundationStack.getBottomImage(self)