Exemple #1
0
        private void LoadPreview(Summon st)
        {
            sittingSummonIndex         = st.Index;
            cbSummonSpell.SelectedItem = st.SummonSpell;
            cbSummonSpell.Text         = st.SummonSpell;
            tbName.Text  = st.Name;
            nudSTR.Value = st.Abilities.Str;
            nudDEX.Value = st.Abilities.Dex;
            nudCON.Value = st.Abilities.Con;
            nudINT.Value = st.Abilities.Int;
            nudWIS.Value = st.Abilities.Wis;
            nudCHA.Value = st.Abilities.Cha;

            nudFort.Value = st.Saves.Fort;
            nudRef.Value  = st.Saves.Ref;
            nudWill.Value = st.Saves.Will;

            nudLevel.Value   = st.Level;
            nudHD.Value      = st.HitDie;
            nudNatural.Value = st.NaturalArmor;
            nudBAB.Value     = st.BAB;
            nudGrapple.Value = st.Grapple;

            cbSize.SelectedItem = st.Size.ToString();
            tbType.Text         = st.Type;
            tbEnvironment.Text  = st.Environment;
            tbSpace.Text        = st.Space;
            tbReach.Text        = st.Reach;
            tbMovement.Text     = st.Movement;

            rtbSkills.Text      = string.Join(",", st.Skills);
            tbFeats.Text        = string.Join(",", st.Feats);
            tbSpecAtks.Text     = string.Join(",", st.SpecAtks);
            tbSpecQual.Text     = string.Join(",", st.SpecQual);
            rtbCombat.Text      = string.Join("\r", st.Notes);
            rtbAttacks.Text     = string.Join("\r", st.Attacks);
            rtbFullAttacks.Text = string.Join("\r", st.FullAttacks);
        }
Exemple #2
0
        public static Summon GetSummonTemplateFromText(string text)
        {
            Summon thisTemplate = new Summon();
            string name         = "";
            string sizetype     = "";
            string hitdie       = "";
            string speed        = "";
            string armor        = "";
            string babgrapple   = "";
            string attacks      = "";
            string fullattacks  = "";
            string spacereach   = "";
            string specatk      = "";
            string specqual     = "";
            string saves        = "";
            string abilities    = "";
            string skills       = "";
            string feats        = "";
            string environment  = "";

            string[] textArray = text.Replace("\r\n", "~").Replace("\r", "~").Replace("\n", "~").Split('~');
            bool     combat    = false;

            for (int i = 0; i < textArray.Length; i++)
            {
                string line = textArray[i];
                line = line.Replace("–", "-");
                if (!combat)
                {
                    if (i == 0 || line.Contains("click to see monster"))
                    {
                        name = line;
                    }
                    if (line.StartsWith("Size/Type"))
                    {
                        sizetype = line;
                    }
                    if (line.StartsWith("Hit Dice"))
                    {
                        hitdie = line;
                    }
                    if (line.StartsWith("Speed"))
                    {
                        speed = line;
                    }
                    if (line.StartsWith("Armor Class"))
                    {
                        armor = line;
                    }
                    if (line.StartsWith("Base Attack"))
                    {
                        babgrapple = line;
                    }
                    if (line.StartsWith("Attack"))
                    {
                        attacks = line;
                    }
                    if (line.StartsWith("Full Attack"))
                    {
                        fullattacks = line;
                    }
                    if (line.StartsWith("Space"))
                    {
                        spacereach = line;
                    }
                    if (line.StartsWith("Special Attacks"))
                    {
                        specatk = line;
                    }
                    if (line.StartsWith("Special Qualities"))
                    {
                        specqual = line;
                    }
                    if (line.StartsWith("Saves"))
                    {
                        saves = line;
                    }
                    if (line.StartsWith("Abilities"))
                    {
                        abilities = line;
                    }
                    if (line.StartsWith("Skills:"))
                    {
                        skills = line;
                    }
                    if (line.StartsWith("Feats"))
                    {
                        feats = line;
                    }
                    if (line.StartsWith("Environment"))
                    {
                        environment = line;
                    }
                    if (line.ToUpper().StartsWith("COMBAT"))
                    {
                        combat = true;
                    }
                }
                else
                {
                    thisTemplate.Notes.Add(line);
                }
            }

            thisTemplate.Name      = CapitalizeFirstLetter(name.Replace(" click to see monster", ""));
            thisTemplate.Size      = GetSize(sizetype, out string type);
            thisTemplate.Type      = type;
            thisTemplate.Abilities = GetAbilities(abilities);

            thisTemplate.NaturalArmor = GetNaturalArmor(armor);
            thisTemplate.Saves        = GetSaves(saves);

            thisTemplate.Environment = GetEnvironment(environment);

            thisTemplate.Movement = GetSpeeds(speed);

            thisTemplate.Space = GetSpaceReach(spacereach, out string reach);
            thisTemplate.Reach = reach;

            thisTemplate.Attacks     = GetAttacks(attacks);
            thisTemplate.FullAttacks = GetFullAttacks(fullattacks);

            thisTemplate.Skills = GetSkills(skills);

            thisTemplate.Feats    = GetFeats(feats);
            thisTemplate.SpecAtks = GetSpecAtk(specatk);
            thisTemplate.SpecQual = GetSpecQual(specqual);
            thisTemplate.BAB      = GetBABGrapple(babgrapple, out int grapple);
            thisTemplate.Grapple  = grapple;
            thisTemplate.HitDie   = GetHitDie(hitdie, out int level);
            thisTemplate.Level    = level;

            return(thisTemplate);
        }
