Example #1
0
        public void MartialWeaponsAreProficientIfMartiallyTrained()
        {
            var prof = new WeaponProficiency("martial");
            var wpn  = new Weapon();

            wpn.Level = WeaponTrainingLevel.Martial;
            Assert.True(prof.IsProficient(wpn));
        }
Example #2
0
        public void NameContainsAListOfWeapons()
        {
            var config = new MemoryStore();

            config.SetValue("weapons", new string[] { "mace", "sword" });
            var prof = new WeaponProficiency(config);

            Assert.Equal("mace, sword", prof.Name);
        }
 private Weapon(string name, double cost, double weight, Dictionaries.WeaponTypes weaponType, WeaponRanges range, Dice damage, string damagetype, string info, int amount = 1) : base(name, cost, weight, amount)
 {
     WeaponType        = weaponType;
     Range             = range;
     Damage            = damage;
     DamageType        = damagetype;
     Info              = info;
     WeaponProficiency = Dictionaries.WeaponProficiencies[WeaponType];
 }
Example #4
0
        public void ShouldProperlyRecognizeProficiencyWithMasterworkWeapons()
        {
            var prof = new WeaponProficiency("Shortbow");
            var wpn  = new Weapon();

            wpn.Name = "Shortbow";
            var mwkWpn = new MasterworkWeapon(wpn);

            Assert.True(prof.IsProficient(mwkWpn));
        }
Example #5
0
        public void MatchesBasedOnNameIfNotTrainingLevel()
        {
            var prof = new WeaponProficiency("Shortbow");
            var wpn  = new Weapon();

            wpn.Name = "Longsword";
            Assert.False(prof.IsProficient(wpn));
            wpn.Name = "Shortbow";
            Assert.True(prof.IsProficient(wpn));
        }
Example #6
0
        public void SimpleWeaponsAreProficientForSimple()
        {
            var prof = new WeaponProficiency("simple");
            var wpn  = new Weapon();

            wpn.Level = WeaponTrainingLevel.Simple;
            Assert.True(prof.IsProficient(wpn));
            wpn.Level = WeaponTrainingLevel.Martial;
            Assert.False(prof.IsProficient(wpn));
        }
Example #7
0
        public void CanSelectWeaponsBasedOnProficiencies()
        {
            var repo = new WeaponYamlGateway(WeaponYamlFile.ParseYaml());
            var prof = new WeaponProficiency("dagger");

            var results = repo.FindByProficient(new WeaponProficiency[] { prof });

            Assert.AreEqual(1, results.Count());
            Assert.AreEqual("Dagger", results.First().Name);
        }
Example #8
0
 public void CharactersGetARangedAndMeleeWeaponTheyAreProficientIn()
 {
     //Bad test, but good enough for now
     for (int i = 0; i < 1000; i++)
     {
         var inventory     = new Inventory();
         var repo          = new EquipMeleeAndRangedWeapon(new WeaponTestRepo());
         var proficiencies = new WeaponProficiency[] { new WeaponProficiency("simple"), new WeaponProficiency("martial") };
         repo.AssignWeapons(inventory, proficiencies);
         Assert.AreEqual(inventory.Weapons.Count(), 2);
         Assert.IsTrue(inventory.Weapons.Any(x => x.Type == WeaponType.Ranged));
         Assert.IsTrue(inventory.Weapons.Any(x => x.Type != WeaponType.Ranged));
         Assert.IsFalse(inventory.Weapons.Any(x => x.Level == WeaponTrainingLevel.Exotic));
     }
 }
Example #9
0
        public void SomeRacialProficienciesAreBasedOnWhetherAWordIsInTheName()
        {
            var config = new MemoryStore();

            config.SetValue("weapons", new string[] { "\"dwarven\"" });
            var prof          = new WeaponProficiency(config);
            var dwarvenShovel = new Weapon();

            dwarvenShovel.Name = "Ancient Dwarven Shovel of DOOM";
            Assert.True(prof.IsProficient(dwarvenShovel));

            var elvishComb = new Weapon();

            elvishComb.Name = "Handy Elvish Comb of Prettiness";
            Assert.False(prof.IsProficient(elvishComb));
        }
