private void AddNewCombatant(object sender, ExecutedRoutedEventArgs e)
        {
            Combatant newCombatant = new Combatant(textBlock15.Text, "", textBlock21.Text, textBlock22.Text,
                    textBlock19.Text, textBlock20.Text, textBlock21.Text, textBlock22.Text, textBlock23.Text,
                    textBlock26.Text, textBlock27.Text, textBlock28.Text, textBox1.Text, textBox2.Text, (bool)isNPC.IsChecked);

            if (combatant == null)
            {
                CommAddCombatant addComm = new CommAddCombatant(combatants, newCombatant);
                addComm.Execute();
            }
            else
            {
                int index = combatants.IndexOf(combatant);

                CommRemoveCombatant commRmv = new CommRemoveCombatant(combatants, combatant);
                commRmv.Execute();
                CommAddCombatant addComm = new CommAddCombatant(combatants, newCombatant);
                addComm.Execute();
                CommRepositionCombatant commRepos = new CommRepositionCombatant(combatants, newCombatant, index - combatants.Count);
                commRepos.Execute();
            }

            this.Close();
        }
Exemplo n.º 2
0
        private void clearDead_Click(object sender, RoutedEventArgs e)
        {
            int count = listi.Count;
            List<Combatant> toBeRemoved = new List<Combatant>();

            for (int i = 0; i < count; i++)
            {
                Combatant combatant = listi[i];
                if (combatant.HP < 0)
                {
                    toBeRemoved.Add(combatant);
                }
            }
            foreach (Combatant exCombatant in toBeRemoved)
            {
                CommRemoveCombatant commRmv = new CommRemoveCombatant(listi, exCombatant);
                commRmv.Execute();
            }
        }
Exemplo n.º 3
0
 private void RemoveSelectedCombatant(object sender, ExecutedRoutedEventArgs e)
 {
     Combatant toBeRemovedCombatant = getSelectedCombatant();
     if (toBeRemovedCombatant != null)
     {
         CommRemoveCombatant commRmv = new CommRemoveCombatant(listi, toBeRemovedCombatant);
         commRmv.Execute();
     }
 }