本文整理匯總了Python中pysollib.stack.AbstractFoundationStack.acceptsCards方法的典型用法代碼示例。如果您正苦於以下問題:Python AbstractFoundationStack.acceptsCards方法的具體用法?Python AbstractFoundationStack.acceptsCards怎麽用?Python AbstractFoundationStack.acceptsCards使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pysollib.stack.AbstractFoundationStack
的用法示例。
在下文中一共展示了AbstractFoundationStack.acceptsCards方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: acceptsCards
# 需要導入模塊: from pysollib.stack import AbstractFoundationStack [as 別名]
# 或者: from pysollib.stack.AbstractFoundationStack import acceptsCards [as 別名]
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return False
if not self.cards:
return True
dir = self._getDir()
return (self.cards[-1].rank+dir) % self.cap.mod == cards[0].rank
示例2: acceptsCards
# 需要導入模塊: from pysollib.stack import AbstractFoundationStack [as 別名]
# 或者: from pysollib.stack.AbstractFoundationStack import acceptsCards [as 別名]
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return False
if self.cards:
# check the rank
if (2 * self.cards[-1].rank + 1) % self.cap.mod != cards[0].rank:
return False
return True
示例3: acceptsCards
# 需要導入模塊: from pysollib.stack import AbstractFoundationStack [as 別名]
# 或者: from pysollib.stack.AbstractFoundationStack import acceptsCards [as 別名]
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return False
# check the rank
if self.cards:
r1, r2 = self.cards[-1].rank, cards[0].rank
return (r1 + 1) % self.cap.mod == r2
return True
示例4: acceptsCards
# 需要導入模塊: from pysollib.stack import AbstractFoundationStack [as 別名]
# 或者: from pysollib.stack.AbstractFoundationStack import acceptsCards [as 別名]
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return False
# check the rank
if len(self.cards) > 12:
return cards[0].rank == 25 - len(self.cards)
else:
return cards[0].rank == len(self.cards)
示例5: acceptsCards
# 需要導入模塊: from pysollib.stack import AbstractFoundationStack [as 別名]
# 或者: from pysollib.stack.AbstractFoundationStack import acceptsCards [as 別名]
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return False
c = cards[0]
for s in self.game.s.rows:
if s is not from_stack and s.cards and s.cards[-1].suit == c.suit:
if s.cards[-1].rank > c.rank or s.cards[-1].rank == ACE:
# found a higher rank or an Ace on the row stacks
return c.rank != ACE
return False
示例6: acceptsCards
# 需要導入模塊: from pysollib.stack import AbstractFoundationStack [as 別名]
# 或者: from pysollib.stack.AbstractFoundationStack import acceptsCards [as 別名]
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return False
if self.game.base_rank is None:
return True
if not self.cards:
return cards[-1].rank == self.game.base_rank
# check the rank
return (self.cards[-1].rank + self.cap.dir) % \
self.cap.mod == cards[0].rank
示例7: acceptsCards
# 需要導入模塊: from pysollib.stack import AbstractFoundationStack [as 別名]
# 或者: from pysollib.stack.AbstractFoundationStack import acceptsCards [as 別名]
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.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
示例8: acceptsCards
# 需要導入模塊: from pysollib.stack import AbstractFoundationStack [as 別名]
# 或者: from pysollib.stack.AbstractFoundationStack import acceptsCards [as 別名]
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return 0
if not self.cards:
return cards[0].suit == self.game.base_card.suit
stack_dir = self.game.getFoundationDir()
if stack_dir == 0:
card_dir = (cards[0].suit - self.cards[-1].suit) % 12
return card_dir in (1, 11)
else:
return (self.cards[-1].suit + stack_dir) % 12 == cards[0].suit
示例9: acceptsCards
# 需要導入模塊: from pysollib.stack import AbstractFoundationStack [as 別名]
# 或者: from pysollib.stack.AbstractFoundationStack import acceptsCards [as 別名]
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return 0
if not self.cards:
return 1
stack_dir = self.game.getFoundationDir()
if stack_dir == 0:
card_dir = (cards[0].rank - self.cards[-1].rank) % self.cap.mod
return card_dir in (1, 15)
else:
return (self.cards[-1].rank + stack_dir) % self.cap.mod \
== cards[0].rank
示例10: acceptsCards
# 需要導入模塊: from pysollib.stack import AbstractFoundationStack [as 別名]
# 或者: from pysollib.stack.AbstractFoundationStack import acceptsCards [as 別名]
def acceptsCards(self, from_stack, cards):
if not (from_stack in self.game.s.rows and
AbstractFoundationStack.acceptsCards(self, from_stack, cards)):
return 0
pile, rank, suit = from_stack.getPile(), 0, 0
if self.cards:
rank = (self.cards[-1].rank + 1) % 12
suit = self.cards[-1].suit + (rank == 0)
if (not pile or len(pile) <= 11 - rank or
not isSameSuitSequence(pile[-(12 - rank):])):
return 0
return cards[0].suit == suit and cards[0].rank == rank
示例11: acceptsCards
# 需要導入模塊: from pysollib.stack import AbstractFoundationStack [as 別名]
# 或者: from pysollib.stack.AbstractFoundationStack import acceptsCards [as 別名]
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return False
if not self.cards:
return True
stack_dir = self.game.getFoundationDir()
if stack_dir == 0:
card_dir = self.getRankDir(cards=(self.cards[-1], cards[0]))
return card_dir in (1, -1)
else:
return ((self.cards[-1].rank + stack_dir) %
self.cap.mod == cards[0].rank)
示例12: acceptsCards
# 需要導入模塊: from pysollib.stack import AbstractFoundationStack [as 別名]
# 或者: from pysollib.stack.AbstractFoundationStack import acceptsCards [as 別名]
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return False
# search foundation with max number of cards
assert len(cards) == 1
max_s, max_cards = None, -1
for s in self.game.s.foundations:
if len(s.cards) > max_cards:
max_s, max_cards = s, len(s.cards)
# if we have less cards, then rank must match the card in this
# foundation
if len(self.cards) < max_cards:
if cards[0].rank != max_s.cards[len(self.cards)].rank:
return False
#
return True
示例13: acceptsCards
# 需要導入模塊: from pysollib.stack import AbstractFoundationStack [as 別名]
# 或者: from pysollib.stack.AbstractFoundationStack import acceptsCards [as 別名]
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return False
if from_stack not in self.game.s.rows:
return False
if cards[0].rank == ACE:
return True
if not self.cards:
return False
rank = self.cards[-1].rank
if rank == ACE:
rank = 5
if (rank + self.cap.dir) % self.cap.mod != cards[0].rank:
return False
if cards[0].rank == QUEEN:
return True
i = list(self.game.s.foundations).index(self)
j = list(self.game.s.rows).index(from_stack)
return i == j
示例14: acceptsCards
# 需要導入模塊: from pysollib.stack import AbstractFoundationStack [as 別名]
# 或者: from pysollib.stack.AbstractFoundationStack import acceptsCards [as 別名]
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return False
return isSameColorSequence(cards, self.cap.mod, self.cap.dir)
示例15: acceptsCards
# 需要導入模塊: from pysollib.stack import AbstractFoundationStack [as 別名]
# 或者: from pysollib.stack.AbstractFoundationStack import acceptsCards [as 別名]
def acceptsCards(self, from_stack, cards):
if not AbstractFoundationStack.acceptsCards(self, from_stack, cards):
return False
# We accept any King. Pairs will get delivered by _dropPairMove.
return cards[0].rank == KING