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); }
public CharacterWeaponInfo(WeaponSkill weapon, int rank, Character character) { ExceptionUtils.CheckArgumentNotNull(weapon); ExceptionUtils.CheckArgumentNotNull(character); _character = character; Weapon = weapon; Rank = rank; }
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); }
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); }
public void AddLanguageToCharacterAtInitialization() { var language = new Language("foo"); var c = new Character() { Languages = { { language, 1, 2 } } }; c.Languages.Single().Language.Should().BeSameAs(language); }
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; }
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; }
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); } }
public void EffectiveAgilityShouldNotBeAffectedIfInventoryIsEmptyAndStrengthIsReasonably() { var c = new Character { Agility = 10, PhysicalStrength = 15 }; CharacterEquations.ComputeEffectiveAgility(c).Should().Be(c.Agility); }
public void EffectiveAgilityShouldBeAffectedByInventoryWeight() { var c = new Character { Agility = 10, PhysicalStrength = 10, Inventory = { new Item("Thing", 6m) } }; CharacterEquations.ComputeEffectiveAgility(c).Should().BeLessThan(c.Agility); }
public void DexterityAffectsStrikeChanceIfRanked() { var c = new Character { ManualDexterity = 20 }; c.WeaponRanks[BatWeapon.Skill] = 0; CharacterEquations.ComputeStrikeChance(c, BatWeapon).Should().Be(50); }
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); }
public void BetterMagicalAptitudeShouldIncreaseSpellCastChance() { var c = new Character { MagicalAptitude = 20 }; c.SpellRanks[this.fakeSpell] = 0; CharacterEquations.ComputeCastChance(c, this.fakeSpell).Should().Be(15); }
public void SpellCastChanceShouldBeBaseChanceIfNotRankedOrGreatAtMagic() { var c = new Character { MagicalAptitude = 15 }; c.SpellRanks[this.fakeSpell] = 0; CharacterEquations.ComputeCastChance(c, this.fakeSpell).Should().Be(10); }
/// <summary> /// Construct a ViewModel for the specified character. /// </summary> public CharacterViewModel(Character c) : this() { Character = c; }
public void CharacterCanBeInitializedWithItemInInventory() { var item = new Item("Fake item", 0); var character = new Character { Inventory = { item } }; character.Inventory.Should().Contain(item); }
public void RankAffectsStrikeChance() { var c = new Character { ManualDexterity = 0 }; c.WeaponRanks[BatWeapon.Skill] = 3; CharacterEquations.ComputeStrikeChance(c, BatWeapon).Should().Be(42); }
public void HigherRankShouldIncreaseSpellCastChance() { var c = new Character { MagicalAptitude = 15 }; c.SpellRanks[this.fakeSpell] = 3; CharacterEquations.ComputeCastChance(c, this.fakeSpell).Should().Be(19); }
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)); }
public void ForUnrankedStrikeChanceIsJustBaseChance() { var c = new Character { ManualDexterity = 20 }; // No ranks added to character CharacterEquations.ComputeStrikeChance(c, BatWeapon).Should().Be(30); }
public static int ComputeCastChance(Character character, Spell spell) { ExceptionUtils.CheckArgumentNotNull(character); ExceptionUtils.CheckArgumentNotNull(spell); return CompiledCastChance.Value(character, spell); }
public void StrikeChanceStartsWithBaseChanceIfRanked() { var c = new Character { ManualDexterity = 0 }; c.WeaponRanks[BatWeapon.Skill] = 0; CharacterEquations.ComputeStrikeChance(c, BatWeapon).Should().Be(30); }
public CharacterSpellInfo(Spell spell, int rank, Character character) { _character = character; Spell = spell; Rank = rank; }
public void ArmorAffectsAgility() { var c = new Character { Agility = 10, PhysicalStrength = 15, EquippedArmor = new Armor("A straightjacket", -10, 0) }; c.EffectiveAgility().Should().Be(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); }
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); }