Exemplo 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);
        }
Exemplo n.º 2
0
        private void d100_Click_1(object sender, EventArgs e)
        {
            //Clears Output window
            textBox_d100.Text = "";

            //Parses input box and coverts it to int
            int.TryParse(t4DiceCount.Text, out int intDiceCount);

            //Calls roll method (dice count, number of rolls)
            //Returns int array of roll values
            DiceTools rollDice = new DiceTools();

            int[] roll = rollDice.RollDice(100, intDiceCount);

            //outputs each roll to a new line in multiline text box
            foreach (int item in roll)
            {
                textBox_d100.Text += item.ToString() + Environment.NewLine;
            }

            textBox_d100Avg.Text = rollDice.RollAverage(roll).ToString();
        }
Exemplo n.º 3
0
        private void testCombat_Click(object sender, EventArgs e)
        {
            int.TryParse(TextBoxAttackerWSBS.Text, out int atkBSWS);
            int.TryParse(TextBoxAttackerStr.Text, out int atkStr);
            int.TryParse(TextBoxAttackerAPM.Text, out int atkAtks);
            int.TryParse(TextBoxAttackerAS.Text, out int atkAS);
            int.TryParse(TextBoxAttackerToughness.Text, out int atkToug);
            int.TryParse(TextBoxDefenderWSBS.Text, out int defBSWS);
            int.TryParse(TextBoxDefenderStr.Text, out int defStr);
            int.TryParse(TextBoxDefenderAPM.Text, out int defAtks);
            int.TryParse(TextBoxDefenderAS.Text, out int defAS);
            int.TryParse(TextBoxDefenderToughness.Text, out int defTough);
            int.TryParse(TextBoxAttackerCount.Text, out int atkCount);
            int.TryParse(TextBoxDefenderCount.Text, out int defCount);

            int hits = 0;

            int[] wounds = { 0, 0 };
            int   saves  = 0;
            int   kills  = 0;

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

            hits             = Combat.Attack(Dice.RollDice(6, atkCount * atkAtks), Combat.WSBSTable(atkBSWS));
            TextBoxHits.Text = hits.ToString();


            wounds             = Combat.Wound(Dice.RollDice(6, hits), Combat.WoundTable(atkStr, defTough));
            TextBoxWounds.Text = wounds[0].ToString();

            saves = Combat.Defend(Dice.RollDice(6, wounds[0] - wounds[1]), defAS, wounds[1]);
            TextBoxCritWound.Text = wounds[1].ToString();

            kills = defCount - saves;
            TextBoxDefLeft.Text = kills.ToString();
        }