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


Python Game.get_games_in_state方法代码示例

本文整理汇总了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([]))
开发者ID:hellochar,项目名称:the_game_bazaar,代码行数:19,代码来源:tests.py

示例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)
开发者ID:hellochar,项目名称:the_game_bazaar,代码行数:12,代码来源:tests.py

示例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)
开发者ID:hellochar,项目名称:the_game_bazaar,代码行数:16,代码来源:views.py

示例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")
开发者ID:hellochar,项目名称:the_game_bazaar,代码行数:8,代码来源:views.py


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