Example #1
0
        public bool IsSame(ArenaPlayerData _ArenaPlayerData)
        {
            if (TeamName != _ArenaPlayerData.TeamName)
            {
                return(false);
            }
            if (TeamRating != _ArenaPlayerData.TeamRating)
            {
                return(false);
            }
            if (GamesPlayed != _ArenaPlayerData.GamesPlayed)
            {
                return(false);
            }
            if (GamesWon != _ArenaPlayerData.GamesWon)
            {
                return(false);
            }
            if (PlayerPlayed != _ArenaPlayerData.PlayerPlayed)
            {
                return(false);
            }
            if (PlayerRating != _ArenaPlayerData.PlayerRating)
            {
                return(false);
            }

            return(true);
        }
Example #2
0
 private void InitData(string _ArenaDataString)
 {
     try
     {
         if (_ArenaDataString == "")
         {
             return;
         }
         string[] arenaDatas = _ArenaDataString.Split(new char[] { ',' });
         foreach (string arenaData in arenaDatas)
         {
             string[]        arenaPlayerData = arenaData.Split(new char[] { ':' });
             int             teamSize        = int.Parse(arenaPlayerData[1]);
             ArenaPlayerData newData         = new ArenaPlayerData();
             newData.TeamName     = arenaPlayerData[0];
             newData.TeamRating   = int.Parse(arenaPlayerData[2]);
             newData.GamesPlayed  = int.Parse(arenaPlayerData[3]);
             newData.GamesWon     = int.Parse(arenaPlayerData[4]);
             newData.PlayerPlayed = int.Parse(arenaPlayerData[5]);
             newData.PlayerRating = int.Parse(arenaPlayerData[6]);
             if (teamSize == 2)
             {
                 Team2v2 = newData;
             }
             else if (teamSize == 3)
             {
                 Team3v3 = newData;
             }
             else if (teamSize == 5)
             {
                 Team5v5 = newData;
             }
             else
             {
                 throw new Exception("Unknown Arena Team Size: \"" + teamSize + "\"");
             }
         }
     }
     catch (Exception)
     { }
 }
Example #3
0
        public bool GetPlayerArenaData(SQLArenaInfo _ArenaInfo, out PlayerData.ArenaData _ResultArenaData)
        {
            _ResultArenaData = null;
            if (_ArenaInfo.IsNull() == true)
            {
                return(false);
            }

            int[] teamIDs        = new int[3];
            int   teamIDsCounter = 0;

            if (_ArenaInfo.Team2v2 != 0)
            {
                teamIDs[teamIDsCounter++] = _ArenaInfo.Team2v2;
            }
            if (_ArenaInfo.Team3v3 != 0)
            {
                teamIDs[teamIDsCounter++] = _ArenaInfo.Team3v3;
            }
            if (_ArenaInfo.Team5v5 != 0)
            {
                teamIDs[teamIDsCounter++] = _ArenaInfo.Team5v5;
            }
            if (teamIDs.Length > teamIDsCounter)
            {
                int[] oldTeamIDs = teamIDs;
                teamIDs = new int[teamIDsCounter];
                for (int i = 0; i < teamIDsCounter; ++i)
                {
                    teamIDs[i] = oldTeamIDs[i];
                }
            }

            var conn = OpenConnection();

            try
            {
                const int ID_COLUMN                = 0;
                const int TEAMNAME_COLUMN          = 1;
                const int TEAMRATING_COLUMN        = 2;
                const int GAMESPLAYED_COLUMN       = 3;
                const int GAMESWON_COLUMN          = 4;
                const int PLAYERGAMESPLAYED_COLUMN = 5;
                const int PLAYERRATING_COLUMN      = 6;

                using (var cmd = new NpgsqlCommand("SELECT id, teamname, teamrating, gamesplayed, gameswon, playergamesplayed, playerrating FROM PlayerArenaDataTable WHERE id = ANY(:IDs)", conn))
                {
                    {
                        var idsParam = new NpgsqlParameter("IDs", NpgsqlDbType.Array | NpgsqlDbType.Integer);
                        idsParam.Value = teamIDs;
                        cmd.Parameters.Add(idsParam);
                    }
                    using (var reader = cmd.ExecuteReader())
                    {
                        if (reader.HasRows == true)
                        {
                            _ResultArenaData = new PlayerData.ArenaData();
                            while (reader.Read() == true)
                            {
                                var arenaTeamData = new PlayerData.ArenaPlayerData();
                                int id            = reader.GetInt32(ID_COLUMN);

                                arenaTeamData.TeamName     = reader.GetString(TEAMNAME_COLUMN);
                                arenaTeamData.TeamRating   = reader.GetInt32(TEAMRATING_COLUMN);
                                arenaTeamData.GamesPlayed  = reader.GetInt32(GAMESPLAYED_COLUMN);
                                arenaTeamData.GamesWon     = reader.GetInt32(GAMESWON_COLUMN);
                                arenaTeamData.PlayerPlayed = reader.GetInt32(PLAYERGAMESPLAYED_COLUMN);
                                arenaTeamData.PlayerRating = reader.GetInt32(PLAYERRATING_COLUMN);

                                if (id == _ArenaInfo.Team2v2)
                                {
                                    _ResultArenaData.Team2v2 = arenaTeamData;
                                }
                                if (id == _ArenaInfo.Team3v3)
                                {
                                    _ResultArenaData.Team3v3 = arenaTeamData;
                                }
                                if (id == _ArenaInfo.Team5v5)
                                {
                                    _ResultArenaData.Team5v5 = arenaTeamData;
                                }
                            }
                            return(true);
                        }
                    }
                }
            }
            finally
            {
                CloseConnection();
            }
            return(false);
        }