public void Test_BasicAttack_AbilityScoreRangedWeaponCombinations(int strength, int constitution, int dexterity, int intelligence,
            RangedType type, WeaponHandedness handedness, WeaponWeight weight, int expectedAttackBonus, int expectedDamageDiceCount, 
            DiceType expectedDamageDiceType, int expectedDamageBonus, int expectedRange)
        {
            Character character;
            BasicAttack basicAttack;

            character = new Character(new int[] { strength, constitution, dexterity, intelligence },
                new NullOrigin(ScoreType.Wisdom), new NullOrigin(ScoreType.Charisma), ScoreType.Acrobatics);
            character.SetHeldItem(Hand.Main, new RangedWeapon(type, handedness, weight));
            character.Update();

            basicAttack = character.GetPowers().First(x => x is BasicAttack) as BasicAttack;
            Assert.That(basicAttack, !Is.Null, "Basic Attack is null");
            Assert.That(basicAttack.Attacks.Count, Is.EqualTo(1), "Incorrect number of Basic Attack attacks");
            Assert.That(basicAttack.Attacks[0].AttackBonus.Total, Is.EqualTo(expectedAttackBonus),
                string.Format("Incorrect Basic Attack attack bonus: {0}", basicAttack.Attacks[0].AttackBonus));
            Assert.That(basicAttack.Attacks[0].Damage.Dice, Is.EqualTo(new Dice(expectedDamageDiceCount, expectedDamageDiceType)),
                "Incorrect Basic Attack damage");
            Assert.That(basicAttack.Attacks[0].DamageBonus.Total, Is.EqualTo(expectedDamageBonus),
                string.Format("Incorrect Basic Attack damage bonus: {0}", basicAttack.Attacks[0].DamageBonus));
            Assert.That(basicAttack.AttackTypeAndRange.AttackType, Is.EqualTo(AttackType.Ranged),
                "Incorrect Basic Attack attack type");
            Assert.That(basicAttack.AttackTypeAndRange.Range, Is.EqualTo(expectedRange.ToString()),
                "Incorrect Basic Attack range");
        }
 /// <summary>
 /// Get the ranged weapon's name.
 /// </summary>
 /// <param name="rangedType">
 /// Whether the weapon requires ammunition.
 /// </param>
 /// <param name="handedness">
 /// Whether the weapon is one or two handed.
 /// </param>
 /// <param name="weight">
 /// Whether the weapon is light or heavy.
 /// </param>
 /// <returns>
 /// The weapon's name.
 /// </returns>
 internal static string GetRangedWeaponName(RangedType rangedType, WeaponHandedness handedness, WeaponWeight weight)
 {
     return string.Format("{0} {1}-handed {2}",
         weight == WeaponWeight.Heavy ? "Heavy" : "Light",
         handedness == WeaponHandedness.TwoHanded ? "two" : "one",
         rangedType == RangedType.Weapon ? "ranged weapon" : "gun");
 }
Пример #3
0
        public Weapon(int numberOfDice,
                      int diceSides,
                      int damageMod,
                      int penetration,
                      int encumbrance,
                      int enchantmentLevel,
                      int price,
                      WeaponType type,
                      WeaponReach reach,
                      WeaponHandedness handedness,
                      WeaponSize size) :
            base("", "", encumbrance, price)
        {
            NumberOfDice     = numberOfDice;
            DiceSides        = diceSides;
            DamageMod        = damageMod;
            Penetration      = penetration;
            EnchantmentLevel = enchantmentLevel;
            Type             = type;
            Reach            = reach;
            Handedness       = handedness;
            Size             = size;
            IsDire           = false;
            Quality          = WeaponQuality.MAX;
            Material         = WeaponMaterial.MAX;

            _isEquippable = true;

            WeaponId = NextAvailableId;
            NextAvailableId++;
        }
 /// <summary>
 /// Create a new <see cref="MeleeWeapon"/>.
 /// </summary>
 /// <param name="handedness">
 /// Is the weapon one or two handed?
 /// </param>
 /// <param name="weight">
 /// is the weapon light or heavy?
 /// </param>
 public MeleeWeapon(WeaponHandedness handedness, WeaponWeight weight)
     : base(WeaponHelper.GetMeleeWeaponName(handedness, weight), handedness, weight)
 {
     // Do nothing
 }
 /// <summary>
 /// Get the melee weapon's name.
 /// </summary>
 /// <param name="handedness">
 /// Whether the weapon is one or two handed.
 /// </param>
 /// <param name="weight">
 /// Whether the weapon is light or heavy.
 /// </param>
 /// <returns>
 /// The weapon's name.
 /// </returns>
 public static string GetMeleeWeaponName(WeaponHandedness handedness, WeaponWeight weight)
 {
     return string.Format("{0} {1}-handed melee weapon",
         weight == WeaponWeight.Heavy ? "Heavy" : "Light",
         handedness == WeaponHandedness.TwoHanded ? "two" : "one");
 }
 public void TestName(RangedType rangedType, WeaponHandedness handedness, WeaponWeight weight, string expectedName)
 {
     Assert.That(new RangedWeapon(rangedType, handedness, weight).Name, Is.EqualTo(expectedName));
 }
 public void TestExpectedRange(RangedType rangedType, WeaponHandedness handedness, WeaponWeight weight, int expectedRange)
 {
     Assert.That(new RangedWeapon(rangedType, handedness, weight).Range, Is.EqualTo(expectedRange));
 }
 public void TestExpectedDamageDice(RangedType rangedType, WeaponHandedness handedness, WeaponWeight weight, int expectedNumber, DiceType expectedDiceType)
 {
     Assert.That(new RangedWeapon(rangedType, handedness, weight).Damage, Is.EqualTo(new Dice(expectedNumber, expectedDiceType)));
 }
 public void TestAccuracyBonus(RangedType rangedType, WeaponHandedness handedness, WeaponWeight weight, int expectedAccuracyBonus)
 {
     Assert.That(new RangedWeapon(rangedType, handedness, weight).AccuracyBonus, Is.EqualTo(expectedAccuracyBonus));
 }
 public void TestName(WeaponHandedness handedness, WeaponWeight weight, string expectedName)
 {
     Assert.That(new MeleeWeapon(handedness, weight).Name, Is.EqualTo(expectedName));
 }
 /// <summary>
 /// Create a new <see cref="RangedWeapon"/>.
 /// </summary>
 /// <param name="rangedType">
 /// Is the weapon a gun?
 /// </param>
 /// <param name="handedness">
 /// Is the weapon one or two handed?
 /// </param>
 /// <param name="weight">
 /// is the weapon light or heavy?
 /// </param>
 public RangedWeapon(RangedType rangedType, WeaponHandedness handedness, WeaponWeight weight)
     : base(WeaponHelper.GetRangedWeaponName(rangedType, handedness, weight), handedness, weight)
 {
     Type = rangedType;
 }
 /// <summary>
 /// Create a new <see cref="Weapon"/>.
 /// </summary>
 /// <param name="name">
 /// The weapon's name.
 /// </param>
 /// <param name="handedness">
 /// Is the weapon one or two handed?
 /// </param>
 /// <param name="weight">
 /// is the weapon light or heavy?
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="name"/> cannot be null or empty.
 /// </exception>
 protected Weapon(string name, WeaponHandedness handedness, WeaponWeight weight)
     : base(name, Slot.Hands)
 {
     Handedness = handedness;
     Weight = weight;
 }