public override void ApplyWhenAttacking(
            ICreaturesInBattle attackerWithSpecialty,
            ICreaturesInBattle defender)
        {
            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }

            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }

            if (this.rounds <= 0)
            {
                // Effect expires after fixed number of rounds
                return;
            }

            attackerWithSpecialty.CurrentAttack *= 2;
            this.rounds--;

            // I don't remove invoking base method, because in future could be added some different logic.
            base.ApplyWhenAttacking(attackerWithSpecialty, defender);
        }
 public override void ApplyOnSkip(ICreaturesInBattle skipCreature)
 {
     if (skipCreature == null)
     {
         throw new NullReferenceException("skipCreature");
     }
 }
 public virtual decimal ChangeDamageWhenAttacking(
     ICreaturesInBattle attackerWithSpecialty, 
     ICreaturesInBattle defender, 
     decimal currentDamage)
 {
     return currentDamage;
 }
Example #4
0
        public override decimal ChangeDamageWhenAttacking(
            ICreaturesInBattle attackerWithSpecialty,
            ICreaturesInBattle defender,
            decimal currentDamage)
        {
            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }

            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }

            if (this.rounds > 0)
            {
                this.rounds--;
                return(currentDamage * 2);
            }
            else
            {
                return(currentDamage);
            }
        }
Example #5
0
        public override decimal ChangeDamageWhenAttacking(
            ICreaturesInBattle attackerWithSpecialty,
            ICreaturesInBattle defender,
            decimal currentDamage)
        {
            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }

            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }

            if (this.rounds <= 0)
            {
                // Effect expires after fixed number of rounds

                // Perhaps in this case the most correct way is to invoke base method
                // return base.ChangeDamageWhenAttacking(attackerWithSpecialty, defender, currentDamage);
                return(currentDamage);
            }
            else
            {
                this.rounds--;

                return(currentDamage * 2);
            }
        }
Example #6
0
 protected void CheckInputCreatures(ICreaturesInBattle creature, string name)
 {
     if (creature == null)
     {
         throw new ArgumentNullException(name);
     }
 }
        protected override void AddCreaturesByIdentifier(CreatureIdentifier creatureIdentifier, ICreaturesInBattle creaturesInBattle)
        {
            if (creatureIdentifier == null)
            {
                throw new ArgumentNullException("creatureIdentifier");
            }

            if (creaturesInBattle == null)
            {
                throw new ArgumentNullException("creaturesInBattle");
            }

            if (creatureIdentifier.ArmyNumber >= 3)
            {
                int armyNumber = creatureIdentifier.ArmyNumber;
                if (armies.Capacity < armyNumber)
                {
                    armies.AddRange(new ICollection<ICreaturesInBattle>[armyNumber - armies.Capacity + 1]);
                }

                if (armies[armyNumber] == null)
                {
                    armies[armyNumber] = new List<ICreaturesInBattle>();
                }

                this.armies[armyNumber].Add(creaturesInBattle);
                //this.thirthArmyCreatures.Add(creaturesInBattle);
            }
            else
            {
                base.AddCreaturesByIdentifier(creatureIdentifier, creaturesInBattle);
            }
        }
Example #8
0
 public virtual decimal ChangeDamageWhenAttacking(
     ICreaturesInBattle attackerWithSpecialty,
     ICreaturesInBattle defender,
     decimal currentDamage)
 {
     return(currentDamage);
 }
Example #9
0
        protected virtual void AddCreaturesByIdentifier(
            CreatureIdentifier creatureIdentifier,
            ICreaturesInBattle creaturesInBattle)
        {
            if (creatureIdentifier == null)
            {
                throw new ArgumentNullException("creatureIdentifier");
            }

            if (creaturesInBattle == null)
            {
                throw new ArgumentNullException("creaturesInBattle");
            }

            if (creatureIdentifier.ArmyNumber == 1)
            {
                this.firstArmyCreatures.Add(creaturesInBattle);
            }
            else if (creatureIdentifier.ArmyNumber == 2)
            {
                this.secondArmyCreatures.Add(creaturesInBattle);
            }
            else
            {
                throw new ArgumentException(
                          string.Format(
                              CultureInfo.InvariantCulture,
                              "Invalid ArmyNumber: {0}",
                              creatureIdentifier.ArmyNumber));
            }
        }
        public void DealDamage_WhenDefenderIsNull_ShouldThrowArgumentNullException()
        {
            ICreaturesInBattle defender = null;
            var tested = new CreaturesInBattle(new AncientBehemoth(), 1);

            Assert.Throws <ArgumentNullException>(() => tested.DealDamage(defender));
        }
