Example #1
0
        private static void SetFigure(Session Session, ClientMessage Message)
        {
            // todo: verify data(!!!!)
            if (Session.CurrentRoomId == 3)
            {
                string NewGender = Message.PopString().ToLower();
                string NewFigure = UserInputFilter.FilterString(Message.PopString());

                if (NewGender != "m" && NewGender != "f")
                {
                    NewGender = "m";
                }

                if (NewFigure.Length == 0 || (NewFigure == Session.CharacterInfo.Figure))
                {
                    return;
                }

                else
                {
                    using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                    {
                        Session.CharacterInfo.UpdateFigure(MySqlClient, NewGender, NewFigure);
                        AchievementManager.ProgressUserAchievement(MySqlClient, Session, "ACH_AvatarLooks", 1);
                        int newamount = Session.CharacterInfo.CreditsBalance - 4;

                    }

                    QuestManager.ProgressUserQuest(Session, QuestType.PROFILE_CHANGE_LOOK);
                    RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);
                    RoomActor Actor = (Instance == null ? null : Instance.GetActorByReferenceId(Session.CharacterId));
                    Session.SendData(UserInfoUpdateComposer.Compose(Actor.Id, Actor.Figure, Session.CharacterInfo.Gender, Session.CharacterInfo.Motto, Session.CharacterInfo.Score));
                    Instance.BroadcastMessage(UserInfoUpdateComposer.Compose(Actor.Id, Actor.Figure, Session.CharacterInfo.Gender, Session.CharacterInfo.Motto, Session.CharacterInfo.Score));
                    Session.SendInfoUpdate();
                    Instance.BroadcastMessage(RoomChatComposer.Compose(Actor.Id, "*Freshens up their looks*", 0, ChatType.Shout));
                }
            }
            else
            {
                RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);
                RoomActor Actor = (Instance == null ? null : Instance.GetActorByReferenceId(Session.CharacterId));

                Session.SendData(RoomChatComposer.Compose(Actor.Id, "You must be in Fitted Clothing [3] to buy clothes!", 0, ChatType.Whisper));
            }
        }
Example #2
0
        private static void SetFigure(Session Session, ClientMessage Message)
        {
            // todo: verify data(!!!!)

            string NewGender = Message.PopString().ToLower();
            string NewFigure = UserInputFilter.FilterString(Message.PopString());

            if (NewGender != "m" && NewGender != "f")
            {
                NewGender = "m";
            }

            if (NewFigure.Length == 0 || (NewFigure == Session.CharacterInfo.Figure))
            {
                return;
            }

            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                Session.CharacterInfo.UpdateFigure(MySqlClient, NewGender, NewFigure);
                AchievementManager.ProgressUserAchievement(MySqlClient, Session, "ACH_AvatarLooks", 1);
            }

            QuestManager.ProgressUserQuest(Session, QuestType.PROFILE_CHANGE_LOOK);

            Session.SendInfoUpdate();
        }
Example #3
0
        public static bool ProgressUserAchievement(SqlDatabaseClient MySqlClient, Session Session, string AchievementGroup, int ProgressAmount)
        {
            if (!mAchievements.ContainsKey(AchievementGroup))
            {
                return false;
            }

            Achievement AchievementData = null;

            lock (mSyncRoot)
            {
                AchievementData = mAchievements[AchievementGroup];
            }

            UserAchievement UserData = Session.AchievementCache.GetAchievementData(AchievementGroup);

            int TotalLevels = AchievementData.Levels.Count;

            if (UserData != null && UserData.Level == TotalLevels)
            {
                return false; // done, no more.
            }

            int TargetLevel = (UserData != null ? UserData.Level + 1 : 1);

            if (TargetLevel > TotalLevels)
            {
                TargetLevel = TotalLevels;
            }

            AchievementLevel TargetLevelData = AchievementData.Levels[TargetLevel];

            int NewProgress = (UserData != null ? UserData.Progress + ProgressAmount : ProgressAmount);
            int NewLevel = (UserData != null ? UserData.Level : 0);
            int NewTarget = NewLevel + 1;

            if (NewTarget > TotalLevels)
            {
                NewTarget = TotalLevels;
            }

            if (NewProgress >= TargetLevelData.Requirement)
            {
                NewLevel++;
                NewTarget++;

                int ProgressRemainder = NewProgress - TargetLevelData.Requirement;
                NewProgress = 0;

                Badge BadgeData = RightsManager.GetBadgeByCode(AchievementGroup + TargetLevel);

                if (NewTarget > TotalLevels)
                {
                    NewTarget = TotalLevels;
                }

                Session.BadgeCache.UpdateAchievementBadge(MySqlClient, AchievementGroup, BadgeData);
                Session.NewItemsCache.MarkNewItem(MySqlClient, 4, BadgeData.Id);
                Session.SendData(InventoryNewItemsComposer.Compose(4, BadgeData.Id));

                Session.CharacterInfo.UpdateActivityPointsBalance(MySqlClient, TargetLevelData.PixelReward);
                Session.SendData(ActivityPointsBalanceComposer.Compose(Session.CharacterInfo.ActivityPointsBalance,
                    TargetLevelData.PixelReward));

                Session.SendData(AchievementUnlockedComposer.Compose(AchievementData, TargetLevel, TargetLevelData.PointsReward,
                    TargetLevelData.PixelReward));

                Session.AchievementCache.AddOrUpdateData(MySqlClient, AchievementGroup, NewLevel, NewProgress);

                Session.CharacterInfo.UpdateScore(MySqlClient, TargetLevelData.PointsReward);
                Session.SendData(AchievementScoreUpdateComposer.Compose(Session.CharacterInfo.Score));

                AchievementLevel NewLevelData = AchievementData.Levels[NewTarget];
                Session.SendData(AchievementProgressComposer.Compose(AchievementData, NewTarget, NewLevelData,
                    TotalLevels, Session.AchievementCache.GetAchievementData(AchievementGroup)));

                Session.SendInfoUpdate();

                Session.MessengerFriendCache.BroadcastToFriends(MessengerFriendEventComposer.Compose(Session.CharacterId,
                    MessengerFriendEventType.AchievementUnlocked, BadgeData.Code));

                RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);

                if (Instance != null)
                {
                    Instance.BroadcastMessage(RoomUserBadgesComposer.Compose(Session.CharacterId,
                        Session.BadgeCache.EquippedBadges));
                }

                if (ProgressRemainder > 0)
                {
                    ProgressUserAchievement(MySqlClient, Session, AchievementGroup, ProgressRemainder);
                }

                return true;
            }

            Session.AchievementCache.AddOrUpdateData(MySqlClient, AchievementGroup, NewLevel, NewProgress);
            Session.SendData(AchievementProgressComposer.Compose(AchievementData, TargetLevel, TargetLevelData,
            TotalLevels, Session.AchievementCache.GetAchievementData(AchievementGroup)));
            return false;
        }