Ejemplo n.º 1
0
        public void WeaponlessActorDoesNoDamage()
        {
            var a = new GameActor();
            var b = new GameActor();

            a.Attack(b);

            Assert.AreEqual(b.baseHealth, b.Health);
            Assert.IsTrue(b.Alive);
        }
Ejemplo n.º 2
0
        public void WeaponfulActorCanKill()
        {
            var a = new GameActor();
            var b = new GameActor();

            a.Weapon = new GameWeapon("deadly apple", b.baseHealth);

            a.Attack(b);
            Assert.AreEqual(b.Health, 0);
            Assert.IsFalse(b.Alive);
        }
Ejemplo n.º 3
0
        public void DamageFromBehindShouldCrit()
        {
            var a = new GameActor();
            var b = new GameActor();

            a.Weapon = new GameWeapon("sneaky shiv", a.baseHealth / 10);
            a.dir    = PointUtil.right;
            b.dir    = PointUtil.right;

            a.Attack(b);
            Assert.AreEqual(a.Weapon.damage * 2, b.baseHealth - b.Health);
        }
Ejemplo n.º 4
0
        public void WeaponfulActorDoesDamage()
        {
            var a = new GameActor();
            var b = new GameActor();

            a.Weapon = new GameWeapon("lunchbox to the head", b.baseHealth - 1);

            a.Attack(b);
            Assert.AreEqual(b.Health, b.baseHealth - a.Weapon.damage);
            Assert.IsTrue(a.Alive);
            Assert.IsTrue(b.Alive);
        }
Ejemplo n.º 5
0
        public void DamageNotFromBehindShouldBeNormal()
        {
            var a = new GameActor();
            var b = new GameActor();

            a.Weapon = new GameWeapon("test weapon", 10);

            a.Attack(b);
            Assert.AreEqual(b.Health, b.baseHealth - a.Weapon.damage);

            a.dir = PointUtil.right;
            b.dir = PointUtil.left;
        }
Ejemplo n.º 6
0
 public void act(Game g, GameActor actor)
 {
     if (g == null)
     {
         throw new ArgumentNullException(nameof(g));
     }
     if (actor == null)
     {
         throw new ArgumentNullException(nameof(actor));
     }
     //KAI: will currently flunk test - call g.GetTargets, iterate them, attack for each one
     foreach (var target in g.GetTargets())
     {
         actor.Attack(target);
     }
 }
Ejemplo n.º 7
0
        public void CritDamageShouldFireEvent()
        {
            var a = new GameActor();
            var b = new GameActor();

            a.Weapon = new GameWeapon("sneaky shiv", a.baseHealth / 10);
            a.dir    = PointUtil.right;
            b.dir    = PointUtil.right;

            bool fired = false;

            GameEvents.Instance.AttackWillCrit += (one, two) =>
            {
                fired = true;
            };
            a.Attack(b);

            Assert.IsTrue(fired);
        }
Ejemplo n.º 8
0
        public void AttackShouldFireEvents()
        {
            var a        = new GameActor();
            var b        = new GameActor();
            int progress = 0;

            GameEvents.Instance.AttackStart += (actorA, actorB) =>
            {
                Assert.AreEqual(0, progress++);
                Assert.AreEqual(a, actorA);
                Assert.AreEqual(b, actorB);
            };
            GameEvents.Instance.AttackEnd += (actorA, actorB) =>
            {
                Assert.AreEqual(1, progress++);
                Assert.AreEqual(a, actorA);
                Assert.AreEqual(b, actorB);
            };

            a.Weapon = new GameWeapon("deadly apple", b.baseHealth / 2);
            a.Attack(b);

            Assert.AreEqual(2, progress);
        }
Ejemplo n.º 9
0
        public void AttackShouldChangeCharacterDirection()
        {
            var a = new GameActor();
            var b = new GameActor();

            a.Weapon = new GameWeapon("wet noodle", b.baseHealth / 100);

            bool AttackChangesDir(Point <int> aDir)
            {
                a.dir = aDir;
                a.Attack(b);
                return(a.dir != aDir);
            }

            a.pos = new Point <int>(-2, 0);
            b.pos = new Point <int>(2, 0);

            Assert.IsFalse(AttackChangesDir(PointUtil.right));
            Assert.IsTrue(AttackChangesDir(PointUtil.left));

            a.pos = new Point <int>(4, 0);
            Assert.IsTrue(AttackChangesDir(PointUtil.right));
            Assert.IsFalse(AttackChangesDir(PointUtil.left));
        }
 public void Execute(GameActor actor)
 {
     actor.Attack();
 }
Ejemplo n.º 11
0
 public override void Execute()
 {
     actor.Attack();
 }