本文整理汇总了Python中Board.is_playable方法的典型用法代码示例。如果您正苦于以下问题:Python Board.is_playable方法的具体用法?Python Board.is_playable怎么用?Python Board.is_playable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Board
的用法示例。
在下文中一共展示了Board.is_playable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import Board [as 别名]
# 或者: from Board import is_playable [as 别名]
#.........这里部分代码省略.........
for modifier in player.modifiers:
modifier.cleanupLogic(self.board)
for spell in self.board.spells[id]:
if spell is not None:
for modifier in spell.modifiers:
modifier.cleanupLogic(self.board)
for building in self.board.buildings[id]:
if building is not None:
for modifier in building.modifiers:
modifier.cleanupLogic(self.board)
num_removed = self.board.remove_dead()
# Calculate Gameover
is_tie = True
for id, player in self.players.iteritems():
if player.get_curr_health() > 0:
is_tie = False
for id, player in self.players.iteritems():
if player.get_curr_health() <= 0:
return 'Tie' if is_tie else (id + 1) % 2
return None
def get_turn_advantage(self):
return self.turn_advantage
def calculate_advantage(self):
return self.board.get_next_turn_advantage()
def play_unit(self, card_name, id, position):
"""plays a card for player id from his hand at position (u,v)"""
if not self.board.is_playable(self.players[id], position):
logging.debug("{0} not playable at {1}".format(card_name, position))
return False
card = self.players[id].play(card_name)
if card == None:
return False
unit = self.board.place_unit(card, self.players[id], position)
if unit.play_effect != None:
Effect.applyEffect(
unit.play_effect,
self.players[id],
self.players[(id + 1) % 2],
unit,
self.board,
unit.play_effect_args
)
return True
def play_spell(self, spell_name, id, slot):
""" Plays a spell at a given position (0-4 inclusive) for id"""
if (self.board.spells[id][slot]):
logging.debug("{0} not playable at {1}".format(spell_name, slot))
return False
card = self.players[id].play(spell_name)
if card == None:
return False
self.board.place_spell(card, self.players[id], slot)
return True