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


Python Game.play_building方法代码示例

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


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

示例1: __init__

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import play_building [as 别名]
class BaseController:
    def __init__(self):
        self.game = Game(input_type='')

        self.game.pre_main_phases()

    #up to controller to decide what exactly this advances
    def advance(self):
        result = self.game.post_main_phases()
        if result is not None:
            return result

        self.game.pre_main_phases()

    def buy_card(self, player_id, card_name):
        player = self.game.players[player_id]
        player.buy(card_name)
        
    def play_unit_card(self, card, player_id, location):
        self.game.play_unit(card, player_id, location)

    def play_spell_card(self, card, player_id, slot):
        self.game.play_spell(card, player_id, slot)

    def play_building_card(self, card, player_id, slot):
        self.game.play_building(card, player_id, slot)
开发者ID:dustice,项目名称:grimwar,代码行数:28,代码来源:BaseController.py

示例2: __init__

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import play_building [as 别名]
class SimulatorController:
    def __init__(self):
        self.game = Game(input_type='')

        self.game.pre_main_phases()

        self._init_simulator_casting_hexes()

    def advance(self):
        result = self.game.post_main_phases()
        if result is not None:
            return result

        self.game.pre_main_phases()

    def play_unit_card(self, card_name, player_id, location):
        self.add_card_and_gold(card_name, player_id)
        self.game.play_unit(card_name, player_id, location)

    def play_spell_card(self, card_name, player_id, slot):
        self.add_card_and_gold(card_name, player_id)
        self.game.play_spell(card_name, player_id, slot)

    def play_building_card(self, card_name, player_id, slot):
        self.add_card_and_gold(card_name, player_id)
        self.game.play_building(card_name, player_id, slot)

    def clear(self):
        self.game.reset()

    def next(self):
        self.advance()

    def add_card_and_gold(self, card_name, player_id):
        card = Card.get_card(card_name)
        self.game.players[player_id].hand.append(card)
        self.game.players[player_id].gold += card.cost

    def _init_simulator_casting_hexes(self):
        sector_dict = {}
        for x in xrange(self.game.board.field_length):
            for y in xrange(self.game.board.field_width):
                if x == self.game.board.field_length - 1 and y % 2 == 1:
                    continue
                pos = BoardTools.get_backend_position_for_visual_position((x, y), self.game.board.field_width)
                sector = self.game.board.get_sector_for_position(pos)
                if sector in sector_dict:
                    sector_dict[sector].append(pos)
                else:
                    sector_dict[sector] = [pos]

        self.game.board.right_facing_casting_zones = []
        self.game.board.right_facing_casting_zones.extend(sector_dict[0])
        self.game.board.right_facing_casting_zones.extend(sector_dict[1])

        self.game.board.left_facing_casting_zones = []
        self.game.board.left_facing_casting_zones.extend(sector_dict[3])
        self.game.board.left_facing_casting_zones.extend(sector_dict[4])
开发者ID:dustice,项目名称:grimwar,代码行数:60,代码来源:SimulatorController.py


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