Пример #1
0
		internal void Initialize(IQueryAdapter dbClient)
		{
			dbClient.setQuery("SELECT * FROM achievements_talenttrack ORDER BY `order_num` ASC");
			DataTable table = dbClient.getTable();
			foreach (DataRow dataRow in table.Rows)
			{
				Talent talent = new Talent((int)dataRow["id"], (string)dataRow["type"], (int)dataRow["parent_category"], (int)dataRow["level"], (string)dataRow["achievement_group"], (int)dataRow["achievement_level"], (string)dataRow["prize"], (uint)dataRow["prize_baseitem"]);
				this.Talents.Add(talent.Id, talent);
			}
		}
Пример #2
0
		internal void CompleteUserTalent(GameClient Session, Talent Talent)
		{
			if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().CurrentTalentLevel < Talent.Level)
			{
				return;
			}
			if (!this.LevelIsCompleted(Session, Talent.Level))
			{
				return;
			}
			if (Talent.Prize != "" && Talent.PrizeBaseItem > 0u)
			{
				Item item = CyberEnvironment.GetGame().GetItemManager().GetItem(Talent.PrizeBaseItem);
				CyberEnvironment.GetGame().GetCatalog().DeliverItems(Session, item, 1, "", 0, 0, "");
			}
			UserTalent value = new UserTalent(Talent.Id, 1);
			Session.GetHabbo().Talents.Add(Talent.Id, value);
			using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
			{
				queryreactor.runFastQuery(string.Concat(new object[]
				{
					"REPLACE INTO user_talents VALUES (",
					Session.GetHabbo().Id,
					", ",
					Talent.Id,
					", ",
					1,
					");"
				}));
				queryreactor.runFastQuery(string.Concat(new object[]
				{
					"UPDATE users SET talent_status = '",
					Talent.Type,
					"' WHERE id = ",
					Session.GetHabbo().Id,
					";"
				}));
			}
			ServerMessage serverMessage = new ServerMessage(Outgoing.TalentLevelUpMessageComposer);
			serverMessage.AppendString(Session.GetHabbo().TalentStatus);
			serverMessage.AppendInt32(Talent.Level);
			serverMessage.AppendInt32(0);
			serverMessage.AppendInt32(1);
			serverMessage.AppendString(Talent.Prize);
			serverMessage.AppendInt32(0);
			Session.SendMessage(serverMessage);
		}
