本文整理匯總了Python中pysollib.stack.BasicRowStack類的典型用法代碼示例。如果您正苦於以下問題:Python BasicRowStack類的具體用法?Python BasicRowStack怎麽用?Python BasicRowStack使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了BasicRowStack類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: createGame
def createGame(self):
l, s = Layout(self), self.s
self.setSize(l.XM+8.5*l.XS, l.YM+4*l.YS)
y = l.YM
suit = 0
for i in (0, 1, 3, 4):
x = l.XM+(2+i)*l.XS
s.foundations.append(SS_FoundationStack(x, y, self, suit=suit))
suit += 1
x, y = l.XM+4*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
for i, j in ((0, 0), (1, 0), (2, 0), (5, 0), (6, 0), (7, 0),
(0, 1), (1, 1), (2, 1), (5, 1), (6, 1), (7, 1),
):
x, y = l.XM+(0.5+i)*l.XS, l.YM+(1.5+j)*l.YS
stack = BasicRowStack(x, y, self, max_accept=0)
s.rows.append(stack)
stack.CARD_YOFFSET = 0
x, y = l.XM, l.YM
s.talon = DealRowRedealTalonStack(x, y, self, max_rounds=3)
l.createText(s.talon, 'se')
l.createRoundText(s.talon, 'ne')
l.defaultStackGroups()
示例2: createGame
def createGame(self):
# create layout
l, s = Layout(self), self.s
# set window
w, h = max(2*l.XM+2*l.XS+(5+13)*l.XOFFSET, l.XM + 8*l.XS), l.YM+8*l.YS
self.setSize(w, h)
# create stacks
x, y, = l.XM, l.YM
for i in range(4):
stack = BasicRowStack(x, y, self, max_move=1, max_accept=0)
stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0
s.rows.append(stack)
y += l.YS
x, y, = 2*l.XM+l.XS+5*l.XOFFSET, l.YM
for i in range(4):
stack = Osmosis_Foundation(
x, y, self, i, base_rank=ANY_RANK, max_move=0)
stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0
s.foundations.append(stack)
y += l.YS
y = l.YM + 4*l.YS
for i in range(4):
x = l.XM
for j in range(8):
s.reserves.append(OpenStack(x, y, self, max_accept=0))
x += l.XS
y += l.YS
x, y = w-l.XS, l.YM
s.talon = InitialDealTalonStack(x, y, self)
# define stack-groups
l.defaultStackGroups()
示例3: createGame
def createGame(self):
l, s = Layout(self), self.s
w0 = l.XS+5*l.XOFFSET
self.setSize(l.XM+5*w0, l.YM+5*l.YS)
x, y = l.XM, l.YM
for i in range(3):
s.reserves.append(TripleAlliance_Reserve(x, y, self))
x += l.XS
x, y = self.width-l.XS, l.YM
s.foundations.append(AbstractFoundationStack(x, y, self, suit=ANY_SUIT,
max_move=0, max_accept=0, max_cards=52))
l.createText(s.foundations[0], 'nw')
y = l.YM+l.YS
nstacks = 0
for i in range(4):
x = l.XM
for j in range(5):
stack = BasicRowStack(x, y, self, max_accept=0)
s.rows.append(stack)
stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0
x += w0
nstacks += 1
if nstacks >= 18:
break
y += l.YS
x, y = self.width-l.XS, self.height-l.YS
s.talon = InitialDealTalonStack(x, y, self)
l.defaultStackGroups()
示例4: moveMove
def moveMove(self, ncards, to_stack, frames=-1, shadow=-1):
assert ncards == 1 and to_stack in self.game.s.rows
if to_stack.cards:
self._dropPairMove(ncards, to_stack, frames=-1, shadow=shadow)
else:
BasicRowStack.moveMove(
self, ncards, to_stack, frames=frames, shadow=shadow)
示例5: acceptsCards
def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards):
return False
if self.id % self.game.RSTEP == 0:
return cards[0].rank == self.game.RBASE
left = self.game.s.rows[self.id - 1]
return left.cards and left.cards[-1].rank + 1 == cards[0].rank
示例6: acceptsCards
def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards):
return False
# check
if self.cards or self.game.s.talon.cards:
return False
return True
示例7: acceptsCards
def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards):
return False
if from_stack is self.game.s.talon or \
from_stack in self.game.s.reserves:
return True
return False
示例8: acceptsCards
def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards):
return False
if not self.cards:
return True
c1, c2 = self.cards[-1], cards[0]
if c1.rank == c2.rank+1:
return True
return c1.rank == c2.rank
示例9: acceptsCards
def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards):
return False
if self.cards:
# check the rank - an ACE equals a Six
rank = self.cards[-1].rank
if rank == ACE:
rank = 5
if (rank + self.cap.dir) % self.cap.mod != cards[0].rank:
return False
return True
示例10: createGame
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()
示例11: createGame
def createGame(self, rows=(7, 7, 7, 5)):
# create layout
l, s = Layout(self), self.s
# set window
w, h = l.XM+max(
max(rows)*(l.XS+3*l.XOFFSET), 9*l.XS), l.YM+(len(rows)+2)*l.YS
self.setSize(w, h)
# create stacks
x, y = l.XM+(w-l.XM-8*l.XS)//2, l.YM
for i in range(4):
s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
x += l.XS
for i in range(4):
s.foundations.append(SS_FoundationStack(x, y, self,
base_rank=KING, suit=i, dir=-1))
x += l.XS
n = 0
y = l.YM+l.YS
for i in rows:
x = l.XM
for j in range(i):
stack = BasicRowStack(x, y, self, max_move=1, max_accept=0)
stack.CARD_XOFFSET, stack.CARD_YOFFSET = l.XOFFSET, 0
s.rows.append(stack)
x += l.XS+3*l.XOFFSET
n += 1
y += l.YS
x, y = l.XM+(w-l.XM-8*l.XS)//2, h-l.YS
for i in range(8):
s.reserves.append(ReserveStack(x, y, self))
x += l.XS
s.talon = InitialDealTalonStack(w-l.XS, h-l.YS, self)
# default
l.defaultAll()
示例12: createGame
def createGame(self, rows=4):
# create layout
max_rows = max(10, 4+rows)
l, s = Layout(self), self.s
# set window
w, h = l.XM+max_rows*l.XS, l.YM+2*l.YS+18*l.YOFFSET
self.setSize(w, h)
# create stacks
x, y = l.XM, l.YM
s.talon = GrandDuchess_Talon(x, y, self, max_rounds=4)
l.createText(s.talon, 'se')
l.createRoundText(s.talon, 'ne')
x += 2*l.XS
for i in range(4):
s.foundations.append(SS_FoundationStack(x, y, self, suit=i))
x += l.XS
for i in range(4):
s.foundations.append(SS_FoundationStack(x, y, self,
suit=i, base_rank=KING, dir=-1))
x += l.XS
x, y = l.XM+(max_rows-rows)*l.XS//2, l.YM+l.YS
for i in range(rows):
stack = BasicRowStack(x, y, self, max_move=1, max_accept=0)
stack.CARD_YOFFSET = l.YOFFSET
s.rows.append(stack)
x += l.XS
dx = (max_rows-rows)*l.XS//4-l.XS//2
x, y = l.XM+dx, l.YM+l.YS
s.reserves.append(GrandDuchess_Reserve(x, y, self))
x, y = self.width-dx-l.XS, l.YM+l.YS
s.reserves.append(GrandDuchess_Reserve(x, y, self))
# define stack-groups
l.defaultStackGroups()
示例13: canMoveCards
def canMoveCards(self, cards):
if not BasicRowStack.canMoveCards(self, cards):
return False
c1 = cards[0]
for c2 in cards[1:]:
if c1.suit != c2.suit:
return False
# check the rank - an ACE equals a Six
rank = c1.rank
if rank == ACE:
rank = 5
if (rank + self.cap.dir) % self.cap.mod != c2.rank:
return False
c1 = c2
return True
示例14: acceptsCards
def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards):
return False
if self.id % 10 != 0:
# left neighbour
s = self.game.s.rows[self.id - 1]
if s.cards and s.cards[-1].suit == cards[0].suit \
and (s.cards[-1].rank + 1) % 13 == cards[0].rank:
return True
if self.id % 10 != 10 - 1:
# right neighbour
s = self.game.s.rows[self.id + 1]
if s.cards and s.cards[-1].suit == cards[0].suit \
and (s.cards[-1].rank - 1) % 13 == cards[0].rank:
return True
return False
示例15: acceptsCards
def acceptsCards(self, from_stack, cards):
if not BasicRowStack.acceptsCards(self, from_stack, cards):
return False
# this stack accepts any one card from the Waste pile
return from_stack is self.game.s.waste