/// <summary> /// This is a dataquest that belongs to a player /// </summary> /// <param name="questingPlayer"></param> /// <param name="dbQuest"></param> /// <param name="charQuest"></param> public DataQuest(GamePlayer questingPlayer, GameObject sourceObject, DBDataQuest dataQuest, CharacterXDataQuest charQuest) { m_questPlayer = questingPlayer; m_step = 1; m_dataQuest = dataQuest; m_charQuest = charQuest; if (sourceObject != null) { if (sourceObject is GameNPC) { m_startNPC = sourceObject as GameNPC; } m_startObject = sourceObject; } ParseQuestData(); }
/// <summary> /// Dataquest that belongs to a player /// </summary> /// <param name="questingPlayer"></param> /// <param name="dataQuest"></param> /// <param name="charQuest"></param> public DataQuest(GamePlayer questingPlayer, DBDataQuest dataQuest, CharacterXDataQuest charQuest) : this(questingPlayer, null, dataQuest, charQuest) { }
/// <summary> /// DataQuest object assigned to an object or NPC that is used to start or offer the quest /// </summary> /// <param name="dbQuest"></param> public DataQuest(DBDataQuest dataQuest, GameObject startingObject) { m_questPlayer = null; m_step = 1; m_dataQuest = dataQuest; m_startObject = startingObject; m_lastErrorText = ""; ParseSearchAreas(); ParseQuestData(); }
/// <summary> /// This version of a DataQuest is used to give the quest to a player /// </summary> /// <param name="dbQuest"></param> public DataQuest(DBDataQuest dataQuest) { m_questPlayer = null; m_step = 1; m_dataQuest = dataQuest; ParseQuestData(); }
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); } }