Exemple #1
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));
            }
        }
        protected override ICreaturesInBattle GetByIdentifier(CreatureIdentifier identifier)
        {
            if (identifier == null)
            {
                throw new ArgumentNullException("identifier");
            }

            if (identifier.ArmyNumber == 3)
            {
                return this.thirdArmyCreatures.FirstOrDefault(x => x.Creature.GetType().Name == identifier.CreatureType);
            }

            return base.GetByIdentifier(identifier);
        }
Exemple #3
0
        public void AddCreatures_ShouldCallWriteLineMethodOfLogger_WhenValidIdentifierIsProvided()
        {
            var mockedLogger = new Mock <ILogger>();

            mockedLogger.Setup(x => x.WriteLine(It.IsAny <string>()));
            var mockFactory = new Mock <ICreaturesFactory>();

            mockFactory.Setup(x => x.CreateCreature(It.IsAny <string>())).Returns(new Angel());
            var manager    = new BattleManager(mockFactory.Object, mockedLogger.Object);
            var identifier = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)");

            manager.AddCreatures(identifier, 1);

            mockedLogger.Verify(x => x.WriteLine(It.IsAny <string>()), Times.Once);
        }
Exemple #4
0
        public void Attack_WhenDefenderCreatureIdentifierIsNull_ShouldThrowArgumentException()
        {
            // Arrange
            var mockedFactory = new Mock <ICreaturesFactory>();
            var mockedLogger  = new Mock <ILogger>();

            var battleManager = new BattleManager(mockedFactory.Object, mockedLogger.Object);

            // The code itself should be refactored. Think about sealed class to be changed or the static method itself
            // You could use an unconstrained Mocking framework
            var identifier = CreatureIdentifier.CreatureIdentifierFromString("Pesho(1)");

            // Act & Assert
            Assert.Throws <ArgumentException>(() => battleManager.Attack(identifier, identifier));
        }
Exemple #5
0
        protected override ICreaturesInBattle GetByIdentifier(
            CreatureIdentifier identifier)
        {
            if (identifier.ArmyNumber == 1)
            {
                return(this.attacker);
            }

            else if (identifier.ArmyNumber == 2)
            {
                return(this.defender);
            }

            return(null);
        }
        public void Attack(CreatureIdentifier attackerIdentifier, CreatureIdentifier defenderIdentifier)
        {
            var attackerCreature = this.GetByIdentifier(attackerIdentifier);

            if (attackerCreature == null)
            {
                throw new ArgumentException(
                          string.Format(CultureInfo.InvariantCulture, "Attacker not found: {0}", attackerIdentifier));
            }

            var defenderCreature = this.GetByIdentifier(defenderIdentifier);

            if (defenderCreature == null)
            {
                throw new ArgumentException(
                          string.Format(CultureInfo.InvariantCulture, "Defender not found: {0}", defenderIdentifier));
            }

            attackerCreature.StartNewTurn();
            defenderCreature.StartNewTurn();

            this.logger.WriteLine(string.Format(CultureInfo.InvariantCulture, LogFormat, "Attacker before", attackerCreature));
            this.logger.WriteLine(string.Format(CultureInfo.InvariantCulture, LogFormat, "Defender before", defenderCreature));

            // Call ApplyWhenAttacking on attacker
            foreach (var speciallity in attackerCreature.Creature.Specialties)
            {
                speciallity.ApplyWhenAttacking(attackerCreature, defenderCreature);
            }

            // Call ApplyWhenDefending on defender
            foreach (var speciallity in defenderCreature.Creature.Specialties)
            {
                speciallity.ApplyWhenDefending(defenderCreature, attackerCreature);
            }

            // Call ChangeDamage on attacker
            attackerCreature.DealDamage(defenderCreature);

            // Call ApplyAfterDefending on defender
            foreach (var speciallity in defenderCreature.Creature.Specialties)
            {
                speciallity.ApplyAfterDefending(defenderCreature);
            }

            this.logger.WriteLine(string.Format(CultureInfo.InvariantCulture, LogFormat, "Attacker after", attackerCreature));
            this.logger.WriteLine(string.Format(CultureInfo.InvariantCulture, LogFormat, "Defender after", defenderCreature));
        }
        protected override ICreaturesInBattle GetByIdentifier(CreatureIdentifier identifier)
        {
            if (identifier == null)
            {
                throw new ArgumentNullException("identifier");
            }

            if (identifier.ArmyNumber == 3)
            {
                return(this.thirdArmyCreatures.FirstOrDefault(x => x.Creature.GetType().Name == identifier.CreatureType));
            }
            else
            {
                return(base.GetByIdentifier(identifier));
            }
        }
