Exemple #1
0
        public WN8ExpValues()
        {
            XmlDocument xmlDoc      = new XmlDocument();
            XmlNodeList nodes       = null;
            XmlNodeList headerNodes = null;

            try
            {
                xmlDoc.Load(WOTHelper.GetWN8ExpectedTankValuesFile());
                XmlElement root = xmlDoc.DocumentElement;
                nodes       = root.SelectSingleNode("WN8").ChildNodes;
                headerNodes = root.SelectSingleNode("Header").ChildNodes;
            }
            catch (Exception ex)
            {
                WOTHelper.AddToLog(ex.Message);
            }
            WN8Version   = 0;
            WN8DateEpoch = 0;
            WN8Date      = new DateTime(1970, 1, 1, 0, 0, 0);
            if (headerNodes != null)
            {
                foreach (XmlNode headerNode in headerNodes)
                {
                    if (headerNode.Name == "Version")
                    {
                        WN8Version = Convert.ToInt16(headerNode.InnerText);
                    }

                    if (headerNode.Name == "Date")
                    {
                        WN8DateEpoch = Convert.ToInt32(headerNode.InnerText);
                        WN8Date      = new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(WN8DateEpoch);
                    }
                }
            }

            if (nodes != null)
            {
                MessageQueue     _messages       = null;
                TankDescriptions tankDescription = new TankDescriptions(_messages);
                foreach (XmlNode node in nodes)
                {
                    WN8ExpValue expVal = new WN8ExpValue();

                    expVal.Tank       = tankDescription.Description(Convert.ToInt32(node.Attributes["countryid"].Value), Convert.ToInt32(node.Attributes["tankid"].Value));
                    expVal.Country    = Translations.TranslationGet(Convert.ToString(node.Attributes["countryid"].Value), "DE", Convert.ToString(node.Attributes["countryid"].Value));
                    expVal.Tier       = tankDescription.Tier(Convert.ToInt32(node.Attributes["countryid"].Value), Convert.ToInt32(node.Attributes["tankid"].Value));
                    expVal.tankID     = Convert.ToInt32(node.Attributes["tankid"].Value);
                    expVal.countryID  = Convert.ToInt32(node.Attributes["countryid"].Value);
                    expVal.expFrag    = double.Parse(node.Attributes["expFrag"].Value, System.Globalization.CultureInfo.InvariantCulture);
                    expVal.expDamage  = double.Parse(node.Attributes["expDamage"].Value, System.Globalization.CultureInfo.InvariantCulture);
                    expVal.expSpot    = double.Parse(node.Attributes["expSpot"].Value, System.Globalization.CultureInfo.InvariantCulture);
                    expVal.expDefense = double.Parse(node.Attributes["expDef"].Value, System.Globalization.CultureInfo.InvariantCulture);
                    expVal.expWin     = double.Parse(node.Attributes["expWinRate"].Value, System.Globalization.CultureInfo.InvariantCulture);

                    Add(expVal);
                }
            }
        }
