private void applyDamage(float damageAmount)
 {
     Combatant toBeDamagedCombatant = getSelectedCombatant();
     if (toBeDamagedCombatant == null)
         return;
     float previousHP = toBeDamagedCombatant.HP;
     CommUpdateCombatant commUpdt = new CommUpdateCombatant(toBeDamagedCombatant, CombatantAttributes.hp, previousHP + damageAmount);
     commUpdt.Execute();
 }
 private void button1_Click(object sender, RoutedEventArgs e)
 {
     float newInititive = App.getFloatFromString(initiativeBox.Text);
     if (newInititive != 0)
     {
         Combatant newInitiativeCombatant = getSelectedCombatant();
         if (newInitiativeCombatant == null)
             return;
         float previousHP = newInitiativeCombatant.HP;
         CommUpdateCombatant commUpdt = new CommUpdateCombatant(newInitiativeCombatant, CombatantAttributes.initiative, newInititive);
         commUpdt.Execute();
     }
 }
        private void SetThisInitiative(object sender, ExecutedRoutedEventArgs e)
        {
            float initiative = App.getFloatFromString(initBox.Text);
            Combatant selectedCombatant = (Combatant)listBox1.SelectedItem;
            CommUpdateCombatant commUpdt = new CommUpdateCombatant(selectedCombatant, CombatantAttributes.initiative, initiative);
            commUpdt.Execute();

            int indexOfSelected = table.IndexOf(selectedCombatant);
            if (indexOfSelected < table.Count - 1)
            {
                listBox1.SelectedItem = table[indexOfSelected + 1];
                initBox.Text = "";
            }
            else
            {
                this.Close();
            }
        }
 private void XP_Click(object sender, RoutedEventArgs e)
 {
     float xpAmount = App.getFloatFromString(damageHealBox.Text);
     if (xpAmount != 0)
     {
         Combatant toBexpedCombatant = getSelectedCombatant();
         if (toBexpedCombatant == null)
             return;
         float previousxp = toBexpedCombatant.XP;
         CommUpdateCombatant commUpdt = new CommUpdateCombatant(toBexpedCombatant, CombatantAttributes.xp, previousxp + xpAmount);
         commUpdt.Execute();
     }
 }
        private void rollNPCInit_Click(object sender, RoutedEventArgs e)
        {
            List<UndoableCommand> commList = new List<UndoableCommand>();
            Random random = new Random();
            for (int i = 0; i < listi.Count; i++)
            {
                Combatant rollInitCombatant = listi[i];
                if (rollInitCombatant.IsNPC)
                {
                    float initiative = rollInitCombatant.InitMod + random.Next(1, 21);
                    CommUpdateCombatant commUpdt = new CommUpdateCombatant(rollInitCombatant, CombatantAttributes.initiative, initiative);
                    commList.Add(commUpdt);
                }

            }
            if (commList.Count > 0)
            {
                CommCommandPackStarter commPack = new CommCommandPackStarter(commList);
                commPack.Execute();
            }
        }
 private void restoreSelectedHp_Click(object sender, RoutedEventArgs e)
 {
     Combatant toBeRestoredCombatant = getSelectedCombatant();
     if (toBeRestoredCombatant == null)
         return;
     float maxHP = toBeRestoredCombatant.MaxHP;
     CommUpdateCombatant commUpdt = new CommUpdateCombatant(toBeRestoredCombatant, CombatantAttributes.hp, maxHP);
     commUpdt.Execute();
 }
        private void restoreNPCHP_Click(object sender, RoutedEventArgs e)
        {
            List<UndoableCommand> commList = new List<UndoableCommand>();
            for (int i = 0; i < listi.Count; i++)
            {
                Combatant toBeRestoredCombatant = listi[i];

                if (toBeRestoredCombatant.IsNPC)
                {
                    float maxHP = toBeRestoredCombatant.MaxHP;
                    CommUpdateCombatant commUpdt = new CommUpdateCombatant(toBeRestoredCombatant, CombatantAttributes.hp, maxHP);
                    commList.Add(commUpdt);
                }

            }
            if (commList.Count > 0)
            {
                CommCommandPackStarter commPack = new CommCommandPackStarter(commList);
                commPack.Execute();
            }
        }
 private void restoreAllHP_Click(object sender, RoutedEventArgs e)
 {
     for (int i = 0; i < listi.Count; i++)
     {
         Combatant toBeRestoredCombatant = listi[i];
         float maxHP = toBeRestoredCombatant.MaxHP;
         CommUpdateCombatant commUpdt = new CommUpdateCombatant(toBeRestoredCombatant, CombatantAttributes.hp, maxHP);
         commUpdt.Execute();
     }
 }
 private void Gold_Click(object sender, RoutedEventArgs e)
 {
     float goldAmount = App.getFloatFromString(damageHealBox.Text);
     if (goldAmount != 0)
     {
         Combatant toBeGoldedCombatant = getSelectedCombatant();
         if (toBeGoldedCombatant == null)
             return;
         float previousGold = toBeGoldedCombatant.Gold;
         CommUpdateCombatant commUpdt = new CommUpdateCombatant(toBeGoldedCombatant, CombatantAttributes.gold, previousGold + goldAmount);
         commUpdt.Execute();
     }
 }
        private void GiveXP_Click(object sender, RoutedEventArgs e)
        {
            List<UndoableCommand> commList = new List<UndoableCommand>();
            int numPCs = 0;
            for (int i = 0; i < listi.Count; i++)
            {
                if (!listi[i].IsNPC)
                {
                    numPCs++;
                }
            }
            Window2 inputGetter = new Window2("How much xp will be Awarded?");
            inputGetter.ShowDialog();
            float xpShare = App.getFloatFromString(inputGetter.InputValue) / (float)numPCs;
            for (int i = 0; i < listi.Count; i++)
            {
                if (!listi[i].IsNPC)
                {
                    float xp = listi[i].XP + xpShare;
                    CommUpdateCombatant commUpdt = new CommUpdateCombatant(listi[i], CombatantAttributes.xp, xp);
                    commList.Add(commUpdt);
                }

            }
            if (commList.Count > 0)
            {
                CommCommandPackStarter commPack = new CommCommandPackStarter(commList);
                commPack.Execute();
            }
        }
 private void damageHeal_Click(object sender, RoutedEventArgs e)
 {
     float lifeAmount = App.getFloatFromString(damageHealBox.Text);
     if (lifeAmount != 0)
     {
         Combatant toBeDamagedCombatant = getSelectedCombatant();
         if (toBeDamagedCombatant == null)
             return;
         float previousHP = toBeDamagedCombatant.HP;
         CommUpdateCombatant commUpdt = new CommUpdateCombatant(toBeDamagedCombatant, CombatantAttributes.hp, previousHP - lifeAmount);
         commUpdt.Execute();
     }
 }