public AchievementsComposer(Character Character, IEnumerable<AchievementCategory> Categorys) { base.WriteHeader(MessageComposerIds.AchievementsComposer); base.Write(System.HabboSystem.AchievementManager.GetAchievementAmount()); foreach (AchievementCategory Category in Categorys) { foreach (Achievement Achievement in Category.Achievements.Values) { int CurrentLevel = Character.GetAchievementProgress(Achievement.Id); int NextLevel = (CurrentLevel + 1); if (NextLevel > Achievement.Levels) { NextLevel = Achievement.Levels; } base.Write(Achievement.Id); base.Write(NextLevel); base.Write(Achievement.GetBadgeCode(NextLevel)); base.Write(Achievement.GetRequired(NextLevel)); base.Write(Achievement.GetPixelReward(NextLevel)); base.Write((int)AchievementRewardType.Pixels); base.Write(Character.GetAchievementProgessLimit(Achievement.Id)); base.Write(CurrentLevel == Achievement.Levels); base.Write(Category.Caption.ToLower()); base.Write(Achievement.Levels); } } }
public FriendListUpdateComposer(Character ToCharacter, Dictionary<int, int> Updates) { base.WriteHeader(MessageComposerIds.FriendListUpdateComposer); base.Write(ToCharacter.MessengerGroups.Count); foreach (var MessengerGroup in ToCharacter.MessengerGroups) { base.Write(MessengerGroup.Id); base.Write(MessengerGroup.Caption); } base.Write(Updates.Count); foreach (var kvp in Updates) { CharacterStatus Status = System.HabboSystem.CharacterManager.GetStatus(kvp.Key); base.Write(kvp.Value); base.Write(kvp.Key); base.Write(System.HabboSystem.CharacterManager.GetUsername(kvp.Key)); base.Write(true); base.Write(Status == CharacterStatus.Online); base.Write(System.HabboSystem.CharacterManager.GetCurrentRoom(kvp.Key)); base.Write(Status == CharacterStatus.Online ? System.HabboSystem.CharacterManager.GetFigure(kvp.Key) : string.Empty); base.Write(System.HabboSystem.MessengerManager.GetGroupId(ToCharacter.MessengerGroups, kvp.Key)); base.Write(Status == CharacterStatus.Online ? System.HabboSystem.CharacterManager.GetMotto(kvp.Key) : string.Empty); base.Write(Status == CharacterStatus.Offline ? System.HabboSystem.CharacterManager.GetLastSeen(kvp.Key) : string.Empty); base.Write(System.HabboSystem.CharacterManager.GetAlternativeName(kvp.Key)); base.Write(string.Empty); } }
public UserObjectComposer(Character Character) { base.WriteHeader(MessageComposerIds.UserObjectComposer); base.Write(Character.Id + string.Empty); base.Write(Character.Username); base.Write(Character.Figure); base.Write(Character.Gender); base.Write(Character.Motto); base.Write("String1"); // TODO base.Write(1); base.Write(Character.RespectEarned); base.Write(Character.RespectLeftHuman); base.Write(Character.RespectLeftAnimal); }
public HabboSearchResultComposer(Character Character, ICollection<int> Friends, ICollection<int> NoFriends) { base.WriteHeader(MessageComposerIds.HabboSearchResultComposer); base.Write(Friends.Count); foreach (int CharacterId in Friends) { CharacterStatus Status = System.HabboSystem.CharacterManager.GetStatus(CharacterId); base.Write(CharacterId); base.Write(System.HabboSystem.CharacterManager.GetUsername(CharacterId)); base.Write(Status == CharacterStatus.Online ? System.HabboSystem.CharacterManager.GetMotto(CharacterId) : string.Empty); base.Write(Status == CharacterStatus.Online); base.Write(System.HabboSystem.CharacterManager.GetCurrentRoom(CharacterId)); base.Write(string.Empty); base.Write(System.HabboSystem.MessengerManager.GetGroupId(Character.MessengerGroups, CharacterId)); base.Write(Status == CharacterStatus.Online ? System.HabboSystem.CharacterManager.GetFigure(CharacterId) : string.Empty); base.Write(Status == CharacterStatus.Offline ? System.HabboSystem.CharacterManager.GetLastSeen(CharacterId) : string.Empty); base.Write(string.Empty); } base.Write(NoFriends.Count); foreach (int CharacterId in NoFriends) { CharacterStatus Status = System.HabboSystem.CharacterManager.GetStatus(CharacterId); base.Write(CharacterId); base.Write(System.HabboSystem.CharacterManager.GetUsername(CharacterId)); base.Write(Status == CharacterStatus.Online ? System.HabboSystem.CharacterManager.GetMotto(CharacterId) : string.Empty); base.Write(Status == CharacterStatus.Online); base.Write(System.HabboSystem.CharacterManager.GetCurrentRoom(CharacterId)); base.Write(string.Empty); base.Write(System.HabboSystem.MessengerManager.GetGroupId(Character.MessengerGroups, CharacterId)); base.Write(Status == CharacterStatus.Online ? System.HabboSystem.CharacterManager.GetFigure(CharacterId) : string.Empty); base.Write(Status == CharacterStatus.Offline ? System.HabboSystem.CharacterManager.GetLastSeen(CharacterId) : string.Empty); base.Write(string.Empty); } }
public AchievementComposer(Character Character, Achievement Achievement) { base.WriteHeader(MessageComposerIds.AchievementComposer); int CurrentLevel = Character.GetAchievementProgress(Achievement.Id); int NextLevel = (CurrentLevel + 1); if (NextLevel > Achievement.Levels) { NextLevel = Achievement.Levels; } base.Write(Achievement.Id); base.Write(NextLevel); base.Write(Achievement.GetBadgeCode(NextLevel)); base.Write(Achievement.GetRequired(NextLevel)); base.Write(Achievement.GetPixelReward(NextLevel)); base.Write((int)AchievementRewardType.Pixels); base.Write(Character.GetAchievementProgessLimit(Achievement.Id)); base.Write(CurrentLevel == Achievement.Levels); base.Write(System.HabboSystem.AchievementManager.GetCategory(Achievement.CategoryId).Caption.ToLower()); base.Write(Achievement.Levels); }
public MessengerInitComposer(short MAX_FRIENDS, Character Character) { base.WriteHeader(MessageComposerIds.MessengerInitComposer); base.Write(MAX_FRIENDS); base.Write(System.HabboSystem.MessengerManager.MAX_FRIENDS_DEFAULT); base.Write(System.HabboSystem.MessengerManager.MAX_FRIENDS_CLUB); base.Write(System.HabboSystem.MessengerManager.MAX_FRIENDS_VIP); base.Write(Character.MessengerGroups.Count); foreach (var MessengerGroup in Character.MessengerGroups) { base.Write(MessengerGroup.Id); base.Write(MessengerGroup.Caption); } base.Write(Character.MessengerFriends.Count); foreach (var MessengerFriend in Character.MessengerFriends) { CharacterStatus Status = System.HabboSystem.CharacterManager.GetStatus(MessengerFriend); base.Write(MessengerFriend); base.Write(System.HabboSystem.CharacterManager.GetUsername(MessengerFriend)); base.Write(true); base.Write(Status == CharacterStatus.Online); base.Write(System.HabboSystem.CharacterManager.GetCurrentRoom(MessengerFriend)); base.Write(Status == CharacterStatus.Online ? System.HabboSystem.CharacterManager.GetFigure(MessengerFriend) : string.Empty); base.Write(System.HabboSystem.MessengerManager.GetGroupId(Character.MessengerGroups, MessengerFriend)); base.Write(Status == CharacterStatus.Online ? System.HabboSystem.CharacterManager.GetMotto(MessengerFriend) : string.Empty); base.Write(Status == CharacterStatus.Offline ? System.HabboSystem.CharacterManager.GetLastSeen(MessengerFriend) : string.Empty); base.Write(System.HabboSystem.CharacterManager.GetAlternativeName(MessengerFriend)); base.Write(string.Empty); } base.Write(System.HabboSystem.MessengerManager.MAX_FRIENDS_PER_PAGE); }
/// <summary> /// Updates the character. /// </summary> /// <param name="Character"></param> public void UpdateCharacter(Character Character) { this.Character = Character; this.UpdateSessionProgress(ProgressType.Authenticated); this.Character.OnLogin(); }
/// <summary> /// Returns an character from Username. /// </summary> /// <param name="Username"></param> /// <returns></returns> public bool GetCharacter(string Username, out Character Character) { Character = null; foreach(Character xCharacter in WeakSQLCache.Values) { if (xCharacter.Username.ToLower() == Username.ToLower()) { Character = xCharacter; } } if (Character != null) { return true; } else { DataRow Obj = System.MySQLManager.GetObject(new CastCharacterQuery(Username)).GetOutput<DataRow>(); if (Obj != null) { Character = new Character(Obj); WeakSQLCache.Add(Character.Id, Character); } return Character != null; } }
/// <summary> /// Returns an character from Id. /// </summary> /// <param name="CharacterId"></param> /// <returns></returns> public bool GetCharacter(int CharacterId, out Character Character) { Character = null; if (WeakSQLCache.ContainsKey(CharacterId)) { Character = WeakSQLCache[CharacterId]; } else { DataRow Obj = System.MySQLManager.GetObject(new CastCharacterQuery(CharacterId)).GetOutput<DataRow>(); if (Obj != null) { Character = new Character(Obj); WeakSQLCache.Add(CharacterId, Character); } return Character != null; } return Character != null; }
/// <summary> /// Calculates the score of an character. /// </summary> /// <param name="Character"></param> /// <returns></returns> public int GetAchievementScore(Character Character) { int Output = default(int); foreach (var kvp in Character.Achievements) { Achievement Achievement = GetAchievement(kvp.Value); if (Achievement == null) { continue; } for (int i = 0; i <= kvp.Value; i++) { Output += Achievement.GetScoreReward(i); } } return Output; }