/// <summary>
        ///     Composes the specified achievement.
        /// </summary>
        /// <param name="achievement">The achievement.</param>
        /// <param name="targetLevel">The target level.</param>
        /// <param name="targetLevelData">The target level data.</param>
        /// <param name="totalLevels">The total levels.</param>
        /// <param name="userData">The user data.</param>
        /// <returns>ServerMessage.</returns>
        internal static ServerMessage Compose(Achievement achievement, int targetLevel, AchievementLevel targetLevelData, int totalLevels, UserAchievement userData)
        {
            var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("AchievementProgressMessageComposer"));

            serverMessage.AppendInteger(achievement.Id);
            serverMessage.AppendInteger(targetLevel);
            serverMessage.AppendString($"{achievement.GroupName}{targetLevel}");
            serverMessage.AppendInteger(targetLevelData.Requirement);
            serverMessage.AppendInteger(targetLevelData.Requirement);
            serverMessage.AppendInteger(targetLevelData.RewardPixels);
            serverMessage.AppendInteger(0);
            serverMessage.AppendInteger(userData.Progress);
            serverMessage.AppendBool(userData.Level >= totalLevels);
            serverMessage.AppendString(achievement.Category);
            serverMessage.AppendString(string.Empty);
            serverMessage.AppendInteger(totalLevels);
            serverMessage.AppendInteger(0);

            return serverMessage;
        }
        /// <summary>
        ///     Gets the achievement levels.
        /// </summary>
        /// <param name="achievements">The achievements.</param>
        /// <param name="dbClient">The database client.</param>
        internal static void GetAchievementLevels(out Dictionary<string, Achievement> achievements,
            IQueryAdapter dbClient)
        {
            achievements = new Dictionary<string, Achievement>();
            dbClient.SetQuery("SELECT * FROM achievements_data");

            var table = dbClient.GetTable();

            foreach (DataRow dataRow in table.Rows)
            {
                var id = Convert.ToUInt32(dataRow["id"]);
                var category = (string)dataRow["category"];
                var text = (string)dataRow["group_name"];
                var level = (int)dataRow["level"];
                var rewardPixels = (int)dataRow["reward_pixels"];
                var rewardPoints = (int)dataRow["reward_points"];
                var requirement = (int)dataRow["progress_needed"];

                var level2 = new AchievementLevel(level, rewardPixels, rewardPoints, requirement);

                if (!achievements.ContainsKey(text))
                {
                    var achievement = new Achievement(id, text, category);
                    achievement.AddLevel(level2);
                    achievements.Add(text, achievement);
                }
                else
                {
                    if (!achievements[text].CheckLevel(level2))
                        achievements[text].AddLevel(level2);
                    else
                        Out.WriteLine("Was Found a Duplicated Level for: " + text + ", Level: " + level2.Level,
                            "[Azure.Achievements]", ConsoleColor.Cyan);
                }
            }
        }
Exemplo n.º 3
0
 public bool CheckLevel(AchievementLevel level)
 {
     return Levels.ContainsKey(level.Level);
 }
Exemplo n.º 4
0
 /// <summary>
 ///     Adds the level.
 /// </summary>
 /// <param name="level">The level.</param>
 public void AddLevel(AchievementLevel level)
 {
     Levels.Add(level.Level, level);
 }