示例#1
0
        public void Attacking_A_Target_Yields_A_Result()
        {
            // Arrange
            ICombatEntity target = new TargetDummy();
            ICombatEntity attacker = new TargetDummy();

            // Act
            ICombatResult result = attacker.PerformAttack(attacker.BasicAttack(target));

            // Assert
            Assert.IsNotNull(result);
        }
示例#2
0
        public void An_Attack_Is_Logged_In_Global_Combat_Log()
        {
            // Arrange
            ICombatEntity target = new TargetDummy();
            ICombatEntity attacker = new TargetDummy();
            double logCount = GlobalLog.GetInstance().GetLogCount();

            // Act
            attacker.PerformAttack(attacker.BasicAttack(target));

            // Assert
            Assert.AreNotEqual(GlobalLog.GetInstance().GetLogCount(), logCount);
        }
示例#3
0
        /// <summary>
        /// This is the "main"
        /// </summary>
        /// <param name="args">
        /// The args. ??
        /// </param>
        public static void Main(string[] args)
        {
            logger.LogMessage += LogMessageHandler;

            var dummy1 = new TargetDummy("Kalle");
            var dummy2 = new TargetDummy("Urban");
            var drunkenness = new HitModifier() { Description = "Drunk", Value = -10 };
            for (int i = 0; i < 10; i++)
            {
                dummy1.PerformAttack(dummy1.BasicAttack(dummy2).ModifyHit(drunkenness));
                drunkenness.Value -= 10;
            }

            Console.ReadLine();
        }
示例#4
0
        public void Hitting_A_Target_Yields_A_Hit_Result()
        {
            // Arrange
            ICombatEntity target = new TargetDummy();
            ICombatEntity attacker = new TargetDummy();
            HitModifier guaranteedHit = new HitModifier() { Description = "GuaranteeHit", Value = 100 };

            // Act
            ICombatResult result = attacker.PerformAttack(attacker.BasicAttack(target).ModifyHit(guaranteedHit));

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(HitResult));
        }
示例#5
0
        public void Performing_An_Attack_Created_By_Another_Entity_Yields_An_Exception()
        {
            // Arrange
            ICombatEntity target = new TargetDummy();
            ICombatEntity attacker = new TargetDummy();

            // Act
            // The Attacker performs an attack that is created by the target.
            // In other words the attacker commands another entity to perform an attack
            ICombatResult result = attacker.PerformAttack(target.BasicAttack(target));

            // Assert
            // Assert is made by expecting exception
            Assert.IsNull(result);
        }
示例#6
0
        public void Hit_Chance_Can_Be_Multiplied()
        {
            // Arrange
            ICombatEntity target = new TargetDummy();
            ICombatEntity attacker = new TargetDummy();

            // Act
            IAttackCommand attackCommand = attacker.BasicAttack(target);
            attackCommand.MultiplyHit(new HitMultiplier() { Description = "testMultiplier", Value = 2 });

            // Assert
            Assert.AreEqual(attackCommand.BaseHitChance * 2, attackCommand.GetFinalHitChance());
        }
示例#7
0
        public void Hit_Chance_Can_Be_Modified()
        {
            // Arrange
            ICombatEntity target = new TargetDummy();
            ICombatEntity attacker = new TargetDummy();

            // Act
            IAttackCommand attackCommand = attacker.BasicAttack(target);
            attackCommand.ModifyHit(new HitModifier() { Description = string.Empty, Value = -10 });
            attackCommand.ModifyHit(new HitModifier() { Description = string.Empty, Value = 20 });
            attackCommand.MultiplyHit(new HitMultiplier() { Description = "testDivider", Value = .5 });
            attackCommand.MultiplyHit(new HitMultiplier() { Description = "testDivider", Value = .5 });

            // Assert
            Assert.AreEqual(Convert.ToInt32(((double)attackCommand.BaseHitChance + 10) / 4), attackCommand.GetFinalHitChance());
        }
示例#8
0
        public void Hit_Chance_Can_Be_Decreased()
        {
            // Arrange
            ICombatEntity target = new TargetDummy();
            ICombatEntity attacker = new TargetDummy();

            // Act
            IAttackCommand attackCommand = attacker.BasicAttack(target);
            attackCommand.ModifyHit(new HitModifier() { Description = string.Empty, Value = -10 });

            // Assert
            Assert.AreEqual(attackCommand.BaseHitChance - 10, attackCommand.GetFinalHitChance());
        }
示例#9
0
        public void Hitting_A_Target_Yields_A_Result_With_Damage()
        {
            // Arrange, make target defenceless to guarantee a hit
            ICombatEntity target = new TargetDummy();
            ICombatEntity attacker = new TargetDummy();
            HitModifier guaranteedHit = new HitModifier() { Description = "GuaranteeHit", Value = 100 };

            // Act
            HitResult result = attacker.PerformAttack(attacker.BasicAttack(target).ModifyHit(guaranteedHit)) as HitResult;

            // Assert
            Assert.IsTrue(result.InflictedDamage > 0);
        }