Exemple #1
0
        private string CheckForCritical(int defense, int attackBonus, int modifier)
        {
            var diceRollForCritical = DiceRoller.RollDice();
            var criticalTestValue   = GetTotalAttackingPower(attackBonus, modifier, diceRollForCritical);

            if (criticalTestValue > defense)
            {
                return("Critical!");
            }
            return("Hit!");
        }
Exemple #2
0
        private int CalculateAttackDamage(string attackStatus)
        {
            switch (attackStatus)
            {
            case "Miss!":
                return(0);

            case "Hit!":
                return(DiceRoller.RollDice(4, 11));

            case "Critical!":
                return(15);

            default:
                return(0);
            }
        }
Exemple #3
0
        public string CheckIfAttackSuccessful(ICharacter attacker, ICharacter defender)
        {
            var attackSuccessfullness = "Miss!";
            var attackBonus           = (attacker.Strength - 10) / 2;
            var modifier            = attacker.Modifier;
            var diceRoll            = DiceRoller.RollDice();
            int totalAttackingPower = GetTotalAttackingPower(attackBonus, modifier, diceRoll);

            if (diceRoll == maxValue)
            {
                attackSuccessfullness = CheckForCritical(defender.Constitution, attackBonus, modifier);
            }
            else if (totalAttackingPower > defender.Constitution)
            {
                attackSuccessfullness = "Hit!";
            }
            return(attackSuccessfullness);
        }