Esempio n. 1
0
        public static int CalculateGainAttackerWouldGetIfPowerAndThoughnessWouldIncrease(Card attacker,
          IEnumerable<Card> blockers, int powerIncrease, int toughnessIncrease)
        {
            if ((blockers.None()) && powerIncrease > 0)
            {
                return CalculateDefendingPlayerLifeloss(attacker, blockers) > 0 ? 2 : 0;
            }

            if (toughnessIncrease < 1 && !attacker.Has().Charge)
                return 0;

            var p = new AttackerEvaluationParameters(attacker, blockers);

            var canBeDealtLeathalDamageWithoutBoost = CanAttackerBeDealtLeathalDamage(p);

            if (canBeDealtLeathalDamageWithoutBoost == false)
                return 0;

            p.AttackerPowerIncrease = powerIncrease;
            p.AttackerToughnessIncrease = toughnessIncrease;

            var canBeDealtLeathalDamageWithBoost = CanAttackerBeDealtLeathalDamage(p);

            return canBeDealtLeathalDamageWithBoost ? 0 : attacker.Score;
        }
Esempio n. 2
0
        //public static int CalculateTrampleDamage(Card attacker, IEnumerable<Card> blockers)
        //{
        //    var p = new AttackerEvaluationParameters(attacker, blockers);
        //    return CalculateTrampleDamage(p);
        //}
        //public static int CalculateTrampleDamage(AttackerEvaluationParameters p)
        //{
        //    if (p.Attacker.Has().Trample == false)
        //        return 0;
        //    var total = p.Attacker.CalculateCombatDamageAmount(singleDamageStep: false, powerIncrease: p.AttackerPowerIncrease);
        //    total = total - p.Blockers.Sum(x => x.Card.Life + x.ToughnessIncrease);
        //    return total > 0 ? total : 0;
        //}
        public static int CalculateDefendingPlayerLifeloss(AttackerEvaluationParameters p)
        {
            var total = 0;

            if (p.Blockers.None())
            {
                total = p.Attacker.CalculateCombatDamageAmount(singleDamageStep: false, powerIncrease: p.AttackerPowerIncrease);
            }
            //else if (p.Attacker.Has().Trample)
            //{
            //    total = CalculateTrampleDamage(p);
            //}

            if (total == 0)
                return 0;

            var prevented = p.Attacker.Controller.Opponent.CalculatePreventedReceivedDamageAmount(total, p.Attacker,
              isCombat: true);

            return total - prevented;
        }
Esempio n. 3
0
        public static Card GetBlockerThatDealsLeathalDamageToAttacker(Card attacker, IEnumerable<Card> blockers)
        {
            var p = new AttackerEvaluationParameters(attacker, blockers);

            var performance = new AttackerEvaluation(p);
            var results = performance.Evaluate();

            return results.LeathalBlocker;
        }
Esempio n. 4
0
 public static int GetAmountOfDamageThatWillBeDealtToAttacker(AttackerEvaluationParameters p)
 {
     var results = new AttackerEvaluation(p).Evaluate();
     return results.TotalDamage;
 }
Esempio n. 5
0
        public static int GetAmountOfDamageThatNeedsToBePreventedToSafeAttackerFromDying(Card attacker,
          IEnumerable<Card> blockers)
        {
            var p = new AttackerEvaluationParameters(attacker, blockers);
            var results = new AttackerEvaluation(p).Evaluate();

            if (!results.ReceivesLeathalDamage)
                return 0;

            if (results.DeathTouchDamage > 0)
                return results.DeathTouchDamage;

            var prevented = results.TotalDamage - attacker.Life + 1;
            return prevented;
        }
Esempio n. 6
0
 public static bool CanAttackerBeDealtLeathalDamage(AttackerEvaluationParameters p)
 {
     var attackerEvaluation = new AttackerEvaluation(p);
     var results = attackerEvaluation.Evaluate();
     return results.ReceivesLeathalDamage;
 }
 public AttackerEvaluation(AttackerEvaluationParameters p)
 {
     _p = p;
 }