예제 #1
0
        public string Save(DBDataQuest quest)
        {
            if (!quest.IsPersisted)
            {
                quest.ObjectId = IDGenerator.GenerateID();
                DatabaseManager.Database.AddObject(quest);
                return(quest.ObjectId);
            }

            DatabaseManager.Database.SaveObject(quest);
            return(quest.ObjectId);
        }
예제 #2
0
        public void CheckQuestQualification_DependentQuestNotDone_False()
        {
            var player      = NewFakePlayer();
            var dbDataQuest = new DBDataQuest();

            dbDataQuest.QuestDependency = "SomeQuestName";
            var dataQuest = NewDataQuest(dbDataQuest);

            bool isQualified = dataQuest.CheckQuestQualification(player);

            Assert.IsFalse(isQualified);
        }
예제 #3
0
        public void CheckQuestQualification_PlayerIsPaladinAndAllowedClassIsCleric_False()
        {
            var player = NewFakePlayer();

            player.fakeCharacterClass = new ClassPaladin();
            var dbDataQuest   = new DBDataQuest();
            var clericClassID = (int)eCharacterClass.Cleric;

            dbDataQuest.AllowedClasses = clericClassID.ToString();
            var dataQuest = NewDataQuest(dbDataQuest);

            bool isQualified = dataQuest.CheckQuestQualification(player);

            Assert.IsFalse(isQualified);
        }
예제 #4
0
        private async Task LoadQuest(string questId)
        {
            stepNumber.Text = @"1";
            CleanDictionaries();
            Clear();

            if (string.IsNullOrWhiteSpace(questId))
            {
                return;
            }

            _quest = await _questService.Get(questId);

            if (_quest == null)
            {
                MessageBox.Show($@"Object with ObjectId: {questId} not found", @"Object not found");
                return;
            }

            BindingService.BindData(_quest, this);
            // need to grab the serialized data and turn it back to usable form
            DeserializeData(_quest);
        }
