예제 #1
0
 public void CarryingStuffSlowsCharacterDown()
 {
     var c = new Character { Agility = 10, PhysicalStrength = 10, Race = Race.Human };
     var tmr = c.TacticalMovementRate();
     c.Inventory.Add(_heavyItem);
     c.TacticalMovementRate().Should().BeLessThan(tmr);
 }
예제 #2
0
 public CharacterWeaponInfo(WeaponSkill weapon, int rank, Character character)
 {
     ExceptionUtils.CheckArgumentNotNull(weapon);
     ExceptionUtils.CheckArgumentNotNull(character);
     _character = character;
     Weapon = weapon;
     Rank = rank;
 }
예제 #3
0
 public void AddLanguageToCharacter()
 {
     var c = new Character();
     c.Languages = new CharacterLanguageRanks(c);
     var language = new Language("foo");
     c.Languages.Add(language, 1, 2);
     c.Languages.Single().Language.Should().BeSameAs(language);
 }
예제 #4
0
        public static int ComputeStrikeChance(Character character, Weapon weapon)
        {
            ExceptionUtils.CheckArgumentNotNull(character);
            ExceptionUtils.CheckArgumentNotNull(weapon);
            var info = character.WeaponRanks.SingleOrDefault(i => i.Weapon == weapon.Skill);
            if (info != null)
            {
                return CompiledRankedStrikeChance.Value(character, weapon);
            }

            return CompiledUnrankedStrikeChance.Value(character, weapon);
        }
예제 #5
0
 public void AddLanguageToCharacterAtInitialization()
 {
     var language = new Language("foo");
     var c = new Character()
         {
             Languages =
                 {
                     { language, 1, 2 }
                 }
         };
     c.Languages.Single().Language.Should().BeSameAs(language);
 }
예제 #6
0
        public static int ComputeEffectiveAgility(Character character)
        {
            ExceptionUtils.CheckArgumentNotNull(character);
            decimal totalWeight = character.Inventory.GetWeightForSet(character.Inventory.EquiptedSetName);
            var agility = character.Agility;

            if (character.EquippedArmor != null)
            {
                agility += character.EquippedArmor.AgilityModifier;
            }

            agility += FatigueAndEncumberanceChart.Lookup(character.PhysicalStrength, totalWeight).AgilityModifier;

            return agility;
        }
예제 #7
0
        internal bool AddRanksForMeleeFighter(IList<WeaponSkill> possibilities, Character character)
        {
            var meleeWeapons = possibilities.Where(w => w.Use.HasFlag(WeaponKind.Melee)).ToArray();
            if (meleeWeapons.Length == 0)
            {
                return false;
            }

            var primaryWeapon = meleeWeapons[this._rand.Next(meleeWeapons.Length)];
            var ranksOfPrimary = this._rand.Next(primaryWeapon.MaxRank + 1);

            // TODO Consider eliminating really high / low ranks
            character.WeaponRanks.Add(primaryWeapon, ranksOfPrimary);

            // TODO Consider adding ranks to 1-2 secondary weapons
            return true;
        }
        public Character GenerateFromTemplate(NonPlayerCharacterTemplate template)
        {
            var character = new Character
                {
                    PhysicalStrength = this._characteristicGenerator.Generate(template.PhysicalStrengthRange),
                    ManualDexterity = this._characteristicGenerator.Generate(template.ManualDexterityRange),
                    Agility = this._characteristicGenerator.Generate(template.AgilityRange),
                    MagicalAptitude = this._characteristicGenerator.Generate(template.MagicalAptitudeRange),
                    Willpower = this._characteristicGenerator.Generate(template.WillpowerRange),
                    Endurance = this._characteristicGenerator.Generate(template.EnduranceRange),
                    Fatigue = this._characteristicGenerator.Generate(template.FatigueRange),
                    Perception = this._characteristicGenerator.Generate(template.PerceptionRange),
                    PhysicalBeauty = this._characteristicGenerator.Generate(template.PhysicalBeautyRange),
                    NaturalArmor = this._characteristicGenerator.Generate(template.NaturalArmorRange)
                };

            this._weaponChooser.ChooseWeapons(character);

            // TODO Other stuff

            return character;
        }
예제 #9
0
        public void ChooseWeapons(Character character)
        {
            ExceptionUtils.CheckArgumentNotNull(character);

            // Step 1: Make list of all possible weapons we could have ranks in based on the character's stats
            var possibilities = this.CreatePossibilities(character.PhysicalStrength, character.ManualDexterity);

            // Step 2: Choose an archtype and delegate
            //         Sometimes an archtype isn't possible due to eliminated weapons, so we try again if that happens
            var availibleArchtypes = _baseArchtypes.ToList();
            var success = false;

            while (!success)
            {
                if (availibleArchtypes.Count == 0)
                {
                    return;
                }

                var index = this._rand.Next(availibleArchtypes.Count);
                success = availibleArchtypes[index](possibilities, character);
                availibleArchtypes.RemoveAt(index);
            }
        }
예제 #10
0
 public void EffectiveAgilityShouldNotBeAffectedIfInventoryIsEmptyAndStrengthIsReasonably()
 {
     var c = new Character { Agility = 10, PhysicalStrength = 15 };
     CharacterEquations.ComputeEffectiveAgility(c).Should().Be(c.Agility);
 }
예제 #11
0
 public void EffectiveAgilityShouldBeAffectedByInventoryWeight()
 {
     var c = new Character { Agility = 10, PhysicalStrength = 10, Inventory = { new Item("Thing", 6m) } };
     CharacterEquations.ComputeEffectiveAgility(c).Should().BeLessThan(c.Agility);
 }
