def createGame(self): l, s = Layout(self), self.s w, h = l.XM + 8 * l.XS, 2 * l.YM + 3 * l.YS self.setSize(w, h) x, y = l.XM + 3 * l.XS, l.YM for i in range(4): s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) x += l.XS x, y = l.XM, l.YM s.talon = WasteTalonStack(x, y, self, max_rounds=1) l.createText(s.talon, 'se') y += l.YS s.waste = WasteStack(x, y, self) l.createText(s.waste, 'se') y = 2 * l.YM + l.YS for i in range(2): x = l.XM + 2 * l.XS for j in range(6): stack = SS_RowStack(x, y, self, max_move=1) stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, 0 s.rows.append(stack) x += l.XS y += l.YS l.defaultStackGroups()
def createGame(self): l, s = Layout(self), self.s w1 = l.XS+12*l.XOFFSET w, h = l.XM+2*l.XS+2*w1, l.YM+4*l.YS self.setSize(w, h) for x, y in ((l.XM, l.YM), (l.XM+w1+2*l.XS+l.XM, l.YM), (l.XM, l.YM+3*l.YS), (l.XM+w1+2*l.XS+l.XM, l.YM+3*l.YS),): stack = SS_RowStack(x, y, self, max_move=1) stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0 s.rows.append(stack) i = 0 for x, y in ((l.XM+w1, l.YM), (l.XM+w1+l.XS, l.YM), (l.XM+w1-2*l.XS-l.XS//2-l.XM, l.YM+1.5*l.YS), (l.XM+w1-l.XS-l.XS//2-l.XM, l.YM+1.5*l.YS), (l.XM+w1+2*l.XS+l.XS//2+l.XM, l.YM+1.5*l.YS), (l.XM+w1+3*l.XS+l.XS//2+l.XM, l.YM+1.5*l.YS), (l.XM+w1, l.YM+3*l.YS), (l.XM+w1+l.XS, l.YM+3*l.YS),): s.foundations.append(SS_FoundationStack(x, y, self, suit=i % 4)) i += 1 x, y = l.XM+w1, l.YM+1.5*l.YS s.talon = WasteTalonStack(x, y, self, max_rounds=4) l.createText(s.talon, 's') l.createRoundText(s.talon, 'nn') x += l.XS s.waste = WasteStack(x, y, self) l.createText(s.waste, 's') l.defaultStackGroups()
def moveMove(self, ncards, to_stack, frames=-1, shadow=-1): game, r = self.game, self.game.s.reserves[0] if to_stack is not r: SS_RowStack.moveMove(self, ncards, to_stack, frames=frames, shadow=shadow) return f = self._canDrawCard() assert f and game.draw_done == 0 and ncards == 1 # 1) top card from self to reserve game.updateStackMove(r, 2 | 16) # update view for undo game.moveMove(1, self, r, frames=frames, shadow=shadow) game.updateStackMove(r, 3 | 64) # update model game.updateStackMove(r, 1 | 16) # update view for redo # 2) second card from self to foundation/row if 1 or not game.demo: game.playSample("drop", priority=200) if frames == 0: frames = -1 game.moveMove(1, self, f, frames=frames, shadow=shadow) # 3) from reserve back to self # (need S_FILL because the move is normally not valid) old_state = game.enterState(game.S_FILL) game.moveMove(1, r, self, frames=frames, shadow=shadow) game.leaveState(old_state)
def createGame(self): l, s = Layout(self), self.s w, h = l.XM+8*l.XS, 2*l.YM+3*l.YS self.setSize(w, h) x, y = l.XM+3*l.XS, l.YM for i in range(4): s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) x += l.XS x, y = l.XM, l.YM s.talon = WasteTalonStack(x, y, self, max_rounds=1) l.createText(s.talon, 'se') y += l.YS s.waste = WasteStack(x, y, self) l.createText(s.waste, 'se') y = 2*l.YM+l.YS for i in range(2): x = l.XM+2*l.XS for j in range(6): stack = SS_RowStack(x, y, self, max_move=1) stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, 0 s.rows.append(stack) x += l.XS y += l.YS l.defaultStackGroups()
def createGame(self): l, s = Layout(self), self.s self.setSize(l.XM+9.5*l.XS, l.YM+4*l.YS) x, y = l.XM+l.XS, l.YM for i in range(8): s.foundations.append(SS_FoundationStack(x, y, self, suit=i % 4, base_rank=JACK, dir=-1, max_cards=11)) x += l.XS x, y = l.XM+l.XS, l.YM+l.YS for i in range(8): s.foundations.append(Adela_Foundation(x, y, self, suit=i % 4, base_rank=QUEEN, max_cards=1)) x += l.XS x, y = l.XM+l.XS, l.YM+2*l.YS for i in range(8): s.foundations.append(Adela_Foundation(x, y, self, suit=i % 4, base_rank=KING, max_cards=1)) x += l.XS x, y = l.XM, l.YM+l.YS s.talon = DealRowTalonStack(x, y, self) l.createText(s.talon, 'n') x, y = l.XM+l.XS//2, l.YM+3*l.YS for i in range(9): stack = SS_RowStack(x, y, self, max_move=1, dir=1) s.rows.append(stack) stack.CARD_YOFFSET = 0 x += l.XS l.defaultStackGroups()
def moveMove(self, ncards, to_stack, frames=-1, shadow=-1): SS_RowStack.moveMove(self, ncards, to_stack, frames, shadow) if self.game.base_rank is None and to_stack in self.game.s.foundations: old_state = self.game.enterState(self.game.S_FILL) self.game.saveStateMove(2 | 16) # for undo self.game.base_rank = to_stack.cards[-1].rank self.game.saveStateMove(1 | 16) # for redo self.game.leaveState(old_state)
def __init__(self, x, y, game, base_rank, yoffset): SS_RowStack.__init__(self, x, y, game, base_rank=base_rank, max_accept=1, max_move=1) self.CARD_YOFFSET = 1
def __init__(self, x, y, game, base_rank, yoffset, dir=3, max_cards=4): SS_RowStack.__init__(self, x, y, game, base_rank=base_rank, dir=dir, max_cards=max_cards, max_accept=1) self.CARD_YOFFSET = yoffset
def __init__(self, x, y, game, suit): SS_RowStack.__init__(self, x, y, game, suit=suit, base_rank=QUEEN, mod=13, dir=-1, min_cards=1, max_cards=12)
def __init__(self, x, y, game, suit): SS_RowStack.__init__(self, x, y, game, suit=suit, base_rank=KING, mod=13, dir=1, min_cards=1, max_cards=12) self.CARD_YOFFSET = -self.CARD_YOFFSET
def createGame(self): l, s = Layout(self), self.s playcards = 7 w0 = l.XS + (playcards - 1) * l.XOFFSET w, h = l.XM + 3 * w0 + 4 * l.XS, l.YM + 6 * l.YS self.setSize(w, h) x1, x2 = l.XM, self.width - 2 * l.XS for i in range(2): y = l.YM for j in range(4): s.foundations.append( SS_FoundationStack(x1, y, self, suit=j, dir=2, max_cards=7)) s.foundations.append( SS_FoundationStack(x2, y, self, base_rank=1, suit=j, dir=2, max_cards=6)) y += l.YS x1 += l.XS x2 += l.XS x, y = l.XM + 3 * l.XS, l.YM for i in (0, 1): stack = SS_RowStack(x, y, self, max_move=1, base_rank=KING) stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0 s.rows.append(stack) x += w0 y = l.YM + l.YS for i in range(4): x = l.XM + 2 * l.XS for j in range(3): stack = SS_RowStack(x, y, self, max_move=1, base_rank=KING) stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0 s.rows.append(stack) x += w0 y += l.YS x, y = l.XM + 3 * l.XS, l.YM + 5 * l.YS for i in (0, 1): stack = SS_RowStack(x, y, self, max_move=1, base_rank=KING) stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0 s.rows.append(stack) x += w0 x, y = l.XM, self.height - l.YS s.talon = ForestGlade_Talon(x, y, self, max_rounds=3) l.createText(s.talon, 'ne') l.createRoundText(s.talon, 'se') l.defaultStackGroups()
def acceptsCards(self, from_stack, cards): if not SS_RowStack.acceptsCards(self, from_stack, cards): return False if not self.cards: # don't accepts from lid return from_stack not in self.game.s.lid return True
def createGame(self): l, s = Layout(self), self.s w, h = l.XM+8*l.XS, l.YM+4*l.YS self.setSize(w, h) x, y = l.XM, l.YM for i in range(8): s.foundations.append(SS_FoundationStack(x, y, self, suit=i//2, base_rank=KING, mod=13)) x += l.XS x, y = l.XM, l.YM+l.YS s.talon = TheSpark_Talon(x, y, self, max_rounds=1, num_deal=3) l.createText(s.talon, 'se') y += l.YS for i in (0, 1): stack = WasteStack(x, y, self) s.reserves.append(stack) l.createText(stack, 'se') y += l.YS y = l.YM+l.YS*3//2 for i in range(2): x = l.XM+2*l.XS for j in range(6): stack = SS_RowStack(x, y, self, max_move=1) stack.CARD_XOFFSET, stack.CARD_YOFFSET = 0, 0 s.rows.append(stack) x += l.XS y += l.YS l.defaultStackGroups()
def canMoveCards(self, cards): self_index, self_row = self._getStackIndex(self) if self_row in (0, 1): below_stack = self.game.s.rows[self_index+12] if below_stack.cards: return False return SS_RowStack.canMoveCards(self, cards)
def acceptsCards(self, from_stack, cards): if not SS_RowStack.acceptsCards(self, from_stack, cards): return False self_index, self_row = self._getStackIndex(self) if self_row in (1, 2): above_stack = self.game.s.rows[self_index-12] if not above_stack.cards: return False below_stack = None if self_row in (0, 1): below_stack = self.game.s.rows[self_index+12] # from_stack is waste if from_stack is self.game.s.waste: if below_stack is None or not below_stack.cards: return True else: return False # from_stack in rows from_index, from_row = self._getStackIndex(from_stack) if below_stack and below_stack.cards: return from_stack is below_stack return from_row > self_row
def acceptsCards(self, from_stack, cards): if not SS_RowStack.acceptsCards(self, from_stack, cards): return False # check that the base card is correct if self.cards and self.cards[0].rank != self.cap.base_rank: return False return True
def createGame(self): l, s = Layout(self), self.s self.setSize(l.XM + 10 * l.XS, l.YM + 3 * l.YS + 16 * l.YOFFSET) x, y, = l.XM + l.XS, l.YM for i in range(8): s.foundations.append(SS_FoundationStack(x, y, self, suit=i / 2)) x = x + l.XS x, y, = l.XM, l.YM + l.YS for i in range(10): s.rows.append(SS_RowStack(x, y, self, max_move=1)) x += l.XS x, y = l.XM, self.height - l.YS s.talon = ThreePirates_Talon(x, y, self) l.createText(s.talon, 'n') x += l.XS for i in (0, 1, 2): stack = WasteStack(x, y, self) s.reserves.append(stack) l.createText(stack, 'n') x += l.XS l.defaultStackGroups()
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()
def acceptsCards(self, from_stack, cards): if not SS_RowStack.acceptsCards(self, from_stack, cards): return False self_index, self_row = self._getStackIndex(self) if self_row in (1, 2): above_stack = self.game.s.rows[self_index - 12] if not above_stack.cards: return False below_stack = None if self_row in (0, 1): below_stack = self.game.s.rows[self_index + 12] # from_stack is waste if from_stack is self.game.s.waste: if below_stack is None or not below_stack.cards: return True else: return False # from_stack in rows from_index, from_row = self._getStackIndex(from_stack) if below_stack and below_stack.cards: return from_stack is below_stack return from_row > self_row
def canMoveCards(self, cards): self_index, self_row = self._getStackIndex(self) if self_row in (0, 1): below_stack = self.game.s.rows[self_index + 12] if below_stack.cards: return False return SS_RowStack.canMoveCards(self, cards)
def createGame(self, rows=8): # create layout l, s = Layout(self), self.s # set window w, h = l.XM + (rows + 2) * l.XS, max( l.YM + 3 * l.XS + 10 * l.YOFFSET, l.YM + 2 * l.YS + self.RESERVE_CARDS * l.YOFFSET + l.TEXT_HEIGHT) self.setSize(w, h) # create stacks y = l.YM for i in range(4): x = l.XM + (rows - 8) * l.XS // 2 + i * l.XS s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) x = l.XM + (rows // 2 + 2) * l.XS + i * l.XS s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) x, y = l.XM + rows * l.XS // 2, l.YM s.reserves.append(Backbone_BraidStack(x, y, self, max_accept=0)) x += l.XS s.reserves.append(Backbone_BraidStack(x, y, self, max_accept=0)) x, y = l.XM + (rows + 1) * l.XS // 2, l.YM + self.RESERVE_CARDS * l.YOFFSET s.reserves.append(BasicRowStack(x, y, self, max_accept=0)) x, y = l.XM, l.YM + l.YS for i in range(rows // 2): s.rows.append(SS_RowStack(x, y, self, max_move=1)) x += l.XS x, y = l.XM + (rows // 2 + 2) * l.XS, l.YM + l.YS for i in range(rows // 2): s.rows.append(SS_RowStack(x, y, self, max_move=1)) x += l.XS x, y = l.XM + rows * l.XS // 2, 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") # define stack-groups l.defaultStackGroups()
def createGame(self): # create layout l, s = Layout(self), self.s # set window h = l.YS + 7 * l.YOFFSET self.setSize(l.XM + 10 * l.XS, l.YM + l.YS + 2 * h) # create stacks x, y = self.width - l.XS, self.height - l.YS s.talon = InitialDealTalonStack(x, y, self) x, y = l.XM + l.XS, l.YM for i in range(8): s.rows.append( SS_RowStack(x, y, self, dir=1, max_move=1, max_accept=1)) x += l.XS x, y = l.XM + l.XS, l.YM + l.YS + h for i in range(8): s.rows.append( SS_RowStack(x, y, self, dir=-1, max_move=1, max_accept=1)) x += l.XS x, y = l.XM + l.XS, l.YM + h for i in range(8): stack = HeadsAndTails_Reserve(x, y, self) s.reserves.append(stack) l.createText(stack, "n") x += l.XS x, y = l.XM, l.YM for i in range(4): s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) y += l.YS x, y = l.XM + 9 * l.XS, l.YM for i in range(4): s.foundations.append( SS_FoundationStack(x, y, self, suit=i, base_rank=KING, dir=-1)) y += l.YS # define stack-groups l.defaultStackGroups()
def createGame(self): # create layout l, s = Layout(self), self.s Layout.bakersDozenLayout(l, rows=13) self.setSize(l.size[0], l.size[1]) # create stacks s.talon = Cruel_Talon(l.s.talon.x, l.s.talon.y, self, max_rounds=-1) for r in l.s.foundations: s.foundations.append( SS_FoundationStack(r.x, r.y, self, suit=r.suit)) for r in l.s.rows: s.rows.append(SS_RowStack(r.x, r.y, self, base_rank=NO_RANK)) # default l.defaultAll()
def moveMove(self, ncards, to_stack, frames=-1, shadow=-1): game, r = self.game, self.game.s.reserves[0] if to_stack is not r: SS_RowStack.moveMove( self, ncards, to_stack, frames=frames, shadow=shadow) return f = self._canDrawCard() assert f and game.draw_done == 0 and ncards == 1 # 1) top card from self to reserve game.updateStackMove(r, 2 | 16) # update view for undo game.moveMove(1, self, r, frames=frames, shadow=shadow) game.updateStackMove(r, 3 | 64) # update model game.updateStackMove(r, 1 | 16) # update view for redo # 2) second card from self to foundation/row if 1 or not game.demo: game.playSample("drop", priority=200) if frames == 0: frames = -1 game.moveMove(1, self, f, frames=frames, shadow=shadow) # 3) from reserve back to self # (need S_FILL because the move is normally not valid) old_state = game.enterState(game.S_FILL) game.moveMove(1, r, self, frames=frames, shadow=shadow) game.leaveState(old_state)
def canMoveCards(self, cards): if not SS_RowStack.canMoveCards(self, cards): return False # don't work in demo-mode with cloned stack # index = list(self.game.s.rows).index(self) index = self.id col = index % 4 row = index // 4 if index < 16: # left for i in range(col+1, 4): r = self.game.s.rows[row*4+i] if r.cards: return False else: # right for i in range(0, col): r = self.game.s.rows[row*4+i] if r.cards: return False return True
def createGame(self): # create layout l, s = Layout(self), self.s # set window self.setSize(l.XM + 12 * l.XS, l.YM + 3 * l.YS + 14 * l.YOFFSET) # create stacks x, y = l.XM, l.YM for i in range(12): stack = TwelveSleepingMaids_Reserve(x, y, self) stack.CARD_YOFFSET = l.YOFFSET s.reserves.append(stack) x += l.XS x, y = l.XM + 2 * l.XS, l.YM + l.YS + 3 * l.YOFFSET for i in range(8): s.foundations.append( SS_FoundationStack(x, y, self, suit=i // 2, base_rank=KING, mod=13)) x += l.XS x, y = l.XM + 2 * l.XS, l.YM + 2 * l.YS + 3 * l.YOFFSET for i in range(8): s.rows.append(SS_RowStack(x, y, self)) x += l.XS x, y = self.width - l.XS, self.height - l.YS s.talon = WasteTalonStack(x, y, self, max_rounds=3) l.createText(s.talon, 'n') l.createRoundText(s.talon, 'nnn') x -= l.XS s.waste = WasteStack(x, y, self) l.createText(s.waste, 'n') # define stack-groups l.defaultStackGroups()
def createGame(self): # create layout l, s = Layout(self), self.s s.addattr(xwastes=[]) # register extra stack variable # set window w, h = l.XM + 11 * l.XS, l.YM + 6 * l.YS self.setSize(w, h) # create stacks x, y, = l.XM, l.YM s.talon = Interment_Talon(x, y, self) l.createText(s.talon, 'ne') x += 1.5 * 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 for i in range(3): stack = Interment_Waste(x, y, self, max_cards=UNLIMITED_CARDS) l.createText(stack, 'ne') s.xwastes.append(stack) y += l.YS x, y = l.XM + 1.5 * l.XS, l.YM + l.YS for i in range(8): s.rows.append(SS_RowStack(x, y, self, max_move=1)) x += l.XS x, y = self.width - l.XS, l.YM stack = Interment_Reserve(x, y, self) s.reserves.append(stack) l.createText(stack, 'nw') y += l.YS for i in range(5): s.reserves.append(OpenStack(x, y, self)) y += l.YS # define stack-groups l.defaultStackGroups() self.sg.dropstacks += s.xwastes self.sg.openstacks += s.xwastes self.sg.dropstacks.append(s.talon)
def createGame(self): l, s = Layout(self), self.s playcards = 7 w0 = l.XS+(playcards-1)*l.XOFFSET w, h = l.XM + 3*w0 + 4*l.XS, l.YM+6*l.YS self.setSize(w, h) x1, x2 = l.XM, self.width - 2*l.XS for i in range(2): y = l.YM for j in range(4): s.foundations.append(SS_FoundationStack(x1, y, self, suit=j, dir=2, max_cards=7)) s.foundations.append(SS_FoundationStack(x2, y, self, base_rank=1, suit=j, dir=2, max_cards=6)) y += l.YS x1 += l.XS x2 += l.XS x, y = l.XM + 3*l.XS, l.YM for i in (0, 1): stack = SS_RowStack(x, y, self, max_move=1, base_rank=KING) stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0 s.rows.append(stack) x += w0 y = l.YM+l.YS for i in range(4): x = l.XM + 2*l.XS for j in range(3): stack = SS_RowStack(x, y, self, max_move=1, base_rank=KING) stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0 s.rows.append(stack) x += w0 y += l.YS x, y = l.XM + 3*l.XS, l.YM + 5*l.YS for i in (0, 1): stack = SS_RowStack(x, y, self, max_move=1, base_rank=KING) stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0 s.rows.append(stack) x += w0 x, y = l.XM, self.height - l.YS s.talon = ForestGlade_Talon(x, y, self, max_rounds=3) l.createText(s.talon, 'ne') l.createRoundText(s.talon, 'se') l.defaultStackGroups()
def __init__(self, x, y, game, base_rank, yoffset): SS_RowStack.__init__( self, x, y, game, base_rank=base_rank, max_accept=1, max_move=1) self.CARD_YOFFSET = 1
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 SS_RowStack.basicAcceptsCards(self, from_stack, cards)
def acceptsCards(self, from_stack, cards): if len(self.cards) == 0 and len(cards) > 1: return False return SS_RowStack.acceptsCards(self, from_stack, cards)
def acceptsCards(self, from_stack, cards): if not SS_RowStack.acceptsCards(self, from_stack, cards): return False if len(self.cards) < 3: return False return True
def createGame(self): # create layout l, s = Layout(self), self.s # set window self.setSize(l.XM + 6 * l.XS, l.YM + 6 * l.YS + l.TEXT_HEIGHT) # register extra stack variables s.addattr(wastes=[]) # foundations suit = 0 x0, y0 = l.XM + 1.5 * l.XS, l.YM + 1.5 * l.YS + l.TEXT_HEIGHT for xx, yy in ((3, 0), (0, 3), (3, 3), (0, 0)): x, y = x0 + xx * l.XS, y0 + yy * l.YS s.foundations.append( SS_FoundationStack(x, y, self, suit=suit, base_rank=KING, mod=13, max_cards=26, dir=-1, max_move=0)) suit += 1 # rows x0, y0 = l.XM + l.XS, l.YM + l.YS + l.TEXT_HEIGHT for xx, yy in ((0, 2), (2, 0), (4, 2), (2, 4)): x, y = x0 + xx * l.XS, y0 + yy * l.YS stack = SS_RowStack(x, y, self, dir=1, mod=13, max_move=1) stack.getBottomImage = stack._getReserveBottomImage stack.CARD_YOFFSET = 0 s.rows.append(stack) # left stack x, y = l.XM, l.YM + l.YS + l.TEXT_HEIGHT stack = SS_RowStack(x, y, self, base_rank=ACE, dir=1, mod=13, max_move=1) stack.getBottomImage = stack._getReserveBottomImage stack.CARD_YOFFSET = 0 s.rows.append(stack) # reserves x0, y0 = l.XM + 2 * l.XS, l.YM + 2 * l.YS + l.TEXT_HEIGHT for xx, yy, anchor in ((0, 1, 'e'), (1, 0, 's'), (2, 1, 'w'), (1, 2, 'n')): x, y = x0 + xx * l.XS, y0 + yy * l.YS stack = OpenStack(x, y, self) l.createText(stack, anchor) s.reserves.append(stack) # wastes x, y = l.XM + l.XS, l.YM for i in range(5): stack = WasteStack(x, y, self) l.createText(stack, 's', text_format='%D') s.wastes.append(stack) x += l.XS # talon x, y = l.XM, l.YM s.talon = Well_TalonStack(x, y, self, max_rounds=5) l.createText(s.talon, "s") # define stack-groups self.sg.talonstacks = [s.talon] + s.wastes self.sg.openstacks = s.foundations + s.rows self.sg.dropstacks = s.rows + s.wastes + s.reserves
def acceptsCards(self, from_stack, cards): if not SS_RowStack.acceptsCards(self, from_stack, cards): return False if not self.cards: return from_stack is self.game.s.waste return True
def __init__(self, x, y, game, base_rank, yoffset, dir=3, max_cards=4): SS_RowStack.__init__( self, x, y, game, base_rank=base_rank, dir=dir, max_cards=max_cards, max_accept=1) self.CARD_YOFFSET = yoffset
def createGame(self): # create layout l, s = Layout(self), self.s # set window self.setSize(l.XM+6*l.XS, l.YM+6*l.YS+l.TEXT_HEIGHT) # register extra stack variables s.addattr(wastes=[]) # foundations suit = 0 x0, y0 = l.XM+1.5*l.XS, l.YM+1.5*l.YS+l.TEXT_HEIGHT for xx, yy in ((3, 0), (0, 3), (3, 3), (0, 0)): x, y = x0+xx*l.XS, y0+yy*l.YS s.foundations.append(SS_FoundationStack(x, y, self, suit=suit, base_rank=KING, mod=13, max_cards=26, dir=-1, max_move=0)) suit += 1 # rows x0, y0 = l.XM+l.XS, l.YM+l.YS+l.TEXT_HEIGHT for xx, yy in ((0, 2), (2, 0), (4, 2), (2, 4)): x, y = x0+xx*l.XS, y0+yy*l.YS stack = SS_RowStack(x, y, self, dir=1, mod=13, max_move=1) stack.getBottomImage = stack._getReserveBottomImage stack.CARD_YOFFSET = 0 s.rows.append(stack) # left stack x, y = l.XM, l.YM+l.YS+l.TEXT_HEIGHT stack = SS_RowStack( x, y, self, base_rank=ACE, dir=1, mod=13, max_move=1) stack.getBottomImage = stack._getReserveBottomImage stack.CARD_YOFFSET = 0 s.rows.append(stack) # reserves x0, y0 = l.XM+2*l.XS, l.YM+2*l.YS+l.TEXT_HEIGHT for xx, yy, anchor in ((0, 1, 'e'), (1, 0, 's'), (2, 1, 'w'), (1, 2, 'n')): x, y = x0+xx*l.XS, y0+yy*l.YS stack = OpenStack(x, y, self) l.createText(stack, anchor) s.reserves.append(stack) # wastes x, y = l.XM+l.XS, l.YM for i in range(5): stack = WasteStack(x, y, self) l.createText(stack, 's', text_format='%D') s.wastes.append(stack) x += l.XS # talon x, y = l.XM, l.YM s.talon = Well_TalonStack(x, y, self, max_rounds=5) l.createText(s.talon, "s") # define stack-groups self.sg.talonstacks = [s.talon] + s.wastes self.sg.openstacks = s.foundations + s.rows self.sg.dropstacks = s.rows + s.wastes + s.reserves