Esempio n. 1
0
        public void CalculateDamageTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Laser);
            int maxvalue = attackImplement.Power * 4;

            Assert.True(attackImplement.CalculateDamage() <= maxvalue);
        }
Esempio n. 2
0
        public static void DecorateShip(IStarShip ship, IAttackImplement attackImplement)
        {
            if (ship.NumberOfAttackSlotsAvailable >= attackImplement.Size)
            {
                ship.AttackImplements.Add(attackImplement);
                ship.Health = ship.Health + attackImplement.ShipHealthModification;
                ship.Speed  = ship.Speed + attackImplement.ShipSpeedModification;
                ship.Power  = ship.Power + attackImplement.ShipPowerModification;
                ship.Armor  = ship.Armor + attackImplement.ShipArmorModification;

                if (ship.Health < 0)
                {
                    ship.Health = 0;
                }

                if (ship.Speed < 0)
                {
                    ship.Speed = 0;
                }

                if (ship.Power < 0)
                {
                    ship.Power = 0;
                }

                if (ship.Armor < 0)
                {
                    ship.Armor = 0;
                }
            }
        }
 private static void SetLaserDefaultValues(IAttackImplement attackImplement)
 {
     attackImplement.Power  = 1;
     attackImplement.Health = 100;
     attackImplement.Ammo   = null;
     attackImplement.Size   = 1;
     attackImplement.ShipSpeedModification = -1;
 }
 private static void SetPlasmaCannonDefaultValues(IAttackImplement attackImplement)
 {
     attackImplement.Power  = 2;
     attackImplement.Health = 100;
     attackImplement.Ammo   = 100;
     attackImplement.Size   = 8;
     attackImplement.ShipSpeedModification = -4;
 }
Esempio n. 5
0
        public void GetWeekTargetShipTest()
        {
            IFleet           fleet           = FleetFactory.CreateFleet(FleetConfigurationType.SmallShips, BattleStratageyType.WeekShipsFirst);
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Laser);
            var ship = attackImplement.GetTargetShip(BattleStratageyType.WeekShipsFirst, fleet);

            Assert.NotNull(ship);
        }
 private static void SetPhotonTorpedoDefaultValues(IAttackImplement attackImplement)
 {
     attackImplement.Power  = 2;
     attackImplement.Health = 100;
     attackImplement.Ammo   = 10;
     attackImplement.Size   = 4;
     attackImplement.ShipSpeedModification = -3;
 }
Esempio n. 7
0
        public void GetTargetShipTest()
        {
            IFleet           fleet           = FleetFactory.CreateFleet(FleetConfigurationType.HeavyShips, BattleStratageyType.NoPriority);
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Laser);
            var ship = attackImplement.GetTargetShip(null, fleet);

            Assert.NotNull(ship);
        }
 private static void SetMissileDefaultValues(IAttackImplement attackImplement)
 {
     attackImplement.Power  = 1;
     attackImplement.Health = 100;
     attackImplement.Ammo   = 4;
     attackImplement.Size   = 2;
     attackImplement.ShipSpeedModification = -2;
 }
        public void PlasmaCannonAmmoUnAvailableTest()
        {
            IAttackImplement ai    = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PlasmaCannon);
            IFleet           fleet = FleetFactory.CreateFleet(FleetConfigurationType.BalancedShips, BattleStratageyType.WeekShipsFirst);
            var shots = ai.Ammo;

            for (int i = 0; i < shots; i++)
            {
                ai.Fire(fleet, BattleStratageyType.StrongShipsFirst);
            }
            Assert.False(ai.AmmoAvailable);
        }
        public void LaserAmmoNeverUnAvailableTest()
        {
            IAttackImplement ai    = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Laser);
            IFleet           fleet = FleetFactory.CreateFleet(FleetConfigurationType.BalancedShips, BattleStratageyType.WeekShipsFirst);

            for (int i = 0; i < 600; i++)
            {
                ai.Fire(fleet, BattleStratageyType.StrongShipsFirst);
            }
            Assert.True(ai.AmmoAvailable);
            Assert.False(ai.Ammo.HasValue);
        }