Example #10
0
        public void CanLoadFromAConfigurationListOfWeaponsAndMatchAllOfThem()
        {
            var config = new MemoryStore();

            config.SetValue("weapons", new string[] { "mace", "sword" });
            var prof = new WeaponProficiency(config);

            var mace = new Weapon();

            mace.Name = "Mace";
            Assert.True(prof.IsProficient(mace));
            var sword = new Weapon();

            sword.Name = "Sword";
            Assert.True(prof.IsProficient(sword));
            var bow = new Weapon();

            bow.Name = "Bow";
            Assert.False(prof.IsProficient(bow));
        }
Example #11
0
        public void WeaponsAreTreatedAsMartialForDeterminingProficiencyLevel()
        {
            var config = new MemoryStore();

            config.SetValue("weapons", new string[] { "%dwarven%" });
            var exotic  = new WeaponProficiencyExoticToMartial(config);
            var martial = new WeaponProficiency("martial");
            var bob     = CharacterTestTemplates.AverageBob();

            bob.Add(martial);
            bob.Add(exotic);

            var dwarvenHammer = new Weapon();

            dwarvenHammer.Level = WeaponTrainingLevel.Exotic;
            dwarvenHammer.Name  = "Dwarven Hammer";
            Assert.True(bob.Offense.IsProficient(dwarvenHammer));

            var elvenBow = new Weapon();

            elvenBow.Level = WeaponTrainingLevel.Exotic;
            elvenBow.Name  = "Elven Bow";
            Assert.False(bob.Offense.IsProficient(elvenBow));
        }
Example #12
0
        public void NameLooksHumanReadable()
        {
            var prof = new WeaponProficiency("simple");

            Assert.AreEqual("Simple weapons", prof.Name);
        }
Example #13
0
 public EnumBase(WeaponProficiency weaponProficiency) : base()
 {
     Value = weaponProficiency;
     Description = weaponProficiency.Description();
     
 }
Example #14
0
 public int calculateWeaponDefenceBonus(WeaponProficiency wp, Weapon w)
 {
     if (wp == null)
     {
         return 0;
     }
     return Convert.ToInt16((float)w.DefenceBonus * (wp.Value / 100f));
 }
Example #15
0
        public int[] calculateRangedDamage(WeaponProficiency wp, Weapon w)
        {
            int[] dmg = new int[3];
            dmg[0] = w.RangeDamage[0];
            dmg[1] = w.RangeDamage[1];
            dmg[2] = w.RangeDamage[2];

            for (int i = 0; i < dmg.GetLength(0); i++)
            {
                if (dmg[i] == 0)
                {
                    //do not calcualte dmg if base dmg is 0
                    continue;
                }
                if (wp != null)
                {
                    dmg[i] = Convert.ToInt16((float)dmg[i] * (wp.Value / 100f)) + Convert.ToInt16(Math.Round(Stat[PrimaryStats.STRENGTH].currentValue / 4f));
                }
                else
                {
                    dmg[i] = Convert.ToInt16(Math.Round(Stat[PrimaryStats.STRENGTH].currentValue / 4f));
                }
                
            }

            return dmg;
        }
Example #16
0
 public int calculateToHit(WeaponProficiency wp)
 {
     if (wp == null)
     {
         return Convert.ToInt16(Math.Round(Stat[PrimaryStats.STRENGTH].currentValue / 10f)) + Convert.ToInt16(Math.Round(Stat[PrimaryStats.DEXTERITY].actualValue / 10f));
     }
     return wp.Value + Convert.ToInt16(Math.Round(Stat[PrimaryStats.STRENGTH].currentValue / 10f)) + Convert.ToInt16(Math.Round(Stat[PrimaryStats.DEXTERITY].actualValue / 10f));
 }