本文整理汇总了Python中giles.state.State.set_sub方法的典型用法代码示例。如果您正苦于以下问题:Python State.set_sub方法的具体用法?Python State.set_sub怎么用?Python State.set_sub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类giles.state.State
的用法示例。
在下文中一共展示了State.set_sub方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Expeditions
# 需要导入模块: from giles.state import State [as 别名]
# 或者: from giles.state.State import set_sub [as 别名]
#.........这里部分代码省略.........
print_str += "\n"
self.tell_pre(player, print_str)
def send_layout(self, show_metadata=True):
for player in self.channel.listeners:
self.show(player, show_metadata)
for seat in self.seats:
if seat.player:
self.show_hand(seat.player)
def deal(self):
# Deal cards until each player has hand_size cards.
self.bc_pre("A fresh hand is dealt to both players.\n")
for i in range(self.hand_size):
self.left.data.hand.add(self.draw_pile.discard())
self.right.data.hand.add(self.draw_pile.discard())
# Sort hands.
self.left.data.hand = sorted_hand(self.left.data.hand)
self.right.data.hand = sorted_hand(self.right.data.hand)
# Clear scores.
self.left.data.curr_score = 0
self.right.data.curr_score = 0
def tick(self):
# If both seats are full and the game is active, autostart.
if (self.state.get() == "need_players" and self.seats[0].player
and self.seats[1].player and self.active):
self.state.set("playing")
self.state.set_sub("play")
self.bc_pre("^CLeft^~: ^Y%s^~; ^MRight^~: ^Y%s^~\n" %
(self.left.player_name, self.right.player_name))
self.turn = self.left
self.first_player = self.left
self.deal()
self.send_layout()
def calculate_deck_size(self, suits, agrees):
# Eventually this will depend on just what cards are in the deck,
# but for now there are 9 point cards per suit plus the agreements.
return (9 + agrees) * suits
def set_suits(self, player, suit_str):
if not suit_str.isdigit():
self.tell_pre(player, "You didn't even send a number!\n")
return False
new_suit_count = int(suit_str)
if new_suit_count < MIN_SUITS or new_suit_count > MAX_SUITS:
self.tell_pre(player, "The number of suits must be between %d and %d inclusive.\n" % (MIN_SUITS, MAX_SUITS))
return False
# Does this give too few cards for the hand size?
if self.calculate_deck_size(new_suit_count, self.agreement_count) <= self.hand_size * 2:
self.tell_pre(player, "That number of suits is too small for the hand size.\n")
return False
# Valid.
self.suit_count = new_suit_count
self.bc_pre("^M%s^~ has changed the suit count to ^G%s^~.\n" % (player, new_suit_count))