Exemple #8
0
        protected override ICreaturesInBattle GetByIdentifier(CreatureIdentifier identifier)
        {
            if (identifier.ArmyNumber == 1)
            {
                return(this.FirstArmyOfCreatures.FirstOrDefault(x => x.Creature.GetType().Name == identifier.CreatureType));
            }
            else
            {
                return(this.SecondArmyOfCreatures.FirstOrDefault(x => x.Creature.GetType().Name == identifier.CreatureType));
            }

            //var creature = new Angel();

            //return new CreaturesInBattle(creature, 1);
            //return null;
        }
Exemple #9
0
        public void Attack_ShouldCallLoggerWriteLineMethodFourTimes_WhenAttackIsSuccessfull()
        {
            var mockedFactory      = new Mock <ICreaturesFactory>();
            var mockedLogger       = new Mock <ILogger>();
            var battleManager      = new MockedBattleManager(mockedFactory.Object, mockedLogger.Object);
            var identifierAttacker = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)");
            var identifierDefender = CreatureIdentifier.CreatureIdentifierFromString("Angel(2)");
            var creature           = new Angel();

            mockedFactory.Setup(x => x.CreateCreature(It.IsAny <string>())).Returns(creature);
            battleManager.AddCreatures(identifierAttacker, 3);
            battleManager.AddCreatures(identifierDefender, 3);

            battleManager.Attack(identifierAttacker, identifierDefender);

            mockedLogger.Verify(x => x.WriteLine(It.IsAny <string>()), Times.Exactly(6));
        }
        public void CallCreateCreature_WhenValidIdentifierIsPassed()
        {
            var mockedFactory = new Mock <ICreaturesFactory>();
            var mockedLogger  = new Mock <ILogger>();

            var bmanager = new BattleManager(mockedFactory.Object, mockedLogger.Object);

            var identifier = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)");

            var creature = new Angel();

            mockedFactory.Setup(x => x.CreateCreature(It.IsAny <string>())).Returns(creature);

            bmanager.AddCreatures(identifier, 1);

            mockedFactory.Verify(x => x.CreateCreature(It.IsAny <string>()), Times.Exactly(1));
        }
Exemple #11
0
        protected override ICreaturesInBattle GetByIdentifier(CreatureIdentifier identifier)
        {
            // TOCHECK: to make shure there is need to check null validatino here
            if (identifier == null)
            {
                throw new ArgumentNullException("identifier");
            }

            if (identifier.ArmyNumber == 3)
            {
                return(this.thitdArmyCreatures.FirstOrDefault(x => x.Creature.GetType().Name == identifier.CreatureType));
            }
            else
            {
                return(base.GetByIdentifier(identifier));
            }
        }
Exemple #12
0
        public void AddCreatures_ShouldCallCreteCreatureFromFactory_IfInputIsValid()
        {
            int count = 5;
            var creatureIdentifier = CreatureIdentifier.CreatureIdentifierFromString("AncientBehemoth(1)");

            var creaturesFactoryMock = new Mock <ICreaturesFactory>();
            var loggerMock           = new Mock <ILogger>();

            var battleManager = new BattleManager(creaturesFactoryMock.Object, loggerMock.Object);

            try
            {
                battleManager.AddCreatures(creatureIdentifier, count);
            }
            catch { }

            creaturesFactoryMock.Verify(x => x.CreateCreature(It.IsAny <string>()), Times.Once());
        }