Exemple #3
0
        public SummonToForm(Summon s)
        {
            Index       = s.Index;
            SummonSpell = string.Copy(s.SummonSpell);

            Name      = s.Name;
            Size      = s.Size;
            Type      = s.Type;
            Abilities = new Abilities()
            {
                Str = s.Abilities.Str,
                Dex = s.Abilities.Dex,
                Con = s.Abilities.Con,
                Int = s.Abilities.Int,
                Wis = s.Abilities.Wis,
                Cha = s.Abilities.Cha
            };

            BaseAbilities = new Abilities()
            {
                Str = s.Abilities.Str,
                Dex = s.Abilities.Dex,
                Con = s.Abilities.Con,
                Int = s.Abilities.Int,
                Wis = s.Abilities.Wis,
                Cha = s.Abilities.Cha
            };

            NaturalArmor = s.NaturalArmor;
            Feats        = new List <string>(s.Feats);
            SpecAtks     = new List <string>(s.SpecAtks);
            SpecQual     = new List <string>(s.SpecQual);

            Saves = new Saves()
            {
                Fort = s.Saves.Fort,
                Ref  = s.Saves.Ref,
                Will = s.Saves.Will
            };

            Saves.Fort -= s.Abilities.ConMod;
            Saves.Ref  -= s.Abilities.DexMod;
            Saves.Will -= s.Abilities.WisMod;

            if (Feats.Any(x => x.ToUpper() == "IRON WILL"))
            {
                Saves.Will -= 2; MiscWill += 2;
            }

            Environment = s.Environment;

            Movement = s.Movement;

            Space = s.Space;
            Reach = s.Reach;

            Attacks     = new List <Attack>(s.Attacks);
            FullAttacks = new List <FullAttack>(s.FullAttacks);

            Skills = Summon.GetSkillMods(s.Skills);

            for (int i = 0; i < s.Skills.Count; i++)
            {
                Skills[i] = Summon.CorrectSkillModBackward(Skills[i], BaseAbilities);
            }

            Notes       = new List <string>(s.Notes);
            BAB         = s.BAB;
            MiscGrapple = s.Grapple - s.BAB - s.Abilities.StrMod - Summon.GetGrappleSizeMod(s.Size);
            HitDie      = s.HitDie;
            Level       = s.Level;
        }
