Exemple #1
0
        public void GetResponse(OutMessage Message, Character Character)
        {
            var Achievements = StorageHandler.GetCharacterAchievements(Character.Id);
            var Details = StorageHandler.GetAchievementDetailsSorted(Id);

            int MaxLevel = Details.Count() > 0 ? Details.Count() : 1;

            var MyProgress = new CharacterAchievement(-1, Character.Id, Id, 0);

            foreach (var Item in Achievements)
            {
                if (Item.AchievementId == Id)
                {
                    MyProgress = Item;
                }
            }

            var CurrentLevel = MyProgress.CurrentLevel;
            var NextLevel = (CurrentLevel + 1);

            int NextRequired = 1;

            foreach (var Item in Details)
            {
                if (Item.Level == NextLevel)
                {
                    NextRequired = Item.RequiredAmmount;
                }
            }

            if (NextLevel > MaxLevel)
            {
                NextLevel = MaxLevel;
            }

            if (CurrentLevel >= MaxLevel)
            {
                CurrentLevel = MaxLevel;
            }

            Message.Append(Id);
            Message.Append(NextLevel);
            Message.Append(GetBadge(NextLevel));
            Message.Append(NextRequired);
            Message.Append(GetPixelReward(NextLevel));
            Message.Append(0); // TODO <> BadgeId
            Message.Append(0); // TODO <> GotAlready
            Message.Append(CurrentLevel == MaxLevel);
            Message.Append(AchievementHandler.GetCategory(ParentId).Caption.ToLower());
            Message.Append(MaxLevel);
        }
Exemple #2
0
        public static SerializeResult Serialize()
        {
            NavigatorHandler.Serialize();
            AchievementHandler.Serialize();

            try
            {
                CharacterIgnores = new Dictionary<int, CharacterIgnore>();

                using (var Adapter = new DatabaseClient("SELECT * FROM character_ignores"))
                {
                    var Table = Adapter.GetTable();

                    foreach (DataRow Row in Table.Rows)
                    {
                        var Item = new CharacterIgnore(Row);

                        CharacterIgnores.Add(Item.Id, Item);
                    }
                }

                CharacterAchievements = new Dictionary<int, CharacterAchievement>();

                using (var Adapter = new DatabaseClient("SELECT * FROM character_achievements"))
                {
                    var Table = Adapter.GetTable();

                    foreach (DataRow Row in Table.Rows)
                    {
                        var Item = new CharacterAchievement(Row);

                        CharacterAchievements.Add(Item.Id, Item);
                    }
                }

                AchievementDetails = new Dictionary<int, AchievementDetail>();

                using (var Adapter = new DatabaseClient("SELECT * FROM achievements_details"))
                {
                    var Table = Adapter.GetTable();

                    foreach (DataRow Row in Table.Rows)
                    {
                        var Item = new AchievementDetail(Row);

                        AchievementDetails.Add(Item.Id, Item);
                    }
                }
            }
            catch { return SerializeResult.Broken; }

            return SerializeResult.Finished;
        }