Esempio n. 1
0
 /// <summary>
 /// Remove an Ability from the list.
 /// </summary>
 /// <param name="index">The index of the Ability to remove</param>
 /// <returns></returns>
 public Ability Remove(int index)
 {
     if (Abilities.Count > index)
     {
         Ability toReturn = Abilities.ElementAt(index);
         Abilities.RemoveAt(index);
         // Save the changes made.
         Save();
         return(toReturn);
     }
     else
     {
         // Return null if the index is out of range.
         return(null);
     }
 }
Esempio n. 2
0
        public Model.Attack GetAttack()
        {
            bool   askForInput = true;
            string feedback    = null;

            Model.Attack attack = null;
            while (askForInput)
            {
                View.AddAttackWindow addAttackWindow = new View.AddAttackWindow(feedback);
                addAttackWindow.DataContext = this;

                if (addAttackWindow.ShowDialog() == true)
                {
                    try
                    {
                        attack = new Model.Attack
                        {
                            Name           = Name,
                            Modifier       = Convert.ToInt32(Modifier),
                            Type           = Methods.GetAttackTypeFromString(AttackTypes.ElementAt(Type)),
                            Ability        = Methods.GetAbilityFromString(Abilities.ElementAt(Ability)),
                            ThreatRangeMin = Methods.GetThreatRangeMinFromString(ThreatRanges.ElementAt(SelectedThreatRange)),
                            CritMultiplier = Methods.GetCritMultiplierFromString(CritMultipliers.ElementAt(SelectedCritMultiplier)),
                            TwoHanded      = TwoHanded,
                        };

                        foreach (DamageViewModel damageViewModel in Damages)
                        {
                            attack.Damages.Add(damageViewModel.Damage);
                        }

                        askForInput = false;
                    }
                    catch (FormatException)
                    {
                        feedback = "Invalid format";
                    }
                }
                else
                {
                    askForInput = false;
                }
            }

            return(attack);
        }