Exemple #2
0
        public static void printRatingStruct(RatingStructure ratingStruct)
        {
            WOTHelper.AddToLog("ratingStruct.countryID:" + ratingStruct.countryID);
            WOTHelper.AddToLog("ratingStruct.tankID:" + ratingStruct.tankID);
            WOTHelper.AddToLog("ratingStruct.tier:" + ratingStruct.tier);
            WOTHelper.AddToLog("ratingStruct.battlesCount:" + ratingStruct.battlesCount);
            WOTHelper.AddToLog("ratingStruct.battlesCount8_8:" + ratingStruct.battlesCount8_8);
            WOTHelper.AddToLog("ratingStruct.capturePoints:" + ratingStruct.capturePoints);
            WOTHelper.AddToLog("ratingStruct.defencePoints:" + ratingStruct.defencePoints);
            WOTHelper.AddToLog("ratingStruct.damageAssistedRadio:" + ratingStruct.damageAssistedRadio);
            WOTHelper.AddToLog("ratingStruct.damageAssistedTracks:" + ratingStruct.damageAssistedTracks);
            WOTHelper.AddToLog("ratingStruct.damageDealt:" + ratingStruct.damageDealt);
            WOTHelper.AddToLog("ratingStruct.frags:" + ratingStruct.frags);
            WOTHelper.AddToLog("ratingStruct.spotted:" + ratingStruct.spotted);
            WOTHelper.AddToLog("ratingStruct.wins:" + ratingStruct.wins);
            WOTHelper.AddToLog("ratingStruct.winRate:" + ratingStruct.winRate);
            WOTHelper.AddToLog("--------------");
            WOTHelper.AddToLog("ratingStruct.AvgcapturePoints:" + ratingStruct.AvgCapturePoints);
            WOTHelper.AddToLog("ratingStruct.AvgdefencePoints:" + ratingStruct.AvgDefencePoints);
            WOTHelper.AddToLog("ratingStruct.AvgdamageAssistedRadio:" + ratingStruct.AvgDamageAssistedRadio);
            WOTHelper.AddToLog("ratingStruct.AvgdamageAssistedTracks:" + ratingStruct.AvgDamageAssistedTracks);
            WOTHelper.AddToLog("ratingStruct.AvgdamageDealt:" + ratingStruct.AvgDamageDealt);
            WOTHelper.AddToLog("ratingStruct.Avgfrags:" + ratingStruct.AvgFrags);
            WOTHelper.AddToLog("ratingStruct.Avgspotted:" + ratingStruct.AvgSpotted);
            WOTHelper.AddToLog("--------------");
            WOTHelper.AddToLog("ratingStruct.overallDamageDealt:" + ratingStruct.overallDamageDealt);
            WOTHelper.AddToLog("ratingStruct.overallFrag:" + ratingStruct.overallFrags);
            WOTHelper.AddToLog("ratingStruct.overallSpot:" + ratingStruct.overallSpotted);
            WOTHelper.AddToLog("ratingStruct.overallDefensePoints:" + ratingStruct.overallDefencePoints);
            WOTHelper.AddToLog("ratingStruct.overallWinrate:" + ratingStruct.overallWinRate);

            WOTHelper.AddToLog("--------------");
        }
Exemple #3
0
 private static void printExpectedTank(WN8ExpValue WN8EX)
 {
     WOTHelper.AddToLog("WN8ExpValue.expDamage:" + WN8EX.expDamage);
     WOTHelper.AddToLog("WN8ExpValue.expDefense:" + WN8EX.expDefense);
     WOTHelper.AddToLog("WN8ExpValue.expFrag:" + WN8EX.expFrag);
     WOTHelper.AddToLog("WN8ExpValue.expSpot:" + WN8EX.expSpot);
     WOTHelper.AddToLog("WN8ExpValue.expWin:" + WN8EX.expWin);
 }
Exemple #4
0
 public static void PrintDictionary(Dictionary <string, string> oDictionary)
 {
     WOTHelper.AddToLog("Printing Dictionary");
     foreach (KeyValuePair <string, string> kvp in oDictionary)
     {
         WOTHelper.AddToLog("Key = {0}, Value = {1}" + kvp.Key + kvp.Value);
     }
 }
