def findGame(user, length): query = Game.gql("WHERE current_players <:1 AND game_length =:2 ORDER BY current_players ASC", MAX_PLAYERS, length) results = query.fetch(None) if len(results) == 0: return None for result in results: game_id = joinGame(user, result.game_id) if game_id is False: continue else: return result.game_id return None
def getLobbyGames(): query = Game.gql("WHERE current_players <:1 AND started =:2 ORDER BY current_players DESC", MAX_PLAYERS, False) return query.fetch(1000000)