예제 #12
0
 public void DexterityAffectsStrikeChanceIfRanked()
 {
     var c = new Character { ManualDexterity = 20 };
     c.WeaponRanks[BatWeapon.Skill] = 0;
     CharacterEquations.ComputeStrikeChance(c, BatWeapon).Should().Be(50);
 }
예제 #13
0
 public void EffectOfWeightOnAgilityIsMoreForWeakerCharacter()
 {
     var c = new Character { Agility = 10, PhysicalStrength = 10, Inventory = { _heavyItem } };
     var withMediumStrength = CharacterEquations.ComputeEffectiveAgility(c);
     c.PhysicalStrength -= 5;
     CharacterEquations.ComputeEffectiveAgility(c).Should().BeLessThan(withMediumStrength);
 }
예제 #14
0
 public void BetterMagicalAptitudeShouldIncreaseSpellCastChance()
 {
     var c = new Character { MagicalAptitude = 20 };
     c.SpellRanks[this.fakeSpell] = 0;
     CharacterEquations.ComputeCastChance(c, this.fakeSpell).Should().Be(15);
 }
예제 #15
0
 public void SpellCastChanceShouldBeBaseChanceIfNotRankedOrGreatAtMagic()
 {
     var c = new Character { MagicalAptitude = 15 };
     c.SpellRanks[this.fakeSpell] = 0;
     CharacterEquations.ComputeCastChance(c, this.fakeSpell).Should().Be(10);
 }
예제 #16
0
 /// <summary>
 /// Construct a ViewModel for the specified character.
 /// </summary>
 public CharacterViewModel(Character c)
     : this()
 {
     Character = c;
 }
예제 #17
0
 public void CharacterCanBeInitializedWithItemInInventory()
 {
     var item = new Item("Fake item", 0);
     var character = new Character { Inventory = { item } };
     character.Inventory.Should().Contain(item);
 }
예제 #18
0
 public void RankAffectsStrikeChance()
 {
     var c = new Character { ManualDexterity = 0 };
     c.WeaponRanks[BatWeapon.Skill] = 3;
     CharacterEquations.ComputeStrikeChance(c, BatWeapon).Should().Be(42);
 }
예제 #19
0
 public void HigherRankShouldIncreaseSpellCastChance()
 {
     var c = new Character { MagicalAptitude = 15 };
     c.SpellRanks[this.fakeSpell] = 3;
     CharacterEquations.ComputeCastChance(c, this.fakeSpell).Should().Be(19);
 }
예제 #20
0
 public void HeavierItemsAffectAgilityMoreThanLightOnes()
 {
     var withHeavyItem = new Character { Agility = 10, PhysicalStrength = 10, Inventory = { _heavyItem } };
     var withDagger = new Character { Agility = 10, PhysicalStrength = 10, Inventory = { Items.Dagger } };
     CharacterEquations.ComputeEffectiveAgility(withHeavyItem).Should().BeLessThan(CharacterEquations.ComputeEffectiveAgility(withDagger));
 }
예제 #21
0
 public void ForUnrankedStrikeChanceIsJustBaseChance()
 {
     var c = new Character { ManualDexterity = 20 };
     // No ranks added to character
     CharacterEquations.ComputeStrikeChance(c, BatWeapon).Should().Be(30);
 }
예제 #22
0
 public static int ComputeCastChance(Character character, Spell spell)
 {
     ExceptionUtils.CheckArgumentNotNull(character);
     ExceptionUtils.CheckArgumentNotNull(spell);
     return CompiledCastChance.Value(character, spell);
 }
예제 #23
0
 public void StrikeChanceStartsWithBaseChanceIfRanked()
 {
     var c = new Character { ManualDexterity = 0 };
     c.WeaponRanks[BatWeapon.Skill] = 0;
     CharacterEquations.ComputeStrikeChance(c, BatWeapon).Should().Be(30);
 }
예제 #24
0
 public CharacterSpellInfo(Spell spell, int rank, Character character)
 {
     _character = character;
     Spell = spell;
     Rank = rank;
 }
예제 #25
0
 public void ArmorAffectsAgility()
 {
     var c = new Character { Agility = 10, PhysicalStrength = 15, EquippedArmor = new Armor("A straightjacket", -10, 0) };
     c.EffectiveAgility().Should().Be(0);
 }
예제 #26
0
 public void OtherWeaponsRanksDoNotAffectNonmatchingWeaponStrikeChance()
 {
     var c = new Character { ManualDexterity = 0 };
     c.WeaponRanks[new WeaponSkill("Foo", 10, WeaponKind.Melee, 1, 1, 1)] = 3;
     CharacterEquations.ComputeStrikeChance(c, BatWeapon).Should().Be(30);
 }
예제 #27
0
 public void EffectiveAgilityShouldUseCurrentlyEquiptedItemSet()
 {
     var c = new Character { Agility = 10, PhysicalStrength = 10, Inventory = { { new Item("Thing", 6m), "Combat" }, _heavyItem } };
     var withAllItems = CharacterEquations.ComputeEffectiveAgility(c);
     c.Inventory.EquiptedSetName = "Combat";
     var agilityWithSubsetOfItems = CharacterEquations.ComputeEffectiveAgility(c);
     agilityWithSubsetOfItems.Should().BeLessThan(c.Agility);
     agilityWithSubsetOfItems.Should().BeGreaterThan(withAllItems);
 }