コード例 #1
0
        public void AddQuestLink(QuestViewModel fromQuest, QuestViewModel toQuest)
        {
            // TODO: index this collection so we don't need to linear search
            if (this.questLinksMutable.Any(questLink => questLink.Conflicts(fromQuest, toQuest)))
            {
                MessageBox.Show("TODO: nicer error message here, but for now... there's a conflict yo!");
                return;
            }

            this.questLinksMutable.Add(new QuestLinkViewModel(fromQuest: fromQuest, toQuest: toQuest));
        }
コード例 #2
0
 public void CopyFrom(QuestViewModel other)
 {
     this.Id = other.id;
     this.XPos = other.xPos;
     this.YPos = other.yPos;
     this.Name = other.name;
     this.Description = other.description;
     this.Icon = other.icon;
     this.IsBig = other.isBig;
     this.QuestSet = other.questSet;
     this.RepeatOption.RepeatType = other.RepeatOption.RepeatType;
     this.RepeatOption.RepeatIntervalHours = other.RepeatOption.RepeatIntervalHours;
     this.TriggerOption.TriggerType = other.TriggerOption.TriggerType;
     this.TriggerOption.TaskCount = other.TriggerOption.TaskCount;
     this.ModifiedParentRequirement.UseModifiedParentRequirement = other.ModifiedParentRequirement.UseModifiedParentRequirement;
     this.ModifiedParentRequirement.ModifiedParentRequirementCount = other.ModifiedParentRequirement.ModifiedParentRequirementCount;
     this.reputationRewardsMutable.Clear();
     this.reputationRewardsMutable.AddRange(other.reputationRewardsMutable);
 }
コード例 #3
0
        private void Edit()
        {
            QuestViewModel copiedQuest = new QuestViewModel();
            copiedQuest.CopyFrom(this);

            EditQuestMessage message = new EditQuestMessage { Quest = copiedQuest };
            this.MessengerInstance.Send(message);
            if (message.Accepted)
            {
                this.CopyFrom(copiedQuest);
            }
        }
コード例 #4
0
 public EditQuestViewModel(QuestViewModel quest)
 {
     this.Quest = quest.ValidateNotNull(nameof(quest));
     this.EditIconCommand = new RelayCommand(this.EditIcon);
     this.EditReputationRewardsCommand = new RelayCommand(this.EditReputationRewards);
 }
コード例 #5
0
 public EditQuestWindow(QuestViewModel quest)
 {
     this.ViewModel = new EditQuestViewModel(quest.ValidateNotNull(nameof(quest)));
     this.InitializeComponent();
 }
コード例 #6
0
 private void AddQuest()
 {
     QuestViewModel newQuest = new QuestViewModel { QuestSet = this };
     EditQuestMessage message = new EditQuestMessage { Quest = newQuest };
     this.MessengerInstance.Send(message);
     if (message.Accepted)
     {
         this.AddQuest(newQuest);
     }
 }
コード例 #7
0
 public void RemoveQuest(QuestViewModel quest)
 {
     quest.QuestSet = null;
     this.questsMutable.Remove(quest);
 }
コード例 #8
0
 public void AddQuest(QuestViewModel quest)
 {
     this.questsMutable.Add(quest);
     quest.QuestSet = this;
 }
コード例 #9
0
        private void LoadQuestLine()
        {
            SelectSourceFileMessage message = new SelectSourceFileMessage
            {
                FileExtension = ".hqm",
                FileExtensionFilter = "HQM Files (*.hqm)|*.hqm|All Files (*.*)|*.*"
            };
            this.MessengerInstance.Send(message);
            if (String.IsNullOrEmpty(message.SelectedFilePath))
            {
                return;
            }

            this.questSetsMutable.Clear();

            QuestLine ql;
            using (var stream = File.OpenRead(message.SelectedFilePath))
            {
                ql = new HQMQuestLineReader().ReadQuestLine(stream);
            }

            this.PassCode = ql.PassCode;
            this.Description = ql.Description;

            Dictionary<int, QuestSetViewModel> questSetMapping = ql.QuestSets.ToDictionary(qs => qs.Id, qs => new QuestSetViewModel { Id = qs.Id, Name = qs.Name });
            Dictionary<int, QuestViewModel> questMapping = new Dictionary<int, QuestViewModel>();

            foreach (var quest in ql.Quests.Where(q => q != null))
            {
                QuestSetViewModel set = questSetMapping[quest.QuestSetId];
                QuestViewModel q = new QuestViewModel
                {
                    Id = quest.Id,
                    Description = quest.Description,
                    Name = quest.Name,
                    XPos = quest.XPos,
                    YPos = quest.YPos,
                    Icon = Conversions.ItemStackToItemStackViewModel(quest.Icon),
                    IsBig = quest.IsBig,
                    RepeatOption =
                    {
                        RepeatIntervalHours = quest.RepeatIntervalHours,
                        RepeatType = quest.RepeatType
                    },
                    TriggerOption =
                    {
                        TriggerType = quest.TriggerType,
                        TaskCount = quest.TriggerTaskCount
                    }
                };

                q.ReplaceReputationRewards(quest.ReputationRewards.Select(reward => new ReputationRewardViewModel { ReputationId = reward.Id, Value = reward.Value }));

                // TODO: tasks.
                set.AddQuest(q);
                questMapping.Add(q.Id, q);
            }

            foreach (var q in questMapping.Values)
            {
                var qOrig = ql.Quests[q.Id];
                if (qOrig.RequiredQuestIds == null)
                {
                    continue;
                }

                foreach (var id in qOrig.RequiredQuestIds)
                {
                    var reQ = ql.Quests[id];
                    QuestViewModel fromQuest = questMapping[reQ.Id];
                    QuestSetViewModel set = questSetMapping[reQ.QuestSetId];

                    if (qOrig.QuestSetId == reQ.QuestSetId)
                    {
                        set.AddQuestLink(fromQuest, q);
                    }
                    else
                    {
                        this.crossSetQuestLinksMutable.Add(new QuestLinkViewModel(fromQuest: fromQuest, toQuest: q));
                    }
                }
            }

            foreach (var set in questSetMapping.OrderBy(q => q.Key).Select(q => q.Value))
            {
                this.questSetsMutable.Add(set);
            }

            foreach (var reputation in ql.Reputations)
            {
                this.reputationsMutable.Add(Conversions.ReputationToReputationViewModel(reputation));
            }

            this.SelectedQuestSet = this.questSetsMutable[0];
        }
コード例 #10
0
 public EditQuestViewModel(QuestViewModel quest)
 {
     this.Quest           = quest.ValidateNotNull(nameof(quest));
     this.EditIconCommand = new RelayCommand(this.EditIcon);
     this.EditReputationRewardsCommand = new RelayCommand(this.EditReputationRewards);
 }