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


Python Board.refresh_units方法代码示例

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


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

示例1: __init__

# 需要导入模块: import Board [as 别名]
# 或者: from Board import refresh_units [as 别名]
class Game:
    def __init__(self):
        self.players = {}
        self.board = None
        self.setup_phase()
        self.turn = 0
        self.turn_advantage = 0

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

    def setup_phase(self):
        # Set up board
        self.board = Board(self, field_length=BOARD_LENGTH, field_width=BOARD_WIDTH)

        # Instantiate Players
        self.players[0] = Player(0)
        self.players[1] = Player(1)
        self.players[1].set_direction(Const.FACING_LEFT)

        # Initial Decks
        self.players[0].set_deck([
            Card.get_card('Rifleman'),
            Card.get_card('Footman'),
            Card.get_card('Footman'),
            Card.get_card('Peasant'),
            Card.get_card('Peasant'),
        ])
        self.players[0].set_hand([
            Card.get_card('Footman'),
            Card.get_card('Rifleman'),
            Card.get_card('Scout'),
            Card.get_card('Peasant'),
            Card.get_card('Peasant'),
        ])
        self.players[1].set_deck([
            Card.get_card('Rifleman'),
            Card.get_card('Footman'),
            Card.get_card('Footman'),
            Card.get_card('Peasant'),
            Card.get_card('Peasant'),
        ])
        self.players[1].set_hand([
            Card.get_card('Footman'),
            Card.get_card('Rifleman'),
            Card.get_card('Scout'),
            Card.get_card('Peasant'),
            Card.get_card('Peasant'),
        ])

        # Initial Heroes
        middle = (BOARD_WIDTH - 1) / 2
        self.put_in_play(Card.get_card('Arius'), 0, (-1, middle))
        self.put_in_play(Card.get_card('Arius'), 1, (BOARD_LENGTH - 2, middle))

    def main_loop(self):
        # Main Loop
        while (True):
            winner = self.main_loop_once()
            if winner is not None:
                return winner

    def main_loop_once(self):
        self.pre_main_phases()
        gameover = self.post_main_phases()
        if gameover is not None:
            return gameover

    def pre_main_phases(self):
        logging.info("********************")
        logging.info("Beginning of Turn {0}".format(self.turn))
        self.upkeep_phase()
        self.cleanup_phase()
        self.draw_phase()

    def post_main_phases(self):
        self.spell_phase()
        self.damage_phase()
        self.cleanup_phase()
        self.move_phase()

        self.money_phase()

        result = self.cleanup_phase()
        if result is not None:
            return result

        logging.info("End of Turn {0}".format(self.turn))
        logging.info("********************")
        self.increment_turn()

    def increment_turn(self):
        self.turn += 1

    def upkeep_phase(self):
        self.turn_advantage = self.calculate_advantage()
        logging.info("Player {0} has advantage for this turn".format(self.turn_advantage))
        # Refresh must occur first
        self.board.refresh_units()
        # Let modifiers do updates. This must occur before effects, as a
#.........这里部分代码省略.........
开发者ID:dustice,项目名称:grimwar,代码行数:103,代码来源:Game.py


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