Esempio n. 11
0
        public void FireTest()
        {
            IFleet           fleet = FleetFactory.CreateFleet(FleetConfigurationType.HeavyShips, BattleStratageyType.NoPriority);
            var              oTotalHealthAndArmor = fleet.StarShips.Sum(x => x.Health) + fleet.StarShips.Sum(x => x.Armor);
            IAttackImplement attackImplement      = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Laser);

            //Has A random miss rate
            for (int i = 0; i < 1000; i++)
            {
                attackImplement.Fire(fleet, BattleStratageyType.WeekShipsFirst);
            }

            var newTotalHealthAndArmor = fleet.StarShips.Sum(x => x.Health) + fleet.StarShips.Sum(x => x.Armor);

            Assert.True(oTotalHealthAndArmor > newTotalHealthAndArmor);
        }
        public void PlasmaCannonPowerBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PlasmaCannon);

            Assert.Equal(2, attackImplement.Power);
        }
Esempio n. 13
0
        public void PhotonTorpedoSizeBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PhotonTorpedo);

            Assert.Equal(4, attackImplement.Size);
        }
        public void MissileSizeBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Missile);

            Assert.Equal(2, attackImplement.Size);
        }
Esempio n. 15
0
        public void PhotonTorpedoAmmoBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PhotonTorpedo);

            Assert.Equal(10, attackImplement.Ammo);
        }
Esempio n. 16
0
        public void PhotonTorpedoPowerBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PhotonTorpedo);

            Assert.Equal(2, attackImplement.Power);
        }
        public void PlasmaCannonAmmoAvailableTest()
        {
            IAttackImplement i = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PlasmaCannon);

            Assert.True(i.AmmoAvailable);
        }
        public void MissileShipSpeedModificationBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Missile);

            Assert.Equal(-2, attackImplement.ShipSpeedModification);
        }
        public void PlasmaCannonShipSpeedModificationBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PlasmaCannon);

            Assert.Equal(-4, attackImplement.ShipSpeedModification);
        }
        public void MissileAmmoAvailableTest()
        {
            IAttackImplement i = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Missile);

            Assert.True(i.AmmoAvailable);
        }
        public void MissileAmmoBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Missile);

            Assert.Equal(4, attackImplement.Ammo);
        }
        public void MissileHealthBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Missile);

            Assert.Equal(100, attackImplement.Health);
        }
        public void PlasmaCannonSizeBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PlasmaCannon);

            Assert.Equal(8, attackImplement.Size);
        }
Esempio n. 24
0
        public void PhotonTorpedoShipSpeedModificationBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PhotonTorpedo);

            Assert.Equal(-3, attackImplement.ShipSpeedModification);
        }
        public void PlasmaCannonAmmoBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PlasmaCannon);

            Assert.Equal(100, attackImplement.Ammo);
        }
Esempio n. 26
0
        public void PhotonTorpedoAmmoAvailableTest()
        {
            IAttackImplement i = AttackImplementFactory.CreateAttackImplement(AttackImplementType.PhotonTorpedo);

            Assert.True(i.AmmoAvailable);
        }
        public void LaserAmmoBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Laser);

            Assert.Equal(false, attackImplement.Ammo.HasValue);
        }
        public void MissilePowerBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Missile);

            Assert.Equal(1, attackImplement.Power);
        }
        public void LaserSizeBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Laser);

            Assert.Equal(1, attackImplement.Size);
        }
        public void LaserShipSpeedModificationBaseValueTest()
        {
            IAttackImplement attackImplement = AttackImplementFactory.CreateAttackImplement(AttackImplementType.Laser);

            Assert.Equal(-1, attackImplement.ShipSpeedModification);
        }