예제 #1
0
def round(request):
    """ Play next round """
    if GrandChallengeGame.last is None
        user_list = Player.objects.all().order_by('-points')[:16]
    GrandChallengeGame.next_round(user_list)
    gchalls = GrandChallenge.objects.all()

    return render_to_response('cpanel/grandchallenges.html',
                            {'gchalls': gchalls},
                            context_instance=RequestContext(request))
예제 #2
0
파일: views.py 프로젝트: cvicentiu/wouso
def index(request):
    """ Shows all rounds played by the current user """
    profile = request.user.get_profile()
    gc_user = profile.get_extension(GrandChallengeUser)

    active = gc_user.get_active()
    played = gc_user.get_played()

    if not gc_user in GrandChallengeGame.base_query():
        return do_result(request, error='Ne pare rau, nu participi in turneu ')

    return render_to_response('grandchallenge/index.html',
            {'active': active, 'played': played, 'gcuser': gc_user, 'gc': GrandChallengeGame},
            context_instance=RequestContext(request))
예제 #3
0
파일: views.py 프로젝트: ArmandNM/wouso
def index(request):
    """ Shows all rounds played by the current user """
    profile = request.user.get_profile()
    gc_user = profile.get_extension(GrandChallengeUser)

    active = gc_user.get_active()
    played = gc_user.get_played()

    if not gc_user in GrandChallengeGame.base_query():
        messages.error(request, _('We are sorry, you are not part of the tournament'))
        return render(request, 'grandchallenge/message.html')

    return render_to_response('grandchallenge/index.html',
            {'active': active, 'played': played, 'gcuser': gc_user, 'gc': GrandChallengeGame},
            context_instance=RequestContext(request))
예제 #4
0
파일: tests.py 프로젝트: AndreiRO/wouso
    def test_start_gc(self):
        u1 = self._get_player(1)
        u2 = self._get_player(2)

        GrandChallengeGame.reset()
        self.assertFalse(GrandChallengeGame.is_started())
        GrandChallengeGame.start()
        self.assertTrue(GrandChallengeGame.is_started())

        c = Challenge.objects.filter(Q(user_from__user=u1, user_to__user=u2)|Q(user_from__user=u2, user_to__user=u1))
        self.assertEqual(c.count(), 1)
예제 #5
0
def index(request):
    """ Shows all rounds played by the current user """
    profile = request.user.get_profile()
    gc_user = profile.get_extension(GrandChallengeUser)

    active = gc_user.get_active()
    played = gc_user.get_played()

    if not gc_user in GrandChallengeGame.base_query():
        return do_result(request, error='Ne pare rau, nu participi in turneu ')

    return render_to_response('grandchallenge/index.html', {
        'active': active,
        'played': played,
        'gcuser': gc_user,
        'gc': GrandChallengeGame
    },
                              context_instance=RequestContext(request))
예제 #6
0
파일: tests.py 프로젝트: vladeugeniu/wouso
    def test_start_gc(self):
        u1 = self._get_player(1)
        u2 = self._get_player(2)

        GrandChallengeGame.reset()
        self.assertFalse(GrandChallengeGame.is_started())
        GrandChallengeGame.start()
        self.assertTrue(GrandChallengeGame.is_started())

        c = Challenge.objects.filter(
            Q(user_from__user=u1, user_to__user=u2)
            | Q(user_from__user=u2, user_to__user=u1))
        self.assertEqual(c.count(), 1)
예제 #7
0
def index(request):
    """ Shows all rounds played by the current user """
    profile = request.user.get_profile()
    gc_user = profile.get_extension(GrandChallengeUser)

    active = gc_user.get_active()
    played = gc_user.get_played()

    if not gc_user in GrandChallengeGame.base_query():
        messages.error(request,
                       _('We are sorry, you are not part of the tournament'))
        return render(request, 'grandchallenge/message.html')

    return render_to_response('grandchallenge/index.html', {
        'active': active,
        'played': played,
        'gcuser': gc_user,
        'gc': GrandChallengeGame
    },
                              context_instance=RequestContext(request))
예제 #8
0
파일: tests.py 프로젝트: vladeugeniu/wouso
 def test_16_players(self):
     self._simulate_n_users(17)
     self.assertEqual(GrandChallengeGame.get_winner().id,
                      self._get_player(1).id)
예제 #9
0
파일: tests.py 프로젝트: vladeugeniu/wouso
    def _simulate_n_users(self, n):
        """
        Create n users and simulate a GC run.
        """
        for i in range(n):
            self._get_player(i)

        GrandChallengeGame.start()
        self.assertEqual(GrandChallengeGame.get_current_round().round_number,
                         1)
        self.assertEqual(GrandChallengeGame.base_query().count(), n)
        self.assertEqual(
            len(GrandChallengeGame.get_current_round().participants()),
            n - n % 2)
        while not GrandChallengeGame.is_finished():
            GrandChallengeGame.round_next()
        GrandChallengeGame.force_round_close(
            GrandChallengeGame.get_current_round())
        GrandChallengeGame.round_next()
        GrandChallengeGame.force_round_close(
            GrandChallengeGame.get_current_round())
예제 #10
0
파일: tests.py 프로젝트: AndreiRO/wouso
 def test_16_players(self):
     self._simulate_n_users(17)
     self.assertEqual(GrandChallengeGame.get_winner().id, self._get_player(1).id)
예제 #11
0
파일: tests.py 프로젝트: AndreiRO/wouso
    def _simulate_n_users(self, n):
        """
        Create n users and simulate a GC run.
        """
        for i in range(n):
            self._get_player(i)

        GrandChallengeGame.start()
        self.assertEqual(GrandChallengeGame.get_current_round().round_number, 1)
        self.assertEqual(GrandChallengeGame.base_query().count(), n)
        self.assertEqual(len(GrandChallengeGame.get_current_round().participants()), n - n % 2)
        while not GrandChallengeGame.is_finished():
            GrandChallengeGame.round_next()
        GrandChallengeGame.force_round_close(GrandChallengeGame.get_current_round())
        GrandChallengeGame.round_next()
        GrandChallengeGame.force_round_close(GrandChallengeGame.get_current_round())