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


Python Board.place_spell方法代码示例

本文整理汇总了Python中Board.place_spell方法的典型用法代码示例。如果您正苦于以下问题:Python Board.place_spell方法的具体用法?Python Board.place_spell怎么用?Python Board.place_spell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Board的用法示例。


在下文中一共展示了Board.place_spell方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import Board [as 别名]
# 或者: from Board import place_spell [as 别名]

#.........这里部分代码省略.........
                        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

    def play_building(self, building_name, id, slot):
        """ Plays a buidling at a given position (0-4 inclusive) for id"""
        if (self.board.buildings[id][slot]):
            logging.debug("{0} not playable at {1}".format(building_name, slot))
            return False
        card = self.players[id].play(building_name)
        if card == None:
            return False

        self.board.place_building(card, self.players[id], slot)
        return True

    def put_in_play(self, card, id, position):
        """ puts a unit into play without paying the cost """
        self.board.is_playable(self.players[id], position)
        self.players[id].inplay.append(card)
        self.board.grid[(position)] = Unit.get_unit(card, self.players[id])

    def apply_phase_effects(self):
        """
        Go through each building and apply its Effect
        TODO: Should go through everything on the board and apply effects.
        TODO: Make this phase independent
        """
        first = self.get_turn_advantage()
        second = (first + 1) % 2
        self.apply_phase_effects_for_player(first, second)
        self.apply_phase_effects_for_player(second, first)

    def apply_phase_effects_for_player(self, player_id, opponent_id):
        for object in self.board.get_everything():
            if object and object.upkeep_effect and \
                    object.owner_id == player_id:
                Effect.applyEffect(
                    object.upkeep_effect,
                    self.players[player_id],
                    self.players[opponent_id],
                    object,
                    self.board,
                    object.upkeep_effect_args
                )
开发者ID:dustice,项目名称:grimwar,代码行数:104,代码来源:Game.py


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