Ejemplo n.º 1
0
        public int[] Fight(string AtkName, string DefName, string UnitCount)
        {
            //name strength toughness wsbs armor attack
            //handles display of stats
            XMLTools toolA = new XMLTools();
            XMLTools toolD = new XMLTools();
            ArmyList ListA = new ArmyList();

            string[] armyA = toolA.readXML(AtkName);
            string[] armyD = toolD.readXML(DefName);

            int.TryParse(armyA[1], out int atkStr);
            int.TryParse(armyD[1], out int defStr);

            int.TryParse(armyA[2], out int atkTough);
            int.TryParse(armyD[2], out int defTough);

            int.TryParse(armyA[3], out int atkBSWS);
            int.TryParse(armyD[3], out int defBSWS);

            int.TryParse(armyD[4], out int atkAS);
            int.TryParse(armyD[4], out int defAS);

            int.TryParse(armyD[5], out int atkAtks);
            int.TryParse(armyD[5], out int defAtks);

            int.TryParse(UnitCount, out int UnitCT);

            int[] results = new int [7];

            Combat    Combat = new Combat();
            DiceTools Dice   = new DiceTools();

            for (int i = -3; i <= 3; i++)
            {
                int   hits       = 0;
                int[] wounds     = { 0, 0 };
                int   saves      = 0;
                int   remainingD = 0;
                int   remainingA = 0;

                hits       = Combat.Attack(Dice.RollDice(6, (UnitCT + i) * atkAtks), Combat.WSBSTable(atkBSWS));
                wounds     = Combat.Wound(Dice.RollDice(6, hits), Combat.WoundTable(atkStr, defTough));
                saves      = Combat.Defend(Dice.RollDice(6, wounds[0] - wounds[1]), defAS, wounds[1]);
                remainingD = UnitCT - wounds[1] - wounds[0] + saves;

                hits       = Combat.Attack(Dice.RollDice(6, (remainingD) * defAtks), Combat.WSBSTable(defBSWS));
                wounds     = Combat.Wound(Dice.RollDice(6, hits), Combat.WoundTable(defStr, atkTough));
                saves      = Combat.Defend(Dice.RollDice(6, wounds[0] - wounds[1]), atkAS, wounds[1]);
                remainingA = UnitCT - wounds[1] - wounds[0] + saves;

                results[i + 3] = remainingA - remainingD;
            }
            ;

            return(results);
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //handles display of stats
            XMLTools toolA = new XMLTools();
            ArmyList ListA = new ArmyList();

            string[] armyA = toolA.readXML((string)t1AtkCombo.SelectedItem);

            //Outputs army stats & name from method
            t1aName.Text  = armyA[0];
            t1aStr.Text   = armyA[1];
            t1aTough.Text = armyA[2];
            t1aWSBS.Text  = armyA[3];
            t1aArmor.Text = armyA[4];
            t1aAtk.Text   = armyA[5];

            //handles display of stats
            XMLTools toolD = new XMLTools();
            ArmyList ListD = new ArmyList();

            string[] armyD = toolD.readXML((string)t1DCombo.SelectedItem);

            //Outputs army stats & name from method
            t1bName.Text  = armyD[0];
            t1bStr.Text   = armyD[1];
            t1bTough.Text = armyD[2];
            t1bWSBS.Text  = armyD[3];
            t1bArmor.Text = armyD[4];
            t1bAtk.Text   = armyD[5];

            //ensures attacker and defender and unit count are chosen
            if (t1AtkCombo.SelectedItem == null)
            {
            }
            else if (t1DCombo.SelectedItem == null)
            {
            }
            else if (t1UnitCombo.SelectedItem == null)
            {
            }
            else
            {
                t1Fight.Enabled = true;
            };
        }
Ejemplo n.º 3
0
        //Loads currently selected army into view
        private void t2Load_Click(object sender, EventArgs e)
        {
            XMLTools tool = new XMLTools();
            ArmyList List = new ArmyList();

            string[] army = tool.readXML((string)t2Army.SelectedItem);

            //Outputs army stats & name from method
            t2ArmyName.Text = army[0];
            t2Str.Text      = army[1];
            t2Tough.Text    = army[2];
            t2WSBS.Text     = army[3];
            t2AS.Text       = army[4];
            t2Atk.Text      = army[5];

            //Convert strings to ints for calculations.
            List.Name = army[0];
            int n;

            if (int.TryParse(army[1], out n))
            {
                List.Strength = n;
            }
            if (int.TryParse(army[2], out n))
            {
                List.Toughness = n;
            }
            if (int.TryParse(army[3], out n))
            {
                List.WSBS = n;
            }
            if (int.TryParse(army[4], out n))
            {
                List.Armor = n;
            }
            if (int.TryParse(army[5], out n))
            {
                List.Attacks = n;
            }
        }