Exemplo n.º 1
0
        public Bonus(Character character, string source, BonusCalculator bonusCalculator)
        {
            Source = source;

            _character = character;
            _bonusCalculator = bonusCalculator;
        }
Exemplo n.º 2
0
        public void TestStaticValue()
        {
            var character = new Character();
            
            var bonus = new Bonus(character, "test", 2);

            Assert.That(bonus.Value, Is.EqualTo(2));
        }
Exemplo n.º 3
0
        public BonusType(Character character, string name, bool stacks = false)
        {
            Name = name;
            Stacks = stacks;

            _character = character;
            _bonuses = new Dictionary<string, Bonus>();
        }
Exemplo n.º 4
0
        public void TestDerivedValue()
        {
            var character = new Character { Dexterity = { Ranks = 16 } };

            var bonus = new Bonus(character, "test", c => c.Dexterity.Modifier);

            Assert.That(bonus.Value, Is.EqualTo(3));
        }
Exemplo n.º 5
0
        public void TestCanUse(bool canUseUntrained, uint ranks, bool expectedCanUse)
        {
            var character = new Character();

            var skill = new Skill("test", "Test", Abilities.Wisdom, canUseUntrained);
            var skillScore = new SkillScore(character, skill, ranks);

            Assert.That(skillScore.CanUse, Is.EqualTo(expectedCanUse));
        }
Exemplo n.º 6
0
 protected RankBasedScore(
     Character character,
     uint ranks, 
     IEnumerable<string> bonusNames,
     IEnumerable<string> stackingBonusNames)
     : base(character, bonusNames, stackingBonusNames)
 {
     Ranks = ranks;
 }
Exemplo n.º 7
0
        public void TestScore()
        {
            var character = new Character { Intelligence = { Ranks = 12 } };

            var skill = new Skill("test", "Test", Abilities.Intelligence, true);
            var skillScore = new SkillScore(character, skill, 2);

            Assert.That(character.Intelligence.Modifier, Is.EqualTo(1));
            Assert.That(skillScore.BaseScore, Is.EqualTo(3));
        }
Exemplo n.º 8
0
        public void TestValue(int bonus1, int bonus2, bool stacks, int expectedValue)
        {
            var character = new Character();

            var bonusType = new BonusType(character, "Test", stacks);

            bonusType.AddBonus("Test 1", bonus1);
            bonusType.AddBonus("Test 2", bonus2);

            Assert.That(bonusType.Value, Is.EqualTo(expectedValue));
        }
Exemplo n.º 9
0
        protected Score(Character character, IEnumerable<string> bonusNames, IEnumerable<string> stackingBonusNames)
        {
            bonusNames = bonusNames ?? new string[] { };
            stackingBonusNames = stackingBonusNames ?? new string[] { };

            var nonStackingBonusTypes = bonusNames.Select(bonusName => new BonusType(character, bonusName));
            var stackingBonusTypes = stackingBonusNames.Select(bonusName => new BonusType(character, bonusName, true));
            
            var bonusTypes = nonStackingBonusTypes.Union(stackingBonusTypes).ToDictionary(bonusType => bonusType.Name);

            BonusTypes = new ReadOnlyDictionary<string, BonusType>(bonusTypes);
        }
Exemplo n.º 10
0
        public void SaveCharacter(Character character)
        {
            if (FileName == null)
            {
                FileName = Path.Combine(_characterDirectory, character.Name + ".json");
            }

            if (!Directory.Exists(_characterDirectory))
            {
                Directory.CreateDirectory(_characterDirectory);
            }

            var contents = JsonConvert.SerializeObject(character, _converter);

            File.WriteAllText(FileName, contents);
        }
Exemplo n.º 11
0
 public Bonus(Character character, string source, int value)
     : this(character, source, StaticValue(value))
 {
 }
Exemplo n.º 12
0
 public ArmorClass(Character character)
     : base(character, 10, new[] { "DEX", "Deflection", "Armor", "Shield", "Natural Armor", "Size" }, new[] { "Dodge" })
 {
 }
Exemplo n.º 13
0
 public SkillScore(Character character, Skill skill, uint ranks = 0)
     : base(character, ranks, new[] { "Class Skill", "Race" }, null)
 {
     AbilityScore = character.GetAttributeScore(skill.Ability);
     Skill = skill;
 }
Exemplo n.º 14
0
 protected DerivedScore(Character character, int baseScore, IEnumerable<string> bonusNames, IEnumerable<string> stackingBonusNames) : base(character, bonusNames, stackingBonusNames)
 {
     _baseScore = baseScore;
 }
Exemplo n.º 15
0
 public AbilityScore(Character character, Abilities ability, uint ranks = 10)
     : base(character, ranks, new[] { "Race" }, null)
 {
     Ability = ability;
 }