Example #11
0
        public override decimal ChangeDamageWhenAttacking(
            ICreaturesInBattle attackerWithSpecialty,
            ICreaturesInBattle defender,
            decimal currentDamage)
        {
            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }

            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }

            if (this.rounds <= 0)
            {
                // Effect expires after fixed number of rounds
                return(currentDamage);
            }

            this.rounds--;

            return(currentDamage * 2);
        }
        public override decimal ChangeDamageWhenAttacking(
            ICreaturesInBattle attackerWithSpecialty,
            ICreaturesInBattle defender,
            decimal currentDamage)
        {
            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }

            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }

            if (this.Rounds <= 0)
            {
                // Effect expires after fixed number of rounds
                return currentDamage;
            }

            //attackerWithSpecialty.CurrentDefense *= 2;

            this.rounds--;
            return currentDamage * 2;
        }
Example #13
0
        protected override void AddCreaturesByIdentifier(CreatureIdentifier creatureIdentifier, ICreaturesInBattle creaturesInBattle)
        {
            if (creatureIdentifier == null)
            {
                throw new ArgumentNullException("creatureIdentifier");
            }

            if (creaturesInBattle == null)
            {
                throw new ArgumentNullException("creaturesInBattle");
            }

            if (creatureIdentifier.ArmyNumber == 1)
            {
                this.firstArmyCreatures.Add(creaturesInBattle);
            }
            else if (creatureIdentifier.ArmyNumber == 2)
            {
                this.secondArmyCreatures.Add(creaturesInBattle);
            }
            else if (creatureIdentifier.ArmyNumber == 3)
            {
                this.thirdArmyCreatures.Add(creaturesInBattle);
            }
            else
            {
                throw new ArgumentException(
                    string.Format(CultureInfo.InvariantCulture, "Invalid ArmyNumber: {0}", creatureIdentifier.ArmyNumber));
            }
        }
Example #14
0
        public override void ApplyWhenAttacking(
            ICreaturesInBattle attackerWithSpecialty,
            ICreaturesInBattle defender)
        {
            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }

            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }

            if (this.rounds <= 0)
            {
                // Effect expires after fixed number of rounds
                return;
            }

            attackerWithSpecialty.CurrentAttack *= 2;
            this.rounds--;

            // I don't remove invoking base method, because in future could be added some different logic.
            base.ApplyWhenAttacking(attackerWithSpecialty, defender);
        }
Example #15
0
        public override decimal ChangeDamageWhenAttacking(
            ICreaturesInBattle attackerWithSpecialty,
            ICreaturesInBattle defender,
            decimal currentDamage)
        {
            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }

            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }

            if (this.rounds <= 0)
            {
                // Effect expires after fixed number of rounds

                // Perhaps in this case the most correct way is to invoke base method
                // return base.ChangeDamageWhenAttacking(attackerWithSpecialty, defender, currentDamage);
                return currentDamage;
            }
            else
            {
                this.rounds--;

                return currentDamage * 2;
            }
        }
Example #16
0
 public void ApplyWhenSkip(ICreaturesInBattle skipCreature)
 {
     if (skipCreature == null)
     {
         throw new ArgumentNullException("skipCreature");
     }
     skipCreature.PermanentAttack += this.points;
 }
        public override void ApplyWhenAttacking(ICreaturesInBattle attackerWithSpecialty, ICreaturesInBattle defender)
        {
            if (roundsRemaining <= 0)
                return;

            attackerWithSpecialty.CurrentAttack *= 2;
            roundsRemaining--;
        }
Example #18
0
 public override void ApplyOnSkip(ICreaturesInBattle skipCreature)
 {
     if (skipCreature == null)
     {
         throw new ArgumentNullException("skipCreature");
     }
     skipCreature.PermanentAttack += this.attackToAdd;
 }
        protected override void AddCreaturesByIdentifier(CreatureIdentifier creatureIdentifier, ICreaturesInBattle creaturesInBattle)
        {
            if (creatureIdentifier.ArmyNumber == 3)
            {
                this.thirdArmyCreatues.Add(creaturesInBattle);
            }

            base.AddCreaturesByIdentifier(creatureIdentifier, creaturesInBattle);
        }
Example #20
0
        public override void ApplyOnSkip(ICreaturesInBattle skipCreature)
        {
            if (skipCreature == null)
            {
                throw new ArgumentNullException("skipCreature");
            }

            skipCreature.PermanentAttack += this.attackToAdd;
        }
