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); }
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); }
/// <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(); }
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)); }
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); }
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()); }
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()); }
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()); }
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); }