Exemple #5
0
 private static void LoadFile()
 {
     _translation.Clear();
     _languages.Clear();
     try
     {
         //Lets load the xml
         XmlDocument xmlDoc = new XmlDocument();
         xmlDoc.Load(WOTHelper.GetTranslationFile());
         XmlElement  root     = xmlDoc.DocumentElement;
         XmlNodeList nodeList = root.SelectSingleNode("//WorldOfTanks").ChildNodes;
         foreach (XmlNode baseNode in nodeList)
         {
             foreach (XmlNode childNode in baseNode.ChildNodes)
             {
                 if (childNode.Name.ToUpper() == "LANGUAGES")
                 {
                     foreach (XmlNode fieldNode in childNode.ChildNodes)
                     {
                         string national = fieldNode.SelectSingleNode("NameNat").InnerText;
                         string english  = fieldNode.SelectSingleNode("NameENG").InnerText;
                         WOTHelper.AddToLog("Adding Language to dict: " + english);
                         _languages.Add(fieldNode.Attributes["ID"].Value, new Languages()
                         {
                             National = national, English = english
                         });
                     }
                 }
                 else if (childNode.Name.ToUpper() == "FIELDS")
                 {
                     foreach (XmlNode fieldNode in childNode.ChildNodes)
                     {
                         foreach (XmlNode item in fieldNode)
                         {
                             if (item.Name != "#comment")
                             {
                                 if (!_translation.ContainsKey(String.Format("{0}|{1}", fieldNode.Attributes["Name"].Value, item.Attributes["LanID"].Value)))
                                 {
                                     _translation.Add(String.Format("{0}|{1}", fieldNode.Attributes["Name"].Value, item.Attributes["LanID"].Value), item.InnerText);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         WOTHelper.AddToLog("Error with Translation: " + ex.Message);
         // throw ex;
     }
 }
Exemple #6
0
        public void Add(string value)
        {
            int max;

            if (base.Count == 0)
            {
                max = 0;
            }
            else
            {
                max = (from m in base.Keys
                       select m).Max();
            }

            base.Add(max + 1, string.Format("{0:yyyy-MM-dd HH:mm:ss} : {1}", DateTime.Now, value));
            OnAdd(new MessageEventArgs(max + 1, string.Format("{0:yyyy-MM-dd HH:mm:ss} : {1}", DateTime.Now, value)));
            WOTHelper.AddToLog(value);
        }
Exemple #7
0
        private static RatingStorage GetRatingWN8Calc(RatingStructure ratingStruct)
        {
            ratingStruct.RatingType = "WN8";
            RatingStorage Storage = new RatingStorage(ratingStruct);
            if (ratingStruct.battlesCount == 0)
            {
                return Storage;
            }

            //WOTHelper.AddToLog(countryID);
            //WOTHelper.AddToLog(tankID);


            WN8ExpValue WN8ExpectedTank = null;
            try
            {
                WN8ExpectedTank = ratingStruct.WN8ExpectedTankList.GetByTankID(ratingStruct.countryID, ratingStruct.tankID);
            }
            catch (Exception ex)
            {
                WOTHelper.AddToLog(ex.Message);
            }


            
            if (WN8ExpectedTank == null)
            {
                WOTHelper.AddToLog("WNExpectedTank is NULL: " + ratingStruct.countryID + " - " + ratingStruct.tankID);
                return Storage;
            }

            //rDAMAGE=sum(TotalDamageOfSingleTank)/sum(ExpectedDamagePerTank*BattlesInThatTank)
            //rSPOT=sum(totalSpotOfSingleTank)/sum(ExpectedSpotPerTank*BattlesInThatTank)
            //rFRAG=sum(totalFragsOfSingleTank)/sum(ExpectedFragsPerTank*BattlesInThatTank)
            //rWin=sum(WinsOfSingleTanks)/Sum(ExpectedWinsPerTank*BattlesInThatTank)

            Storage.expDAMAGE = WN8ExpectedTank.expDamage;
            Storage.expFRAG = WN8ExpectedTank.expFrag;
            Storage.expSPOT = WN8ExpectedTank.expSpot;
            Storage.expDEF = WN8ExpectedTank.expDefense;
            Storage.expWIN = WN8ExpectedTank.expWin;

            //Storage.damage = ratingStruct.AvgDamageDealt;
            //Storage.frags = ratingStruct.AvgFrags;
            //Storage.spotted = ratingStruct.AvgSpotted;
            //Storage.defence = ratingStruct.AvgDefencePoints;
            //Storage.winRate = ratingStruct.winRate;

            Storage.rDAMAGEc = WN8_Damage(WN8ExpectedTank, ratingStruct);
            Storage.rFRAGc = WN8_Frags(WN8ExpectedTank, Storage.rDAMAGEc, ratingStruct);
            Storage.rSPOTc = WN8_Spotted(WN8ExpectedTank, Storage.rDAMAGEc, ratingStruct);
            Storage.rDEFc = WN8_Defence(WN8ExpectedTank, Storage.rDAMAGEc, ratingStruct);
            Storage.rWINc = WN8_WinRate(WN8ExpectedTank, ratingStruct);

            Storage.rDAMAGE = 980 * Storage.rDAMAGEc;
            Storage.rFRAG = 210 * Storage.rDAMAGEc * Storage.rFRAGc;
            Storage.rSPOT = 155 * Storage.rFRAGc * Storage.rSPOTc;
            Storage.rDEF = 75 * Storage.rDEFc * Storage.rFRAGc;
            Storage.rWIN = 145 * Math.Min(1.8, Storage.rWINc);

            //if (ratingStruct.countryID == 0 & ratingStruct.tankID == 32)

            //if (Storage.damage == 820)
            //if (ratingStruct.isOverall)
            //{

            //    WOTHelper.AddToLog("Setting exp: " + Storage.rWIN);
            //    WOTHelper.AddToLog("#############");
            //    printExpectedTank(WN8ExpectedTank);
            //    printRatingStruct(ratingStruct);
            //    WOTHelper.AddToLog("rDAMAGEc " + Storage.rDAMAGEc);
            //    WOTHelper.AddToLog("rFRAGc " + Storage.rFRAGc);
            //    WOTHelper.AddToLog("rSPOTc " + Storage.rSPOTc);
            //    WOTHelper.AddToLog("rDEFc " + Storage.rDEFc);
            //    WOTHelper.AddToLog("rWINc " + Storage.rWINc);
            //    WOTHelper.AddToLog("____");
            //    printRatingStruct(ratingStruct);
            //    WOTHelper.AddToLog("rFRAGc " + Storage.rFRAGc);
            //    WOTHelper.AddToLog("rSPOTc " + Storage.rSPOTc);
            //    WOTHelper.AddToLog("rDEFc " + Storage.rDEFc);
            //    WOTHelper.AddToLog("rWINc " + Storage.rWINc);
            //    WOTHelper.AddToLog("____");
            //    WOTHelper.AddToLog("rDAMAGE " + Storage.rDAMAGE);
            //    WOTHelper.AddToLog("rFRAG " + Storage.rFRAG);
            //    WOTHelper.AddToLog("rSPOT " + Storage.rSPOT);
            //    WOTHelper.AddToLog("rDEF " + Storage.rDEF);
            //    WOTHelper.AddToLog("rWIN " + Storage.rWIN);
            //    WOTHelper.AddToLog("rSUM " + Storage.Value);
            //    WOTHelper.AddToLog("rWeight " + Storage.Weight);
            //    WOTHelper.AddToLog("#############");
            //}

            Storage.HTMLColorDescription = WOTStatistics.Core.WOTHtml.WN8ColorScaleDescription(Storage.Value);
            Storage.HTMLColor = WOTStatistics.Core.WOTHtml.WN8ColorScale(Storage.Value);

            return Storage;

        }
        private void CreateRecentBattle(MemoryTables mt)
        {
            //try
            //{
            Dossier  fileB     = new Dossier(GetCurrentPlayerFile(), _playerName, _messages);
            WOTStats stats     = fileB.GetStats();
            double   avgTier   = stats.AverageTier;
            double   vics      = stats.Victory_Percentage;
            double   defPoints = stats.AverageDefencePoints;

            List <string> cur = (from x in  mt.GetTable("File_Total").AsEnumerable()
                                 select x["foLastBattleTime"].ToString()).ToList();
            List <string> saved;
            DataTable     currentRecord;
            DataTable     Kills;

            using (IDBHelpers db = new DBHelpers(WOTHelper.GetDBPath(_playerName), false))
            {
                saved = (from x in  db.GetDataTable("select foLastBattleTime from File_Total").AsEnumerable()
                         select x["foLastBattleTime"].ToString()).ToList();

                currentRecord = db.GetDataTable(@"select
                                  case when T2.bpBattleMode = 7 then 7 else 15 end as bpBattleMode, T1.cmID, T1.cmCountryID, T1.cmTankID, T1.cmUpdated, (T2.bpBattleCount) bpBattleCount, (t2.bpSpotted) bpSpotted,  (t2.bpHits) bpHits,  (t2.bpMaxFrags) bpMaxFrags,  (t2.bpMaxXP) bpMaxXP,  (t2.bpWins) bpWins,  (t2.bpCapturePoints) bpCapturePoints,  (t2.bpLosses) bpLosses,
                                   (t2.bpSurvivedBattles) bpSurvivedBattles, min(T4.foBattleLifeTime) foBattleLifeTime,  (t2.bpDefencePoints) bpDefencePoints, min(t4.foLastBattleTime) foLastBattleTime,  (t2.bpDamageReceived) bpDamageReceived,  (t2.bpShots) bpShots,  (t2.bpWinAndSurvive) bpWinAndSurvive,  (t2.bpFrags8P) bpFrags8P,
                                    (t2.bpXP) bpXP,                                   
                                    (t2.bpDamageDealt) bpDamageDealt,  
                                    (t2.bpDamageAssistedRadio) bpDamageAssistedRadio,  
                                    (t2.bpDamageAssistedTracks) bpDamageAssistedTracks,  
                                    (t2.bpMileage) bpMileage, 
                                    (t2.bpRatingEffWeight)/(t2.bpBattleCount) bpRatingEff,  
                                    (t2.bpRatingBRWeight)/(t2.bpBattleCount) bpRatingBR,  
                                    (t2.bpRatingWN7Weight)/(t2.bpBattleCount) bpRatingWN7,  
                                    (t2.bpRatingWN8Weight)/(t2.bpBattleCount) bpRatingWN8,  
                                   (t2.bpFrags) bpFrags, t4.foTreesCut, t3.faMarkOfMastery
                                  from File_TankDetails T1
                                  inner join File_Battles T2
                                  on T1.cmID = T2.bpParentID
                                  inner join File_Achievements T3
                                  on T1.cmID = T3.faParentID
                                  inner join File_Total T4
                                  on T1.cmID = T4.foParentID
                                  where cmFileID =  " + GetCurrentPlayerFileKey() + " group by T2.bpBattleMode, T1.cmID, T1.cmCountryID, T1.cmTankID, T1.cmUpdated, t4.foTreesCut, t3.faMarkOfMastery");

                Kills = db.GetDataTable(String.Format(@"select fgParentID, fgCountryID, fgTankID, sum(fgValue) kills from File_TankDetails
                                                                                            inner join File_FragList
                                                                                            on cmID = fgParentID
                                                                                            where cmFileID = {0}
                                                                                            group by  fgParentID, fgCountryID, fgTankID", GetCurrentPlayerFileKey()));
            }

            List <string> diff        = cur.Except(saved).ToList();
            RecentBattles lb          = new RecentBattles(GetPlayerName, _messages);
            var           battleCheck = from x in mt.GetTable("File_TankDetails").AsEnumerable()
                                        join y in mt.GetTable("File_Battles").AsEnumerable()
                                        on x.GetSafeInt("cmID") equals y.GetSafeInt("bpParentID")
                                        join z in mt.GetTable("File_Total").AsEnumerable()
                                        on x.GetSafeInt("cmID") equals z.GetSafeInt("foParentID")
                                        join d in diff
                                        on z["foLastBattleTime"].ToString() equals d
                                        group y by new { ID = x.GetSafeInt("cmID"), countryID = x.GetSafeInt("cmCountryID"), tankID = x.GetSafeInt("cmTankID"), battleTime = z["foLastBattleTime"].ToString(), BattleMode = y["bpBattleMode"] } into tank
                          select new
            {
                ID                   = tank.Key.ID,
                CountryID            = tank.Key.countryID,
                TankID               = tank.Key.tankID,
                BattleTime           = tank.Key.battleTime,
                BattleCount          = tank.Sum(y => y.GetSafeInt("bpBattleCount")),
                Hits                 = tank.Sum(y => y.GetSafeInt("bpHits")),
                Shots                = tank.Sum(y => y.GetSafeInt("bpShots")),
                Victory              = tank.Sum(y => y.GetSafeInt("bpWins")),
                Losses               = tank.Sum(y => y.GetSafeInt("bpLosses")),
                Survived             = tank.Sum(y => y.GetSafeInt("bpSurvivedBattles")),
                DefencePoints        = tank.Sum(y => y.GetSafeInt("bpDefencePoints")),
                CapturePoints        = tank.Sum(y => y.GetSafeInt("bpCapturePoints")),
                Spotted              = tank.Sum(y => y.GetSafeInt("bpSpotted")),
                DamageDealt          = tank.Sum(y => y.GetSafeInt("bpDamageDealt")),
                DamageAssistedRadio  = tank.Sum(y => y.GetSafeInt("bpDamageAssistedRadio")),
                DamageAssistedTracks = tank.Sum(y => y.GetSafeInt("bpDamageAssistedTracks")),
                DamageReceived       = tank.Sum(y => y.GetSafeInt("bpDamageReceived")),
                Kills                = tank.Sum(y => y.GetSafeInt("bpFrags")),
                Mileage              = tank.Sum(y => y.GetSafeInt("bpMileage")),
                RatingEff            = tank.Sum(y => y.GetSafeInt("bpRatingEff")),
                RatingBR             = tank.Sum(y => y.GetSafeInt("bpRatingBR")),
                RatingWN7            = tank.Sum(y => y.GetSafeInt("bpRatingWN7")),
                RatingWN8            = tank.Sum(y => y.GetSafeInt("bpRatingWN8")),
                XPReceived           = tank.Sum(y => y.GetSafeInt("bpXP")),
                BattleMode           = int.Parse(tank.Key.BattleMode.ToString())
            };



            if (currentRecord.Rows.Count > 0)
            {
                foreach (var item in battleCheck)
                {
                    //WOTHelper.AddToLog("BM 1: " + item.BattleMode);
                    DataRow dr = currentRecord.Select(String.Format("cmCountryID = {0} and cmTankID = {1} and bpBattleMode = {2}", item.CountryID, item.TankID, item.BattleMode)).DefaultIfEmpty(null).FirstOrDefault();

                    if (dr != null)
                    {
                        if (item.BattleCount - dr.GetSafeInt("bpBattleCount") > 0)
                        {
                            int           i        = 0;
                            List <string> newKills = new List <string>();
                            foreach (DataRow killRow in mt.GetTable("File_FragList").Select("fgParentID = " + item.ID))
                            {
                                DataRow dr_oldKills = Kills.Select(String.Format(@"fgParentID = {0} and  fgCountryID = {1} and fgTankID = {2}", dr.GetSafeInt("cmID"), killRow.GetSafeInt("fgCountryID"), killRow.GetSafeInt("fgTankID"))).FirstOrDefault();
                                if (dr_oldKills != null)
                                {
                                    if (killRow.GetSafeInt("fgValue") > dr_oldKills.GetSafeInt("kills"))
                                    {
                                        newKills.Add(String.Format("{0}:{1}_{2}", i, killRow.GetSafeInt("fgCountryID"), killRow.GetSafeInt("fgTankID")));
                                        i++;
                                    }
                                }
                                else
                                {
                                    newKills.Add(String.Format("{0}:{1}_{2}", i, killRow.GetSafeInt("fgCountryID"), killRow.GetSafeInt("fgTankID")));
                                    i++;
                                }
                            }

                            int vic = 0;
                            if (item.Victory - dr.GetSafeInt("bpWins") > 0)
                            {
                                vic = 0;
                            }
                            else if (item.Losses - dr.GetSafeInt("bpLosses") > 0)
                            {
                                vic = 1;
                            }
                            else
                            {
                                vic = 2;
                            }
                            //WOTHelper.AddToLog("ASD: " + dr.GetSafeInt("bpRatingWN8"));
                            lb.Add(int.Parse(item.BattleTime), new RecentBattle()
                            {
                                CountryID              = item.CountryID,
                                TankID                 = item.TankID,
                                Battles                = item.BattleCount - dr.GetSafeInt("bpBattleCount"),
                                BattleTime             = int.Parse(item.BattleTime),
                                Hits                   = item.Hits - dr.GetSafeInt("bpHits"),
                                Shot                   = item.Shots - dr.GetSafeInt("bpShots"),
                                Victory                = vic,
                                Survived               = item.Survived - dr.GetSafeInt("bpSurvivedBattles"),
                                DefencePoints          = item.DefencePoints - dr.GetSafeInt("bpDefencePoints"),
                                CapturePoints          = item.CapturePoints - dr.GetSafeInt("bpCapturePoints"),
                                Spotted                = item.Spotted - dr.GetSafeInt("bpSpotted"),
                                DamageDealt            = item.DamageDealt - dr.GetSafeInt("bpDamageDealt"),
                                DamageAssistedRadio    = item.DamageAssistedRadio - dr.GetSafeInt("bpDamageAssistedRadio"),
                                DamageAssistedTracks   = item.DamageAssistedTracks - dr.GetSafeInt("bpDamageAssistedTracks"),
                                DamageReceived         = item.DamageReceived - dr.GetSafeInt("bpDamageReceived"),
                                Kills                  = item.Kills - dr.GetSafeInt("bpFrags"),
                                Mileage                = item.Mileage - dr.GetSafeInt("bpMileage"),
                                RatingEff              = item.RatingEff - dr.GetSafeInt("bpRatingEff"),
                                RatingBR               = item.RatingBR - dr.GetSafeInt("bpRatingBR"),
                                RatingWN7              = item.RatingWN7 - dr.GetSafeInt("bpRatingWN7"),
                                RatingWN8              = item.RatingWN8 - dr.GetSafeInt("bpRatingWN8"),
                                XPReceived             = item.XPReceived - dr.GetSafeInt("bpXP"),
                                OriginalBattleCount    = item.BattleCount - dr.GetSafeInt("bpBattleCount"),
                                FragList               = string.Join(";", newKills.ToArray().Take(15)),
                                GlobalAvgTier          = avgTier,
                                GlobalWinPercentage    = vics,
                                GlobalAvgDefencePoints = defPoints,
                                BattleMode             = item.BattleMode,
                                DBEntry                = false
                            });

                            lb.Save();
                        }
                    }
                    else
                    {
                        int           i        = 0;
                        List <string> newKills = new List <string>();
                        WOTHelper.AddToLog("BM 2: " + item.BattleMode);
                        dr = currentRecord.Select(String.Format("cmCountryID = {0} and cmTankID = {1} and bpBattleMode <> '{2}'", item.CountryID, item.TankID, item.BattleMode)).DefaultIfEmpty(null).FirstOrDefault();

                        if (dr != null)
                        {
                            foreach (DataRow killRow in mt.GetTable("File_FragList").Select("fgParentID = " + item.ID))
                            {
                                DataRow dr_oldKills = Kills.Select(String.Format(@"fgParentID = {0} and  fgCountryID = {1} and fgTankID = {2}", dr.GetSafeInt("cmID"), killRow.GetSafeInt("fgCountryID"), killRow.GetSafeInt("fgTankID"))).FirstOrDefault();
                                if (dr_oldKills != null)
                                {
                                    if (killRow.GetSafeInt("fgValue") > dr_oldKills.GetSafeInt("kills"))
                                    {
                                        newKills.Add(String.Format("{0}:{1}_{2}", i, killRow.GetSafeInt("fgCountryID"), killRow.GetSafeInt("fgTankID")));
                                        i++;
                                    }
                                }
                                else
                                {
                                    newKills.Add(String.Format("{0}:{1}_{2}", i, killRow.GetSafeInt("fgCountryID"), killRow.GetSafeInt("fgTankID")));
                                    i++;
                                }
                            }
                        }
                        else
                        {
                            foreach (DataRow killRow in mt.GetTable("File_FragList").Select("fgParentID = " + item.ID))
                            {
                                newKills.Add(String.Format("{0}:{1}_{2}", i, killRow.GetSafeInt("fgCountryID"), killRow.GetSafeInt("fgTankID")));
                                i++;
                            }
                        }
                        int vic = 0;
                        if (item.Victory - 0 > 0)
                        {
                            vic = 0;
                        }
                        else if (item.Losses - 0 > 0)
                        {
                            vic = 1;
                        }
                        else
                        {
                            vic = 2;
                        }

                        lb.Add(int.Parse(item.BattleTime), new RecentBattle()
                        {
                            CountryID              = item.CountryID,
                            TankID                 = item.TankID,
                            Battles                = item.BattleCount,
                            BattleTime             = int.Parse(item.BattleTime),
                            Hits                   = item.Hits,
                            Shot                   = item.Shots,
                            Victory                = vic,
                            Survived               = item.Survived,
                            DefencePoints          = item.DefencePoints,
                            CapturePoints          = item.CapturePoints,
                            Spotted                = item.Spotted,
                            DamageDealt            = item.DamageDealt,
                            DamageAssistedRadio    = item.DamageAssistedRadio,
                            DamageAssistedTracks   = item.DamageAssistedTracks,
                            DamageReceived         = item.DamageReceived,
                            Kills                  = item.Kills,
                            Mileage                = item.Mileage,
                            XPReceived             = item.XPReceived,
                            OriginalBattleCount    = item.BattleCount,
                            FragList               = string.Join(";", newKills.ToArray().Take(15)),
                            GlobalAvgTier          = avgTier,
                            GlobalWinPercentage    = vics,
                            GlobalAvgDefencePoints = defPoints,
                            BattleMode             = item.BattleMode,
                            RatingEff              = item.RatingEff,
                            RatingBR               = item.RatingBR,
                            RatingWN7              = item.RatingWN7,
                            RatingWN8              = item.RatingWN8,
                            DBEntry                = false
                        });

                        lb.Save();
                    }
                }
            }
            //}
            //catch (Exception ex)
            //{
            //    _messages.Add(String.Format("Error : Cannot create last battle ({0}) - {1}", GetPlayerName, ex.Message));
            //}
        }