예제 #5
0
        private void questSave_Click(object sender, EventArgs e)
        {
            int stepNum = int.Parse(stepNumber.Text);
            int optNum  = int.Parse(optNumber.Text);
            int finNum  = int.Parse(finNumber.Text);

            if (!steptype_dictionary.ContainsKey(stepNum)) //Adds step data to the dictionary on last step if the forward/back button has not been pressed yet
            {
                advtext_dictionary.Remove(stepNum);
                advtext_dictionary.Add(stepNum, AdvanceText.Text);
                colitem_dictionary.Remove(stepNum);
                colitem_dictionary.Add(stepNum, CollectItem.Text);
                money_dictionary.Remove(stepNum);
                money_dictionary.Add(stepNum, RewardMoney.Text);
                xp_dictionary.Remove(stepNum);
                xp_dictionary.Add(stepNum, RewardXp.Text);
                clxp_dictionary.Remove(stepNum);
                clxp_dictionary.Add(stepNum, RewardCLXp.Text);
                rp_dictionary.Remove(stepNum);
                rp_dictionary.Add(stepNum, RewardRp.Text);
                bp_dictionary.Remove(stepNum);
                bp_dictionary.Add(stepNum, RewardBp.Text);
                srctext_dictionary.Remove(stepNum);
                srctext_dictionary.Add(stepNum, SourceText.Text);
                srcname_dictionary.Remove(stepNum);
                srcname_dictionary.Add(stepNum, SourceName.Text);
                stepitem_dictionary.Remove(stepNum);
                stepitem_dictionary.Add(stepNum, StepItem.Text);
                steptext_dictionary.Remove(stepNum);
                steptext_dictionary.Add(stepNum, StepText.Text);
                trgtname_dictionary.Remove(stepNum);
                trgtname_dictionary.Add(stepNum, TargetName.Text);
                trgttext_dictionary.Remove(stepNum);
                trgttext_dictionary.Add(stepNum, TargetText.Text);
                steptype_dictionary.Remove(stepNum);
                steptype_dictionary.Add(stepNum, StepType.Text);
            }
            if (!opt_dictionary.ContainsKey(optNum))
            {
                opt_dictionary.Remove(stepNum);
                opt_dictionary.Add(stepNum, OptionalReward.Text);
            }
            if (!fin_dictionary.ContainsKey(finNum))
            {
                fin_dictionary.Remove(stepNum);
                fin_dictionary.Add(stepNum, FinalReward.Text);
            }

            try
            {
                #region String conversions
                _OptionalRewardItemTemplates = String.Join("|", Array.ConvertAll(opt_dictionary.Values.ToArray(), i => i.ToString()));
                _FinalRewardItemTemplates    = String.Join("|", Array.ConvertAll(fin_dictionary.Values.ToArray(), i => i.ToString()));
                _AdvanceText         = String.Join("|", Array.ConvertAll(advtext_dictionary.Values.ToArray(), i => i.ToString()));
                _CollectItemTemplate = String.Join("|", Array.ConvertAll(colitem_dictionary.Values.ToArray(), i => i.ToString()));
                _RewardMoney         = String.Join("|", Array.ConvertAll(money_dictionary.Values.ToArray(), i => i.ToString()));
                _RewardXP            = String.Join("|", Array.ConvertAll(xp_dictionary.Values.ToArray(), i => i.ToString()));
                _RewardCLXP          = String.Join("|", Array.ConvertAll(clxp_dictionary.Values.ToArray(), i => i.ToString()));
                _RewardRp            = String.Join("|", Array.ConvertAll(rp_dictionary.Values.ToArray(), i => i.ToString()));
                _RewardBp            = String.Join("|", Array.ConvertAll(bp_dictionary.Values.ToArray(), i => i.ToString()));
                _SourceText          = String.Join("|", Array.ConvertAll(srctext_dictionary.Values.ToArray(), i => i.ToString()));
                _SourceName          = String.Join("|", Array.ConvertAll(srcname_dictionary.Values.ToArray(), i => i.ToString()));
                _StepItemTemplates   = String.Join("|", Array.ConvertAll(stepitem_dictionary.Values.ToArray(), i => i.ToString()));
                _StepText            = String.Join("|", Array.ConvertAll(steptext_dictionary.Values.ToArray(), i => i.ToString()));
                _TargetName          = String.Join("|", Array.ConvertAll(trgtname_dictionary.Values.ToArray(), i => i.ToString()));
                _TargetText          = String.Join("|", Array.ConvertAll(trgttext_dictionary.Values.ToArray(), i => i.ToString()));
                _StepType            = String.Join("|", Array.ConvertAll(steptype_dictionary.Values.ToArray(), i => i.ToString()));
                //string acl = String.Join("|", allowedClasses.SelectedItems.Cast<object>().Select(i => i.ToString()));
                //eStepType string replace values:

                StringBuilder stype = new StringBuilder(_StepType);
                stype.Replace("Kill", "0");
                stype.Replace("killFinish", "1");
                stype.Replace("Deliver", "2");
                stype.Replace("deliverFinish", "3");
                stype.Replace("Interact", "4");
                stype.Replace("interactFinish", "5");
                stype.Replace("Whisper", "6");
                stype.Replace("whisperFinish", "7");
                stype.Replace("Search", "8");
                stype.Replace("searchFinish", "9");
                stype.Replace("Collect", "10");
                stype.Replace("collectFinish", "11");
                stype.Replace("RewardQuest", "200");
                _StepType = stype.ToString();

                StringBuilder allcl = new StringBuilder(_AllowedClasses);
                allcl.Replace("Armsman", "2");
                allcl.Replace("Cabalist", "13");
                allcl.Replace("Cleric", "6");
                allcl.Replace("Friar", "10");
                allcl.Replace("Heretic", "33");
                allcl.Replace("Infiltrator", "9");
                allcl.Replace("Mercenary", "11");
                allcl.Replace("Minstrel", "4");
                allcl.Replace("Necromancer", "12");
                allcl.Replace("Paladin", "1");
                allcl.Replace("Reaver", "19");
                allcl.Replace("Scout", "3");
                allcl.Replace("Sorcerer", "8");
                allcl.Replace("Theurgist", "5");
                allcl.Replace("Wizard", "7");
                allcl.Replace("MaulerAlb", "60");
                allcl.Replace("Berserker", "31");
                allcl.Replace("Bonedancer", "30");
                allcl.Replace("Healer", "36");
                allcl.Replace("Hunter", "35");
                allcl.Replace("Runemaster", "29");
                allcl.Replace("Savage", "32");
                allcl.Replace("Shadowblade", "23");
                allcl.Replace("Shaman", "28");
                allcl.Replace("Skald", "24");
                allcl.Replace("Spiritmaster", "27");
                allcl.Replace("Thane", "21");
                allcl.Replace("Valkyrie", "34");
                allcl.Replace("Warlock", "59");
                allcl.Replace("Warrior", "22");
                allcl.Replace("MaulerMid", "61");
                allcl.Replace("Animist", "55");
                allcl.Replace("Bainshee", "39");
                allcl.Replace("Bard", "48");
                allcl.Replace("Blademaster", "43");
                allcl.Replace("Champion", "45");
                allcl.Replace("Druid", "47");
                allcl.Replace("Eldritch", "40");
                allcl.Replace("Enchanter", "41");
                allcl.Replace("Hero", "44");
                allcl.Replace("Mentalist", "42");
                allcl.Replace("Nightshade", "49");
                allcl.Replace("Ranger", "50");
                allcl.Replace("Valewalker", "56");
                allcl.Replace("Vampiir", "58");
                allcl.Replace("Warden", "46");
                allcl.Replace("MaulerHib", "62");
                allcl.Replace("Acolyte", "16");
                allcl.Replace("AlbionRogue", "17");
                allcl.Replace("Disciple", "20");
                allcl.Replace("Elementalist", "15");
                allcl.Replace("Fighter", "14");
                allcl.Replace("Forester", "57");
                allcl.Replace("Guardian", "52");
                allcl.Replace("Mage", "18");
                allcl.Replace("Magician", "51");
                allcl.Replace("MidgardRogue", "38");
                allcl.Replace("Mystic", "36");
                allcl.Replace("Naturalist", "53");
                allcl.Replace("Seer", "37");
                allcl.Replace("Stalker", "54");
                allcl.Replace("Viking", "35");


                _AllowedClasses = allcl.ToString();
                #endregion
            }
            catch (Exception g)
            {
                MessageBox.Show(g.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            DBDataQuest q = new DBDataQuest();
            // q.ID = int.Parse(_ID.Text);

            q.Name = _Name.Text;

            q.StartType = (byte)((_StartType.SelectedIndex) - 1);
            if (q.StartType == 6)
            {
                q.StartType = 200;
            }                               // mannik's lazy workaround.
            if (q.StartType >= 201 || q.StartType < 0)
            {
                q.StartType = 0;
                MessageBox.Show("Quest type entered invald. Replaced with quest type Standard (0), please check DB to correct.", "Invalid Quest Type", MessageBoxButtons.OK, MessageBoxIcon.Error);
            } //Mannik's other lazy workaround.

            q.StartName                   = _StartName.Text;
            q.StartRegionID               = ushort.Parse(_StartRegionID.Text);
            q.AcceptText                  = _AcceptText.Text;
            q.Description                 = _Description.Text;
            q.SourceText                  = _SourceText;          //serialized
            q.SourceName                  = _SourceName;
            q.StepType                    = _StepType;            //serialized
            q.StepText                    = _StepText;            //serialized
            q.StepItemTemplates           = _StepItemTemplates;   //serialized
            q.AdvanceText                 = _AdvanceText;         //serialized
            q.TargetName                  = _TargetName;          //serialized
            q.TargetText                  = _TargetText;          //serialized
            q.CollectItemTemplate         = _CollectItemTemplate; //serialized
            q.MaxCount                    = byte.Parse(_MaxCount.Text);
            q.MinLevel                    = byte.Parse(_MinLevel.Text);
            q.MaxLevel                    = byte.Parse(_MaxLevel.Text);
            q.RewardMoney                 = _RewardMoney; //serialized
            q.RewardXP                    = _RewardXP;    //serialized
            q.RewardCLXP                  = _RewardCLXP;  //serialized
            q.RewardRP                    = _RewardRp;    //serialized
            q.RewardBP                    = _RewardBp;    //serialized
            q.OptionalRewardItemTemplates = _OptionalRewardItemTemplates;
            q.FinalRewardItemTemplates    = _FinalRewardItemTemplates;
            q.FinishText                  = _FinishText.Text;
            q.QuestDependency             = _QuestDependency; //might need to serialize....if quest has multiple dependencies
            q.AllowedClasses              = _AllowedClasses;  //serialized
            q.ClassType                   = _ClassType.Text;
            DatabaseManager.Database.AddObject(q);
        }
예제 #6
0
 private void Clear()
 {
     _quest = null;
     BindingService.ClearData(this);
 }
예제 #7
0
 public DataQuestSpy(DBDataQuest dbDataQuest) : base(dbDataQuest)
 {
     m_charQuest = new CharacterXDataQuest();
 }
예제 #8
0
 public void Delete(DBDataQuest quest)
 {
     DatabaseManager.Database.DeleteObject(quest);
 }
예제 #9
0
 public DataQuestSpy(GamePlayer player, DBDataQuest dbDataQuest, CharacterXDataQuest charXDataQuest) : base(player, dbDataQuest, charXDataQuest)
 {
 }
예제 #10
0
 private DataQuestSpy NewDataQuest(DBDataQuest dbDataQuest) => new DataQuestSpy(null, dbDataQuest, new CharacterXDataQuest());
예제 #11
0
        private void questSave_Click(object sender, EventArgs e)
        {
            var stepNum = int.Parse(stepNumber.Text);
            var optNum  = int.Parse(optNumber.Text);
            var finNum  = int.Parse(finNumber.Text);

            // Refresh step data to the dictionary if the forward/back button has not been pressed
            RefreshDictionaries(stepNum);

            _optDictionary.Remove(optNum - 1); // do this in case it was edited without pressing forward/back
            if (!string.IsNullOrWhiteSpace(_OptionalReward.Text))
            {
                _optDictionary.Add(optNum - 1, _OptionalReward.Text);
            }

            _finDictionary.Remove(finNum - 1); // do this in case it was edited without pressing forward/back
            if (!string.IsNullOrWhiteSpace(_FinalReward.Text))
            {
                _finDictionary.Add(finNum - 1, _FinalReward.Text);
            }

            try
            {
                _optionalRewardItemTemplates = string.Join("|", Array.ConvertAll(_optDictionary.Values.ToArray(), i => i.ToString()));
                _finalRewardItemTemplates    = string.Join("|", Array.ConvertAll(_finDictionary.Values.ToArray(), i => i.ToString()));
                _advanceText         = string.Join("|", Array.ConvertAll(_advTextDictionary.Values.ToArray(), i => i.ToString()));
                _collectItemTemplate = string.Join("|", Array.ConvertAll(_colItemDictionary.Values.ToArray(), i => i.ToString()));
                _rewardMoney         = string.Join("|", Array.ConvertAll(_moneyDictionary.Values.ToArray(), i => i.ToString()));
                _rewardXp            = string.Join("|", Array.ConvertAll(_xpDictionary.Values.ToArray(), i => i.ToString()));
                _rewardClXp          = string.Join("|", Array.ConvertAll(_clXpDictionary.Values.ToArray(), i => i.ToString()));
                _rewardRp            = string.Join("|", Array.ConvertAll(_rpDictionary.Values.ToArray(), i => i.ToString()));
                _rewardBp            = string.Join("|", Array.ConvertAll(_bpDictionary.Values.ToArray(), i => i.ToString()));
                _sourceText          = string.Join("|", Array.ConvertAll(_srcTextDictionary.Values.ToArray(), i => i.ToString()));
                _sourceName          = string.Join("|", Array.ConvertAll(_srcNameDictionary.Values.ToArray(), i => i.ToString()));
                _stepItemTemplates   = string.Join("|", Array.ConvertAll(_stepItemDictionary.Values.ToArray(), i => i.ToString()));
                _stepText            = string.Join("|", Array.ConvertAll(_stepTextDictionary.Values.ToArray(), i => i.ToString()));
                _targetName          = string.Join("|", Array.ConvertAll(_trgNameDictionary.Values.ToArray(), i => i.ToString()));
                _targetText          = string.Join("|", Array.ConvertAll(_trgTextDictionary.Values.ToArray(), i => i.ToString()));
                _stepType            = string.Join("|", Array.ConvertAll(_stepTypeDictionary.Values.ToArray(), i => i.ToString()));
                _allowedClasses      = string.Join("|", listClasses.SelectedItems.Cast <object>().Select(i => i.ToString()));

                //eStepType string replace values:
                StringBuilder stype = new StringBuilder(_stepType);
                // Start with long wording first to avoid any bad replace
                stype.Replace("KillFinish", "1");
                stype.Replace("DeliverFinish", "3");
                stype.Replace("InteractFinish", "5");
                stype.Replace("WhisperFinish", "7");
                stype.Replace("SearchFinish", "9");
                stype.Replace("CollectFinish", "11");
                stype.Replace("Kill", "0");
                stype.Replace("Deliver", "2");
                stype.Replace("Interact", "4");
                stype.Replace("Whisper", "6");
                stype.Replace("Search", "8");
                stype.Replace("Collect", "10");
                stype.Replace("RewardQuest", "200");
                _stepType = stype.ToString();

                StringBuilder allcl = new StringBuilder(_allowedClasses);
                allcl.Replace("All", ""); // added all incase one is selected, you cannot deselect
                allcl.Replace("Armsman", "2");
                allcl.Replace("Cabalist", "13");
                allcl.Replace("Cleric", "6");
                allcl.Replace("Friar", "10");
                allcl.Replace("Heretic", "33");
                allcl.Replace("Infiltrator", "9");
                allcl.Replace("Mercenary", "11");
                allcl.Replace("Minstrel", "4");
                allcl.Replace("Necromancer", "12");
                allcl.Replace("Paladin", "1");
                allcl.Replace("Reaver", "19");
                allcl.Replace("Scout", "3");
                allcl.Replace("Sorcerer", "8");
                allcl.Replace("Theurgist", "5");
                allcl.Replace("Wizard", "7");
                allcl.Replace("MaulerAlb", "60");
                allcl.Replace("Berserker", "31");
                allcl.Replace("Bonedancer", "30");
                allcl.Replace("Healer", "26");
                allcl.Replace("Hunter", "25");
                allcl.Replace("Runemaster", "29");
                allcl.Replace("Savage", "32");
                allcl.Replace("Shadowblade", "23");
                allcl.Replace("Shaman", "28");
                allcl.Replace("Skald", "24");
                allcl.Replace("Spiritmaster", "27");
                allcl.Replace("Thane", "21");
                allcl.Replace("Valkyrie", "34");
                allcl.Replace("Warlock", "59");
                allcl.Replace("Warrior", "22");
                allcl.Replace("MaulerMid", "61");
                allcl.Replace("Animist", "55");
                allcl.Replace("Bainshee", "39");
                allcl.Replace("Bard", "48");
                allcl.Replace("Blademaster", "43");
                allcl.Replace("Champion", "45");
                allcl.Replace("Druid", "47");
                allcl.Replace("Eldritch", "40");
                allcl.Replace("Enchanter", "41");
                allcl.Replace("Hero", "44");
                allcl.Replace("Mentalist", "42");
                allcl.Replace("Nightshade", "49");
                allcl.Replace("Ranger", "50");
                allcl.Replace("Valewalker", "56");
                allcl.Replace("Vampiir", "58");
                allcl.Replace("Warden", "46");
                allcl.Replace("MaulerHib", "62");
                allcl.Replace("Acolyte", "16");
                allcl.Replace("AlbionRogue", "17");
                allcl.Replace("Disciple", "20");
                allcl.Replace("Elementalist", "15");
                allcl.Replace("Fighter", "14");
                allcl.Replace("Forester", "57");
                allcl.Replace("Guardian", "52");
                allcl.Replace("Mage", "18");
                allcl.Replace("Magician", "51");
                allcl.Replace("MidgardRogue", "38");
                allcl.Replace("Mystic", "36");
                allcl.Replace("Naturalist", "53");
                allcl.Replace("Seer", "37");
                allcl.Replace("Stalker", "54");
                allcl.Replace("Viking", "35");
                _allowedClasses = allcl.ToString();
            }
            catch (Exception g)
            {
                MessageBox.Show(g.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            DBDataQuest q = new DBDataQuest();

            // Before saving check for missing or wrong information in the quest
            if (CheckQuestOk() == false)
            {
                MessageBox.Show(
                    $"Quest data is invalid, please fix the below fields : \n\n{string.Join("\n", _questErrors)}",
                    @"Error on quest",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            // Save can be done : retrieve all values from Form for DB insertion
            if (!_ID.Text.Equals(""))
            {
                q.ID = int.Parse(_ID.Text);
            }

            q.Name = _Name.Text;

            var item = (ComboboxService.SelectItemModel)_StartType.Items[_StartType.SelectedIndex];

            q.StartType                   = Convert.ToByte(item.Id);
            q.StartName                   = _StartName.Text;
            q.StartRegionID               = ushort.Parse(_StartRegionID.Text);
            q.AcceptText                  = _AcceptText.Text;
            q.Description                 = _Description.Text;
            q.SourceText                  = _sourceText;          //serialized
            q.SourceName                  = _sourceName;
            q.StepType                    = _stepType;            //serialized
            q.StepText                    = _stepText;            //serialized
            q.StepItemTemplates           = _stepItemTemplates;   //serialized
            q.AdvanceText                 = _advanceText;         //serialized
            q.TargetName                  = _targetName;          //serialized
            q.TargetText                  = _targetText;          //serialized
            q.CollectItemTemplate         = _collectItemTemplate; //serialized
            q.MaxCount                    = byte.Parse(_MaxCount.Text);
            q.MinLevel                    = byte.Parse(_MinLevel.Text);
            q.MaxLevel                    = byte.Parse(_MaxLevel.Text);
            q.RewardMoney                 = _rewardMoney; //serialized
            q.RewardXP                    = _rewardXp;    //serialized
            q.RewardCLXP                  = _rewardClXp;  //serialized
            q.RewardRP                    = _rewardRp;    //serialized
            q.RewardBP                    = _rewardBp;    //serialized
            q.OptionalRewardItemTemplates = _optionalRewardItemTemplates;
            q.FinalRewardItemTemplates    = _finalRewardItemTemplates;
            q.FinishText                  = _FinishText.Text;
            q.QuestDependency             = _QuestDependency.Text; //might need to serialize....if quest has multiple dependencies
            q.AllowedClasses              = _allowedClasses;       //serialized
            q.ClassType                   = _ClassType.Text;

            try
            { // This is probably a bad way to do this, but i can't get the quest to save onto the same ID
                if (!LoadedQuest)
                {
                    DatabaseManager.Database.AddObject(q);
                    LoadedQuest = true;            // quest has been added to DB so can now be saved on its existing ID
                    _ID.Text    = q.ID.ToString(); // set the generated ID to the ID text field so next save it has a value
                }
                else
                {
                    DatabaseManager.Database.SaveObject(q);
                }
                MessageBox.Show(@"Quest successfully saved!", "", MessageBoxButtons.OK);
            }
            catch (Exception g)
            {
                MessageBox.Show(g.Message, @"Error saving data!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #12
0
        /// <summary>
        /// convert database format "kill bandit;2|talk to NPC;3" to usable format
        /// </summary>
        private void DeserializeData(DBDataQuest quest)
        {
            if (_quest == null)
            {
                return;
            }

            void PrepareInput(string input, Dictionary <int, string> dictionary, Control control)
            {
                if (input == null || input.Equals(""))
                {
                    return;
                }

                var splitStepType = input.Split(new[] { "|" }, StringSplitOptions.None);

                dictionary.Clear();
                StringToDictionary(splitStepType, dictionary);
                control.Text = dictionary[0];
            }

            try
            {
                // Step type
                var builder = new StringBuilder(quest.StepType);
                // Start with long wording first to avoid any bad replace
                builder.Replace("200", "RewardQuest");
                builder.Replace("11", "CollectFinish");
                builder.Replace("10", "Collect");
                builder.Replace("0", "Kill");
                builder.Replace("1", "KillFinish");
                builder.Replace("2", "Deliver");
                builder.Replace("3", "DeliverFinish");
                builder.Replace("4", "Interact");
                builder.Replace("5", "InteractFinish");
                builder.Replace("6", "Whisper");
                builder.Replace("7", "WhisperFinish");
                builder.Replace("8", "Search");
                builder.Replace("9", "SearchFinish");
                _stepType = builder.ToString();

                PrepareInput(_stepType, _stepTypeDictionary, StepType);

                // Source name
                _sourceName = quest.SourceName;
                PrepareInput(_sourceName, _srcNameDictionary, SourceName);

                // Target name
                _targetName = quest.TargetName;
                PrepareInput(_targetName, _trgNameDictionary, TargetName);

                // Source text
                _sourceText = quest.SourceText;
                PrepareInput(_sourceText, _srcTextDictionary, SourceText);

                // Step text
                _stepText = quest.StepText;
                PrepareInput(_stepText, _stepTextDictionary, StepText);

                // Advance text
                _advanceText = quest.AdvanceText;
                PrepareInput(_advanceText, _advTextDictionary, AdvanceText);

                // Target text
                _targetText = quest.TargetText;
                PrepareInput(_targetText, _trgTextDictionary, TargetText);

                // Step item templates
                _stepItemTemplates = quest.StepItemTemplates;
                PrepareInput(_stepItemTemplates, _stepItemDictionary, StepItem);

                // Collect item templates
                _collectItemTemplate = quest.CollectItemTemplate;
                PrepareInput(_collectItemTemplate, _colItemDictionary, CollectItem);

                // Option reward
                _optionalRewardItemTemplates = quest.OptionalRewardItemTemplates;
                PrepareInput(_optionalRewardItemTemplates, _optDictionary, _OptionalReward);

                // Final reward
                _finalRewardItemTemplates = quest.FinalRewardItemTemplates;
                PrepareInput(_finalRewardItemTemplates, _finDictionary, _FinalReward);

                // Money
                _rewardMoney = quest.RewardMoney;
                PrepareInput(_rewardMoney, _moneyDictionary, RewardMoney);

                // XP
                _rewardXp = quest.RewardXP;
                PrepareInput(_rewardXp, _xpDictionary, RewardXp);

                // ClXp
                _rewardClXp = quest.RewardCLXP;
                PrepareInput(_rewardClXp, _clXpDictionary, RewardCLXp);

                // RP
                _rewardRp = quest.RewardRP;
                PrepareInput(_rewardRp, _rpDictionary, RewardRp);

                // BP
                _rewardBp = quest.RewardBP;
                PrepareInput(_rewardBp, _bpDictionary, RewardBp);

                // Allowed classes
                _allowedClasses = quest.AllowedClasses;

                if (!string.IsNullOrWhiteSpace(_allowedClasses))
                {
                    var splitAllowedClasses = _allowedClasses.Split(new[] { "|" }, StringSplitOptions.None);

                    for (var i = 0; i < splitAllowedClasses.Length; i++)
                    {
                        int.TryParse(splitAllowedClasses[i], out int result);
                        splitAllowedClasses[i] = _allClasses[result];
                    }

                    foreach (var allowedClass in splitAllowedClasses)
                    {
                        for (var j = 0; j < listClasses.Items.Count; j++)
                        {
                            var cls = listClasses.Items[j].ToString();
                            if (cls != allowedClass)
                            {
                                continue;
                            }
                            listClasses.SetSelected(j, true);
                        }
                    }
                }

                LoadedQuest = true;
            }
            catch (Exception g)
            {
                MessageBox.Show(
                    g.Message,
                    @"Error while deserializing data! Quest was not loaded completely - Errors in database format.",
                    MessageBoxButtons.OK, MessageBoxIcon.Error
                    );
            }
        }
예제 #13
0
        private void saveToDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int stepNum = int.Parse(stepNumber.Text);
            int optNum  = int.Parse(optNumber.Text);
            int finNum  = int.Parse(finNumber.Text);

            if (!steptype_dictionary.ContainsKey(stepNum)) //Adds step data to the dictionary on last step if the forward/back button has not been pressed yet
            {
                advtext_dictionary.Remove(stepNum);
                advtext_dictionary.Add(stepNum, advanceText.Text);
                colitem_dictionary.Remove(stepNum);
                colitem_dictionary.Add(stepNum, collectItem.Text);
                money_dictionary.Remove(stepNum);
                money_dictionary.Add(stepNum, rewardMoney.Text);
                xp_dictionary.Remove(stepNum);
                xp_dictionary.Add(stepNum, rewardXp.Text);
                clxp_dictionary.Remove(stepNum);
                clxp_dictionary.Add(stepNum, rewardCLXp.Text);
                rp_dictionary.Remove(stepNum);
                rp_dictionary.Add(stepNum, rewardRp.Text);
                bp_dictionary.Remove(stepNum);
                bp_dictionary.Add(stepNum, rewardBp.Text);
                srctext_dictionary.Remove(stepNum);
                srctext_dictionary.Add(stepNum, sourceText.Text);
                stepitem_dictionary.Remove(stepNum);
                stepitem_dictionary.Add(stepNum, stepItem.Text);
                steptext_dictionary.Remove(stepNum);
                steptext_dictionary.Add(stepNum, stepText.Text);
                trgtname_dictionary.Remove(stepNum);
                trgtname_dictionary.Add(stepNum, targetName.Text);
                trgttext_dictionary.Remove(stepNum);
                trgttext_dictionary.Add(stepNum, targetText.Text);
                steptype_dictionary.Remove(stepNum);
                steptype_dictionary.Add(stepNum, eStepType.Text);
            }
            if (!opt_dictionary.ContainsKey(optNum))
            {
                opt_dictionary.Remove(stepNum);
                opt_dictionary.Add(stepNum, getOpt.Text);
            }
            if (!fin_dictionary.ContainsKey(finNum))
            {
                fin_dictionary.Remove(stepNum);
                fin_dictionary.Add(stepNum, getFin.Text);
            }

            try
            {
                #region String conversions
                string opt   = String.Join("|", Array.ConvertAll(opt_dictionary.Values.ToArray(), i => i.ToString()));
                string fin   = String.Join("|", Array.ConvertAll(fin_dictionary.Values.ToArray(), i => i.ToString()));
                string adv   = String.Join("|", Array.ConvertAll(advtext_dictionary.Values.ToArray(), i => i.ToString()));
                string col   = String.Join("|", Array.ConvertAll(colitem_dictionary.Values.ToArray(), i => i.ToString()));
                string mon   = String.Join("|", Array.ConvertAll(money_dictionary.Values.ToArray(), i => i.ToString()));
                string exp   = String.Join("|", Array.ConvertAll(xp_dictionary.Values.ToArray(), i => i.ToString()));
                string cxp   = String.Join("|", Array.ConvertAll(clxp_dictionary.Values.ToArray(), i => i.ToString()));
                string rxp   = String.Join("|", Array.ConvertAll(rp_dictionary.Values.ToArray(), i => i.ToString()));
                string bxp   = String.Join("|", Array.ConvertAll(bp_dictionary.Values.ToArray(), i => i.ToString()));
                string srctx = String.Join("|", Array.ConvertAll(srctext_dictionary.Values.ToArray(), i => i.ToString()));
                string stpit = String.Join("|", Array.ConvertAll(stepitem_dictionary.Values.ToArray(), i => i.ToString()));
                string stptx = String.Join("|", Array.ConvertAll(steptext_dictionary.Values.ToArray(), i => i.ToString()));
                string trgnm = String.Join("|", Array.ConvertAll(trgtname_dictionary.Values.ToArray(), i => i.ToString()));
                string trgtx = String.Join("|", Array.ConvertAll(trgttext_dictionary.Values.ToArray(), i => i.ToString()));
                string stptp = String.Join("|", Array.ConvertAll(steptype_dictionary.Values.ToArray(), i => i.ToString()));
                string acl   = String.Join("|", allowedClasses.SelectedItems.Cast <object>().Select(i => i.ToString()));
                //eStepType string replace values:

                StringBuilder stype = new StringBuilder(stptp);
                stype.Replace("Kill", "0");
                stype.Replace("killFinish", "1");
                stype.Replace("Deliver", "2");
                stype.Replace("deliverFinish", "3");
                stype.Replace("Interact", "4");
                stype.Replace("interactFinish", "5");
                stype.Replace("Whisper", "6");
                stype.Replace("whisperFinish", "7");
                stype.Replace("Search", "8");
                stype.Replace("searchFinish", "9");
                stype.Replace("Collect", "10");
                stype.Replace("collectFinish", "11");
                string steptp = stype.ToString();

                StringBuilder allcl = new StringBuilder(acl);
                allcl.Replace("Armsman", "2");
                allcl.Replace("Cabalist", "13");
                allcl.Replace("Cleric", "6");
                allcl.Replace("Friar", "10");
                allcl.Replace("Heretic", "33");
                allcl.Replace("Infiltrator", "9");
                allcl.Replace("Mercenary", "11");
                allcl.Replace("Minstrel", "4");
                allcl.Replace("Necromancer", "12");
                allcl.Replace("Paladin", "1");
                allcl.Replace("Reaver", "19");
                allcl.Replace("Scout", "3");
                allcl.Replace("Sorcerer", "8");
                allcl.Replace("Theurgist", "5");
                allcl.Replace("Wizard", "7");
                allcl.Replace("MaulerAlb", "60");
                allcl.Replace("Berserker", "31");
                allcl.Replace("Bonedancer", "30");
                allcl.Replace("Healer", "36");
                allcl.Replace("Hunter", "35");
                allcl.Replace("Runemaster", "29");
                allcl.Replace("Savage", "32");
                allcl.Replace("Shadowblade", "23");
                allcl.Replace("Shaman", "28");
                allcl.Replace("Skald", "24");
                allcl.Replace("Spiritmaster", "27");
                allcl.Replace("Thane", "21");
                allcl.Replace("Valkyrie", "34");
                allcl.Replace("Warlock", "59");
                allcl.Replace("Warrior", "22");
                allcl.Replace("MaulerMid", "61");
                allcl.Replace("Animist", "55");
                allcl.Replace("Bainshee", "39");
                allcl.Replace("Bard", "48");
                allcl.Replace("Blademaster", "43");
                allcl.Replace("Champion", "45");
                allcl.Replace("Druid", "47");
                allcl.Replace("Eldritch", "40");
                allcl.Replace("Enchanter", "41");
                allcl.Replace("Hero", "44");
                allcl.Replace("Mentalist", "42");
                allcl.Replace("Nightshade", "49");
                allcl.Replace("Ranger", "50");
                allcl.Replace("Valewalker", "56");
                allcl.Replace("Vampiir", "58");
                allcl.Replace("Warden", "46");
                allcl.Replace("MaulerHib", "62");
                string aclts = allcl.ToString();

                #endregion

                DatabaseManager.SetDatabaseConnection(Settings.Default.Hostname, Settings.Default.Port, Settings.Default.Database, Settings.Default.Username, Settings.Default.Password);
                DBDataQuest q = new DBDataQuest();
                q.ID                          = int.Parse(questID.Text);
                q.Name                        = questName.Text;
                q.StartType                   = (byte)(eStartType.SelectedIndex);
                q.StartName                   = startNPCName.Text;
                q.StartRegionID               = ushort.Parse(questNPCRegionID.Text);
                q.AcceptText                  = acceptText.Text;
                q.Description                 = description.Text;
                q.SourceText                  = srctx;  //serialized
                q.StepType                    = steptp; //serialized
                q.StepText                    = stptx;  //serialized
                q.StepItemTemplates           = stpit;  //serialized
                q.AdvanceText                 = adv;    //serialized
                q.TargetName                  = trgnm;  //serialized
                q.TargetText                  = trgtx;  //serialized
                q.CollectItemTemplate         = col;    //serialized
                q.MaxCount                    = byte.Parse(maxCount.Text);
                q.MinLevel                    = byte.Parse(questMinLevel.Text);
                q.MaxLevel                    = byte.Parse(questMaxLevel.Text);
                q.RewardMoney                 = mon; //serialized
                q.RewardXP                    = exp; //serialized
                q.RewardCLXP                  = cxp; //serialized
                q.RewardRP                    = rxp; //serialized
                q.RewardBP                    = bxp; //serialized
                q.OptionalRewardItemTemplates = opt;
                q.FinalRewardItemTemplates    = fin;
                q.FinishText                  = finishText.Text;
                q.QuestDependency             = questDependency.Text; //might need to serialize....if quest has multiple dependencies
                q.AllowedClasses              = aclts;                //serialized
                q.ClassType                   = questClassType.Text;
                DatabaseManager.Database.AddObject(q);

                MessageBox.Show("Quest added to the database!");
            }
            catch (Exception g)
            {
                MessageBox.Show(g.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #14
0
        private void saveToDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int stepNum = int.Parse(stepNumber.Text);
            int optNum  = int.Parse(optNumber.Text);
            int finNum  = int.Parse(finNumber.Text);

            if (!steptype_dictionary.ContainsKey(stepNum)) //Adds step data to the dictionary on last step if the forward/back button has not been pressed yet
            {
                advtext_dictionary.Remove(stepNum);
                advtext_dictionary.Add(stepNum, advanceText.Text);
                colitem_dictionary.Remove(stepNum);
                colitem_dictionary.Add(stepNum, collectItem.Text);
                money_dictionary.Remove(stepNum);
                money_dictionary.Add(stepNum, rewardMoney.Text);
                xp_dictionary.Remove(stepNum);
                xp_dictionary.Add(stepNum, rewardXp.Text);
                clxp_dictionary.Remove(stepNum);
                clxp_dictionary.Add(stepNum, rewardCLXp.Text);
                rp_dictionary.Remove(stepNum);
                rp_dictionary.Add(stepNum, rewardRp.Text);
                bp_dictionary.Remove(stepNum);
                bp_dictionary.Add(stepNum, rewardBp.Text);
                srctext_dictionary.Remove(stepNum);
                srctext_dictionary.Add(stepNum, sourceText.Text);
                stepitem_dictionary.Remove(stepNum);
                stepitem_dictionary.Add(stepNum, stepItem.Text);
                steptext_dictionary.Remove(stepNum);
                steptext_dictionary.Add(stepNum, stepText.Text);
                trgtname_dictionary.Remove(stepNum);
                trgtname_dictionary.Add(stepNum, targetName.Text);
                trgttext_dictionary.Remove(stepNum);
                trgttext_dictionary.Add(stepNum, targetText.Text);
                steptype_dictionary.Remove(stepNum);
                steptype_dictionary.Add(stepNum, eStepType.Text);
            }
            if (!opt_dictionary.ContainsKey(optNum))
            {
                opt_dictionary.Remove(stepNum);
                opt_dictionary.Add(stepNum, getOpt.Text);
            }
            if (!fin_dictionary.ContainsKey(finNum))
            {
                fin_dictionary.Remove(stepNum);
                fin_dictionary.Add(stepNum, getFin.Text);
            }

            try
            {
                #region String conversions
                string opt   = String.Join("|", Array.ConvertAll(opt_dictionary.Values.ToArray(), i => i.ToString()));
                string fin   = String.Join("|", Array.ConvertAll(fin_dictionary.Values.ToArray(), i => i.ToString()));
                string adv   = String.Join("|", Array.ConvertAll(advtext_dictionary.Values.ToArray(), i => i.ToString()));
                string col   = String.Join("|", Array.ConvertAll(colitem_dictionary.Values.ToArray(), i => i.ToString()));
                string mon   = String.Join("|", Array.ConvertAll(money_dictionary.Values.ToArray(), i => i.ToString()));
                string exp   = String.Join("|", Array.ConvertAll(xp_dictionary.Values.ToArray(), i => i.ToString()));
                string cxp   = String.Join("|", Array.ConvertAll(clxp_dictionary.Values.ToArray(), i => i.ToString()));
                string rxp   = String.Join("|", Array.ConvertAll(rp_dictionary.Values.ToArray(), i => i.ToString()));
                string bxp   = String.Join("|", Array.ConvertAll(bp_dictionary.Values.ToArray(), i => i.ToString()));
                string srctx = String.Join("|", Array.ConvertAll(srctext_dictionary.Values.ToArray(), i => i.ToString()));
                string stpit = String.Join("|", Array.ConvertAll(stepitem_dictionary.Values.ToArray(), i => i.ToString()));
                string stptx = String.Join("|", Array.ConvertAll(steptext_dictionary.Values.ToArray(), i => i.ToString()));
                string trgnm = String.Join("|", Array.ConvertAll(trgtname_dictionary.Values.ToArray(), i => i.ToString()));
                string trgtx = String.Join("|", Array.ConvertAll(trgttext_dictionary.Values.ToArray(), i => i.ToString()));
                string stptp = String.Join("|", Array.ConvertAll(steptype_dictionary.Values.ToArray(), i => i.ToString()));

                //eStepType string replace values:
                StringBuilder stype = new StringBuilder(stptp);
                stype.Replace("Kill", "0");
                stype.Replace("killFinish", "1");
                stype.Replace("Deliver", "2");
                stype.Replace("deliverFinish", "3");
                stype.Replace("Interact", "4");
                stype.Replace("interactFinish", "5");
                stype.Replace("Whisper", "6");
                stype.Replace("whisperFinish", "7");
                stype.Replace("Search", "8");
                stype.Replace("searchFinish", "9");
                stype.Replace("Collect", "10");
                stype.Replace("collectFinish", "11");
                string steptp = stype.ToString();

                #endregion

                DatabaseManager.SetDatabaseConnection(Settings.Default.Hostname, Settings.Default.Port, Settings.Default.Database, Settings.Default.Username, Settings.Default.Password);
                DBDataQuest q = new DBDataQuest();
                q.ID                          = int.Parse(questID.Text);
                q.Name                        = questName.Text;
                q.StartType                   = (byte)(eStartType.SelectedIndex);
                q.StartName                   = startNPCName.Text;
                q.StartRegionID               = ushort.Parse(questNPCRegionID.Text);
                q.AcceptText                  = acceptText.Text;
                q.Description                 = description.Text;
                q.SourceText                  = srctx;  //serialized
                q.StepType                    = steptp; //serialized
                q.StepText                    = stptx;  //serialized
                q.StepItemTemplates           = stpit;  //serialized
                q.AdvanceText                 = adv;    //serialized
                q.TargetName                  = trgnm;  //serialized
                q.TargetText                  = trgtx;  //serialized
                q.CollectItemTemplate         = col;    //serialized
                q.MaxCount                    = byte.Parse(maxCount.Text);
                q.MinLevel                    = byte.Parse(questMinLevel.Text);
                q.MaxLevel                    = byte.Parse(questMaxLevel.Text);
                q.RewardMoney                 = mon; //serialized
                q.RewardXP                    = exp; //serialized
                q.RewardCLXP                  = cxp; //serialized
                q.RewardRP                    = rxp; //serialized
                q.RewardBP                    = bxp; //serialized
                q.OptionalRewardItemTemplates = opt;
                q.FinalRewardItemTemplates    = fin;
                q.FinishText                  = finishText.Text;
                q.QuestDependency             = questDependency.Text; //might need to serialize....if quest has multiple dependencies
                q.AllowedClasses              = allowedClasses.Text;
                q.ClassType                   = questClassType.Text;
                DatabaseManager.Database.AddObject(q);

                MessageBox.Show("Quest added to the database!");
            }
            catch (Exception g)
            {
                MessageBox.Show(g.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }