Beispiel #1
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();
            }
        }
        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);

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

                foreach (Attack 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);
                }
            }
        }