Exemplo n.º 1
0
 public int ToAverageDamage()
 {
     return((int)(DamageDieCount * DamageDie.ToAverageValue()));
 }
Exemplo n.º 2
0
        static void Attack(int AC)
        {
            int    hits = 0, totaldamage = 0, crits = 0;
            int    roll;
            string tohitrolls       = "To Hit Rolls:";
            string tohitrollsbonus  = "To Hit Rolls Plus Bonus:";
            string damagerolls      = "Damage Rolls:";
            string damagerollsbonus = "Damage Rolls Plus Bonus:";
            Random r = new Random();

            for (int i = 0; i < Attacks; i++)
            {
                //Roll d20
                roll             = r.Next(1, 21);
                tohitrolls      += " " + roll.ToString();
                tohitrollsbonus += " " + (roll + ToHit).ToString();
                if (roll == 20 && CritHouseRule)
                {
                    totaldamage      += DamageDie + DamageBonus;
                    damagerolls      += " " + DamageDie.ToString();
                    damagerollsbonus += " " + (DamageDie + DamageBonus).ToString();
                    hits++;
                    crits++;
                }
                else if (roll == 20 && !CritHouseRule)
                {
                    hits += 2;
                    crits++;
                }
                else if ((roll + ToHit) > AC)
                {
                    hits++;
                }
            }
            for (int i = 0; i < hits; i++)
            {
                //Roll damage die
                roll              = r.Next(1, DamageDie + 1);
                damagerolls      += " " + roll.ToString();
                damagerollsbonus += " " + (roll + DamageBonus).ToString();
                totaldamage      += roll + DamageBonus;
            }
            int hitdisplaysubtract = 0;

            //If the crit house rule is not being used, scoring a crit acts as if getting an extra hit, so I increment hits twice.
            //However, there is still technically only one hit. So I use this so the proper amount of hits is displayed.
            if (!CritHouseRule)
            {
                hitdisplaysubtract = crits;
            }
            if (DetailsLevel == 2)
            {
                Console.WriteLine(tohitrolls);
                Console.WriteLine((hits - hitdisplaysubtract).ToString() + " hits, " + crits.ToString() + " crits.");
                Console.WriteLine(damagerolls);
            }
            else if (DetailsLevel == 3)
            {
                Console.WriteLine(tohitrolls);
                Console.WriteLine(tohitrollsbonus);
                Console.WriteLine((hits - hitdisplaysubtract).ToString() + " hits, " + crits.ToString() + " crits.");
                Console.WriteLine(damagerolls);
                Console.WriteLine(damagerollsbonus);
            }
            Console.WriteLine("Total Damage is: " + totaldamage);
        }