コード例 #1
0
ファイル: views.py プロジェクト: JonesAndrew/ChallongeGen
            def tournament(tourney):
                tList = TournamentList.load()

                for t in tList.tournaments.all():
                    if t.name == tourney:
                        return None

                t = Tournament()
                t.name = tourney
                t.save()
                tList.tournaments.add(t)
                tList.save()

                participants = challonge.participants.index(tourney)

                for p in participants:
                    addPlayer(p)

                # Retrieve a tournament by its id (or its url).
                matches = challonge.matches.index(tourney)

                for m in matches:
                    score = re.findall(r'\d+', m["scores-csv"])
                    id1 = m["player1-id"]
                    id2 = m["player2-id"]
                    parts[id1].Gwins+=int(score[0])
                    parts[id1].Glosses+=int(score[1])
                    parts[id2].Gwins+=int(score[1])
                    parts[id2].Glosses+=int(score[0])
                    if m["winner-id"] == id2:
                        temp = id1
                        id1 = id2
                        id2 = temp

                    r1 = Rating(mu=float(parts[id1].mu),sigma=float(parts[id1].sigma))
                    r2 = Rating(mu=float(parts[id2].mu),sigma=float(parts[id2].sigma))

                    r1, r2 = rate_1vs1(r1, r2)

                    parts[id1].mu = r1.mu
                    parts[id1].sigma = r1.sigma
                    parts[id2].mu = r2.mu
                    parts[id1].safe = parts[id1].mu-(3*parts[id1].sigma)
                    parts[id2].sigma = r2.sigma
                    parts[id2].safe = parts[id2].mu-(3*parts[id1].sigma)
                    parts[id1].Swins+=1
                    parts[id2].Slosses+=1
コード例 #2
0
ファイル: views.py プロジェクト: JonesAndrew/ChallongeGen
def index(request):

    players = Player.objects.order_by("-safe")

    return render(request, 'gen/index.html', context = {'elo_players': players, "tournaments": TournamentList.load().tournaments.all()})