Exemple #13
0
 protected override ICreaturesInBattle GetByIdentifier(CreatureIdentifier identifier)
 {
     try
     {
         return(base.GetByIdentifier(identifier));
     }
     catch (ArgumentException)
     {
         if (identifier.ArmyNumber == ExtendedBattleManager.ThirdArmyCreaturesIdentifier)
         {
             return(this.thirddArmyCreatures.FirstOrDefault(x => x.Creature.GetType().Name == identifier.CreatureType));
         }
         else
         {
             throw;
         }
     }
 }
Exemple #14
0
 protected override void AddCreaturesByIdentifier(CreatureIdentifier creatureIdentifier, ICreaturesInBattle creaturesInBattle)
 {
     try
     {
         base.AddCreaturesByIdentifier(creatureIdentifier, creaturesInBattle);
     }
     catch (ArgumentException)
     {
         if (creatureIdentifier.ArmyNumber == ExtendedBattleManager.ThirdArmyCreaturesIdentifier)
         {
             this.thirddArmyCreatures.Add(creaturesInBattle);
         }
         else
         {
             throw;
         }
     }
 }
        public void Skip(CreatureIdentifier creatureIdentifier)
        {
            var creature = this.GetByIdentifier(creatureIdentifier);

            if (creature == null)
            {
                throw new ArgumentException(
                          string.Format(CultureInfo.InvariantCulture, "Skip creature not found: {0}", creatureIdentifier));
            }

            creature.StartNewTurn();

            this.logger.WriteLine(string.Format(CultureInfo.InvariantCulture, LogFormat, "Before skip", creature));

            creature.Skip();
            creature.StartNewTurn();

            this.logger.WriteLine(string.Format(CultureInfo.InvariantCulture, LogFormat, "After skip", creature));
        }
        public void AddCreatures(CreatureIdentifier creatureIdentifier, int count)
        {
            if (creatureIdentifier == null)
            {
                throw new ArgumentNullException("creatureIdentifier");
            }

            var creature          = this.creaturesFactory.CreateCreature(creatureIdentifier.CreatureType);
            var creaturesInBattle = new CreaturesInBattle(creature, count);

            this.AddCreaturesByIdentifier(creatureIdentifier, creaturesInBattle);

            this.logger.WriteLine(
                string.Format(
                    CultureInfo.InvariantCulture,
                    LogFormat,
                    string.Format(CultureInfo.InvariantCulture, "Creature added to army {0}", creatureIdentifier.ArmyNumber),
                    creature));
        }
        public void AddCreature_ShouldCallICreaturesFactoryCreateCreatureWithCorrectCreatureNameString_WhenParametersAreValid()
        {
            var expectedCreatureName = "fake";

            var fakeFactory = new Mock <ICreaturesFactory>();

            fakeFactory.Setup(mock => mock.CreateCreature(expectedCreatureName)).Returns(new FakeCreature());

            var fakeLogger = new Mock <ILogger>();

            var creatureIdentifier = CreatureIdentifier.CreatureIdentifierFromString(expectedCreatureName + "(1)");
            var count = 1;

            var battleManager = new BattleManager(fakeFactory.Object, fakeLogger.Object);

            battleManager.AddCreatures(creatureIdentifier, count);

            fakeFactory.Verify(mock => mock.CreateCreature(expectedCreatureName), Times.Once());
        }
        public void CallWriteLine4Times_WhenAttackIsSucessful()
        {
            var creatureFactoryMock = new Mock <ICreaturesFactory>();
            var loggerMock          = new Mock <ILogger>();

            var battleManager = new MockedBattleManager(creatureFactoryMock.Object, loggerMock.Object);

            var identifier = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)");

            creatureFactoryMock.Setup(x => x.CreateCreature(It.IsAny <string>())).Returns(new Angel());

            battleManager.AddCreatures(identifier, 1);

            loggerMock.Setup(x => x.WriteLine(It.IsAny <string>()));

            battleManager.Attack(identifier, identifier);

            loggerMock.Verify(x => x.WriteLine(It.IsAny <string>()), Times.Exactly(4));
        }
        public void AddCreaturesInThirdArmy_WhenCorrectDataIsPassed()
        {
            var logger  = new Mock <ILogger>();
            var factory = new Mock <ICreaturesFactory>();

            var creature = new Angel();

            factory.Setup(x => x.CreateCreature(It.IsAny <string>())).Returns(creature);

            var battleManager = new MockedBattleManager(factory.Object, logger.Object);

            var creatureIdentifier = CreatureIdentifier.CreatureIdentifierFromString("Angel(3)");

            battleManager.AddCreatures(creatureIdentifier, 1);

            var result = battleManager.ThirdArmyCreatures.FirstOrDefault();

            Assert.IsInstanceOf(typeof(CreaturesInBattle), result);
        }
