def canDropCards(self, stacks): if self.game.demo: return RK_RowStack.canDropCards(self, stacks) for s in self.game.s.foundations: if s.cards: return RK_RowStack.canDropCards(self, stacks) return (None, 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
def createGame(self): l, s = Layout(self), self.s self.setSize(l.XM+5*l.XS, l.YM+4*l.YS) for i, j in ((1, 0), (2, 0), (3, 0), (4, 1.5), (3, 3), (2, 3), (1, 3), (0, 1.5), ): x, y = l.XM+i*l.XS, l.YM+j*l.YS stack = RK_RowStack(x, y, self, dir=1, mod=13, max_move=0) s.rows.append(stack) stack.CARD_YOFFSET = 0 x, y = l.XM+1.5*l.XS, l.YM+1.5*l.YS s.talon = WasteTalonStack(x, y, self, max_rounds=2) l.createText(s.talon, 'nw') l.createRoundText(self.s.talon, 'nn') x += l.XS s.waste = WasteStack(x, y, self) l.createText(s.waste, 'ne') l.defaultStackGroups()
def createGame(self): l, s = Layout(self), self.s self.setSize(l.XM + 5 * l.XS, l.YM + 4 * l.YS) for i, j in ( (1, 0), (2, 0), (3, 0), (4, 1.5), (3, 3), (2, 3), (1, 3), (0, 1.5), ): x, y = l.XM + i * l.XS, l.YM + j * l.YS stack = RK_RowStack(x, y, self, dir=1, mod=13, max_move=0) s.rows.append(stack) stack.CARD_YOFFSET = 0 x, y = l.XM + 1.5 * l.XS, l.YM + 1.5 * l.YS s.talon = WasteTalonStack(x, y, self, max_rounds=2) l.createText(s.talon, 'nw') l.createRoundText(self.s.talon, 'nn') x += l.XS s.waste = WasteStack(x, y, self) l.createText(s.waste, 'ne') l.defaultStackGroups()
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
def createGame(self): # create layout lay, s = Layout(self), self.s # set window playcards = 8 w0 = lay.XS + playcards * lay.XOFFSET w = lay.XM + lay.XS // 2 + max(10 * lay.XS, lay.XS + 4 * w0) h = lay.YM + 5 * lay.YS + lay.TEXT_HEIGHT self.setSize(w, h) # extra settings self.base_card = None # create stacks x, y = lay.XM, lay.YM s.talon = WasteTalonStack(x, y, self, max_rounds=1) lay.createText(s.talon, 's') x += lay.XS s.waste = WasteStack(x, y, self) lay.createText(s.waste, 's') x = self.width - 8 * lay.XS for i in range(8): s.foundations.append( SS_FoundationStack(x, y, self, suit=i % 4, mod=13)) x += lay.XS tx, ty, ta, tf = lay.getTextAttr(None, "ss") tx, ty = x - lay.XS + tx, y + ty font = self.app.getFont("canvas_default") self.texts.info = MfxCanvasText(self.canvas, tx, ty, anchor=ta, font=font) x, y = lay.XM, lay.YM + lay.YS + lay.TEXT_HEIGHT for i in range(4): s.reserves.append(ReserveStack(x, y, self)) y += lay.YS y = lay.YM + lay.YS + lay.TEXT_HEIGHT for i in range(4): x = lay.XM + lay.XS + lay.XS // 2 for j in range(4): stack = RK_RowStack(x, y, self, max_move=1, mod=13) s.rows.append(stack) stack.CARD_XOFFSET, stack.CARD_YOFFSET = lay.XOFFSET, 0 x += w0 y += lay.YS # define stack-groups lay.defaultStackGroups()
def createGame(self): # create layout l, s = Layout(self), self.s # set window self.setSize(l.XM + 5.5 * l.XS, l.YM + 4 * l.YS) # extra settings self.base_card = None # create stacks for i in range(4): dx, dy = ((0, 0), (2, 0), (0, 2), (2, 2))[i] x, y = l.XM + (2 * dx + 5) * l.XS / 2, l.YM + (2 * dy + 1) * l.YS / 2 stack = SS_FoundationStack(x, y, self, i, mod=13, max_move=0) stack.CARD_YOFFSET = 0 s.foundations.append(stack) for i in range(5): dx, dy = ((1, 0), (0, 1), (1, 1), (2, 1), (1, 2))[i] x, y = l.XM + (2 * dx + 5) * l.XS / 2, l.YM + (2 * dy + 1) * l.YS / 2 stack = RK_RowStack(x, y, self, mod=13, max_move=1) stack.CARD_YOFFSET = 0 s.rows.append(stack) x, y = l.XM, l.YM + 3 * l.YS / 2 s.talon = WasteTalonStack(x, y, self, max_rounds=1) l.createText(s.talon, "s") x = x + l.XS s.waste = WasteStack(x, y, self) l.createText(s.waste, "s") # define stack-groups l.defaultStackGroups()
def createGame(self): rows = 8 l, s = Layout(self), self.s self.setSize(l.XM + rows * l.XS, l.YM + 2 * l.YS + 20 * l.YOFFSET) x, y = l.XM, l.YM for i in range(rows): s.rows.append(RK_RowStack(x, y, self)) x += l.XS x, y = l.XM + (rows - 1) * l.XS // 2, self.height - l.YS s.foundations.append( Waterfall_Foundation(x, y, self, suit=ANY_SUIT, max_cards=104)) stack = s.foundations[0] tx, ty, ta, tf = l.getTextAttr(stack, 'se') font = self.app.getFont('canvas_default') stack.texts.misc = MfxCanvasText(self.canvas, tx, ty, anchor=ta, font=font) x, y = self.width - l.XS, self.height - l.YS s.talon = DealRowTalonStack(x, y, self) l.createText(s.talon, 'sw') l.defaultStackGroups()
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()
def createGame(self, rows=8): l, s = Layout(self), self.s w, h = l.XM + rows * l.XS, l.YM + 2 * l.YS + 14 * l.YOFFSET self.setSize(w, h) x, y = l.XM, l.YM for i in range(rows): s.rows.append( RK_RowStack(x, y, self, max_cards=13, mod=13, dir=1, max_move=1)) x += l.XS x, y = l.XM, h - l.YS s.talon = WasteTalonStack(x, y, self, max_rounds=1) l.createText(s.talon, 'n') x += l.XS s.waste = WasteStack(x, y, self) l.createText(s.waste, 'n') l.defaultStackGroups()
def acceptsCards(self, from_stack, cards): if not RK_RowStack.acceptsCards(self, from_stack, cards): return False # Only allow a sequence if pile is empty if len(self.cards) > 0: return False return True
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()
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()
def acceptsCards(self, from_stack, cards): if not RK_RowStack.acceptsCards(self, from_stack, cards): return False if not self.cards: return (from_stack is self.game.s.talon or from_stack in self.game.s.reserves) return True
def createGame(self): # create layout lay, s = Layout(self), self.s # set window playcards = 8 w0 = lay.XS+playcards*lay.XOFFSET w = lay.XM+lay.XS//2+max(10*lay.XS, lay.XS+4*w0) h = lay.YM+5*lay.YS+lay.TEXT_HEIGHT self.setSize(w, h) # extra settings self.base_card = None # create stacks x, y = lay.XM, lay.YM s.talon = WasteTalonStack(x, y, self, max_rounds=1) lay.createText(s.talon, 's') x += lay.XS s.waste = WasteStack(x, y, self) lay.createText(s.waste, 's') x = self.width - 8*lay.XS for i in range(8): s.foundations.append(SS_FoundationStack(x, y, self, suit=i % 4, mod=13)) x += lay.XS tx, ty, ta, tf = lay.getTextAttr(None, "ss") tx, ty = x-lay.XS+tx, y+ty font = self.app.getFont("canvas_default") self.texts.info = MfxCanvasText(self.canvas, tx, ty, anchor=ta, font=font) x, y = lay.XM, lay.YM+lay.YS+lay.TEXT_HEIGHT for i in range(4): s.reserves.append(ReserveStack(x, y, self)) y += lay.YS y = lay.YM+lay.YS+lay.TEXT_HEIGHT for i in range(4): x = lay.XM+lay.XS+lay.XS//2 for j in range(4): stack = RK_RowStack(x, y, self, max_move=1, mod=13) s.rows.append(stack) stack.CARD_XOFFSET, stack.CARD_YOFFSET = lay.XOFFSET, 0 x += w0 y += lay.YS # define stack-groups lay.defaultStackGroups()
def acceptsCards(self, from_stack, cards): if not RK_RowStack.acceptsCards(self, from_stack, cards): return False if cards[0].suit == DIAMOND: return False if self.cards: return self.cards[-1].suit != DIAMOND return True
def createGame(self, rows=12): l, s = Layout(self), self.s self.setSize(l.XM + (rows + 1) * l.XS, l.YM + l.YS + 12 * l.YOFFSET) x, y = l.XM, l.YM s.talon = TalonStack(x, y, self) l.createText(s.talon, "s") x += l.XS for i in range(rows): s.rows.append(RK_RowStack(x, y, self, max_move=1)) x += l.XS l.defaultStackGroups()
def createGame(self, rows=8, playcards=13, reserve_max_cards=4): # create layout l, s = Layout(self), self.s decks = self.gameinfo.decks # set window # (set size so that at least 13 cards are fully playable) w = max(3*l.XS, l.XS+playcards*l.XOFFSET) self.setSize(l.XM+2*w+decks*l.XS, l.YM+l.TEXT_HEIGHT+(rows//2+1)*l.YS) # create stacks y = l.YM x = l.XM + w 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 stack = Zerline_ReserveStack(x, y, self, max_cards=reserve_max_cards) s.reserves.append(stack) stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0 l.createText(stack, "s") x = l.XM + w for j in range(decks): y = l.YM+l.TEXT_HEIGHT+l.YS for i in range(4): s.foundations.append( SS_FoundationStack( x, y, self, i, base_rank=KING, dir=1, max_move=0, mod=13)) y += l.YS x += l.XS x = l.XM for j in range(2): y = l.YM+l.TEXT_HEIGHT+l.YS for i in range(rows//2): stack = RK_RowStack( x, y, self, max_move=1, max_accept=1, base_rank=QUEEN) stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0 s.rows.append(stack) y += l.YS x += l.XM+w+decks*l.XS l.setRegion( s.rows[:4], (-999, l.YM+l.YS+l.TEXT_HEIGHT-l.CH//2, w-l.CW//2, 999999)) # define stack-groups l.defaultStackGroups() # set regions l.defaultRegions()
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()
def createGame(self, reserves=6): l, s = Layout(self), self.s w, h = 3 * l.XM + 5 * l.XS, l.YM + 5 * l.YS self.setSize(w, h) lay = ( (0, 2, 0, QUEEN, -1), (0, 1, 0, QUEEN, -1), (0, 0, 1, QUEEN, -1), (2, 0, 1, QUEEN, -1), (1, 0, 2, QUEEN, -1), (2, 1, 3, QUEEN, -1), (2, 2, 3, QUEEN, -1), (1, 1, 2, KING, 1), ) for xx, yy, suit, base_rank, dir in lay: x, y = 2 * l.XM + l.XS + xx * l.XS, l.YM + yy * l.YS stack = SS_FoundationStack(x, y, self, suit=suit, max_move=0, base_rank=base_rank, dir=dir, mod=13) s.foundations.append(stack) for x, y in ((l.XM, l.YM), (3 * l.XM + 4 * l.XS, l.YM)): for i in range(5): stack = RK_RowStack(x, y, self, dir=1, base_rank=NO_RANK, max_move=1, mod=13) stack.CARD_YOFFSET = 0 s.rows.append(stack) y += l.YS x, y = 2 * l.XM + 1.5 * l.XS, l.YM + 4 * l.YS s.talon = WasteTalonStack(x, y, self, max_rounds=1) l.createText(s.talon, 'n') x += l.XS s.waste = WasteStack(x, y, self) l.createText(s.waste, 'n') l.defaultStackGroups()
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()
def createGame(self): # create layout l, s = Layout(self), self.s # set window # (piles up to 9 cards are fully playable in default window size) dh = max(3 * l.YS / 2 + l.CH, l.YS + (9 - 1) * l.YOFFSET) self.setSize(10 * l.XS + l.XM, l.YM + 2 * dh) # create stacks for i in range(2): x, y = l.XM, l.YM + i * dh for j in range(4): s.rows.append(RK_RowStack(x, y, self, max_move=1, max_accept=1)) x = x + l.XS y = l.YM + dh - l.CH / 2 self.setRegion(s.rows[:4], (-999, -999, x - l.XM / 2, y)) self.setRegion(s.rows[4:], (-999, y, x - l.XM / 2, 999999)) d = [(0, 0), (1, 0.15), (2, 0.5), (2.5, 1.5), (2, 2.5), (1, 2.85)] for i in range(len(d)): d.append((0 - d[i][0], 3 - d[i][1])) x0, y0 = l.XM, l.YM + dh - l.CH for i in range(12): j = (i + 5) % 12 x = int(round(x0 + (6.5 + d[j][0]) * l.XS)) y = int(round(y0 + (-1.5 + d[j][1]) * l.YS)) suit = (1, 2, 0, 3)[i % 4] s.foundations.append( SS_FoundationStack(x, y, self, suit, base_rank=i + 1, mod=13, max_move=0)) s.talon = InitialDealTalonStack(self.width - l.XS, self.height - l.YS, self) # define stack-groups self.sg.openstacks = s.foundations + s.rows self.sg.talonstacks = [s.talon] self.sg.dropstacks = s.rows
def createGame(self, rows=12): l, s = Layout(self), self.s self.setSize(l.XM+rows*l.XS, l.YM+2*l.YS+l.TEXT_HEIGHT+20*l.YOFFSET) x, y = l.XM+(rows-4)//2*l.XS, l.YM for i in range(4): s.foundations.append(SS_FoundationStack(x, y, self, suit=i, mod=13, max_cards=26)) x += l.XS x, y = l.XM, l.YM+l.YS+l.TEXT_HEIGHT for i in range(rows): s.rows.append(RK_RowStack(x, y, self, mod=13)) x += l.XS x, y = l.XM, l.YM s.talon = WasteTalonStack(x, y, self, num_deal=2, max_rounds=1) l.createText(s.talon, 's') x = x + l.XS s.waste = WasteStack(x, y, self, max_cards=2) s.waste.CARD_XOFFSET = l.XOFFSET l.defaultStackGroups()
def createGame(self): l, s = Layout(self), self.s # Set window size self.setSize(l.XM * 3 + l.XS * 9, l.YM + l.YS * 6) # Create row stacks x = l.XM y = l.YM for i in range(8): s.rows.append( RK_RowStack(x, y, self, base_rank=11, max_move=12, max_cards=99)) x = x + l.XS # Create reserve stacks x = self.width - l.XS y = l.YM for i in range(6): s.reserves.append(ReserveStack(x, y, self)) y = y + l.YS y = y - l.YS for i in range(4): x = x - l.XS s.reserves.append(ReserveStack(x, y, self)) self.setRegion(s.rows, (0, 0, l.XM + l.XS * 8, l.YS * 5)) # Create talon s.talon = DealRowTalonStack(l.XM, self.height - l.YS, self) l.createText(s.talon, "n") # Define stack groups l.defaultStackGroups()
def acceptsCards(self, from_stack, cards): if not self.cards and from_stack in self.game.s.reserves: return True return RK_RowStack.acceptsCards(self, from_stack, cards)
def acceptsCards(self, from_stack, cards): if not RK_RowStack.acceptsCards(self, from_stack, cards): return False return BritishConstitution_RowStackMethods.acceptsCards( self, from_stack, cards)
def acceptsCards(self, from_stack, cards): if not RK_RowStack.acceptsCards(self, from_stack, cards): return False if not self.cards: return from_stack is self.game.s.waste return True
def acceptsCards(self, from_stack, cards): if self.game.s.talon.cards: return False if len(self.cards) == 1: return True return RK_RowStack.acceptsCards(self, from_stack, cards)
def acceptsCards(self, from_stack, cards): if self.cards and not self.game.inSuitSequence(self.cards[-1], cards[0]): return False return RK_RowStack.acceptsCards(self, from_stack, cards)
def basicAcceptsCards(self, from_stack, cards): if from_stack in self.game.s.rows: if len(cards) != 1 and len(cards) != len(from_stack.cards): return False return RK_RowStack.basicAcceptsCards(self, from_stack, cards)