Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }
 public static int SetupAC(List <IEquipment> equipment)
 {
     return(CharacterCombatMaths.CalculateArmorClass(equipment));
 }