Exemple #20
0
        public void Attack_ShouldReturnRightResult_WhenTwoBehemothsAttackOne()
        {
            var mockedFactory      = new Mock <ICreaturesFactory>();
            var mockedLogger       = new Mock <ILogger>();
            var battleManager      = new MockedBattleManager(mockedFactory.Object, mockedLogger.Object);
            var identifierAttacker = CreatureIdentifier.CreatureIdentifierFromString("Behemoth(1)");
            var identifierDefender = CreatureIdentifier.CreatureIdentifierFromString("Behemoth(2)");
            var creature           = new Behemoth();

            mockedFactory.Setup(x => x.CreateCreature(It.IsAny <string>())).Returns(creature);
            battleManager.AddCreatures(identifierAttacker, 2);
            battleManager.AddCreatures(identifierDefender, 1);

            battleManager.Attack(identifierAttacker, identifierDefender);

            var result = battleManager.SecondArmyOfCreatures.FirstOrDefault().TotalHitPoints;

            Assert.IsTrue(result == 56);
        }
        public void CallWriteLineExactly2Times_WhenValidValueIsPassed()
        {
            var loggerMock  = new Mock <ILogger>();
            var factoryMock = new Mock <ICreaturesFactory>();

            loggerMock.Setup(x => x.WriteLine(It.IsAny <string>()));

            var battleManager = new MockedBattleManager(factoryMock.Object, loggerMock.Object);

            var creaturesInBattle = new CreaturesInBattle(new Angel(), 1);

            var identifier = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)");

            battleManager.FirstArmyCreatures.Add(creaturesInBattle);

            battleManager.Skip(identifier);

            loggerMock.Verify(x => x.WriteLine(It.IsAny <string>()), Times.Exactly(2));
        }
        public void AttackCreatures_WhenAttackIsSuccessful_ShouldCallWriteLIne4Times()
        {
            var mockedFactory = new Mock <ICreaturesFactory>();
            var mockedLogger  = new Mock <ILogger>();

            var manager    = new MockedBattleManager(mockedFactory.Object, mockedLogger.Object);
            var identifier = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)");

            var creature = new Angel();

            mockedFactory.Setup(x => x.CreateCreature(It.IsAny <string>())).Returns(creature);

            manager.AddCreatures(identifier, 1);

            mockedLogger.Setup(x => x.WriteLine(It.IsAny <string>()));

            manager.Attack(identifier, identifier);

            mockedLogger.Verify(x => x.WriteLine(It.IsAny <string>()), Times.Exactly(4));
        }
