本文整理汇总了Python中giles.state.State.get_sub方法的典型用法代码示例。如果您正苦于以下问题:Python State.get_sub方法的具体用法?Python State.get_sub怎么用?Python State.get_sub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类giles.state.State
的用法示例。
在下文中一共展示了State.get_sub方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Expeditions
# 需要导入模块: from giles.state import State [as 别名]
# 或者: from giles.state.State import get_sub [as 别名]
#.........这里部分代码省略.........
self.printable_layout = []
self.printable_layout.append(" .---.\n")
# Loop through all table rows.
for row in range(self.suit_count):
left = self.left.data.expeditions[row]
right = self.right.data.expeditions[row]
suit_char = left.suit[0].upper()
left_suit_char = suit_char
right_suit_char = suit_char
expedition_str = get_color_code(left.suit)
expedition_str += self.get_expedition_str(left.hand.reversed()).rjust(18)
if self.bonus and len(left.hand) >= self.bonus_length:
left_suit_char = "*"
if self.bonus and len(right.hand) >= self.bonus_length:
right_suit_char = "*"
expedition_str += " %s %s %s " % (left_suit_char, self.get_discard_str(row), right_suit_char)
expedition_str += self.get_expedition_str(right.hand)
expedition_str += "^~\n"
self.printable_layout.append(expedition_str)
self.printable_layout.append(" | |\n")
# Replace the last unnecessary separator row with the end of the board.
self.printable_layout[-1] = " `---'\n"
def get_metadata_str(self):
to_return = "^Y%s^~ remain in the draw pile.\n" % get_plural_str(len(self.draw_pile), "card")
if not self.turn:
to_return += "The game has not started yet.\n"
else:
to_return += "It is %s's turn to " % self.get_sp_str(self.turn)
sub = self.state.get_sub()
if sub == "play":
to_return += "^cplay a card^~.\n"
else:
to_return += "^cdraw a card^~.\n"
to_return += "The goal score for this game is ^Y%s^~.\n" % get_plural_str(self.goal, "point")
to_return += "Overall: %s: %s %s: %s\n" % (self.get_sp_str(self.left), self.left.data.overall_score, self.get_sp_str(self.right), self.right.data.overall_score)
return to_return
def show(self, player, show_metadata=True):
if not self.printable_layout:
self.update_printable_layout()
player.tell_cc("%s %s\n" % (self.get_sp_str(self.left).rjust(21), self.get_sp_str(self.right)))
for line in self.printable_layout:
player.tell_cc(line)
if show_metadata:
player.tell_cc("\n" + self.get_metadata_str())
def show_hand(self, player):
seat = self.get_seat_of_player(player)
if not seat:
self.tell_pre(player, "You're not playing!\n")
return
print_str = "Your current hand:\n "
print_str += hand_to_str(seat.data.hand)
print_str += "\n"
self.tell_pre(player, print_str)