Esempio n. 1
0
        public override bool Run()
        {
            if (base.Run())
            {
                DebugInfo.Add("xboxleaders generator");
                var profileXml = XDocument.Load(this.ProfileFile.FullName);
                var gamesXml = XDocument.Load(this.GamesFile.FullName);

                var xblGames = new List<XblGame>();
                #region Games
                var xblFiles = this.GameFiles;
                foreach (var xblFile in xblFiles)
                {
                    var fileXml = XDocument.Load(xblFile.FullName).Descendants("data").First();
                    var game = new XblGame();
                    game.Title = fileXml.Element("game").Value
                        .Replace("&trade;", "")
                        .Replace("&reg;", "")
                        .Replace("&#039;", "'")
                        .Replace(@"NightsⅡ/NA", "Nights II/NA");
                    // todo Hack until this is once again returned by the XML.
                    game.Id = xblFile.Name.Replace("achievements-", "").Replace(".xml", "");
                    game.LastPlayed = Shared.ConvertStringToDateTime(fileXml.Element("lastplayed").Value);
                    game.EarnedGamerScore = int.Parse(fileXml.Element("gamerscore").Element("current").Value);
                    game.PossibleGamerScore = int.Parse(fileXml.Element("gamerscore").Element("total").Value);
                    game.EarnedAchievements = int.Parse(fileXml.Element("achievement").Element("current").Value);
                    game.PossibleAchievements = int.Parse(fileXml.Element("achievement").Element("total").Value);

                    var achievements = fileXml.Elements("achievements");
                    if (achievements == null || achievements.Count() == 1)
                    {
                        achievements = fileXml.Element("achievements").Elements("achievement");
                    }

                    foreach (var achievement in achievements)
                    {
                        var gameAchievement = new BasicAchievement();
                        gameAchievement.Id = achievement.Element("id").Value;
                        gameAchievement.Title = achievement.Element("title").Value
                            .Replace("Secret Achievement", "")
                            .Replace("&eacute;", "é")
                            .Replace("&quot;", "\"")
                            .Replace("&rsquo;", "'")
                            .Replace("&hellip;", "...")
                            .Replace("&amp;", "&")
                            .Replace("&auml;", "ä")
                            .Replace("&#039;", "'")
                            .Trim();
                        gameAchievement.Image = (!string.IsNullOrWhiteSpace(achievement.Element("artwork").Element("unlocked").Value) ?
                            achievement.Element("artwork").Element("unlocked").Value : achievement.Element("artwork").Element("locked").Value)
                            .Replace("https://live.xbox.com/Content/Images/HiddenAchievement.png", "");
                        gameAchievement.Description = achievement.Element("description").Value
                            .Replace("This is a secret achievement. Unlock it to find out more.", "")
                            .Replace("&amp;", "&")
                            .Replace("&#039;", "'")
                            .Replace("&quot;", "\"")
                            .Replace("&hellip;", "...")
                            .Replace("&eacute;", "é")
                            .Replace("&rsquo;", "'")
                            .Trim();
                        gameAchievement.Earned =
                            achievement.Element("unlocked").Value == "1" ?
                                (achievement.Element("unlockdate") != null && !string.IsNullOrWhiteSpace(achievement.Element("unlockdate").Value)
                                ? Shared.ConvertStringToDateTime(achievement.Element("unlockdate").Value)
                                : new DateTime())
                            : null;
                        if (gameAchievement.Earned.HasValue)
                        {
                            gameAchievement.Earned = gameAchievement.Earned.Value.AddHours(-1);
                            if (gameAchievement.Earned.Value.Year < 1981)
                            {
                                gameAchievement.Earned = new DateTime();
                            }
                        }
                        gameAchievement.GamerScore = achievement.Element("gamerscore").Value
                            .Replace("--", "0");

                        if (achievement.Element("secret").Value == "1" || achievement.Element("description").Value.StartsWith("This is a secret achievement."))
                        {
                            gameAchievement.UpdateHiddenAchievement(achievement.Element("id").Value, game.Id, this.HiddenAchievementsDirectory);
                        }

                        if (gameAchievement.Earned == new DateTime())
                        {
                            gameAchievement.UpdateOfflineAchievement(achievement.Element("id").Value, game.Id, this.OfflineAchievementsXmlPath);
                        }

                        game.Achievements.Add(gameAchievement);
                    }
                    // We only want to add games that have achievements.
                    if (game.Achievements.Count > 0)
                    {
                        xblGames.Add(game);
                    }
                }
                xblGames = xblGames.OrderBy(g => g.Title).ToList();
                this.Games = xblGames;
                #endregion

                #region Achievements
                var xblAchievements = new List<Achievement>();

                foreach (var xblFile in this.GameFiles)
                {
                    var fileXml = XDocument.Load(xblFile.FullName).Descendants("data").First();
                    var gameTitle = fileXml.Element("game").Value
                        .Replace("&trade;", "")
                        .Replace("&reg;", "")
                        .Replace("&#039;", "'")
                        .Replace(@"NightsⅡ/NA", "Nights II/NA");
                    // todo Hack until this is once again returned by the XML.
                    var gameId = xblFile.Name.Replace("achievements-", "").Replace(".xml", "");

                    var achievements = fileXml.Elements("achievements");
                    if (achievements == null || achievements.Count() == 1)
                    {
                        achievements = fileXml.Element("achievements").Elements("achievement");
                    }

                    foreach (var achievement in achievements)
                    {
                        var gameAchievement = new Achievement();
                        gameAchievement.Title = achievement.Element("title").Value
                            .Replace("Secret Achievement", "")
                            .Replace("&eacute;", "é")
                            .Replace("&quot;", "\"")
                            .Replace("&rsquo;", "'")
                            .Replace("&hellip;", "...")
                            .Replace("&amp;", "&")
                            .Replace("&auml;", "ä")
                            .Replace("&#039;", "'")
                            .Trim();
                        gameAchievement.Id = achievement.Element("id").Value;
                        gameAchievement.Image = (!string.IsNullOrWhiteSpace(achievement.Element("artwork").Element("unlocked").Value) ?
                            achievement.Element("artwork").Element("unlocked").Value : achievement.Element("artwork").Element("locked").Value)
                            .Replace("https://live.xbox.com/Content/Images/HiddenAchievement.png", "");
                        gameAchievement.Description = achievement.Element("description").Value
                            .Replace("This is a secret achievement. Unlock it to find out more.", "")
                            .Replace("&amp;", "&")
                            .Replace("&#039;", "'")
                            .Replace("&quot;", "\"")
                            .Replace("&hellip;", "...")
                            .Replace("&eacute;", "é")
                            .Replace("&rsquo;", "'")
                            .Trim();
                        gameAchievement.Earned =
                            achievement.Element("unlocked").Value == "1" ?
                                (achievement.Element("unlockdate") != null && !string.IsNullOrWhiteSpace(achievement.Element("unlockdate").Value)
                                ? Shared.ConvertStringToDateTime(achievement.Element("unlockdate").Value)
                                : new DateTime())
                            : null;
                        // temporary fix
                        if (gameAchievement.Earned.HasValue)
                        {
                            gameAchievement.Earned = gameAchievement.Earned.Value.AddHours(-1);
                            if (gameAchievement.Earned.Value.Year < 1981)
                            {
                                gameAchievement.Earned = new DateTime();
                            }
                        }
                        gameAchievement.GamerScore = achievement.Element("gamerscore").Value
                            .Replace("--", "0");
                        gameAchievement.GameTitle = gameTitle;
                        gameAchievement.GameId = gameId;

                        if (achievement.Element("secret").Value == "1" || achievement.Element("description").Value.StartsWith("This is a secret achievement."))
                        {
                            gameAchievement.UpdateHiddenAchievement(this.HiddenAchievementsDirectory);
                        }

                        if (gameAchievement.Earned == new DateTime())
                        {
                            gameAchievement.UpdateOfflineAchievement(this.OfflineAchievementsXmlPath);
                        }

                        xblAchievements.Add(gameAchievement);
                    }
                    xblAchievements = xblAchievements.OrderBy(a => a.GameTitle).ThenByDescending(a => a.Earned).ToList();
                    this.Achievements = xblAchievements;
                }
                #endregion

                #region Games Basic
                var xblGamesBasic = new List<PlayedGame>();
                foreach (var game in gamesXml.Descendants("game"))
                {
                    var playedGame = new PlayedGame();
                    playedGame.Id = game.Element("id").Value;
                    playedGame.Title = game.Element("title").Value
                        .Replace("&trade;", "")
                        .Replace("&reg;", "")
                        .Replace("&#039;", "'")
                        .Replace(@"NightsⅡ/NA", "Nights II/NA");
                    playedGame.Image = game.Element("artwork").Element("small").Value;
                    playedGame.LastPlayed = Shared.ConvertStringToDateTime(game.Element("lastplayed").Value).Value;
                    playedGame.Progress = double.Parse(game.Element("progress").Value);
                    playedGame.EarnedPoints = int.Parse(game.Element("gamerscore").Element("current").Value);
                    playedGame.EarnedAccomplishments = int.Parse(game.Element("achievements").Element("current").Value);
                    playedGame.TotalPoints = int.Parse(game.Element("gamerscore").Element("total").Value);
                    playedGame.TotalAccomplishments = int.Parse(game.Element("achievements").Element("total").Value);
                    playedGame.Platform = "xbox";

                    var gameAccomplishments = xblAchievements.Where(a => a.GameId == playedGame.Id).Select(a => new
                    {
                        Type = a.GamerScore,
                        Earned = a.Earned
                    });

                    var allTypes = gameAccomplishments.GroupBy(a => a.Type);
                    foreach (var type in allTypes)
                    {
                        playedGame.Accomplishments.Add(new SimpleAccomplishment
                        {
                            Type = type.Key,
                            Value = int.Parse(type.Key),
                            Total = type.Count(),
                            Earned = type.Where(t => t.Earned.HasValue).Count()
                        });
                    }
                    playedGame.Accomplishments = playedGame.Accomplishments.OrderBy(a => a.Value).ToList();
                    if (playedGame.Accomplishments.Count > 0)
                    {
                        xblGamesBasic.Add(playedGame);
                    }
                }
                this.GamesBasic = xblGamesBasic;
                #endregion

                #region Profile
                var xblProfile = new XblProfile();
                xblProfile.Id = gamesXml.Element("xbox").Element("data").Element("gamertag").Value;
                xblProfile.Pic = profileXml.Element("xbox").Element("data").Element("avatar").Element("tile").Value;
                xblProfile.GamerScore = int.Parse(gamesXml.Element("xbox").Element("data").Element("gamerscore").Element("current").Value);
                xblProfile.PossibleGamerScore = int.Parse(gamesXml.Element("xbox").Element("data").Element("gamerscore").Element("total").Value);
                xblProfile.Achievements = int.Parse(gamesXml.Element("xbox").Element("data").Element("achievements").Element("current").Value);
                xblProfile.PossibleAchievements = int.Parse(gamesXml.Element("xbox").Element("data").Element("achievements").Element("total").Value);
                xblProfile.CompletionPercent = double.Parse(gamesXml.Element("xbox").Element("data").Element("progress").Value);
                xblProfile.TotalGames = this.Games.Count;
                this.Profile = xblProfile;
                #endregion

                #region Stats
                var accomplishments = VideoGameAccomplishment.ParseAchievements(this.Achievements);
                this.Stats = new VideoGameStats(accomplishments);
                #endregion

                return true;
            }
            return false;
        }
