示例#1
0
        private void CompleteQuest()
        {
            // Update contact reputation
            foreach (ContactModel c in this.UserCharacter.CharacterContacts)
            {
                if (c.Id == this.SelectedQuest.ContactId)
                {
                    c.Reputation += this.SelectedQuest.ReputationValue;
                }
            }

            // Update XP
            int levelChange = this.UserCharacter.AddXPAndGetLevelDifference(this.SelectedQuest.XPValue);


            // Add new event record
            XPEventModel newRecord = new XPEventModel(
                description: "Completed " + this.SelectedQuest.Title + ".",
                eventId: this.SelectedQuest.Id,
                primarySkill: -1,
                value: this.SelectedQuest.XPValue
                );

            this.UserCharacter.EventHistory.Add(newRecord);

            // Check for level up
            if (levelChange > 0)
            {
                AppSettings.NumOfLevelsOnLevelUp = levelChange;
                var result = DialogHost.Show(new LevelUpViewModel());
            }
        }
示例#2
0
        private void CompleteSelected()
        {
            QuestModel targetQuest;


            targetQuest = (QuestModel)SelectedQuest;
            if (targetQuest == null)
            {
                Console.WriteLine("ERROR: No quest selected!");
                return;
            }

            foreach (QuestModel q in this.UserCharacter.Quests)
            {
                if (q.Status == (int)QuestModel.QuestStatus.ACTIVE)
                {
                    if (q.Id == targetQuest.Id)
                    {
                        q.Status    = (int)QuestModel.QuestStatus.COMPLETED;
                        targetQuest = q;
                    }
                }
            }
            // Update contact reputation
            foreach (ContactModel c in this.UserCharacter.CharacterContacts)
            {
                if (c.Id == targetQuest.ContactId)
                {
                    c.Reputation += targetQuest.ReputationValue;
                }
            }

            // Update XP
            int levelChange = this.UserCharacter.AddXPAndGetLevelDifference(targetQuest.XPValue);

            this.CharacterXP += targetQuest.XPValue;


            // Add new event record
            XPEventModel newRecord = new XPEventModel(
                description: "Completed " + targetQuest.Title + ".",
                eventId: targetQuest.Id,
                primarySkill: -1,
                value: targetQuest.XPValue
                );

            this.UserCharacter.EventHistory.Add(newRecord);
            _eventRecords.Add(newRecord);

            // Level up sequence if needed
            if (levelChange > 0)
            {
                AppSettings.NumOfLevelsOnLevelUp = levelChange;
                var result = DialogHost.Show(new LevelUpViewModel(), LevelUpDialogClosingHandler);
            }

            // Refresh quest filter
            CollectionViewSource.GetDefaultView(ActiveQuests).Refresh();
        }