Example #21
0
        public override void ApplyOnSkip(ICreaturesInBattle skipCreature)
        {
            if (skipCreature == null)
            {
                throw new ArgumentNullException("skipCreature cannot be null");
            }

            skipCreature.PermanentAttack += this.AttackPoints;
        }
Example #22
0
        public void ApplyOnSkip_ShouldThrow_IfPassedICreaturesInBattleParameterIsNull()
        {
            ICreaturesInBattle creaturesInBattle = null;
            var addDefenseWhenSkip = new AddDefenseWhenSkip(5);

            var resultingException = Assert.Throws <ArgumentNullException>(() => addDefenseWhenSkip.ApplyOnSkip(creaturesInBattle));

            Assert.IsTrue(resultingException.Message.Contains("skipCreature"));
        }
Example #23
0
        public void ApplyAfterDefending_ShouldThrowWithCorrectMessage_IfDefenderWithSpecialtyParamenterIsNull()
        {
            ICreaturesInBattle defenderWithSpecialty = null;
            var specialty = new Resurrection();

            var exception = Assert.Throws <ArgumentNullException>(() => specialty.ApplyAfterDefending(defenderWithSpecialty));

            StringAssert.Contains("defenderWithSpecialty", exception.Message);
        }
Example #24
0
 public MockedBattleManager(
     ICreaturesInBattle attacker,
     ICreaturesInBattle defender,
     ICreaturesFactory creaturesFactory,
     ILogger logger)
     : base(creaturesFactory, logger)
 {
     this.attacker = attacker;
     this.defender = defender;
 }
 protected override void AddCreaturesByIdentifier(CreatureIdentifier creatureIdentifier, ICreaturesInBattle creaturesInBattle)
 {
     if (creatureIdentifier.ArmyNumber == 1)
     {
         this.FirstArmyCreatures.Add(creaturesInBattle);
     }
     else if (creatureIdentifier.ArmyNumber == 2)
     {
         this.SecondArmyCreatures.Add(creaturesInBattle);
     }
 }
        public void ApplyWhenAttacking_ShouldThrowWithCorrectMessage_IfDefenderParameterIsNull()
        {
            var attackerWithSpecialty   = new Mock <ICreaturesInBattle>();
            ICreaturesInBattle defender = null;
            var percentage = 50m;
            var specialty  = new ReduceEnemyDefenseByPercentage(percentage);

            var exception = Assert.Throws <ArgumentNullException>(() => specialty.ApplyWhenAttacking(attackerWithSpecialty.Object, defender));

            StringAssert.Contains("defender", exception.Message);
        }
        public void ApplyWhenDefending_ShouldThrowTheCorrectErrorMessage_IfAttackerParameterIsNull()
        {
            var defenderWithSpecialty   = new Mock <ICreaturesInBattle>();
            ICreaturesInBattle attacker = null;
            var rounds = 5;

            var doubleDefenseWhenDefending = new DoubleDefenseWhenDefending(rounds);

            var resultingException = Assert.Throws <ArgumentNullException>(() => doubleDefenseWhenDefending.ApplyWhenDefending(defenderWithSpecialty.Object, attacker));

            Assert.IsTrue(resultingException.Message.Contains("attacker"));
        }
        public override void ApplyOnSkip(ICreaturesInBattle skipCreature)
        {
            if (skipCreature == null)
            {
                throw new ArgumentNullException("skipCreature");
            }

            skipCreature.PermanentAttack += this.attackToAdd;

            // I don't remove invoking base method, because in future could be added some different logic.
            base.ApplyOnSkip(skipCreature);
        }
Example #29
0
        public override void ApplyOnSkip(ICreaturesInBattle skipCreature)
        {
            if (skipCreature == null)
            {
                throw new ArgumentNullException("skipCreature");
            }

            skipCreature.PermanentAttack += this.attackToAdd;

            // I don't remove invoking base method, because in future could be added some different logic.
            base.ApplyOnSkip(skipCreature);
        }
