Ejemplo n.º 1
0
def grandchalls_round_close(request):
    if request.method == 'POST':
        round = GrandChallengeGame.get_current_round()
        GrandChallengeGame.force_round_close(round)
        return redirect('grandchalls')
    return render_to_response('grandchallenge/cpanel/grandchallenge_round_close.html', {'gc': GrandChallengeGame},
                              context_instance=RequestContext(request))
Ejemplo n.º 2
0
def grandchalls_hard_reset(request):
    if request.method == 'POST':
        GrandChallengeGame.reset()
        return redirect('grandchalls')
    return render_to_response(
        'grandchallenge/cpanel/grandchallenge_hard_reset.html',
        {'gc': GrandChallengeGame},
        context_instance=RequestContext(request))
Ejemplo n.º 3
0
def grandchalls_round_close(request):
    if request.method == 'POST':
        round = GrandChallengeGame.get_current_round()
        GrandChallengeGame.force_round_close(round)
        return redirect('grandchalls')
    return render_to_response(
        'grandchallenge/cpanel/grandchallenge_round_close.html',
        {'gc': GrandChallengeGame},
        context_instance=RequestContext(request))
Ejemplo n.º 4
0
def grandchalls(request):
    round = GrandChallengeGame.get_current_round()
    nr = round.round_number if round else -1
    return render_to_response(
        'grandchallenge/cpanel/grandchallenge.html',
        {'nr': nr, 'round': round, 'gc': GrandChallengeGame},
        context_instance=RequestContext(request))
Ejemplo n.º 5
0
def grandchalls_round(request):
    """ Play a round """
    # TODO: move logic to models.
    """ regular round """
    over = 0
    done = GrandChallenge.all_done()
    if not GrandChallengeGame.is_final():
        if done:
            GrandChallenge.joaca(GrandChallengeGame.round_number)
            if GrandChallengeGame.round_number % 2 == 0:
                GrandChallenge.play_round(1)
                GrandChallenge.play_round(0)
            else:
                GrandChallenge.play_round(1)
            GrandChallengeGame.round_number += 1
    else:
        """ final 2 players
            they may have to play 2 rounds if the winners finalist lose
            to the loosers finalist
        """
        if GrandChallengeGame.round_number != 10:
            GrandChallengeGame.final_round()
            GrandChallenge.joaca(GrandChallengeGame.round_number)
            GrandChallenge.play_round(1)
            GrandChallenge.play_round(0)
            if GrandChallengeGame.is_winner():
                over = 1
        else:
            if not GrandChallengeGame.is_winner():
                GrandChallengeGame.final_second_round()
            over = 1

        GrandChallengeGame.round_number += 1
    gchalls = sorted(GrandChallenge.get_challenges(), key=lambda gc: gc.branch)

    return render_to_response('grandchallenge/cpanel/grandchallenge.html', {
        'gchalls': gchalls,
        'nr': GrandChallengeGame.round_number,
        'done': done,
        'over': over
    },
                              context_instance=RequestContext(request))
Ejemplo n.º 6
0
def grandchalls_round(request):
    """ Play a round """
    # TODO: move logic to models.
    """ regular round """
    over = 0
    done = GrandChallenge.all_done()
    if not GrandChallengeGame.is_final():
        if done:
            GrandChallenge.joaca(GrandChallengeGame.round_number)
            if GrandChallengeGame.round_number % 2 == 0:
                GrandChallenge.play_round(1)
                GrandChallenge.play_round(0)
            else:
                GrandChallenge.play_round(1)
            GrandChallengeGame.round_number += 1
    else:
        """ final 2 players
            they may have to play 2 rounds if the winners finalist lose
            to the loosers finalist
        """
        if GrandChallengeGame.round_number != 10:
            GrandChallengeGame.final_round()
            GrandChallenge.joaca(GrandChallengeGame.round_number)
            GrandChallenge.play_round(1)
            GrandChallenge.play_round(0)
            if GrandChallengeGame.is_winner():
                over = 1
        else:
            if not GrandChallengeGame.is_winner():
                GrandChallengeGame.final_second_round()
            over = 1

        GrandChallengeGame.round_number += 1
    gchalls = sorted(GrandChallenge.get_challenges(), key=lambda gc:gc.branch)

    return render_to_response('grandchallenge/cpanel/grandchallenge.html',
            {'gchalls': gchalls,
             'nr': GrandChallengeGame.round_number,
             'done': done,
             'over': over},
        context_instance=RequestContext(request))
Ejemplo n.º 7
0
def grandchalls_start(request):
    """ Play the game """
    GrandChallengeGame.start()
    return redirect('grandchalls')
Ejemplo n.º 8
0
def grandchalls_start(request):
    """ Play the game """
    GrandChallengeGame.start()
    return redirect('grandchalls')