Exemple #23
0
        protected override ICreaturesInBattle GetByIdentifier(CreatureIdentifier identifier)
        {
            if (identifier == null)
            {
                throw new ArgumentNullException("identifier");
            }

            if (identifier.ArmyNumber == 1)
            {
                return(this.firstArmyCreatures.FirstOrDefault(x => x.Creature.GetType().Name == identifier.CreatureType));
            }

            if (identifier.ArmyNumber == 2)
            {
                return(this.secondArmyCreatures.FirstOrDefault(x => x.Creature.GetType().Name == identifier.CreatureType));
            }

            throw new ArgumentException(
                      string.Format(CultureInfo.InvariantCulture, "Invalid ArmyNumber: {0}", identifier.ArmyNumber));
        }
        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 AddCreatures_WhenValidIdentifierIsPassed_FactoryShouldCallCreateCreature()
        {
            var mockedFactory = new Mock <ICreaturesFactory>();
            var mockedLogger  = new Mock <ILogger>();

            var manager = new BattleManager(mockedFactory.Object, mockedLogger.Object);

            var fixture = new Fixture();

            fixture.Customizations.Add(new TypeRelay(typeof(Creature), typeof(Angel)));

            var creature = fixture.Create <Creature>();

            mockedFactory.Setup(x => x.CreateCreature(It.IsAny <string>())).Returns(creature);

            var identifier = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)");

            manager.AddCreatures(identifier, 1);
            mockedFactory.Verify(x => x.CreateCreature(It.IsAny <string>()), Times.Exactly(1));
        }
Exemple #26
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);
            }
        }
Exemple #27
0
        public void AddCreatures_ShouldThrowArgumentException_IfCreatureIsAddedToNonexistentArmy()
        {
            int count = 5;
            var creatureIdentifier = CreatureIdentifier.CreatureIdentifierFromString("AncientBehemoth(3)");

            var creature = new Angel();

            //var fixture = new Fixture();
            //var creature = fixture.Create<Angel>();

            var creaturesFactoryMock = new Mock <ICreaturesFactory>();

            creaturesFactoryMock.Setup(x => x
                                       .CreateCreature(It.IsAny <string>()))
            .Returns(() => creature);

            var loggerMock = new Mock <ILogger>();

            var battleManager = new BattleManager(creaturesFactoryMock.Object, loggerMock.Object);

            Assert.Throws <ArgumentException>(() => battleManager.AddCreatures(creatureIdentifier, count));
        }
Exemple #28
0
        protected override void AddCreaturesByIdentifier(CreatureIdentifier creatureIdentifier, ICreaturesInBattle creaturesInBattle)
        {
            // TOCHECK: to make shure there is need to check null validatino here
            if (creatureIdentifier == null)
            {
                throw new ArgumentNullException("creatureIdentifier");
            }

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

            if (creatureIdentifier.ArmyNumber == 3)
            {
                this.thitdArmyCreatures.Add(creaturesInBattle);
            }
            else
            {
                base.AddCreaturesByIdentifier(creatureIdentifier, creaturesInBattle);
            }
        }
Exemple #29
0
        public void ProcessCommand(IBattleManager battleManager, params string[] arguments)
        {
            if (battleManager == null)
            {
                throw new ArgumentNullException("battleManager");
            }

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

            if (arguments.Length < 1)
            {
                throw new ArgumentException("Invalid number of arguments for skip command");
            }

            var creatureIdentifierString = arguments[0];
            var creatureIdentifier       = CreatureIdentifier.CreatureIdentifierFromString(creatureIdentifierString);

            battleManager.Skip(creatureIdentifier);
        }
Exemple #30
0
        public void Attack_WhenAttackingOwnArmy_ShouldThrowArgumentException()
        {
            // Arrange
            var mockedFactory = new Mock <ICreaturesFactory>();
            var mockedLogger  = new Mock <ILogger>();

            var battleManager = new MockedBattleManager(mockedFactory.Object, mockedLogger.Object);

            var identifierAttacker = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)");
            var identifierDefender = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)");

            var creature = new Angel();

            mockedFactory.Setup(x => x.CreateCreature(It.IsAny <string>())).Returns(creature);

            mockedLogger.Setup(x => x.WriteLine(It.IsAny <string>()));

            battleManager.AddCreatures(identifierAttacker, 1);
            battleManager.AddCreatures(identifierDefender, 1);

            // Act and Assert
            Assert.Throws <ArgumentException>(() => battleManager.Attack(identifierAttacker, identifierDefender));
        }
