Beispiel #1
0
        /// <summary>
        /// Test ave record and fill to elo table if elo table dont exist build 3 position the table
        /// </summary>
        private void EloExist()  // zle kazdy ma ave record
        {
            EloTable  table;
            GameScore bestAvePlayer;

            for (int i = 1; i <= 3; i++)
            {
                if (!(VievModel.Exist(i)))
                {
                    myBaseSqlite.AddPlayerElo(new EloTable());

                    table = myBaseSqlite.GetPlayerElo(i);

                    if (i <= match.playerCount)
                    {
                        if (match.aveList[i - 1] > table.ratioBest)
                        {
                            table.elo       = match.DictGameScore()[i].elo;
                            table.name      = match.DictGameScore()[i].name;
                            table.ratioBest = match.DictGameScore()[i].Ratio;
                            myBaseSqlite._dbconnection.Update(table);

                            for (int j = 1; j <= match.playerCount; j++)
                            {
                                match.DictGameScore().TryGetValue(j, out GameScore bestAve);
                                if (bestAve.Ratio == match.aveList[i - 1])
                                {
                                    bestAvePlayer       = bestAve;
                                    bestAve.RatioRecord = true; // Ave Record
                                    continue;
                                }
                            }
                        }
                    }
                }
                else
                {
                    table = myBaseSqlite.GetPlayerElo(i);

                    if (i <= match.playerCount)
                    {
                        if (match.aveList[i - 1] > table.ratioBest)
                        {
                            table.elo       = match.DictGameScore()[i].elo;
                            table.name      = match.DictGameScore()[i].name;
                            table.ratioBest = match.DictGameScore()[i].Ratio;
                            myBaseSqlite._dbconnection.Update(table);


                            for (int j = 1; j <= match.playerCount; j++)
                            {
                                match.DictGameScore().TryGetValue(j, out GameScore bestAve);
                                if (bestAve.Ratio == match.aveList[i - 1])
                                {
                                    bestAvePlayer       = bestAve;
                                    bestAve.RatioRecord = false; // Ave Record
                                    continue;
                                }
                            }
                        }
                    }
                }
                //log
                string logEloExist = "EloExist() :" + myBaseSqlite.GetPlayerElo(i).ratioBest + " = " + myBaseSqlite.GetPlayerElo(i).name;
                System.Diagnostics.Debug.WriteLine(logEloExist);
                sets.AddLogs(logEloExist);
            }
        }