本文整理汇总了Python中Board.process_spells方法的典型用法代码示例。如果您正苦于以下问题:Python Board.process_spells方法的具体用法?Python Board.process_spells怎么用?Python Board.process_spells使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Board
的用法示例。
在下文中一共展示了Board.process_spells方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import Board [as 别名]
# 或者: from Board import process_spells [as 别名]
#.........这里部分代码省略.........
# Reduce the health of every unit that is out of will by 1/3
for location, unit in self.board.grid.iteritems():
if unit.get_curr_ammo() <= 0:
unit._hp -= int(math.ceil(float(unit._max_hp) / 3.0))
def move_phase(self):
first = self.get_turn_advantage()
second = (first + 1) % 2
self.board.do_movements(self.players[first], self.players[second])
def money_phase(self):
"""
Workers get money from the sector they end up in, but should only be
paid for a sector once per life.
"""
for location, unit in self.board.grid.iteritems():
if isinstance(unit, Worker):
sector = self.board.get_sector_for_position(location)
# Flip sector for p1
if unit.owner_id == 1:
sector = len(self.board.SECTOR_COLS) - 1 - sector
if sector not in unit.visited_sectors:
payout = unit.payout[len(unit.visited_sectors)]
players[unit.owner_id].gold += payout
logging.info("{0} gold gained for sector {1}".format(payout, sector))
unit.visited_sectors.append(sector)
def spell_phase(self):
# Spell logic
first = self.get_turn_advantage()
second = (first + 1) % 2
self.board.process_spells(self.players[first], self.players[second])
self.board.process_spells(self.players[second], self.players[first])
def cleanup_phase(self):
logging.info("Start of cleanup phase")
num_removed = True
while (num_removed):
"""
We run cleanup whenever shit may be needed to be removed from
the board. Cleanup will go through every modifier and check if it
needs to go, then check if any units need to go. It'll keep doing
this until no units die (meaning no modifiers will change, meaning
we've reached a stable state)
"""
for location, unit in self.board.grid.iteritems():
for modifier in unit.modifiers:
modifier.cleanupLogic(self.board)
for id, player in self.players.iteritems():
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