Clear() public static method

public static Clear ( bool isNew = false ) : void
isNew bool
return void
 // Loads the monster data from data model.
 public static void Input(Data source)
 {
     Monster.Clear(true);
     _Abilities          = source._Abilities;
     _Actions            = source._Actions;
     _Legendaries        = source._Legendaries;
     _Reactions          = source._Reactions;
     _Languages          = source._Languages;
     _Senses             = source._Senses;
     AC                  = source.AC;
     CHA                 = source.CHA;
     CON                 = source.CON;
     ConditionImmunities = source.ConditionImmunities;
     CR                  = source.CR;
     CreatureAlign       = source.CreatureAlign;
     CreatureName        = source.CreatureName;
     CreatureSize        = source.CreatureSize;
     CreatureType        = source.CreatureType;
     DamageImmunities    = source.DamageImmunities;
     DamageResistances   = source.DamageResistances;
     DamageVulnerability = source.DamageVulnerability;
     DEX                 = source.DEX;
     HP                  = source.HP;
     INT                 = source.INT;
     proficency          = source.proficency;
     SavingThrowBonuses  = source.SavingThrowBonuses;
     SkillBonuses        = source.SkillBonuses;
     Speed               = source.Speed;
     STR                 = source.STR;
     Title               = source.Title;
     WIS                 = source.WIS;
     CreatureGender      = source.CreatureGender;
     unique              = source.unique;
 }
Beispiel #2
0
 private void NewMonsterButton_Click(object sender, EventArgs e)
 {
     Monster.Clear();
     ClearUI();
 }
Beispiel #3
0
        private void LoadData(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.InitialDirectory = @"C:\";
            dialog.Filter           = "mm files (*.mm)|*.mm";
            dialog.RestoreDirectory = true;

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Data jsonMonster = new Data();
                jsonMonster = JsonConvert.DeserializeObject <Data>(System.IO.File.ReadAllText(dialog.FileName));
                TraitsList.Items.Clear();

                Monster.Input(jsonMonster);

                currentCR = Monster.CR;
                ChallengeRatingDropDown.Text         = "";
                ChallengeRatingDropDown.SelectedText = Help.FindCRByIndex(Monster.CR.Index).CR;
                crChangedUpdateProficiency(null, null);

                AlignmentDropDown.Text         = "";
                AlignmentDropDown.SelectedText = Monster.CreatureAlign;

                StrUpDown.Value = Monster.STR;
                DexUpDown.Value = Monster.DEX;
                ConUpDown.Value = Monster.CON;
                WisUpDown.Value = Monster.WIS;
                IntUpDown.Value = Monster.INT;
                ChaUpDown.Value = Monster.CHA;

                string[] speeds = Monster.Speed.Split(',');
                foreach (string speed in speeds)
                {
                    string check = speed.Split(':')[0].Trim();
                    switch (check)
                    {
                    case "Burrow":
                        int Burrow = 0;
                        int.TryParse(speed.Split(':')[1], out Burrow);
                        burrowUpDown.Value = Burrow;
                        break;

                    case "Climb":
                        int Climb = 0;
                        int.TryParse(speed.Split(':')[1], out Climb);
                        ClimbUpDown.Value = Climb;
                        break;

                    case "Fly":
                        int Fly = 0;
                        if (speed.Split(':')[1].Contains("(Hover)"))
                        {
                            HoverCheckBox.Checked = true;
                            int.TryParse(speed.Split(':')[1].Replace(" (Hover)", ""), out Fly);
                        }
                        else
                        {
                            int.TryParse(speed.Split(':')[1], out Fly);
                        }
                        FlyUpDown.Value = Fly;
                        break;

                    case "Swim":
                        int Swim = 0;
                        int.TryParse(speed.Split(':')[1], out Swim);
                        SwimUpDown.Value = Swim;
                        break;

                    default:
                        try
                        {
                            int temp = 0;
                            int.TryParse(check, out temp);
                            SpeedUpDown.Value = temp;
                        }
                        catch { }
                        break;
                    }
                }

                foreach (Ability item in Monster._Abilities)
                {
                    TraitsList.Items.Add("Ability: " + item.Title);
                }

                foreach (Ability item in Monster._Attacks)
                {
                    TraitsList.Items.Add("Attack: " + item.Title);
                }

                foreach (string language in Monster._Languages)
                {
                    TraitsList.Items.Add("Language: " + language);
                }

                foreach (string senses in Monster._Senses)
                {
                    TraitsList.Items.Add("Sense: " + senses);
                }

                foreach (string CImmunity in Monster.ConditionImmunities)
                {
                    TraitsList.Items.Add("Condition Immunity: " + CImmunity);
                }

                foreach (string DImmunities in Monster.DamageImmunities)
                {
                    TraitsList.Items.Add("Damage Immunity: " + DImmunities);
                }

                foreach (string DResistance in Monster.DamageResistances)
                {
                    TraitsList.Items.Add("Damage Resistance: " + DResistance);
                }

                foreach (string DVulnerability in Monster.DamageVulnerability)
                {
                    TraitsList.Items.Add("Damage Vulnerability: " + DVulnerability);
                }

                foreach (string SavingThrow in Monster.SavingThrowBonuses)
                {
                    string temp      = SavingThrow.Split(' ')[0];
                    int    tempBonus = 0;
                    int.TryParse(SavingThrow.Split('+')[1], out tempBonus);

                    switch (temp)
                    {
                    case "Str":
                        StrSaveBonusUpDown.Value = tempBonus;
                        break;

                    case "Dex":
                        DexSaveBonusUpDown.Value = tempBonus;
                        break;

                    case "Con":
                        ConSaveBonusUpDown.Value = tempBonus;
                        break;

                    case "Int":
                        IntSaveBonusUpDown.Value = tempBonus;
                        break;

                    case "Wis":
                        WisSaveBonusUpDown.Value = tempBonus;
                        break;

                    case "Cha":
                        ChaSaveBonusUpDown.Value = tempBonus;
                        break;
                    }
                }

                foreach (string SkillBonus in Monster.SkillBonuses)
                {
                    TraitsList.Items.Add(SkillBonus);
                }

                HitDieTextBox.Text = Monster.HP;
                try
                {
                    string hpString = Monster.HP.Split('(')[1].Replace(')', ' ').Trim().Split('+')[0];
                    int    DiceSize;
                    int    DiceNumber;
                    int.TryParse(hpString.Split('d')[0], out DiceNumber);
                    int.TryParse(hpString.Split('d')[1], out DiceSize);

                    HitDieUpDown.Value          = DiceNumber;
                    HitDieDropDown.Text         = "";
                    HitDieDropDown.SelectedText = "d" + DiceSize;
                }
                catch { }

                try
                {
                    int ACValue = 0;
                    int.TryParse(Monster.AC.Split(' ')[0], out ACValue);

                    ACUpDown.Value       = ACValue;
                    ACSourceTextBox.Text = Monster.AC.Split(' ')[1];
                }
                catch { }

                MonsterNameTextBox.Text = "";
                SizeDropDown.Text       = "";
                TypeDropDown.Text       = "";
                TagDropDown.Text        = "";

                MonsterNameTextBox.Text   = Monster.CreatureName;
                SizeDropDown.SelectedText = Monster.CreatureSize;
                TypeDropDown.SelectedText = Monster.CreatureType.Split(' ')[0];
                try { TagDropDown.SelectedText = Monster.CreatureType.Split(' ')[1].Replace('(', ' ').Replace(')', ' ').Trim(); }
                catch { }

                //Monster.SkillBonuses.Clear();
                Monster.Clear();
            }
        }
