Exemplo n.º 1
0
def runLadder(userid, player):
    logger.info('running the ladder for %s/%s' % (userid, player))
    challenger = (userid, player)
    
    if Result.objects.count() == 0:  # hack to handle empty ladder
        runMatch(challenger, challenger)
        return
    
    ladder = buildLadder()
    runGauntlet(challenger, ladder)
Exemplo n.º 2
0
def rebuild(request):
    first = Result.objects.count()  # get index of first result to be created in this challenge match
    ladderOld = buildLadder()
    ladder = [ladderOld[0]]

    for challenger in ladderOld[1:]:
        runGauntlet(challenger, ladder)

    results_list = Result.objects.all()[first:]
    return render_to_response(
        "ladder/challenge.html", {"results_list": results_list}, context_instance=RequestContext(request)
    )
Exemplo n.º 3
0
def index(request):
    results_list = Result.objects.order_by("-pk")
    ladder = buildLadder()
    (wins, losses) = countWinsLosses()
    for i in xrange(len(ladder)):
        userid = ladder[i][0]
        player = ladder[i][1]
        upwins = wins.setdefault((userid, player), 0)
        uplosses = losses.setdefault((userid, player), 0)
        ladder[i] = (userid, player, upwins, uplosses)

    return render_to_response(
        "ladder/index.html",
        {"results_list": results_list, "ladder_list": ladder},
        context_instance=RequestContext(request),
    )