Пример #3
0
        internal bool ProgressUserAchievement(GameClient Session, string AchievementGroup, int ProgressAmount, bool FromZero = false)
        {
            if (!this.Achievements.ContainsKey(AchievementGroup) || Session == null)
            {
                return(false);
            }
            Achievement achievement = null;

            achievement = this.Achievements[AchievementGroup];
            UserAchievement userAchievement = Session.GetHabbo().GetAchievementData(AchievementGroup);

            if (userAchievement == null)
            {
                userAchievement = new UserAchievement(AchievementGroup, 0, 0);
                Session.GetHabbo().Achievements.Add(AchievementGroup, userAchievement);
            }
            int count = achievement.Levels.Count;

            if (userAchievement != null && userAchievement.Level == count)
            {
                return(false);
            }
            checked
            {
                int num = (userAchievement != null) ? (userAchievement.Level + 1) : 1;
                if (num > count)
                {
                    num = count;
                }
                AchievementLevel targetLevelData = achievement.Levels[num];
                int num2 = 0;
                if (FromZero)
                {
                    num2 = ProgressAmount;
                }
                else
                {
                    num2 = ((userAchievement != null) ? (userAchievement.Progress + ProgressAmount) : ProgressAmount);
                }
                int num3 = (userAchievement != null) ? userAchievement.Level : 0;
                int num4 = num3 + 1;
                if (num4 > count)
                {
                    num4 = count;
                }
                if (num2 >= targetLevelData.Requirement)
                {
                    num3++;
                    num4++;
                    int arg_E6_0 = num2 - targetLevelData.Requirement;
                    num2 = 0;
                    if (num == 1)
                    {
                        Session.GetHabbo().GetBadgeComponent().GiveBadge(AchievementGroup + num, true, Session, false);
                    }
                    else
                    {
                        Session.GetHabbo().GetBadgeComponent().RemoveBadge(Convert.ToString(AchievementGroup + (num - 1)), Session);
                        Session.GetHabbo().GetBadgeComponent().GiveBadge(AchievementGroup + num, true, Session, false);
                    }
                    if (num4 > count)
                    {
                        num4 = count;
                    }
                    Session.GetHabbo().ActivityPoints += targetLevelData.RewardPixels;
                    Session.GetHabbo().NotifyNewPixels(targetLevelData.RewardPixels);
                    Session.GetHabbo().UpdateActivityPointsBalance();
                    Session.SendMessage(AchievementUnlockedComposer.Compose(achievement, num, targetLevelData.RewardPoints, targetLevelData.RewardPixels));
                    using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                    {
                        queryreactor.setQuery(string.Concat(new object[]
                        {
                            "REPLACE INTO user_achievement VALUES (",
                            Session.GetHabbo().Id,
                            ", @group, ",
                            num3,
                            ", ",
                            num2,
                            ")"
                        }));
                        queryreactor.addParameter("group", AchievementGroup);
                        queryreactor.runQuery();
                    }
                    userAchievement.Level    = num3;
                    userAchievement.Progress = num2;
                    Session.GetHabbo().AchievementPoints += targetLevelData.RewardPoints;
                    Session.GetHabbo().NotifyNewPixels(targetLevelData.RewardPixels);
                    Session.GetHabbo().ActivityPoints += targetLevelData.RewardPixels;
                    Session.GetHabbo().UpdateActivityPointsBalance();
                    Session.SendMessage(AchievementScoreUpdateComposer.Compose(Session.GetHabbo().AchievementPoints));
                    AchievementLevel targetLevelData2 = achievement.Levels[num4];
                    Session.SendMessage(AchievementProgressComposer.Compose(achievement, num4, targetLevelData2, count, Session.GetHabbo().GetAchievementData(AchievementGroup)));
                    Talent talent = null;
                    if (CyberEnvironment.GetGame().GetTalentManager().TryGetTalent(AchievementGroup, out talent))
                    {
                        CyberEnvironment.GetGame().GetTalentManager().CompleteUserTalent(Session, talent);
                    }
                    return(true);
                }
                userAchievement.Level    = num3;
                userAchievement.Progress = num2;
                using (IQueryAdapter queryreactor2 = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                {
                    queryreactor2.setQuery(string.Concat(new object[]
                    {
                        "REPLACE INTO user_achievement VALUES (",
                        Session.GetHabbo().Id,
                        ", @group, ",
                        num3,
                        ", ",
                        num2,
                        ")"
                    }));
                    queryreactor2.addParameter("group", AchievementGroup);
                    queryreactor2.runQuery();
                }
                Session.SendMessage(AchievementProgressComposer.Compose(achievement, num, targetLevelData, count, Session.GetHabbo().GetAchievementData(AchievementGroup)));

                Session.GetMessageHandler().GetResponse().Init(Outgoing.UpdateUserDataMessageComposer);
                Session.GetMessageHandler().GetResponse().AppendInt32(-1);
                Session.GetMessageHandler().GetResponse().AppendString(Session.GetHabbo().Look);
                Session.GetMessageHandler().GetResponse().AppendString(Session.GetHabbo().Gender.ToLower());
                Session.GetMessageHandler().GetResponse().AppendString(Session.GetHabbo().Motto);
                Session.GetMessageHandler().GetResponse().AppendInt32(Session.GetHabbo().AchievementPoints);
                Session.GetMessageHandler().SendResponse();
                return(false);
            }
        }
Пример #4
0
		internal bool TryGetTalent(string AchGroup, out Talent talent)
		{
			foreach (Talent current in this.Talents.Values)
			{
				if (current.AchievementGroup == AchGroup)
				{
					talent = current;
					return true;
				}
			}
			talent = null;
			return false;
		}