Example #30
0
        public void ChangeDamageWhenAttacking_ShouldThrowWithCorrectMessage_WhenDefenderParameterIsNull()
        {
            var attackerWithSpecialty   = new Mock <ICreaturesInBattle>();
            ICreaturesInBattle defender = null;
            var typeToHate = typeof(FakeCreature);
            var damage     = 10m;

            var hate = new Hate(typeToHate);

            var exception = Assert.Throws <ArgumentNullException>(() => hate.ChangeDamageWhenAttacking(attackerWithSpecialty.Object, defender, damage));

            StringAssert.Contains("defender", exception.Message);
        }
        public override void ApplyAfterDefending(ICreaturesInBattle defenderWithSpecialty)
        {
            if (defenderWithSpecialty == null)
            {
                throw new ArgumentNullException("defenderWithSpecialty");
            }

            if (defenderWithSpecialty.TotalHitPoints > 0)
            {
                defenderWithSpecialty.TotalHitPoints = defenderWithSpecialty.Count
                                                       * defenderWithSpecialty.Creature.HealthPoints;
            }
        }
Example #32
0
        public override void ApplyWhenAttacking(ICreaturesInBattle attackerWithSpecialty, ICreaturesInBattle defender)
        {
            base.CheckInputCreatures(attackerWithSpecialty, "attackerWithSpecialty");
            base.CheckInputCreatures(defender, "defender");

            var hasAvailableRounds = base.DecrementRoundsCounter();

            if (hasAvailableRounds)
            {
                attackerWithSpecialty.CurrentAttack *=
                    DoubleAttackWhenAttacking.CurrentAttackBonusModifier;
            }
        }
        public override void ApplyAfterDefending(ICreaturesInBattle defenderWithSpecialty)
        {
            if (defenderWithSpecialty == null)
            {
                throw new ArgumentNullException("defenderWithSpecialty");
            }

            if (defenderWithSpecialty.TotalHitPoints > 0)
            {
                defenderWithSpecialty.TotalHitPoints = defenderWithSpecialty.Count
                                                       * defenderWithSpecialty.Creature.HealthPoints;
            }
        }
Example #34
0
        public void ApplyWhenAttacking(ICreaturesInBattle attacker)
        {
            if (attacker==null)
            {
                throw new ArgumentNullException("attacker");
            }
            if (rounds <= 0)
            {
                return;
            }

            attacker.CurrentAttack *= 2;
            this.rounds--;
        }
Example #35
0
        public override decimal ChangeDamageWhenAttacking(
            ICreaturesInBattle attackerWithSpecialty,
            ICreaturesInBattle defender,
            decimal currentDamage)
        {
            base.CheckInputCreatures(attackerWithSpecialty, "attackerWithSpecialty");
            base.CheckInputCreatures(defender, "defender");

            var hasAvailableRounds = base.DecrementRoundsCounter();

            return(hasAvailableRounds
                ? currentDamage * 2
                : currentDamage);
        }
Example #36
0
        // TODO: extract common validator method for ArgumentNullException
        public override decimal ChangeDamageWhenAttacking(ICreaturesInBattle attackerWithSpecialty, ICreaturesInBattle defender,
                                                          decimal currentDamage)
        {
            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }

            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }

            return(currentDamage * DoubleDamageCoeficient);
        }
        public override void ApplyWhenAttacking(ICreaturesInBattle attackerWithSpecialty, ICreaturesInBattle defender)
        {
            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }

            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }

            var reduceDefenseBy = (int)(defender.CurrentDefense * (this.Percentage / 100.0M));
            defender.CurrentDefense = defender.CurrentDefense - reduceDefenseBy;
        }
        public override void ApplyWhenAttacking(ICreaturesInBattle attackerWithSpecialty, ICreaturesInBattle defender)
        {
            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }

            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }
            this.rounds--;
            attackerWithSpecialty.CurrentAttack *= 2;
            //defender.CurrentAttack *= 2;
        }
        public override decimal ChangeDamageWhenAttacking(ICreaturesInBattle attackerWithSpecialty, ICreaturesInBattle defender,
            decimal currentDamage)
        {
            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }
            if (rounds==0)
            {
                return currentDamage;
            }
            currentDamage *= 2;
            rounds--;

            return currentDamage;
        }
        public override void ApplyWhenAttacking(ICreaturesInBattle attackerWithSpecialty, ICreaturesInBattle defender)
        {
            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }

            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }

            var reduceDefenseBy = (int)(defender.CurrentDefense * (this.Percentage / 100.0M));

            defender.CurrentDefense = defender.CurrentDefense - reduceDefenseBy;
        }
 protected override void AddCreaturesByIdentifier(CreatureIdentifier creatureIdentifier, ICreaturesInBattle creaturesInBattle)
 {
     try
     {
         base.AddCreaturesByIdentifier(creatureIdentifier, creaturesInBattle);
     }
     catch (ArgumentOutOfRangeException e)
     {
         if (creatureIdentifier.ArmyNumber == 3)
         {
             this.thirdArmyCreatures.Add(creaturesInBattle);
         }
         else
         {
             throw new ArgumentException(e.Message);
         }
     }
 }
