Exemplo n.º 1
0
        public void RefreshCombatList()
        {
            FileHandler.SaveCombatantListToFile(monsterCombatants);


            int listIndex = lstCombat.SelectedIndex;

            lstCombat.Items.Clear();
            Combatant highestInitCombatant = new Combatant();

            initiativeList.Clear();
            var compareList = new List <Combatant>();
            int highestInit = -1000;
            int index       = 0;



            foreach (var combatant in monsterCombatants)
            {
                compareList.Add(combatant);
            }


            while (compareList.Count > 0)
            {
                foreach (var combatant in compareList)
                {
                    if (int.Parse(combatant.initiative) > highestInit)
                    {
                        highestInitCombatant = combatant;
                        highestInit          = int.Parse(highestInitCombatant.initiative);
                    }
                }
                highestInit = -1000;
                initiativeList.Add(highestInitCombatant);
                compareList.Remove(highestInitCombatant);
                index++;
            }


            foreach (var combatant in initiativeList)
            {
                lstCombat.Items.Add("ID#" + combatant.ID + ": " + combatant.name + ", HP: " + combatant.HP + "  -  Init: " + combatant.initiative);



                Form form = Application.OpenForms[combatant.ID.ToString()];
                if (form != null)
                {
                    CombatStatUI statUI = (CombatStatUI)form;
                    statUI.Refresh(combatant);
                }
            }



            try
            {
                lstCombat.SelectedIndex = listIndex;
            }
            catch
            {
                try
                {
                    lstCombat.SelectedIndex = listIndex - 1;
                }
                catch
                {
                }
            }
        }
Exemplo n.º 2
0
        private void btnModifyCombatant_Click(object sender, EventArgs e)
        {
            if (lstCombat.SelectedIndex == -1)
            {
                MessageBox.Show("You need to select a monster from the combat list.");
            }
            else
            {
                try
                {
                    int HPChange = 0;
                    if (rbtnManual.Checked)
                    {
                        HPChange = int.Parse(txtModifyHP.Text);
                    }
                    if (rbtnN10.Checked)
                    {
                        HPChange = -10;
                    }
                    if (rbtnN5.Checked)
                    {
                        HPChange = -5;
                    }
                    if (rbtnN1.Checked)
                    {
                        HPChange = -1;
                    }
                    if (rbtnP10.Checked)
                    {
                        HPChange = 10;
                    }
                    if (rbtnP5.Checked)
                    {
                        HPChange = 5;
                    }
                    if (rbtnP1.Checked)
                    {
                        HPChange = 1;
                    }



                    int indexStart = lstCombat.SelectedItem.ToString().IndexOf("#");
                    int indexStop  = lstCombat.SelectedItem.ToString().IndexOf(":");


                    Combatant combatant = monsterCombatants.Single(x => x.ID.ToString() == lstCombat.SelectedItem.ToString().Substring((indexStart + 1), (indexStop - 3)));


                    combatant.HP = combatant.HP + HPChange;

                    Form form = Application.OpenForms[combatant.ID.ToString()];
                    if (form != null)
                    {
                        CombatStatUI statUI = (CombatStatUI)form;
                        if (HPChange < 0)
                        {
                            statUI.AnimateCombat();
                        }
                        else if (HPChange > 0)
                        {
                            statUI.AnimateHeal();
                        }

                        if (combatant.HP < 1)
                        {
                            statUI.Death();
                        }
                    }


                    RefreshCombatList();
                }
                catch
                {
                    MessageBox.Show("HP-value must be an integer.");
                }
            }
        }
Exemplo n.º 3
0
        private void btnModifyCombatant_Click(object sender, EventArgs e)
        {
            try
            {
                int HPChange = 0;

                if (rbtnN10.Checked)
                {
                    HPChange = -10;
                }
                if (rbtnN5.Checked)
                {
                    HPChange = -5;
                }
                if (rbtnN1.Checked)
                {
                    HPChange = -1;
                }
                if (rbtnP10.Checked)
                {
                    HPChange = 10;
                }
                if (rbtnP5.Checked)
                {
                    HPChange = 5;
                }
                if (rbtnP1.Checked)
                {
                    HPChange = 1;
                }



                string[] stringArray = lblNameID.Text.Split(':');



                Combatant combatant = MainWindow.monsterCombatants.Single(x => x.ID.ToString() == stringArray[1].Trim(' '));

                combatant.HP = combatant.HP + HPChange;



                if (HPChange < 0)
                {
                    AnimateCombat();
                }
                else if (HPChange > 0)
                {
                    AnimateHeal();
                }

                if (combatant.HP < 1)
                {
                    Death();
                }



                Program.mainForm.RefreshCombatList();
            }
            catch
            {
                MessageBox.Show("HP-value must be an integer.");
            }
        }