/// <summary> /// Reads skill value DC xx: Details /// </summary> /// <param name="p">text</param> /// <param name="skillName">Skill name.</param> /// <returns>TrapSkillData filled</returns> private TrapSkillData ReadSkill(string p, string skillName) { TrapSkillData tsd = new TrapSkillData(); Match match = _regSkillLine.Match(p); tsd.DC = Convert.ToInt32(match.Groups[1].Value); tsd.SkillName = skillName; tsd.Details = CleanHtml(match.Groups[2].Value); return(tsd); }
public TrapSkillForm(TrapSkillData tsd, int level) { this.InitializeComponent(); foreach (string skillName in Skills.GetSkillNames()) { this.SkillBox.Items.Add(skillName); } Application.Idle += new EventHandler(this.Application_Idle); this.fSkillData = tsd.Copy(); this.fLevel = level; this.SkillBox.Text = this.fSkillData.SkillName; this.DCBtn.Checked = this.fSkillData.DC != 0; this.DCBox.Value = this.fSkillData.DC; this.DetailsBox.Text = this.fSkillData.Details; this.update_advice(); }
private bool TrapsEqual(Trap fromDDI, Trap fromMP) { Assert.IsNotNull(fromMP, fromDDI.Name + " not found in " + Libraries.Count + " test libraries"); Assert.AreEqual(fromMP.Name, fromDDI.Name); Assert.AreEqual(fromMP.Type, fromDDI.Type); AreEqual(fromMP.Role, fromDDI.Role); Assert.AreEqual(fromMP.Level, fromDDI.Level); Assert.AreEqual(fromMP.Details, fromDDI.Details, "Different details"); Assert.AreEqual(fromMP.ReadAloud, fromDDI.ReadAloud); foreach (var tsdMP in fromMP.Skills) { TrapSkillData tsdDDi = fromDDI.Skills.SingleOrDefault(x => x.DC == tsdMP.DC && x.SkillName == tsdMP.SkillName); Assert.IsNotNull(tsdDDi, tsdMP.ToString() + " not found"); Assert.AreEqual(tsdMP.Details, tsdDDi.Details); Assert.AreEqual(tsdMP.ToString(), tsdDDi.ToString()); } AreEqual(fromMP.Attack, fromDDI.Attack, fromDDI.Name); CollectionAssert.AreEqual(fromMP.Countermeasures, fromDDI.Countermeasures); return(true); }
public TrapSkillForm(TrapSkillData tsd, int level) { InitializeComponent(); List <string> skills = Skills.GetSkillNames(); foreach (string skill in skills) { SkillBox.Items.Add(skill); } Application.Idle += new EventHandler(Application_Idle); fSkillData = tsd.Copy(); fLevel = level; SkillBox.Text = fSkillData.SkillName; DCBtn.Checked = (fSkillData.DC != 0); DCBox.Value = fSkillData.DC; DetailsBox.Text = fSkillData.Details; update_advice(); }
private void Browser_Navigating(object sender, WebBrowserNavigatingEventArgs e) { if (e.Url.Scheme == "build") { if (e.Url.LocalPath == "profile") { e.Cancel = true; TrapProfileForm dlg = new TrapProfileForm(fTrap); if (dlg.ShowDialog() == DialogResult.OK) { fTrap.Name = dlg.Trap.Name; fTrap.Type = dlg.Trap.Type; fTrap.Level = dlg.Trap.Level; fTrap.Role = dlg.Trap.Role; fTrap.Initiative = dlg.Trap.Initiative; update_statblock(); } } if (e.Url.LocalPath == "readaloud") { e.Cancel = true; DetailsForm dlg = new DetailsForm(fTrap.ReadAloud, "Read-Aloud Text", null); if (dlg.ShowDialog() == DialogResult.OK) { fTrap.ReadAloud = dlg.Details; update_statblock(); } } if (e.Url.LocalPath == "desc") { e.Cancel = true; DetailsForm dlg = new DetailsForm(fTrap.Description, "Description", null); if (dlg.ShowDialog() == DialogResult.OK) { fTrap.Description = dlg.Details; update_statblock(); } } if (e.Url.LocalPath == "details") { e.Cancel = true; DetailsForm dlg = new DetailsForm(fTrap.Details, "Details", null); if (dlg.ShowDialog() == DialogResult.OK) { fTrap.Details = dlg.Details; update_statblock(); } } if (e.Url.LocalPath == "addskill") { e.Cancel = true; TrapSkillData tsd = new TrapSkillData(); tsd.SkillName = "Perception"; tsd.DC = AI.GetSkillDC(Difficulty.Moderate, fTrap.Level); TrapSkillForm dlg = new TrapSkillForm(tsd, fTrap.Level); if (dlg.ShowDialog() == DialogResult.OK) { fTrap.Skills.Add(dlg.SkillData); update_statblock(); } } if (e.Url.LocalPath == "addattack") { e.Cancel = true; TrapAttack ta = new TrapAttack(); ta.Name = "Attack"; fTrap.Attacks.Add(ta); update_statblock(); } if (e.Url.LocalPath == "addcm") { e.Cancel = true; string cm = ""; TrapCountermeasureForm dlg = new TrapCountermeasureForm(cm, fTrap.Level); if (dlg.ShowDialog() == DialogResult.OK) { fTrap.Countermeasures.Add(dlg.Countermeasure); update_statblock(); } } if (e.Url.LocalPath == "trigger") { e.Cancel = true; DetailsForm dlg = new DetailsForm(fTrap.Trigger, "Trigger", null); if (dlg.ShowDialog() == DialogResult.OK) { fTrap.Trigger = dlg.Details; update_statblock(); } } } if (e.Url.Scheme == "attackaction") { e.Cancel = true; Guid id = new Guid(e.Url.LocalPath); TrapAttack attack = fTrap.FindAttack(id); if (attack != null) { TrapActionForm dlg = new TrapActionForm(attack); if (dlg.ShowDialog() == DialogResult.OK) { attack.Name = dlg.Attack.Name; attack.Action = dlg.Attack.Action; attack.Range = dlg.Attack.Range; attack.Target = dlg.Attack.Target; update_statblock(); } } } if (e.Url.Scheme == "attackremove") { e.Cancel = true; Guid id = new Guid(e.Url.LocalPath); TrapAttack attack = fTrap.FindAttack(id); if (attack != null) { fTrap.Attacks.Remove(attack); update_statblock(); } } if (e.Url.Scheme == "attackattack") { e.Cancel = true; Guid id = new Guid(e.Url.LocalPath); TrapAttack attack = fTrap.FindAttack(id); if (attack != null) { PowerAttackForm dlg = new PowerAttackForm(attack.Attack, false, fTrap.Level, fTrap.Role); if (dlg.ShowDialog() == DialogResult.OK) { attack.Attack = dlg.Attack; update_statblock(); } } } if (e.Url.Scheme == "attackhit") { e.Cancel = true; Guid id = new Guid(e.Url.LocalPath); TrapAttack attack = fTrap.FindAttack(id); if (attack != null) { DetailsForm dlg = new DetailsForm(attack.OnHit, "On Hit", null); if (dlg.ShowDialog() == DialogResult.OK) { attack.OnHit = dlg.Details; update_statblock(); } } } if (e.Url.Scheme == "attackmiss") { e.Cancel = true; Guid id = new Guid(e.Url.LocalPath); TrapAttack attack = fTrap.FindAttack(id); if (attack != null) { DetailsForm dlg = new DetailsForm(attack.OnMiss, "On Miss", null); if (dlg.ShowDialog() == DialogResult.OK) { attack.OnMiss = dlg.Details; update_statblock(); } } } if (e.Url.Scheme == "attackeffect") { e.Cancel = true; Guid id = new Guid(e.Url.LocalPath); TrapAttack attack = fTrap.FindAttack(id); if (attack != null) { DetailsForm dlg = new DetailsForm(attack.Effect, "Effect", null); if (dlg.ShowDialog() == DialogResult.OK) { attack.Effect = dlg.Details; update_statblock(); } } } if (e.Url.Scheme == "attacknotes") { e.Cancel = true; Guid id = new Guid(e.Url.LocalPath); TrapAttack attack = fTrap.FindAttack(id); if (attack != null) { DetailsForm dlg = new DetailsForm(attack.Notes, "Notes", null); if (dlg.ShowDialog() == DialogResult.OK) { attack.Notes = dlg.Details; update_statblock(); } } } if (e.Url.Scheme == "skill") { e.Cancel = true; Guid id = new Guid(e.Url.LocalPath); TrapSkillData tsd = fTrap.FindSkill(id); if (tsd != null) { int index = fTrap.Skills.IndexOf(tsd); TrapSkillForm dlg = new TrapSkillForm(tsd, fTrap.Level); if (dlg.ShowDialog() == DialogResult.OK) { fTrap.Skills[index] = dlg.SkillData; update_statblock(); } } } if (e.Url.Scheme == "skillremove") { e.Cancel = true; Guid id = new Guid(e.Url.LocalPath); TrapSkillData tsd = fTrap.FindSkill(id); if (tsd != null) { fTrap.Skills.Remove(tsd); update_statblock(); } } if (e.Url.Scheme == "cm") { e.Cancel = true; int index = int.Parse(e.Url.LocalPath); string cm = fTrap.Countermeasures[index]; TrapCountermeasureForm dlg = new TrapCountermeasureForm(cm, fTrap.Level); if (dlg.ShowDialog() == DialogResult.OK) { fTrap.Countermeasures[index] = dlg.Countermeasure; update_statblock(); } } }
private void Browser_Navigating(object sender, WebBrowserNavigatingEventArgs e) { if (e.Url.Scheme == "build") { if (e.Url.LocalPath == "profile") { e.Cancel = true; TrapProfileForm trapProfileForm = new TrapProfileForm(this.fTrap); if (trapProfileForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.fTrap.Name = trapProfileForm.Trap.Name; this.fTrap.Type = trapProfileForm.Trap.Type; this.fTrap.Level = trapProfileForm.Trap.Level; this.fTrap.Role = trapProfileForm.Trap.Role; this.fTrap.Initiative = trapProfileForm.Trap.Initiative; this.update_statblock(); } } if (e.Url.LocalPath == "readaloud") { e.Cancel = true; DetailsForm detailsForm = new DetailsForm(this.fTrap.ReadAloud, "Read-Aloud Text", null); if (detailsForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.fTrap.ReadAloud = detailsForm.Details; this.update_statblock(); } } if (e.Url.LocalPath == "desc") { e.Cancel = true; DetailsForm detailsForm1 = new DetailsForm(this.fTrap.Description, "Description", null); if (detailsForm1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.fTrap.Description = detailsForm1.Details; this.update_statblock(); } } if (e.Url.LocalPath == "details") { e.Cancel = true; DetailsForm detailsForm2 = new DetailsForm(this.fTrap.Details, "Details", null); if (detailsForm2.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.fTrap.Details = detailsForm2.Details; this.update_statblock(); } } if (e.Url.LocalPath == "addskill") { e.Cancel = true; TrapSkillData trapSkillDatum = new TrapSkillData() { SkillName = "Perception", DC = AI.GetSkillDC(Difficulty.Moderate, this.fTrap.Level) }; TrapSkillForm trapSkillForm = new TrapSkillForm(trapSkillDatum, this.fTrap.Level); if (trapSkillForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.fTrap.Skills.Add(trapSkillForm.SkillData); this.update_statblock(); } } if (e.Url.LocalPath == "addattack") { e.Cancel = true; TrapAttack trapAttack = new TrapAttack() { Name = "Attack" }; this.fTrap.Attacks.Add(trapAttack); this.update_statblock(); } if (e.Url.LocalPath == "addcm") { e.Cancel = true; TrapCountermeasureForm trapCountermeasureForm = new TrapCountermeasureForm("", this.fTrap.Level); if (trapCountermeasureForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.fTrap.Countermeasures.Add(trapCountermeasureForm.Countermeasure); this.update_statblock(); } } if (e.Url.LocalPath == "trigger") { e.Cancel = true; DetailsForm detailsForm3 = new DetailsForm(this.fTrap.Trigger, "Trigger", null); if (detailsForm3.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.fTrap.Trigger = detailsForm3.Details; this.update_statblock(); } } } if (e.Url.Scheme == "attackaction") { e.Cancel = true; Guid guid = new Guid(e.Url.LocalPath); TrapAttack name = this.fTrap.FindAttack(guid); if (name != null) { TrapActionForm trapActionForm = new TrapActionForm(name); if (trapActionForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { name.Name = trapActionForm.Attack.Name; name.Action = trapActionForm.Attack.Action; name.Range = trapActionForm.Attack.Range; name.Target = trapActionForm.Attack.Target; this.update_statblock(); } } } if (e.Url.Scheme == "attackremove") { e.Cancel = true; Guid guid1 = new Guid(e.Url.LocalPath); TrapAttack trapAttack1 = this.fTrap.FindAttack(guid1); if (trapAttack1 != null) { this.fTrap.Attacks.Remove(trapAttack1); this.update_statblock(); } } if (e.Url.Scheme == "attackattack") { e.Cancel = true; Guid guid2 = new Guid(e.Url.LocalPath); TrapAttack attack = this.fTrap.FindAttack(guid2); if (attack != null) { PowerAttackForm powerAttackForm = new PowerAttackForm(attack.Attack, false, this.fTrap.Level, this.fTrap.Role); if (powerAttackForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { attack.Attack = powerAttackForm.Attack; this.update_statblock(); } } } if (e.Url.Scheme == "attackhit") { e.Cancel = true; Guid guid3 = new Guid(e.Url.LocalPath); TrapAttack details = this.fTrap.FindAttack(guid3); if (details != null) { DetailsForm detailsForm4 = new DetailsForm(details.OnHit, "On Hit", null); if (detailsForm4.ShowDialog() == System.Windows.Forms.DialogResult.OK) { details.OnHit = detailsForm4.Details; this.update_statblock(); } } } if (e.Url.Scheme == "attackmiss") { e.Cancel = true; Guid guid4 = new Guid(e.Url.LocalPath); TrapAttack details1 = this.fTrap.FindAttack(guid4); if (details1 != null) { DetailsForm detailsForm5 = new DetailsForm(details1.OnMiss, "On Miss", null); if (detailsForm5.ShowDialog() == System.Windows.Forms.DialogResult.OK) { details1.OnMiss = detailsForm5.Details; this.update_statblock(); } } } if (e.Url.Scheme == "attackeffect") { e.Cancel = true; Guid guid5 = new Guid(e.Url.LocalPath); TrapAttack details2 = this.fTrap.FindAttack(guid5); if (details2 != null) { DetailsForm detailsForm6 = new DetailsForm(details2.Effect, "Effect", null); if (detailsForm6.ShowDialog() == System.Windows.Forms.DialogResult.OK) { details2.Effect = detailsForm6.Details; this.update_statblock(); } } } if (e.Url.Scheme == "attacknotes") { e.Cancel = true; Guid guid6 = new Guid(e.Url.LocalPath); TrapAttack trapAttack2 = this.fTrap.FindAttack(guid6); if (trapAttack2 != null) { DetailsForm detailsForm7 = new DetailsForm(trapAttack2.Notes, "Notes", null); if (detailsForm7.ShowDialog() == System.Windows.Forms.DialogResult.OK) { trapAttack2.Notes = detailsForm7.Details; this.update_statblock(); } } } if (e.Url.Scheme == "skill") { e.Cancel = true; Guid guid7 = new Guid(e.Url.LocalPath); TrapSkillData trapSkillDatum1 = this.fTrap.FindSkill(guid7); if (trapSkillDatum1 != null) { int skillData = this.fTrap.Skills.IndexOf(trapSkillDatum1); TrapSkillForm trapSkillForm1 = new TrapSkillForm(trapSkillDatum1, this.fTrap.Level); if (trapSkillForm1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.fTrap.Skills[skillData] = trapSkillForm1.SkillData; this.update_statblock(); } } } if (e.Url.Scheme == "skillremove") { e.Cancel = true; Guid guid8 = new Guid(e.Url.LocalPath); TrapSkillData trapSkillDatum2 = this.fTrap.FindSkill(guid8); if (trapSkillDatum2 != null) { this.fTrap.Skills.Remove(trapSkillDatum2); this.update_statblock(); } } if (e.Url.Scheme == "cm") { e.Cancel = true; int countermeasure = int.Parse(e.Url.LocalPath); string item = this.fTrap.Countermeasures[countermeasure]; TrapCountermeasureForm trapCountermeasureForm1 = new TrapCountermeasureForm(item, this.fTrap.Level); if (trapCountermeasureForm1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.fTrap.Countermeasures[countermeasure] = trapCountermeasureForm1.Countermeasure; this.update_statblock(); } } }