本文整理汇总了Python中game.models.Game.get_games_in_state方法的典型用法代码示例。如果您正苦于以下问题:Python Game.get_games_in_state方法的具体用法?Python Game.get_games_in_state怎么用?Python Game.get_games_in_state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类game.models.Game
的用法示例。
在下文中一共展示了Game.get_games_in_state方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_games_in_state
# 需要导入模块: from game.models import Game [as 别名]
# 或者: from game.models.Game import get_games_in_state [as 别名]
def test_get_games_in_state(self):
g1 = Game(map=self.map, players="['', '']", state=Game.LOBBY)
g1.save()
g2 = Game(map=self.map, players="['', '']", state=Game.LOBBY)
g2.save()
g3 = Game(map=self.map, players="['', '']", state=Game.ACTIVE)
g3.save()
lobby_games = set(list(Game.get_games_in_state(Game.LOBBY)))
self.assertEqual(lobby_games, set([g1, g2]))
active_games = set(list(Game.get_games_in_state(Game.ACTIVE)))
self.assertEqual(active_games, set([g3]))
finished_games = set(list(Game.get_games_in_state(Game.FINISHED)))
self.assertEqual(finished_games, set([]))
示例2: test_ajax_lobby_games
# 需要导入模块: from game.models import Game [as 别名]
# 或者: from game.models.Game import get_games_in_state [as 别名]
def test_ajax_lobby_games(self):
User.objects.create_user('aaa', 'aaa', 'aaa')
c = self.client
login(c, 'aaa', 'aaa')
s_resp = c.get(reverse('ajax_lobby_games'))
resp_object = json.loads(s_resp.content)
num = len(Game.get_games_in_state(Game.LOBBY))
self.assertEqual(len(resp_object), num)
示例3: get
# 需要导入模块: from game.models import Game [as 别名]
# 或者: from game.models.Game import get_games_in_state [as 别名]
def get(self, request):
""" Gets the list of all games in the LOBBY state """
game_list = []
games = Game.get_games_in_state(Game.LOBBY).order_by("id").reverse()
for game in games:
game_list.append(game.to_map())
map_list = []
maps = Map.objects.all()
for a_map in maps:
map_list.append(a_map.to_map())
context = {"maps": map_list, "games": game_list}
return render(request, "the_game_bazaar/play.html", context)
示例4: ajax_lobby_games
# 需要导入模块: from game.models import Game [as 别名]
# 或者: from game.models.Game import get_games_in_state [as 别名]
def ajax_lobby_games(request):
game_list = []
games = Game.get_games_in_state(Game.LOBBY).order_by('id').reverse()
for game in games:
game_list.append(game.to_map())
return HttpResponse(json.dumps(game_list), mimetype="application/json")