Example #42
0
        public override decimal ChangeDamageWhenAttacking(ICreaturesInBattle attackerWithSpecialty, ICreaturesInBattle defender,
            decimal currentDamage)
        {
            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }

            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }
            if (NumberOfRounds <= 0)
            {
                return currentDamage;
            }
            this.NumberOfRounds --;
            return currentDamage;
        }
Example #43
0
        public override void ApplyWhenAttacking(ICreaturesInBattle attackerWithSpecialty, ICreaturesInBattle defender)
        {
            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }

            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }

            if (this.rounds <= 0)
            {
                return;
            }
            this.rounds--;
            attackerWithSpecialty.CurrentAttack *= 2;
        }
Example #44
0
        public override void ApplyWhenAttacking(ICreaturesInBattle attackerWithSpecialty, ICreaturesInBattle defender)
        {
            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }

            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }
            if (this.rounds <= 0)
            {
                // Effect expires after fixed number of rounds
                return;
            }
            attackerWithSpecialty.CurrentAttack *= 2;
            this.rounds--;
        }
Example #45
0
        public override decimal ChangeDamageWhenAttacking(ICreaturesInBattle attackerWithSpecialty, ICreaturesInBattle defender, decimal currentDamage)
        {
            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }

            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }

            if (defender.Creature.GetType() == this.creatureTypeToHate)
            {
                return currentDamage * 1.5M;
            }

            return currentDamage;
        }
        public override void ApplyWhenAttacking(ICreaturesInBattle attackerWithSpecialty, ICreaturesInBattle defender)
        {
            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }

            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }
            if (this.rounds <= 0)
            {
                // Effect expires after fixed number of rounds
                return;
            }
            attackerWithSpecialty.CurrentAttack *= 2;
            this.rounds--;
        }
        protected override void AddCreaturesByIdentifier(CreatureIdentifier creatureIdentifier, ICreaturesInBattle creaturesInBattle)
        {
            if (creatureIdentifier == null)
            {
                throw new ArgumentNullException("creatureIdentifier");
            }

            if (creaturesInBattle == null)
            {
                throw new ArgumentNullException("creaturesInBattle");
            }

            if (creatureIdentifier.ArmyNumber == 3)
            {
                this.thirdArmyCreatures.Add(creaturesInBattle);
                return;
            }

            base.AddCreaturesByIdentifier(creatureIdentifier, creaturesInBattle);
        }
        public void DealDamage(ICreaturesInBattle defender)
        {
            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }

            // Calculate bonus for damage
            decimal attackBonus = 1.00M; // Initially 100%

            if (this.CurrentAttack > defender.CurrentDefense)
            {
                attackBonus += 0.05M * (this.CurrentAttack - defender.CurrentDefense);
            }

            // Calculate damage
            decimal damageToMake = this.Creature.Damage * this.Count;

            damageToMake = damageToMake * attackBonus;

            // Apply battle effects for damage (ChangeDamageWhenAttacking)
            foreach (var speciallity in this.Creature.Specialties)
            {
                damageToMake = speciallity.ChangeDamageWhenAttacking(this, defender, damageToMake);
            }

            // Calculate damage reductions
            if (defender.CurrentDefense > this.CurrentAttack)
            {
                decimal reduceDamage = 0.025M * (defender.CurrentDefense - this.CurrentAttack);
                if (reduceDamage > 0.7M)
                {
                    reduceDamage = 0.7M;
                }

                damageToMake = damageToMake * (1M - reduceDamage);
            }

            this.lastDamage          = damageToMake;
            defender.TotalHitPoints -= (int)damageToMake;
        }
Example #49
0
        public override decimal ChangeDamageWhenAttacking(ICreaturesInBattle attackerWithSpecialty, ICreaturesInBattle defender, decimal currentDamage)
        {
            if (rounds < 1)
            {
                return(currentDamage);
            }
            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attacker");
            }
            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }

            //Add class DoubleDamage. The DoubleDamage is a specialty that
            //doubles the current damage during battle

            this.rounds--;
            return(currentDamage * 2);
        }
