コード例 #1
0
ファイル: MainForm.cs プロジェクト: apshen/EloCounter
        private void WriteTournamentToDB(ITournament table)
        {
            Tournament t = dbMgr.InsertTournament(table.GetTournament());

            foreach (Player p in table.GetPlayers())
            {
                TournamentResult res = table.GetResult(p);
                res.Event = t;
                dbMgr.InsertResult(res);

                int newRate = EloTable.GetNewRate(p.GetRate(table.GetGameType()), table.GetAverageRate(p), table.GetMaxPoints(p), table.GetResult(p).Points);
                Player tp = p.Clone();
                tp.SetRate(table.GetGameType(), newRate);
                tp.SetUpdateDate(t.Type, t.EndOn);
                dbMgr.UpdatePlayer(tp);
            }

            foreach (Game g in table.GetGames())
            {
                g.Tournament = t;
                dbMgr.InsertGame(g);
            }

            ReloadPlayersAndView();
        }