本文整理汇总了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)
示例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