Beispiel #1
0
        public void FireAll()
        {
            var items = new IObject[] { new ShipInfo { Code = ItemCode.LightFrigate }, new WeaponInfo { Code = ItemCode.MissileLauncher, MinimumDamage = 100, MaximumDamage = 100 }, };

            var ship = new ShipState(ItemCode.LightFrigate)
            {
                LocalCoordinates = Vector.Parse("0,-1"),
                Heading = Vector.Parse("0,-1"),
                HardPoints = new[]
                {
                    new HardPointState { Weapon = new WeaponState {Code = ItemCode.MissileLauncher}, Position = HardPointPosition.Front },
                    new HardPointState { Weapon = new WeaponState {Code = ItemCode.MissileLauncher}, Position = HardPointPosition.Rear },
                    new HardPointState { Weapon = new WeaponState {Code = ItemCode.MissileLauncher}, Position = HardPointPosition.Top },
                }
            };

            _combat = _combatFactory(ship, new IdResolutionContext(items));

            Assert.That(_combat.Ship.HardPoints, Is.Not.Empty);

            _random.Setup(x => x.GetNext()).Returns(0);

            var result =
                _combat.Ship.HardPoints
                .Where(hp => hp.Weapon != null)
                .Where(hp => hp.InRange(_combat.Target))
                .Select(x => _combat.Fire(x.Weapon))
                .ToArray();

            Assert.That(result, Is.Not.Empty);

            var dmg = result.Aggregate((Damage )null, (current, value) => current + value.TotalDamage);
            Assert.That(dmg.Value, Is.Not.EqualTo(0d));
        }
Beispiel #2
0
        public void SetUp()
        {
            _random = new Mock<IRandom>(MockBehavior.Strict);

            Func<ShipState, ObjectBuilder<Ship>> ship = state => Ship.Builder.Build(null, state);
            _target = new Ship {Statistics = new ShipStatistics(Stats())};
            _weapon = new Weapon();

            _combatFactory = (state, idResolver) => new AttackShipCombat(_random.Object) { Ship = ship(state).Build(idResolver), Target = _target };
            _combat = _combatFactory(new ShipState(ItemCode.LightFrigate), new IdResolutionContext(new[] { new ShipInfo() { Code = ItemCode.LightFrigate } }));
        }