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


Python Game.game_should_end方法代码示例

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


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

示例1: _end_games_that_shouldnt_be_open

# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import game_should_end [as 别名]
    def _end_games_that_shouldnt_be_open(self):
        cur = self.con.cursor()

        cur.execute("SELECT game_id, timestamp, left_team_id, right_team_id, left_score, right_score, ended " +
                    "FROM games WHERE ended=:ended", dict(ended=0))
        open_games = list(cur.fetchall())
        for (game_id, timestamp, _, _, left_score, right_score, ended) in open_games:
            game = Game(game_id=game_id, left_team=None, right_team=None, timestamp=timestamp, left_score=left_score,
                        right_score=right_score, ended=ended)
            if game.game_should_end():
                self.end_game(game)
开发者ID:pizzato,项目名称:FoosballTable,代码行数:13,代码来源:db_access.py

示例2: get_game_by_timestamp

# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import game_should_end [as 别名]
    def get_game_by_timestamp(self, timestamp):
        cur = self.con.cursor()

        cur.execute("SELECT game_id, timestamp, left_team_id, right_team_id, left_score, right_score, ended " +
                    "FROM games WHERE timestamp=:timestamp", dict(timestamp=timestamp))
        game_exists = cur.fetchone()
        if game_exists:
            game_id, _, left_team_id, right_team_id, left_score, right_score, ended = game_exists
            game = Game(game_id=game_id, timestamp=timestamp,
                        left_team=self.get_team(left_team_id), right_team=self.get_team(right_team_id),
                        left_score=left_score, right_score=right_score, ended=ended)

            if game.game_should_end():
                self.end_game(game)
            return game
        else:
            return None
开发者ID:pizzato,项目名称:FoosballTable,代码行数:19,代码来源:db_access.py


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