Esempio n. 2
0
        public override bool Run()
        {
            if (base.Run())
            {
                DebugInfo.Add("psn unofficial generator");
                var profileXml = XDocument.Load(this.ProfileFile.FullName).Root;
                var gamesXml = XDocument.Load(this.GamesFile.FullName);

                var psnGames = new List<PsnGame>();
                var psnXml = gamesXml.Descendants("UserGame");

                #region Games
                foreach (var game in psnXml)
                {
                    var psnGame = new PsnGame();
                    psnGame.Title = game.Element("Title").Value.Trim();
                    psnGame.Id = game.Element("Id").Value;
                    psnGame.LastPlayed = Shared.ParseXmlDateTime(game.Element("LastUpdated").Value, 0);
                    psnGame.EarnedPoints = int.Parse(game.Element("EarnedPoints").Value);
                    psnGame.PossiblePoints = int.Parse(game.Element("TotalPoints").Value);
                    psnGame.EarnedTrophies = int.Parse(game.Element("TotalEarned").Value);
                    psnGame.PossibleTrophies = int.Parse(game.Element("PossibleTrophies").Value);
                    psnGame.EarnedBronze = int.Parse(game.Element("BronzeEarned").Value);
                    psnGame.EarnedSilver = int.Parse(game.Element("SilverEarned").Value);
                    psnGame.EarnedGold = int.Parse(game.Element("GoldEarned").Value);
                    psnGame.EarnedPlatinum = int.Parse(game.Element("PlatinumEarned").Value);
                    psnGame.Platform = game.Element("Platform").Value;

                    var trophyXml = XDocument.Load(this.GameFiles.SingleOrDefault(f => f.Name.Contains(psnGame.Id)).FullName);
                    foreach (var gameTrophy in trophyXml.Descendants("UserTrophy"))
                    {
                        var trophy = new BasicTrophy();
                        trophy.Id = gameTrophy.Element("Id").Value;
                        trophy.Title = gameTrophy.Element("Title").Value.Trim();
                        trophy.Image = gameTrophy.Element("ImageUrl").Value;
                        trophy.Description = gameTrophy.Element("Description").Value;
                        trophy.Earned = Shared.ParseXmlDateTime(gameTrophy.Element("Earned").Value, 0);
                        trophy.Type = gameTrophy.Element("Type").Value.ToUpper();

                        psnGame.Trophies.Add(trophy);
                    }
                    psnGames.Add(psnGame);
                }
                psnGames = psnGames.OrderBy(g => g.Title).ToList();
                this.Games = psnGames;
                #endregion

                #region Trophies
                var psnTrophies = new List<Trophy>();

                foreach (var game in psnXml)
                {
                    var gameTitle = game.Element("Title").Value.Trim();
                    var gameId = game.Element("Id").Value;

                    var trophyXml = XDocument.Load(this.GameFiles.SingleOrDefault(f => f.Name.Contains(gameId)).FullName);
                    foreach (var gameTrophy in trophyXml.Descendants("UserTrophy"))
                    {
                        var trophy = new Trophy();
                        trophy.Title = gameTrophy.Element("Title").Value.Trim();
                        trophy.Id = gameTrophy.Element("Id").Value;
                        trophy.Image = gameTrophy.Element("ImageUrl").Value;
                        trophy.Description = gameTrophy.Element("Description").Value;
                        trophy.Earned = Shared.ParseXmlDateTime(gameTrophy.Element("Earned").Value, 0);
                        trophy.Type = gameTrophy.Element("Type").Value.ToUpper();
                        trophy.GameTitle = gameTitle;
                        trophy.GameId = gameId;

                        psnTrophies.Add(trophy);
                    }
                }
                psnTrophies = psnTrophies.OrderBy(t => t.GameTitle).ThenByDescending(t => t.Earned).ThenBy(t => int.Parse(t.Id)).ToList();
                this.Trophies = psnTrophies;
                #endregion

                #region Games Basic
                var psnGamesBasic = new List<PlayedGame>();

                foreach (var game in psnXml)
                {
                    var playedGame = new PlayedGame();
                    playedGame.Id = game.Element("Id").Value;
                    playedGame.Title = game.Element("Title").Value;
                    playedGame.Image = game.Element("ImageUrl").Value;
                    playedGame.LastPlayed = Shared.ParseXmlDateTime(game.Element("LastUpdated").Value, 0).Value;
                    playedGame.Progress = double.Parse(game.Element("Progress").Value);
                    playedGame.EarnedPoints = int.Parse(game.Element("EarnedPoints").Value);
                    playedGame.EarnedAccomplishments = int.Parse(game.Element("TotalEarned").Value);
                    playedGame.TotalPoints = int.Parse(game.Element("TotalPoints").Value);
                    playedGame.TotalAccomplishments = int.Parse(game.Element("PossibleTrophies").Value);
                    playedGame.Platform = game.Element("Platform").Value;

                    var gameAccomplishments = psnTrophies.Where(t => t.GameId == playedGame.Id).Select(t => new
                    {
                        Type = t.Type,
                        Earned = t.Earned
                    });
                    var allTypes = gameAccomplishments.GroupBy(a => a.Type);
                    foreach (var type in allTypes)
                    {
                        playedGame.Accomplishments.Add(new SimpleAccomplishment
                        {
                            Type = type.Key,
                            Value = Psn.TrophyTypeToPoints(type.Key),
                            Total = type.Count(),
                            Earned = type.Where(t => t.Earned.HasValue).Count()
                        });
                    }
                    playedGame.Accomplishments = playedGame.Accomplishments.OrderBy(a => a.Value).ToList();
                    psnGamesBasic.Add(playedGame);
                }
                this.GamesBasic = psnGamesBasic;
                #endregion

                #region Profile
                var psnProfile = new PsnProfile();
                psnProfile.Id = profileXml.Element("Id").Value;
                psnProfile.Pic = profileXml.Element("ImageUrl").Value;
                psnProfile.Points = int.Parse(profileXml.Element("EarnedPoints").Value);
                psnProfile.Level = int.Parse(profileXml.Element("Level").Value);
                psnProfile.LevelProgress = double.Parse(profileXml.Element("LevelProgress").Value);
                psnProfile.NextLevelPoints = int.Parse(profileXml.Element("LevelNextPoints").Value);
                psnProfile.Trophies = int.Parse(profileXml.Element("TotalEarned").Value);
                psnProfile.TrophiesBronze = int.Parse(profileXml.Element("BronzeEarned").Value);
                psnProfile.TrophiesSilver = int.Parse(profileXml.Element("SilverEarned").Value);
                psnProfile.TrophiesGold = int.Parse(profileXml.Element("GoldEarned").Value);
                psnProfile.TrophiesPlatinum = int.Parse(profileXml.Element("PlatinumEarned").Value);
                psnProfile.PossibleTrophies = Trophies.Count;
                psnProfile.PossibleTrophiesBronze = Trophies.Where(t => t.Type == "BRONZE").Count();
                psnProfile.PossibleTrophiesSilver = Trophies.Where(t => t.Type == "SILVER").Count();
                psnProfile.PossibleTrophiesGold = Trophies.Where(t => t.Type == "GOLD").Count();
                psnProfile.PossibleTrophiesPlatinum = Trophies.Where(t => t.Type == "PLATINUM").Count();
                psnProfile.CompletionPercent = (100d * psnProfile.Trophies / psnProfile.PossibleTrophies);
                psnProfile.TotalGames = gamesXml.Descendants().Elements("UserGame").Count();
                psnProfile.PossiblePoints = ((psnProfile.PossibleTrophiesBronze * (int)Psn.TrophyPoints.Bronze)
                    + (psnProfile.PossibleTrophiesSilver * (int)Psn.TrophyPoints.Silver)
                    + (psnProfile.PossibleTrophiesGold * (int)Psn.TrophyPoints.Gold)
                    + (psnProfile.PossibleTrophiesPlatinum * (int)Psn.TrophyPoints.Platinum));
                this.Profile = psnProfile;
                #endregion

                #region Stats
                var accomplishments = VideoGameAccomplishment.ParseTrophies(this.Trophies);
                this.Stats = new VideoGameStats(accomplishments);
                #endregion

                return true;
            }
            return false;
        }
