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


Python Board.process_spells方法代码示例

本文整理汇总了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
开发者ID:dustice,项目名称:grimwar,代码行数:70,代码来源:Game.py


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