Example #50
0
        protected override void AddCreaturesByIdentifier(CreatureIdentifier creatureIdentifier,
                                                         ICreaturesInBattle creaturesInBattle)
        {
            if (creatureIdentifier == null)
            {
                throw new ArgumentNullException("creatureIdentifier");
            }

            if (creaturesInBattle == null)
            {
                throw new ArgumentNullException("creaturesInBattle");
            }
            if (creatureIdentifier.ArmyNumber == 3)
            {
                this.thirdArmyCreatures.Add(creaturesInBattle);
            }
            else
            {
                base.AddCreaturesByIdentifier(creatureIdentifier, creaturesInBattle);
            }
        }
Example #51
0
        public override decimal ChangeDamageWhenAttacking(ICreaturesInBattle attackerWithSpecialty, ICreaturesInBattle defender, decimal currentDamage)
        {
            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }

            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }

            decimal modifiedDemage = currentDamage;

            if (this.rounds > 0)
            {
                modifiedDemage *= 2;
                this.rounds--;
            }

            return(modifiedDemage);
        }
Example #52
0
        public override void ApplyWhenAttacking(ICreaturesInBattle attackerWithSpecialty, ICreaturesInBattle defender)
        {
            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }

            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }

            if (this.rounds <= 0)
            {
                // Effect expires after fixed number of rounds
                return;
            }

            // TODO: check if attackerWithSpecialty.CurrentAttack needs to be modified.
            //attackerWithSpecialty.CurrentAttack *= DoubleDamageCoeficient;
            this.rounds--;
        }
Example #53
0
        public void DealDamage(ICreaturesInBattle defender)
        {
            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }

            // Calculate bonus for damage
            decimal attackBonus = 1.00M; // Initially 100%
            if (this.CurrentAttack > defender.CurrentDefense)
            {
                attackBonus += 0.05M * (this.CurrentAttack - defender.CurrentDefense);
            }

            // Calculate damage
            decimal damageToMake = this.Creature.Damage * this.Count;
            damageToMake = damageToMake * attackBonus;

            // Apply battle effects for damage (ChangeDamageWhenAttacking)
            foreach (var speciallity in this.Creature.Specialties)
            {
                damageToMake = speciallity.ChangeDamageWhenAttacking(this, defender, damageToMake);
            }

            // Calculate damage reductions
            if (defender.CurrentDefense > this.CurrentAttack)
            {
                decimal reduceDamage = 0.025M * (defender.CurrentDefense - this.CurrentAttack);
                if (reduceDamage > 0.7M)
                {
                    reduceDamage = 0.7M;
                }

                damageToMake = damageToMake * (1M - reduceDamage);
            }

            this.lastDamage = damageToMake;
            defender.TotalHitPoints -= (int)damageToMake;
        }
Example #54
0
        public override decimal ChangeDamageWhenAttacking(
            ICreaturesInBattle attackerWithSpecialty,
            ICreaturesInBattle defender,
            decimal currentDamage)
        {
            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }

            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }

            if (defender.Creature.GetType() == this.CreatureTypeToHate)
            {
                return(currentDamage * 1.5M);
            }

            return(currentDamage);
        }
        public override decimal ChangeDamageWhenAttacking(ICreaturesInBattle attackerWithSpecialty, ICreaturesInBattle defender, decimal currentDamage)
        {
            var test = currentDamage;
            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }

            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }

            if (this.rounds != 0)
            {
                return currentDamage * 2;
                //return attackerWithSpecialty.PermanentAttack;
            }

            return test;
            //return currentDamage * 2;
        }
Example #56
0
        public override decimal ChangeDamageWhenAttacking(ICreaturesInBattle attackerWithSpecialty, ICreaturesInBattle defender,
            decimal currentDamage)
        {
            if (attackerWithSpecialty == null)
            {
                throw new ArgumentNullException("attackerWithSpecialty");
            }

            if (defender == null)
            {
                throw new ArgumentNullException("defender");
            }

            if (roundsRemaining > 0)
            {
                roundsRemaining--;
                return currentDamage * 2;
            }
            else
            {
                return currentDamage;
            }
        }
Example #57
0
File: Hate.cs Project: Vesko1/Exams
 public override void ApplyOnSkip(ICreaturesInBattle skipCreature)
 {
 }
Example #58
0
File: Hate.cs Project: Vesko1/Exams
 public override void ApplyAfterDefending(ICreaturesInBattle defenderWithSpecialty)
 {
 }
Example #59
0
File: Hate.cs Project: Vesko1/Exams
 public override void ApplyWhenDefending(ICreaturesInBattle defenderWithSpecialty, ICreaturesInBattle attacker)
 {
 }
 public abstract void ApplyAfterDefending(ICreaturesInBattle defenderWithSpecialty);