Esempio n. 3
0
        public override bool Run()
        {
            if (base.Run())
            {
                DebugInfo.Add("xboxapi generator");
                var profileXml = XDocument.Load(this.ProfileFile.FullName);
                var gamesXml = XDocument.Load(this.GamesFile.FullName);

                var xblGames = new List<XblGame>();
                #region Games
                var xblFiles = this.GameFiles;
                foreach (var xblFile in xblFiles)
                {
                    var fileXml = XDocument.Load(xblFile.FullName).Root;
                    var game = new XblGame();
                    game.Title = fileXml.Element("Game").Element("Name").Value;
                    game.Id = fileXml.Element("Game").Element("ID").Value;
                    game.LastPlayed = Shared.ConvertStringToDateTime(fileXml.Element("Game").Element("Progress").Element("LastPlayed-UNIX").Value);
                    game.EarnedGamerScore = int.Parse(fileXml.Element("Game").Element("Progress").Element("Gamerscore").Value);
                    game.PossibleGamerScore = int.Parse(fileXml.Element("Game").Element("PossibleGamerscore").Value);
                    game.EarnedAchievements = int.Parse(fileXml.Element("Game").Element("Progress").Element("EarnedAchievements").Value);
                    game.PossibleAchievements = int.Parse(fileXml.Element("Game").Element("PossibleAchievements").Value);

                    var achievements = fileXml.Elements("Achievements");
                    if (achievements == null || achievements.Count() == 1)
                    {
                        continue;
                    }

                    foreach (var achievement in achievements)
                    {
                        var gameAchievement = new BasicAchievement();
                        gameAchievement.Id = achievement.Element("ID").Value;
                        gameAchievement.Title = achievement.Element("Name").Value;
                        gameAchievement.Image = achievement.Element("TileUrl").Value;
                        gameAchievement.Description = achievement.Element("Description").Value;
                        gameAchievement.Earned =
                            !string.IsNullOrWhiteSpace(achievement.Element("EarnedOn-UNIX").Value) ?
                                (achievement.Element("IsOffline").Value != "1" || achievement.Element("EarnedOn-UNIX").Value.StartsWith("-")
                                ? Shared.ConvertStringToDateTime(achievement.Element("EarnedOn-UNIX").Value)
                                : new DateTime())
                            : null;
                        if (gameAchievement.Earned.HasValue)
                        {
                            if (gameAchievement.Earned.Value.Year < 1981)
                            {
                                gameAchievement.Earned = new DateTime();
                            }
                        }
                        gameAchievement.GamerScore = achievement.Element("Score").Value
                            .Replace("--", "0");

                        if (string.IsNullOrWhiteSpace(achievement.Element("Name").Value))
                        {
                            gameAchievement.UpdateHiddenAchievement(achievement.Element("ID").Value, game.Id, this.HiddenAchievementsDirectory);
                        }

                        if (gameAchievement.Earned == new DateTime())
                        {
                            gameAchievement.UpdateOfflineAchievement(achievement.Element("ID").Value, game.Id, this.OfflineAchievementsXmlPath);
                        }

                        game.Achievements.Add(gameAchievement);
                    }
                    // We only want to add games that have achievements.
                    if (game.Achievements.Count > 0)
                    {
                        xblGames.Add(game);
                    }
                }
                xblGames = xblGames.OrderBy(g => g.Title).ToList();
                this.Games = xblGames;
                #endregion

                #region Achievements
                var xblAchievements = new List<Achievement>();

                foreach (var xblFile in this.GameFiles)
                {
                    var fileXml = XDocument.Load(xblFile.FullName).Root;
                    var gameTitle = fileXml.Element("Game").Element("Name").Value;
                    var gameId = fileXml.Element("Game").Element("ID").Value;

                    var achievements = fileXml.Elements("Achievements");
                    if (achievements == null || achievements.Count() == 1)
                    {
                        continue;
                    }

                    foreach (var achievement in achievements)
                    {
                        var gameAchievement = new Achievement();
                        gameAchievement.Title = achievement.Element("Name").Value;
                        gameAchievement.Id = achievement.Element("ID").Value;
                        gameAchievement.Image = achievement.Element("TileUrl").Value;
                        gameAchievement.Description = achievement.Element("Description").Value;
                        gameAchievement.Earned =
                            !string.IsNullOrWhiteSpace(achievement.Element("EarnedOn-UNIX").Value) ?
                                (achievement.Element("IsOffline").Value != "1" || achievement.Element("EarnedOn-UNIX").Value.StartsWith("-")
                                ? Shared.ConvertStringToDateTime(achievement.Element("EarnedOn-UNIX").Value)
                                : new DateTime())
                            : null;
                        if (gameAchievement.Earned.HasValue)
                        {
                            if (gameAchievement.Earned.Value.Year < 1981)
                            {
                                gameAchievement.Earned = new DateTime();
                            }
                        }
                        gameAchievement.GamerScore = achievement.Element("Score").Value
                            .Replace("--", "0");
                        gameAchievement.GameTitle = gameTitle;
                        gameAchievement.GameId = gameId;

                        if (string.IsNullOrWhiteSpace(achievement.Element("Name").Value))
                        {
                            gameAchievement.UpdateHiddenAchievement(achievement.Element("ID").Value, gameId, this.HiddenAchievementsDirectory);
                        }

                        if (gameAchievement.Earned == new DateTime())
                        {
                            gameAchievement.UpdateOfflineAchievement(achievement.Element("ID").Value, gameId, this.OfflineAchievementsXmlPath);
                        }

                        xblAchievements.Add(gameAchievement);
                    }
                    xblAchievements = xblAchievements.OrderBy(a => a.GameTitle).ThenByDescending(a => a.Earned).ToList();
                    this.Achievements = xblAchievements;
                }
                #endregion

                #region Games Basic
                var xblGamesBasic = new List<PlayedGame>();
                foreach (var game in gamesXml.Descendants("Games"))
                {
                    var playedGame = new PlayedGame();
                    playedGame.Id = game.Element("ID").Value;
                    playedGame.Title = game.Element("Name").Value;
                    playedGame.Image = game.Element("BoxArt").Element("Small").Value;
                    playedGame.LastPlayed = Shared.ConvertStringToDateTime(game.Element("Progress").Element("LastPlayed-UNIX").Value).Value;
                    playedGame.EarnedPoints = int.Parse(game.Element("Progress").Element("Score").Value);
                    playedGame.EarnedAccomplishments = int.Parse(game.Element("Progress").Element("Achievements").Value);
                    playedGame.TotalPoints = int.Parse(game.Element("PossibleGamerscore").Value);
                    playedGame.TotalAccomplishments = int.Parse(game.Element("PossibleAchievements").Value);
                    playedGame.Progress = Math.Round((double)playedGame.EarnedAccomplishments / playedGame.TotalAccomplishments * 100, 1);
                    playedGame.Platform = "xbox";

                    var gameAccomplishments = xblAchievements.Where(a => a.GameId == playedGame.Id).Select(a => new
                    {
                        Type = a.GamerScore,
                        Earned = a.Earned
                    });

                    var allTypes = gameAccomplishments.GroupBy(a => a.Type);
                    foreach (var type in allTypes)
                    {
                        playedGame.Accomplishments.Add(new SimpleAccomplishment
                        {
                            Type = type.Key,
                            Value = int.Parse(type.Key),
                            Total = type.Count(),
                            Earned = type.Where(t => t.Earned.HasValue).Count()
                        });
                    }
                    playedGame.Accomplishments = playedGame.Accomplishments.OrderBy(a => a.Value).ToList();
                    if (playedGame.Accomplishments.Count > 0)
                    {
                        xblGamesBasic.Add(playedGame);
                    }
                }
                this.GamesBasic = xblGamesBasic;
                #endregion

                #region Profile
                var xblProfile = new XblProfile();
                xblProfile.Id = gamesXml.Element("Data").Element("Player").Element("Gamertag").Value;
                xblProfile.Pic = profileXml.Element("Data").Element("Player").Element("Avatar").Element("Gamertile").Element("Large").Value;
                xblProfile.GamerScore = int.Parse(gamesXml.Element("Data").Element("Player").Element("Gamerscore").Value);
                xblProfile.PossibleGamerScore = xblGamesBasic.Sum(g => g.TotalPoints);
                xblProfile.Achievements = xblGamesBasic.Sum(g => g.EarnedAccomplishments);
                xblProfile.PossibleAchievements = xblGamesBasic.Sum(g => g.TotalAccomplishments);
                xblProfile.CompletionPercent = double.Parse(gamesXml.Element("Data").Element("Player").Element("PercentComplete").Value);
                xblProfile.TotalGames = this.Games.Count;
                this.Profile = xblProfile;
                #endregion

                #region Stats
                var accomplishments = VideoGameAccomplishment.ParseAchievements(this.Achievements);
                this.Stats = new VideoGameStats(accomplishments);
                #endregion
            }
            return false;
        }