当前位置: 首页>>代码示例>>Python>>正文


Python Error.print_error方法代码示例

本文整理汇总了Python中error.Error.print_error方法的典型用法代码示例。如果您正苦于以下问题:Python Error.print_error方法的具体用法?Python Error.print_error怎么用?Python Error.print_error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在error.Error的用法示例。


在下文中一共展示了Error.print_error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: suitable_pile_pop

# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import print_error [as 别名]
 def suitable_pile_pop(self, bottomCard):
     """
     each Card in the pile
     is face-up, the pile alternates in color, and the pile is
     built top down. Additionally, all Cards in the given pile must
     be face-up.
     """
     if bottomCard is None:
         Error.print_error(Error.CARD_IS_NONE, lineno())
         return False
     if bottomCard.is_face_down():
         Error.print_error(Error.CARD_IS_FACE_DOWN, lineno())
         return False
     idx = self.index(bottomCard)
     popped = self[idx:]
     evenColor = bottomCard.color()
     for i in range(len(popped)):
         c = popped[i]
         if c.is_face_down():
             Error.print_error(Error.CARD_IS_FACE_DOWN, lineno())
         if c.rank != bottomCard.rank - i:
             Error.print_error(Error.INVALID_RANK, lineno())
         if i % 2 == 0 and c.color() != evenColor or i % 2 == 1 and c.color() == evenColor:
             Error.print_error(Error.INVALID_COLOR, lineno())
         if (
             c.is_face_down()
             or c.rank != bottomCard.rank - i
             or i % 2 == 0
             and c.color() != evenColor
             or i % 2 == 1
             and c.color() == evenColor
         ):
             return False
     return True
开发者ID:jakumeowski,项目名称:solitaire-game,代码行数:36,代码来源:tableau.py

示例2: suitable_card_pop

# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import print_error [as 别名]
 def suitable_card_pop(self):
     """
     @todo: commentme
     """
     if self.is_empty():
         Error.print_error(Error.EMPTY_PILE, lineno())
     return not self.is_empty()
开发者ID:jakumeowski,项目名称:solitaire-game,代码行数:9,代码来源:tableau.py

示例3: enqueue_card

# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import print_error [as 别名]
 def enqueue_card(self, card):
     """
     The same as enqueue(), but overwritten by Pile subclasses. Only
     legal for Stock piles.
     """
     if self.suitable_card_enqueue(card):
         return self.enqueue(card)
     Error.print_error(Error.ILLEGAL_ENQUEUE_CARD, lineno())
开发者ID:jakumeowski,项目名称:solitaire-game,代码行数:10,代码来源:pile.py

示例4: pop_card

# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import print_error [as 别名]
 def pop_card(self):
     """
     Equivalent to deque.pop(), but is overridden by Pile subclasses
     for additional functionality.
     """
     if self.suitable_card_pop():
         return self.pop()
     Error.print_error(Error.ILLEGAL_POP_CARD, lineno())
开发者ID:jakumeowski,项目名称:solitaire-game,代码行数:10,代码来源:pile.py

示例5: push_card

# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import print_error [as 别名]
 def push_card(self, card):
     """
     The same as push(), but is overridden by Pile subclasses to 
     check if pushing the Card to this Pile is legal.
     """
     if self.suitable_card_push(card):
         return self.push(card)
     Error.print_error(Error.ILLEGAL_PUSH_CARD, lineno())
开发者ID:jakumeowski,项目名称:solitaire-game,代码行数:10,代码来源:pile.py

示例6: suitable_pile_pop

# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import print_error [as 别名]
 def suitable_pile_pop(self, bottomCard):
     """
     @todo: commentme
     """
     if bottomCard is None:
         Error.print_error(Error.CARD_IS_NONE, lineno())
     if not bottomCard in self:
         Error.print_error(Error.CARD_NOT_IN_PILE, lineno())
     return bottomCard is not None and bottomCard in self
开发者ID:jakumeowski,项目名称:solitaire-game,代码行数:11,代码来源:pile.py

示例7: push_pile

# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import print_error [as 别名]
 def push_pile(self, pile):
     """
     Pushes a list of Cards to the top of this Pile, if it is legal 
     to do so. Overridden by subclasses for which pushing a Pile is 
     legal.
     """
     if self.suitable_pile_push(pile):
         return self.extend(pile)
     Error.print_error(Error.ILLEGAL_PUSH_PILE, lineno())
开发者ID:jakumeowski,项目名称:solitaire-game,代码行数:11,代码来源:pile.py

示例8: suitable_card_enqueue

# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import print_error [as 别名]
 def suitable_card_enqueue(self, card):
     """
     Enqueues the specified card to this Pile if it exists and if
     this Pile is not full. Overridden by subclasses.
     """
     if card is None:
         Error.print_error(Error.CARD_IS_NONE, lineno(), False)
     if len(self) >= self.maxlen:
         Error.print_error(Error.EXCEEDS_MAXIMUM, lineno(), False)
     return card is not None and len(self) < self.maxlen
开发者ID:jakumeowski,项目名称:solitaire-game,代码行数:12,代码来源:pile.py

示例9: card_at

# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import print_error [as 别名]
 def card_at(self, idx):
     """
     Returns the Card at the specified index in this Pile, if the
     index is valid. Otherwise, prints an error message and returns
     None.
     """
     size = len(self)
     if idx >= -size and idx < size:
         return self[idx]
     Error.print_error(Error.INVALID_INDEX, lineno())
开发者ID:jakumeowski,项目名称:solitaire-game,代码行数:12,代码来源:pile.py

示例10: suitable_card_push

# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import print_error [as 别名]
 def suitable_card_push(self, card):
     """
     A suitable card is a card whose value and suit fit them to be
     played or placed onto a pile.
     
     Overridden by subclasses.
     """
     if card is None:
         Error.print_error(Error.CARD_IS_NONE, lineno())
     if len(self) >= self.maxlen:
         Error.print_error(Error.EXCEEDS_MAXIMUM, lineno())
     return card is not None and len(self) < self.maxlen
开发者ID:jakumeowski,项目名称:solitaire-game,代码行数:14,代码来源:pile.py

示例11: suitable_pile_enqueue

# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import print_error [as 别名]
 def suitable_pile_enqueue(self, pile):
     """
     A pile is suitable if it can be legally enqueued to this
     Pile.
     """
     if pile is None:
         return Error.print_error(Error.PILE_IS_NONE, lineno(), False)
     if len(pile) == 1:
         return self.suitable_card_enqueue(self, pile[0])
     if len(self) + len(pile) >= self.maxlen:
         Error.print_error(Error.EXCEEDS_MAXIMUM, lineno())
     return (pile is not None and 
             len(self) + len(pile) < self.maxlen)
开发者ID:jakumeowski,项目名称:solitaire-game,代码行数:15,代码来源:pile.py

示例12: suitable_pile_push

# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import print_error [as 别名]
 def suitable_pile_push(self, pile):
     """
     A suitable pile is a pile of cards that will be accepted
     upon push.
     
     Overridden by subclasses.
     """
     if pile is None:
         Error.print_error(Error.PILE_IS_NONE, lineno())
     if len(self) + len(pile) >= self.maxlen:
         Error.print_error(Error.EXCEEDS_MAXIMUM, lineno())
     return (pile is not None and 
             len(self) + len(pile) < self.maxlen)
开发者ID:jakumeowski,项目名称:solitaire-game,代码行数:15,代码来源:pile.py

示例13: is_complete

# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import print_error [as 别名]
 def is_complete(self):
     """
     Returns true if this Pile contains all 13 Cards of
     its suit in ascending order.
     """
     for i in range(len(self)):
         card = self[i]
         if card.rank != i + 1:
             Error.print_error(Error.INVALID_RANK, lineno())
         if card.suit != self.suit:
             Error.print_error(Error.INVALID_SUIT, lineno())
         if card.rank != i + 1 or card.suit != self.suit:
             return False
     return len(self) == self.maxlen
开发者ID:jakumeowski,项目名称:solitaire-game,代码行数:16,代码来源:foundation.py

示例14: index

# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import print_error [as 别名]
 def index(self, card):
     """
     Returns the index of the specified Card in the Pile, if the 
     Card is in this Pile. Otherwise, prints an error message and
     returns None.
     """
     if card is None:
         return Error.print_error(Error.CARD_IS_NONE, lineno())
     
     # If the card is valid, search for its index in this Pile.
     for i in range(len(self)):
         if self.card_at(i) == card:
             return i
     Error.print_error(Error.CARD_NOT_IN_PILE, lineno())
开发者ID:jakumeowski,项目名称:solitaire-game,代码行数:16,代码来源:pile.py

示例15: suitable_pile_pop

# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import print_error [as 别名]
 def suitable_pile_pop(self, bottomCard):
     """
     Piles of cards cannot be popped from a Foundation pile.
     """
     if bottomCard == self.peek():
         return True
     return Error.print_error(Error.ILLEGAL_POP_PILE, lineno(), False)
开发者ID:jakumeowski,项目名称:solitaire-game,代码行数:9,代码来源:foundation.py


注:本文中的error.Error.print_error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。