예제 #1
0
        private void RunAttackCreatureTest(int sourceId, int targetId)
        {
            CombatCreature attackCreature = player1.Table[sourceId];

            attackCreature.ResetAttacks();

            CombatCreature defenseCreature = player2.Table[targetId];

            int expectedAttCreatureAttack = !defenseCreature.IsWard ? attackCreature.Attack : 0;
            int expectedDefCreatureAttack = !attackCreature.IsWard ? defenseCreature.Attack : 0;

            int expectedMyHealthChange  = attackCreature.IsDrain ? expectedAttCreatureAttack : 0;
            int expectedOppHealthChange = attackCreature.IsTrample ? Math.Max(expectedAttCreatureAttack - defenseCreature.Defense, 0) : 0;

            int expectedMyHealth  = player1.Data.Health + expectedMyHealthChange;
            int expectedOppHealth = player2.Data.Health - expectedOppHealthChange;

            int expectedMyCardDefense  = attackCreature.Defense - expectedDefCreatureAttack;
            int expectedOppCardDefense = defenseCreature.Defense - expectedAttCreatureAttack;

            bool expectedMyShouldDie  = defenseCreature.IsLethal && expectedDefCreatureAttack > 0;
            bool expectedOppShouldDie = attackCreature.IsLethal && expectedAttCreatureAttack > 0;

            bool expectedMyIsDead  = expectedMyShouldDie || expectedMyCardDefense <= 0;
            bool expectedOppIsDead = expectedOppShouldDie || expectedOppCardDefense <= 0;

            int expectedMyTableCount  = expectedMyIsDead ? player1.Table.Count - 1 : player1.Table.Count;
            int expectedOppTableCount = expectedOppIsDead ? player2.Table.Count - 1 : player2.Table.Count;

            AttackAction action = new AttackAction(sourceId, targetId);
            bool         result = action.Execute(player1, player2);

            Assert.IsTrue(result);
            Assert.AreEqual(expectedMyHealth, player1.Data.Health);
            Assert.AreEqual(expectedOppHealth, player2.Data.Health);
            Assert.AreEqual(expectedMyCardDefense, attackCreature.Defense);
            Assert.AreEqual(expectedOppCardDefense, defenseCreature.Defense);
            Assert.AreEqual(expectedMyShouldDie, attackCreature.ShouldDie);
            Assert.AreEqual(expectedOppShouldDie, defenseCreature.ShouldDie);
            Assert.AreEqual(expectedMyIsDead, attackCreature.IsDead);
            Assert.AreEqual(expectedOppIsDead, defenseCreature.IsDead);
            Assert.IsFalse(attackCreature.IsWard);
            Assert.IsFalse(defenseCreature.IsWard);
            Assert.IsFalse(attackCreature.CanAttack);
            Assert.AreEqual(expectedMyTableCount, player1.Table.Count);
            Assert.AreEqual(expectedOppTableCount, player2.Table.Count);
        }
예제 #2
0
        private void RunAttackPlayerTest(int sourceId)
        {
            int target = -1;

            CombatCreature attackCreature = player1.Table[sourceId];

            attackCreature.ResetAttacks();

            int expectedMyHealth  = player1.Data.Health + (attackCreature.IsDrain ? attackCreature.Attack : 0);
            int expectedOppHealth = player2.Data.Health - attackCreature.Attack;

            AttackAction action = new AttackAction(sourceId, target);
            bool         result = action.Execute(player1, player2);

            Assert.IsTrue(result);
            Assert.AreEqual(expectedMyHealth, player1.Data.Health);
            Assert.AreEqual(expectedOppHealth, player2.Data.Health);
            Assert.IsFalse(attackCreature.CanAttack);
        }