private void MoveDown()
 {
     if (SelectedCombatant.TieBreaker != Combatants.Count - 1)
     {
         var nextCombatant = Combatants.FirstOrDefault(c => c.TieBreaker == SelectedCombatant.TieBreaker + 1);
         nextCombatant.TieBreaker--;
         SelectedCombatant.TieBreaker++;
     }
     Combatants.Sort();
 }
 private void MoveUp()
 {
     if (SelectedCombatant.TieBreaker != 0)
     {
         var previousCombatant = Combatants.FirstOrDefault(c => c.TieBreaker == SelectedCombatant.TieBreaker - 1);
         previousCombatant.TieBreaker++;
         SelectedCombatant.TieBreaker--;
     }
     Combatants.Sort();
 }
Пример #3
0
        private void Load()
        {
            Combatants.Clear();
            var eventArgs = new SaveEventArgs();

            LoadTriggered?.Invoke(this, eventArgs);
            foreach (Combatant combatant in eventArgs.SaveData)
            {
                Combatants.Add(combatant);
            }
            Combatants.Sort();
        }
Пример #4
0
        private void Add()
        {
            int initiative;

            if (!int.TryParse(Initiative, out initiative))
            {
                throw new Exception($"{Initiative} is not a valid value.");
            }

            bool initiativeTied = Combatants.Any(c => c.Initiative == initiative);
            var  newCombatant   = new Combatant(Name, initiative, Combatants.Count == 0);

            Combatants.Add(newCombatant);
            if (initiativeTied && InitiativeTied != null)
            {
                newCombatant.TieBreaker = Combatants.Max(c => c.TieBreaker) + 1;
                InitiativeTied?.Invoke(this, new TieInitiativeEventArgs(Combatants.Where(c => c.Initiative == initiative)));
            }
            Combatants.Sort();
            Name       = null;
            Initiative = null;
        }