Exemple #31
0
        public void ProcessCommand(IBattleManager battleManager, params string[] arguments)
        {
            if (battleManager == null)
            {
                throw new ArgumentNullException("battleManager");
            }

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

            if (arguments.Length < 2)
            {
                throw new ArgumentException("Invalid number of arguments for add command");
            }

            var count = int.Parse(arguments[0], CultureInfo.InvariantCulture);
            var creatureIdentifierString = arguments[1];
            var creatureIdentifier       = CreatureIdentifier.CreatureIdentifierFromString(creatureIdentifierString);

            battleManager.AddCreatures(creatureIdentifier, count);
        }
        public void AddCreature_ShouldAddACreatureToFirstArmyCreatures_WhenCreatureIdentifierArmyNumberIsOne()
        {
            var creatureName = "fake";
            var armyNr       = "1";

            var fakeFactory = new Mock <ICreaturesFactory>();

            fakeFactory.Setup(moch => moch.CreateCreature(It.IsAny <string>())).Returns(new FakeCreature());

            var fakeLogger = new Mock <ILogger>();

            var identifier = CreatureIdentifier.CreatureIdentifierFromString(string.Format("{0}({1})", creatureName, armyNr));
            var count      = 1;

            var manager   = new BattleManager(fakeFactory.Object, fakeLogger.Object);
            var managerPO = new MSTest.PrivateObject(manager);

            var firstArmy = (ICollection <ICreaturesInBattle>)managerPO.GetField("firstArmyCreatures");

            manager.AddCreatures(identifier, count);

            Assert.AreEqual(1, firstArmy.Count);
        }
        //[Test]
        public void Attack_WhenAttackingOwnArmy_ShouldThrow()
        {
            //Arrange
            var mockedfacttory          = new Mock <ICreaturesFactory>();
            var mockedLogger            = new Mock <ILogger>();
            var mockedCreaturesInBatlle = new Mock <ICreaturesInBattle>();

            var sut = new MockedBattleManager(mockedfacttory.Object, mockedLogger.Object);

            var identifier1 = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)");
            var identifier2 = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)");

            var creature = new Angel();

            mockedfacttory.Setup(x => x.CreateCreature(It.IsAny <string>())).Returns(creature);
            mockedLogger.Setup(x => x.WriteLine(It.IsAny <string>()));

            //Act
            sut.AddCreatures(identifier1, 1);
            sut.AddCreatures(identifier2, 1);

            //Assert
            Assert.Throws <ArgumentException>(() => sut.Attack(identifier1, identifier2));
        }
Exemple #34
0
        protected override ICreaturesInBattle GetByIdentifier(CreatureIdentifier identifier)
        {
            if (identifier == null)
            {
                throw new ArgumentNullException("identifier");
            }

            if (identifier.ArmyNumber == 1)
            {
                return this.firstArmyCreatures.FirstOrDefault(x => x.Creature.GetType().Name == identifier.CreatureType);
            }

            if (identifier.ArmyNumber == 2)
            {
                return this.secondArmyCreatures.FirstOrDefault(x => x.Creature.GetType().Name == identifier.CreatureType);
            }

            if (identifier.ArmyNumber==3)
            {
                return this.thirdArmyCreatures.FirstOrDefault(x => x.Creature.GetType().Name == identifier.CreatureType);
            }
            throw new ArgumentException(
                string.Format(CultureInfo.InvariantCulture, "Invalid ArmyNumber: {0}", identifier.ArmyNumber));
        }