Exemplo n.º 1
0
 public static void LoadTopsRanking()
 {
     try
     {
         using (NpgsqlConnection connection = new NpgsqlConnection(SQLManager.ConnectionString))
             using (NpgsqlCommand command = connection.CreateCommand())
             {
                 connection.Open();
                 command.CommandText = "SELECT id, exp, rank FROM accounts WHERE rank<'52' AND rank>'46' AND exp>'0' ORDER BY exp DESC";
                 using (NpgsqlDataReader data = command.ExecuteReader())
                 {
                     while (data.Read())
                     {
                         TopRank rank = new TopRank
                         {
                             playerId = data.GetInt64(0),
                             exp      = data.GetInt32(1),
                             rankId   = (byte)data.GetInt32(2)
                         };
                         if (rank.rankId > 46)
                         {
                             TopRankings.Add(rank);
                         }
                     }
                     data.Close();
                     connection.Close();
                 }
             }
     }
     catch (Exception ex)
     {
         Logger.Exception(ex);
     }
 }
Exemplo n.º 2
0
 public static void GetRankCounts(out int ranks47, out int ranks48, out int ranks49, out int ranks50, out int ranks51)
 {
     ranks47 = 0;
     ranks48 = 0;
     ranks49 = 0;
     ranks50 = 0;
     ranks51 = 0;
     for (int i = 0; i < TopRankings.Count; i++)
     {
         TopRank rank = TopRankings[i];
         if (rank.playerId == 0)
         {
             continue;
         }
         if (rank.rankId == 47)
         {
             ranks47++;
         }
         else if (rank.rankId == 48)
         {
             ranks48++;
         }
         else if (rank.rankId == 49)
         {
             ranks49++;
         }
         else if (rank.rankId == 50)
         {
             ranks50++;
         }
         else if (rank.rankId == 51)
         {
             ranks51++;
         }
     }
 }
Exemplo n.º 3
0
 public static bool CheckUp(long playerId, byte rankId, int experience, out long playerIdReduceRank)
 {
     lock (TopRankings)
     {
         playerIdReduceRank = 0;
         byte Ranks47 = 0;
         byte Ranks48 = 0;
         byte Ranks49 = 0;
         byte Ranks50 = 0;
         byte Ranks51 = 0;
         for (int i = 0; i < TopRankings.Count; i++)
         {
             TopRank rank = TopRankings[i];
             if (rank == null)
             {
                 continue;
             }
             if (rank.rankId == 47)
             {
                 Ranks47++;
             }
             else if (rank.rankId == 48)
             {
                 Ranks48++;
             }
             else if (rank.rankId == 49)
             {
                 Ranks49++;
             }
             else if (rank.rankId == 50)
             {
                 Ranks50++;
             }
             else if (rank.rankId == 51)
             {
                 Ranks51++;
             }
         }
         if ((rankId == 46 && Ranks47 >= Settings.MaxRanks47) || (rankId == 47 && Ranks48 >= Settings.MaxRanks48) || (rankId == 48 && Ranks49 >= Settings.MaxRanks49) || (rankId == 49 && Ranks50 >= Settings.MaxRanks50) || (rankId == 50 && Ranks51 >= Settings.MaxRanks51))
         {
             for (int j = 0; j < TopRankings.Count; j++)
             {
                 TopRank rank = TopRankings[j];
                 if (rank != null && rank.playerId != playerId && rank.rankId > rankId && rank.exp < experience)
                 {
                     if (rank.rankId == 47 && TopRankings.Remove(rank))
                     {
                         TopRankings.Add(new TopRank
                         {
                             playerId = playerId,
                             exp      = experience,
                             rankId   = rankId++
                         });
                     }
                     playerIdReduceRank = rank.playerId;
                     return(true);
                 }
             }
         }
         else
         {
             TopRank rank = new TopRank
             {
                 playerId = playerId,
                 exp      = experience,
                 rankId   = rankId++
             };
             TopRankings.Add(rank);
         }
         return(false);
     }
 }