Exemple #4
0
        private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!File.Exists(Properties.Settings.Default.SummonsXML))
            {
                MessageBox.Show("XML file was not found.", "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (sittingSummonIndex == 0)
            {
                MessageBox.Show("Summon does not exist.", "Summon Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                if (tbName.Text == "")
                {
                    MessageBox.Show("Summon Name must be filled out", "Summon Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (cbSummonSpell.Text == "")
                {
                    MessageBox.Show("Summon Spell/Category must be specified", "Summon Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }


                List <Size> sizes = Enum.GetValues(typeof(Size)).Cast <Size>().ToList();
                int         index = sizes.FindIndex(x => x.ToString() == cbSize.SelectedItem.ToString());
                Size        size  = index > -1 ? sizes[index] : DruidAssistant.Size.Medium;

                Summon updateSummon = new Summon
                {
                    Index        = sittingSummonIndex,
                    SummonSpell  = cbSummonSpell.Text,
                    Name         = tbName.Text,
                    Abilities    = new Abilities((int)nudSTR.Value, (int)nudDEX.Value, (int)nudCON.Value, (int)nudINT.Value, (int)nudWIS.Value, (int)nudCHA.Value),
                    Saves        = new Saves((int)nudFort.Value, (int)nudRef.Value, (int)nudWill.Value),
                    Level        = (int)nudLevel.Value,
                    HitDie       = (int)nudHD.Value,
                    NaturalArmor = (int)nudNatural.Value,
                    BAB          = (int)nudBAB.Value,
                    Grapple      = (int)nudGrapple.Value,
                    Size         = size,
                    Type         = tbType.Text,
                    Environment  = tbEnvironment.Text,
                    Space        = tbSpace.Text,
                    Reach        = tbReach.Text,
                    Movement     = tbMovement.Text,
                    Skills       = rtbSkills.Text.Split(',').ToList(),
                    Feats        = tbFeats.Text.Split(',').ToList(),
                    SpecAtks     = tbSpecAtks.Text.Split(',').ToList(),
                    SpecQual     = tbSpecQual.Text.Split(',').ToList(),
                    Notes        = rtbCombat.Text.Split('\r').ToList(),
                    Attacks      = Summon.GetAttacks(rtbAttacks.Text),
                    FullAttacks  = Summon.GetFullAttacks(rtbFullAttacks.Text)
                };

                Summons summons    = Summons.Retrieve(Properties.Settings.Default.SummonsXML);
                int     indexMatch = summons.FindIndex(x => x.Index == sittingSummonIndex);
                if (indexMatch > -1)
                {
                    summons[indexMatch] = updateSummon;
                }
                else
                {
                    MessageBox.Show("Summon cannot be found.", "Summon Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                summons.Save(Properties.Settings.Default.SummonsXML);
                RefreshSummonPage();
            }
        }
Exemple #5
0
        private void AddToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!File.Exists(Properties.Settings.Default.SummonsXML))
            {
                MessageBox.Show("XML file was not found.", "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (tbName.Text == "")
            {
                MessageBox.Show("Summon Name must be filled out", "Summon Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (cbSummonSpell.Text == "")
            {
                MessageBox.Show("Summon Spell/Category must be specified", "Summon Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            List <Size> sizes = Enum.GetValues(typeof(Size)).Cast <Size>().ToList();
            int         index = sizes.FindIndex(x => x.ToString() == cbSize.SelectedItem.ToString());
            Size        size  = index > -1 ? sizes[index] : DruidAssistant.Size.Medium;

            Summon addSummon = new Summon
            {
                SummonSpell  = cbSummonSpell.Text,
                Name         = tbName.Text,
                Abilities    = new Abilities((int)nudSTR.Value, (int)nudDEX.Value, (int)nudCON.Value, (int)nudINT.Value, (int)nudWIS.Value, (int)nudCHA.Value),
                Saves        = new Saves((int)nudFort.Value, (int)nudRef.Value, (int)nudWill.Value),
                Level        = (int)nudLevel.Value,
                HitDie       = (int)nudHD.Value,
                NaturalArmor = (int)nudNatural.Value,
                BAB          = (int)nudBAB.Value,
                Grapple      = (int)nudGrapple.Value,
                Size         = size,
                Type         = tbType.Text,
                Environment  = tbEnvironment.Text,
                Space        = tbSpace.Text,
                Reach        = tbReach.Text,
                Movement     = tbMovement.Text,
                Skills       = rtbSkills.Text.Split(',').ToList(),
                Feats        = tbFeats.Text.Split(',').ToList(),
                SpecAtks     = tbSpecAtks.Text.Split(',').ToList(),
                SpecQual     = tbSpecQual.Text.Split(',').ToList(),
                Notes        = rtbCombat.Text.Split('\r').ToList(),
                Attacks      = Summon.GetAttacks(rtbAttacks.Text),
                FullAttacks  = Summon.GetFullAttacks(rtbFullAttacks.Text)
            };

            Summons summons    = Summons.Retrieve(Properties.Settings.Default.SummonsXML);
            int     indexMatch = summons.FindIndex(x => x.Name.ToUpper() == addSummon.Name.ToUpper() && x.SummonSpell.ToUpper() == addSummon.SummonSpell.ToUpper());

            if (indexMatch > -1)
            {
                if (MessageBox.Show("Summon of the same name and level already exists\rWould you like to add a duplicate?", "Spell already exists", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    addSummon.Index = summons.Max(x => x.Index) + 1;
                    summons.Add(addSummon);
                    ClearSummonPage();
                }
            }
            else
            {
                addSummon.Index = summons.Max(x => x.Index) + 1;
                summons.Add(addSummon);
                ClearSummonPage();
            }

            summons.Save(Properties.Settings.Default.SummonsXML);
            RefreshSummonPage();
        }
Exemple #6
0
        private void LoadPage(SummonToForm st)
        {
            flag1 = true;
            rtbNotes.Clear();
            lbAttacks.Items.Clear();
            lbFeats.Items.Clear();
            lbAttacks.Items.Clear();
            lbFullAttacks.Items.Clear();
            lbSkills.Items.Clear();
            lbSpecialAttacks.Items.Clear();
            lbSpecialQualities.Items.Clear();


            for (int i = 0; i < st.Skills.Count; i++)
            {
                lbSkills.Items.Add(Summon.CorrectSkillModForward(st.Skills[i], st.Abilities));
            }

            for (int i = 0; i < st.Feats.Count; i++)
            {
                lbFeats.Items.Add(st.Feats[i]);
            }

            for (int i = 0; i < st.SpecAtks.Count; i++)
            {
                lbSpecialAttacks.Items.Add(st.SpecAtks[i]);
            }

            for (int i = 0; i < st.SpecQual.Count; i++)
            {
                lbSpecialQualities.Items.Add(st.SpecQual[i]);
            }

            for (int i = 0; i < st.Attacks.Count; i++)
            {
                lbAttacks.Items.Add(st.Attacks[i]);
            }

            for (int i = 0; i < st.FullAttacks.Count; i++)
            {
                lbFullAttacks.Items.Add(st.FullAttacks[i].ToString());
            }

            rtbNotes.AppendText(string.Join("\r", st.Notes));

            tbSummonName.Text = st.Name;
            nudRounds.Value   = st.Rounds;

            nudSTR.Value = st.Abilities.Str;
            nudDEX.Value = st.Abilities.Dex;
            nudCON.Value = st.Abilities.Con;
            nudINT.Value = st.Abilities.Int;
            nudWIS.Value = st.Abilities.Wis;
            nudCHA.Value = st.Abilities.Cha;

            cbSize.Text         = st.Size.ToString();
            tbType.Text         = st.Type;
            nudInitiative.Value = st.Abilities.DexMod;
            tbSpeed.Text        = st.Movement;

            labelACDex.Text     = st.Abilities.DexMod.ToString();
            labelACNatural.Text = st.NaturalArmor.ToString();
            labelACSize.Text    = Summon.GetSizeMod(st.Size).ToString();

            labelTouchDex.Text  = st.Abilities.DexMod.ToString();
            labelTouchSize.Text = Summon.GetSizeMod(st.Size).ToString();

            labelFlatNatural.Text = st.NaturalArmor.ToString();
            labelFlatSize.Text    = Summon.GetSizeMod(st.Size).ToString();

            tbSpaceReach.Text = string.Format("{0}, {1}", st.Space, st.Reach);

            labelFortBase.Text    = st.Saves.Fort.ToString();
            labelFortAbility.Text = st.Abilities.ConMod.ToString();
            nudFortMisc.Value     = st.MiscFort;

            labelRefBase.Text    = st.Saves.Ref.ToString();
            labelRefAbility.Text = st.Abilities.DexMod.ToString();
            nudRefMisc.Value     = st.MiscRef;

            labelWillBase.Text    = st.Saves.Will.ToString();
            labelWillAbility.Text = st.Abilities.WisMod.ToString();
            nudWillMisc.Value     = st.MiscWill;


            tbEnvironment.Text = st.Environment;
            tbHitDie.Text      = string.Format("{0}d{1}", st.Level, st.HitDie);

            int toughnessAddition = GetToughnessHP(st);

            int prevMaxHP = int.Parse(nudMaxHP.Value.ToString());
            int newMaxHP  = int.Parse(Math.Floor(st.Level * 1.000 * Math.Ceiling(st.HitDie * 1.000 / 2) + st.Level * .500 + st.Abilities.ConMod * 1.000 * st.Level + toughnessAddition).ToString());

            nudMaxHP.Value = decimal.Parse(newMaxHP.ToString());
            //new summon
            if (prevMaxHP == 0)
            {
                nudCurrentHP.Value = newMaxHP;
            }
            //nothing changed; regular update
            else if (prevMaxHP == newMaxHP)
            {
            }
            //CON changed
            else
            {
                int difference = prevMaxHP - currentST.CurrentHP;
                nudCurrentHP.Value = newMaxHP - difference;
            }

            labelBaseAttackBonus.Text = st.BAB.ToString();

            //nudGrappleBonus.Value =
            labelGrappleBase.Text    = st.BAB.ToString();
            labelGrappleAbility.Text = st.Abilities.StrMod.ToString();
            labelGrappleSize.Text    = Summon.GetGrappleSizeMod(st.Size).ToString();
            nudGrappleMisc.Value     = st.MiscGrapple;

            //nudMeleeBonus.Value =
            labelMeleeBase.Text    = labelBaseAttackBonus.Text;
            labelMeleeAbility.Text = (HasWeaponFinesse(st) ? Math.Max(st.Abilities.StrMod, st.Abilities.DexMod) : st.Abilities.StrMod).ToString();
            labelMeleeSize.Text    = Summon.GetSizeMod(st.Size).ToString();
            nudMeleeMisc.Value     = st.MiscMelee;

            //nudRangeBonus.Value =
            labelRangeBase.Text    = labelBaseAttackBonus.Text;
            labelRangeAbility.Text = st.Abilities.DexMod.ToString();
            labelRangeSize.Text    = Summon.GetSizeMod(st.Size).ToString();
            nudRangeMisc.Value     = st.MiscRange;
            flag1 = false;
        }