コード例 #1
0
        private static int GetAttackRoll()
        {
            var baseAttackRoll        = DiceManager.Roll(1, 21).Total;
            var bonusAttackAdjustment = CharacterCombatMaths.TotalHitAdjustments(_person);
            var attackRoll            = baseAttackRoll + bonusAttackAdjustment;

            return(attackRoll);
        }
コード例 #2
0
        private int GetAttackRoll()
        {
            var baseAttackRoll        = DiceManager.Roll(1, 21).Total;
            var bonusAttackAdjustment = CharacterCombatMaths.TotalHitAdjustments(CurrentPlayer());
            var attackRoll            = baseAttackRoll + bonusAttackAdjustment;

            return(attackRoll);
        }
コード例 #3
0
        private CombatResponse DoMeleeAttack()
        {
            var cResponse = new CombatResponse();

            try
            {
                var victim = SelectRandomPlayer();

                var attackRoll = GetAttackRoll();
                var Damage     = GetDamageRoll();

                int victimToHitValue = victim.Thaco.Value - CharacterCombatMaths.CalculateArmorClass(victim.EquippedGear);

                if (attackRoll < victimToHitValue)
                {
                    // Missses
                    cResponse.response     = string.Format($"{CurrentPlayer().Name}'s attack misses against {victim.Name}");
                    cResponse.ResponseType = CombatResponseTypes.MISSED;
                }
                else
                {
                    // Hits
                    cResponse.response = string.Format($"{CurrentPlayer().Name} deals {Damage} damage to {victim.Name}");

                    cResponse.ResponseType = CombatResponseTypes.DAMAGED;

                    if (victim.TmpHitPoints - Damage <= 0)
                    {
                        cResponse.response     = string.Format($"{CurrentPlayer().Name} kills {victim.Name}");
                        cResponse.ResponseType = CombatResponseTypes.KILLED;
                    }

                    members = DoDamage(victim, Damage);
                }
            }
            catch (InvalidCombatMechanicException ex)
            {
                cResponse.success  = false;
                cResponse.response = ex.Message;
            }

            /*
             * Console.WriteLine($"-- {CurrentPlayer().Name}'s Turn --");
             * Console.WriteLine($" (HP: {CurrentPlayer().TmpHitPoints}/{CurrentPlayer().HitPoints}   AC: {CurrentPlayer().ArmorClass})");
             * Console.WriteLine($" Attacking: {victim.Name}");
             * Console.WriteLine($" Weapon: {CurrentPlayer().PrimaryWeapon.Name} ({CurrentPlayer().PrimaryWeapon.Damage.Amount}d{CurrentPlayer().PrimaryWeapon.Damage.SidedDie})");
             * Console.WriteLine($" Roll: {attackRoll} (need to match or beat {victimToHitValue})");
             * Console.WriteLine($" Damage: {Damage}");
             */

            return(cResponse);
        }
コード例 #4
0
        public static CombatResponse MeleeAttack(ICharacter person, ICharacter target, IWeapon specificWeapon = null)
        {
            CombatResponse resp = new CombatResponse();

            try
            {
                _person = person;
                _target = target;
                if (specificWeapon != null)
                {
                    _specificWeapon = specificWeapon;
                }

                int attackRoll       = GetAttackRoll();
                int targetToHitValue = target.Thaco.Value - CharacterCombatMaths.CalculateArmorClass(target.EquippedGear);

                if (attackRoll < targetToHitValue)
                {
                    // Attack missed
                    resp.response     = string.Format($"{person.Name}'s attack misses against {target.Name}");
                    resp.ResponseType = CombatResponseTypes.MISSED;
                }
                else
                {
                    // Attack Hit
                    int Damage = GetMeleeDamageTotal();
                    resp.response     = string.Format($"{person.Name} deals {Damage} damage to {target.Name}");
                    resp.ResponseType = CombatResponseTypes.DAMAGED;
                    if (target.TmpHitPoints <= 0)
                    {
                        resp.response     = string.Format($"{person.Name} deals {Damage} and kills {target.Name}");
                        resp.ResponseType = CombatResponseTypes.KILLED;
                    }
                    target = DoDamageToTarget(Damage);
                }
                resp.success = true;
            }
            catch (InvalidCombatMechanicException ex)
            {
                resp.success  = false;
                resp.response = ex.Message;
            }
            return(resp);
        }
コード例 #5
0
 public static int SetupAC(List <IEquipment> equipment)
 {
     return(CharacterCombatMaths.CalculateArmorClass(equipment));
 }