Beispiel #4
0
        // Generates the actual monster itself.
        private void GenerateMonsterData()
        {
            Monster.SkillBonuses.Clear();
            Monster.Clear();
            // Clear existing HTML
            if (Monster.output.Count > 0)
            {
            }

            int.TryParse(ProfBonus.Text, out Monster.proficency);

            Monster.CreatureName  = MonsterNameTextBox.Text;
            Monster.CreatureSize  = SizeDropDown.Text;
            Monster.CreatureAlign = AlignmentDropDown.Text;
            Monster.CreatureType  = TypeDropDown.Text;

            if (!String.IsNullOrEmpty(TagDropDown.Text))
            {
                Monster.CreatureType += " (" + TagDropDown.Text + ")";
            }

            Monster.STR = (int)StrUpDown.Value;
            Monster.DEX = (int)DexUpDown.Value;
            Monster.CON = (int)ConUpDown.Value;
            Monster.INT = (int)IntUpDown.Value;
            Monster.WIS = (int)WisUpDown.Value;
            Monster.CHA = (int)ChaUpDown.Value;

            Monster.Speed = SpeedUpDown.Value.ToString();
            if (burrowUpDown.Value > 0)
            {
                Monster.Speed += ", Burrow: " + burrowUpDown.Value;
            }
            if (ClimbUpDown.Value > 0)
            {
                Monster.Speed += ", Climb: " + ClimbUpDown.Value;
            }
            if (FlyUpDown.Value > 0)
            {
                Monster.Speed += ", Fly: " + FlyUpDown.Value;
            }
            if (HoverCheckBox.Checked)
            {
                Monster.Speed += " (Hover)";
            }
            if (SwimUpDown.Value > 0)
            {
                Monster.Speed += ", Swim: " + SwimUpDown.Value;
            }

            Monster.AC = ACUpDown.Value + " " + ACSourceTextBox.Text;
            Monster.HP = HitDieTextBox.Text;
            Monster.CR = currentCR;

            foreach (string item in TraitsList.Items)
            {
                switch (item.Split(':')[0])
                {
                case "Skill":
                    Monster.AddSkillBonus(item);
                    break;

                case "Damage Vulnerability":
                    Monster.AddDamageVulnerabilities(item.Split(':')[1].Trim());
                    break;

                case "Damage Resistance":
                    Monster.AddDamageResistance(item.Split(':')[1].Trim());
                    break;

                case "Damage Immunity":
                    Monster.AddDamageImmunity(item.Split(':')[1].Trim());
                    break;

                case "Condition Immunity":
                    Monster.AddConditionImmunity(item.Split(':')[1].Trim());
                    break;

                case "Language":
                    Monster._Languages.Add(item.Split(':')[1].Trim());
                    break;

                case "Sense":
                    Monster._Senses.Add(item.Split(':')[1].Trim());
                    break;
                }
            }

            if (StrSaveBonusUpDown.Value > 0)
            {
                Monster.AddSavingThrow("Str +" + StrSaveBonusUpDown.Value);
            }
            if (DexSaveBonusUpDown.Value > 0)
            {
                Monster.AddSavingThrow("Dex +" + DexSaveBonusUpDown.Value);
            }
            if (ConSaveBonusUpDown.Value > 0)
            {
                Monster.AddSavingThrow("Con +" + ConSaveBonusUpDown.Value);
            }
            if (IntSaveBonusUpDown.Value > 0)
            {
                Monster.AddSavingThrow("Int +" + IntSaveBonusUpDown.Value);
            }
            if (WisSaveBonusUpDown.Value > 0)
            {
                Monster.AddSavingThrow("Wis +" + WisSaveBonusUpDown.Value);
            }
            if (ChaSaveBonusUpDown.Value > 0)
            {
                Monster.AddSavingThrow("Cha +" + ChaSaveBonusUpDown.Value);
            }
        }