public Damage CalculateDamage(Weapon weapon) { var roll = Roll(); var range = weapon.WeaponInfo.MaximumDamage - weapon.WeaponInfo.MinimumDamage; var value = weapon.WeaponInfo.MinimumDamage + (range * roll); return new Damage(weapon.WeaponInfo.DamageType) { Value = value }; }
public void PackWeaponInBox() { var itemFactory = new ItemFactory(new IdResolutionContext(new[] { TestItems.Item(ItemCode.MissileLauncher), })); var weaponPacker = new WeaponPacker(new IdGenerator(), itemFactory); var itemPacker = new ItemPacker(new[] { weaponPacker }); var weapon = new Weapon() { WeaponInfo = new WeaponInfo { Code = ItemCode.MissileLauncher} }; Assert.That(itemPacker.CanPack(weapon), Is.True); var weaponInBox = itemPacker.Pack(weapon); Assert.That(weaponInBox, Is.Not.Null); Assert.That(weaponInBox.ItemInfo, Is.InstanceOf<WeaponInfo>()); }
public WeaponAttackResult Fire(Weapon weapon) { if (!DidHit(weapon)) { return Miss(weapon); } var damage = CalculateDamage(weapon); var armour = Target.Statistics.ArmourStrength(weapon.WeaponInfo.DamageType); if (damage.Value <= armour.CurrentValue) { armour.Alter(damage); return Hit(damage); } var hullDamage = new Damage(weapon.WeaponInfo.DamageType) { Value = (damage.Value - armour.CurrentValue) }; var armourDamage = new Damage(weapon.WeaponInfo.DamageType) { Value = (armour.CurrentValue) }; armour.Alter(armourDamage); Target.Statistics[ShipStatistic.HullIntegrity].Alter(hullDamage); return Hit(armourDamage, hullDamage); }
public void EquipWeapon(Weapon weapon) { Weapon = weapon; Weapon.Location = Ship; }
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 } })); }
public void EquipWeapon(Weapon weapon) { Weapon = weapon; Weapon.HardPoint = this; Weapon.Position = new Position(Ship, Vector.Zero); }
public override IItem CreateItem() { var item = new Weapon(this); return item; }
protected WeaponAttackResult Miss(Weapon weapon) { return new WeaponAttackResult { Ship = Ship, Target = Target, Hit = false, }; }
public double ChanceToHit(Weapon weapon) { return 1.0; }
private bool DidHit(Weapon weapon) { var roll = Roll(); return (roll < ChanceToHit(weapon)); }
public void ObjectTypeIsWeapon() { var weapon = new Weapon(); Assert.That(weapon.ObjectType, Is.EqualTo(ObjectType.Weapon)); }