/// <summary> /// Composes the specified session. /// </summary> /// <param name="session">The session.</param> /// <param name="talent">The Talent.</param> /// <returns>ServerMessage.</returns> internal static ServerMessage Compose(GameClient session, Talent talent) { ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("TalentLevelUpMessageComposer")); serverMessage.AppendString(talent.Type); serverMessage.AppendInteger(talent.Level); serverMessage.AppendInteger(0); if (talent.Type == "citizenship" && talent.Level == 4) { serverMessage.AppendInteger(2); serverMessage.AppendString("HABBO_CLUB_VIP_7_DAYS"); serverMessage.AppendInteger(7); serverMessage.AppendString(talent.Prize); serverMessage.AppendInteger(0); } else { serverMessage.AppendInteger(1); serverMessage.AppendString(talent.Prize); serverMessage.AppendInteger(0); } return serverMessage; }
/// <summary> /// Completes the user talent. /// </summary> /// <param name="session">The session.</param> /// <param name="talent">The talent.</param> internal void CompleteUserTalent(GameClient session, Talent talent) { if (session?.GetHabbo() == null || session.GetHabbo().CurrentTalentLevel < talent.Level || session.GetHabbo().Talents.ContainsKey(talent.Id)) return; if (!LevelIsCompleted(session, talent.Type, talent.Level)) return; if (!string.IsNullOrEmpty(talent.Prize) && talent.PrizeBaseItem > 0u) Yupi.GetGame().GetCatalog().DeliverItems(session, Yupi.GetGame().GetItemManager().GetItem(talent.PrizeBaseItem), 1, string.Empty, 0, 0, string.Empty); session.GetHabbo().Talents.Add(talent.Id, new UserTalent(talent.Id, 1)); using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor()) queryReactor.RunFastQuery($"REPLACE INTO users_talents VALUES ('{session.GetHabbo().Id}', '{talent.Id}', '1');"); session.SendMessage(AchievementTalentComposer.Compose(session, talent)); if (talent.Type == "citizenship") { switch (talent.Level) { case 3: Yupi.GetGame().GetAchievementManager().ProgressUserAchievement(session, "ACH_Citizenship", 1); break; case 4: session.GetHabbo().GetSubscriptionManager().AddSubscription(7); using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor()) queryReactor.RunFastQuery($"UPDATE users SET talent_status = 'helper' WHERE id = '{session.GetHabbo().Id}'"); break; } } }