public Bonus(Character character, BonusCalculator bonusCalculator, string condition)
            {
                _character = character;
                _bonusCalculator = bonusCalculator;

                Condition = condition;
            }
        public void TestConditionalValues()
        {
            var masterValuesTable = new List<MasterValueRecord>();
            masterValuesTable.Add(new MasterValueRecord() { Score = 1, PassiveModifier = 2 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 2, PassiveModifier = 4 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 3, PassiveModifier = 6 });

            var character = new Character(masterValuesTable);

            var bonusSource = new BonusSource(character, "Test");

            bonusSource.AddBonus("when foo", 2);
            bonusSource.AddBonus("when foo", 3);

            bonusSource.AddBonus("when bar", 1);

            IReadOnlyDictionary<string, int> actual = bonusSource.ConditionalValues;
            var expected = new Dictionary<string, int>()
            {
                {"when foo", 3},
                {"when bar", 1}
            };

            Assert.That(actual, Is.EquivalentTo(expected));
        }
Exemple #3
0
 public SkillScore(Character character, Skill skill, uint ranks = 0, IEnumerable<string> foci = null)
     : base(ranks, null)
 {
     Skill = skill;
     AttributeScore = character.GetAttributeScore(skill.PrimaryAttribute);
     Foci = new HashSet<string>(foci ?? new string[] { });
 }
        public void TestGetAttributeScore()
        {
            var masterValuesTable = new List<MasterValueRecord>();
            masterValuesTable.Add(new MasterValueRecord() { Score = 1, PassiveModifier = 2 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 2, PassiveModifier = 4 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 3, PassiveModifier = 6 });

            var character = new Character(masterValuesTable);

            var cases = new Dictionary<Attributes, Func<Character, AttributeScore>>()
            {
                { Attributes.Might, c => c.Might },
                { Attributes.Prowess, c => c.Prowess },
                { Attributes.Quickness, c => c.Quickness },
                { Attributes.Vigor, c => c.Vigor },
                { Attributes.Charisma, c => c.Charisma },
                { Attributes.Insight, c => c.Insight },
                { Attributes.Logic, c => c.Logic },
                { Attributes.Resolve, c => c.Resolve },
            };

            foreach (var kvp in cases)
            {
                Assert.That(kvp.Value(character), Is.EqualTo(character.GetAttributeScore(kvp.Key)));
            }
        }
        public void Reload()
        {
            if (FileName == null)
            {
                _character = new Character(_masterValuesTable);
                return;
            }

            var contents = File.ReadAllText(FileName);

            _character = JsonConvert.DeserializeObject<Character>(contents, _converter);
        }
        public BonusSource(Character character, string name, BonusCalculator calculator = null)
        {
            Name = name;

            _character = character;
            _bonuses = new List<Bonus>();

            if (calculator != null)
            {
                AddBonus(calculator);
            }
        }
        private void SyncSkills(Character character, IEnumerable<SkillListing> skillListings)
        {
            var charSkillKeys = character.SkillScores.Select(s => s.Skill.CompoundKey);
            var missingSkills = from s in skillListings.SelectMany(s => s.GetSkills())
                                where !charSkillKeys.Contains(s.CompoundKey)
                                select new SkillScore(character, s);

            foreach (var skill in missingSkills)
            {
                character.SkillScores.Add(skill);
            }
        }
        public void TestValueWhenEmpty()
        {
            var masterValuesTable = new List<MasterValueRecord>();
            masterValuesTable.Add(new MasterValueRecord() { Score = 1, PassiveModifier = 2 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 2, PassiveModifier = 4 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 3, PassiveModifier = 6 });

            var character = new Character(masterValuesTable);

            var bonusSource = new BonusSource(character, "Test");

            Assert.That(bonusSource.Value, Is.EqualTo(0));
        }
        public void TestPassiveValue()
        {
            var masterValuesTable = new List<MasterValueRecord>();
            masterValuesTable.Add(new MasterValueRecord() { Score = 1, PassiveModifier = 2 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 2, PassiveModifier = 4 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 3, PassiveModifier = 6 });

            var character = new Character(masterValuesTable) { Quickness = { Ranks = 3 } };

            var skillScore = new SkillScore(
                character,
                new Skill("foo", "Foo", Attributes.Quickness),
                3);
            
            Assert.That(skillScore.PassiveValue, Is.EqualTo(21), "Should be 12 + attribute passive + skill ranks");
        }
        public void TestAvoidance()
        {
            var masterValuesTable = new List<MasterValueRecord>();
            masterValuesTable.Add(new MasterValueRecord() { Score = 1, PassiveModifier = 2 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 2, PassiveModifier = 4 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 3, PassiveModifier = 6 });

            var character = new Character(masterValuesTable)
                                {
                                    Prowess = { Ranks = 2 },
                                    Insight = { Ranks = 3 },
                                };

            Assert.That(
                character.Avoidance.TotalScore,
                Is.EqualTo(22),
                "Avoidance should be 12 + Prowess passive + Insight passive.");
        }
        public void TestFortitude()
        {
            var masterValuesTable = new List<MasterValueRecord>();
            masterValuesTable.Add(new MasterValueRecord() { Score = 1, PassiveModifier = 2 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 2, PassiveModifier = 4 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 3, PassiveModifier = 6 });

            var character = new Character(masterValuesTable)
            {
                Might = { Ranks = 1 },
                Vigor = { Ranks = 1 },
            };

            Assert.That(
                character.Fortitude.TotalScore,
                Is.EqualTo(16),
                "Fortitude should be 12 + Might passive + Vigor passive.");
        }
        public void TestPace()
        {
            var masterValuesTable = new List<MasterValueRecord>();
            masterValuesTable.Add(new MasterValueRecord() { Score = 1, PassiveModifier = 2 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 2, PassiveModifier = 4 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 3, PassiveModifier = 6 });

            var character = new Character(masterValuesTable)
            {
                Quickness = { Ranks = 2 },
            };

            Assert.That(character.Pace.TotalScore, Is.EqualTo(4), "Pace should be Quickness passive");
        }
        public void TestIntitiative()
        {
            var masterValuesTable = new List<MasterValueRecord>();
            masterValuesTable.Add(new MasterValueRecord() { Score = 1, PassiveModifier = 2 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 2, PassiveModifier = 4 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 3, PassiveModifier = 6 });

            var character = new Character(masterValuesTable)
            {
                Quickness = { Ranks = 3 },
            };

            Assert.That(
                character.InitiativeRoll,
                Is.EqualTo(new DiceRoll(d10: 6)),
                "Initiative should be Quickness passive d10s");
        }
Exemple #14
0
 public Bonus(Character character, BonusCalculator bonusCalculator)
     : this(character, bonusCalculator, string.Empty)
 {
 }
        public void TestWounds()
        {
            var masterValuesTable = new List<MasterValueRecord>();
            masterValuesTable.Add(new MasterValueRecord() { Score = 1, PassiveModifier = 2 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 2, PassiveModifier = 4 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 3, PassiveModifier = 6 });

            var character = new Character(masterValuesTable)
            {
                Vigor = { Ranks = 1 },
            };

            Assert.That(character.Wounds.TotalScore, Is.EqualTo(3), "Wounds should be Vigor passive + 1");
        }
        public void TestStamina()
        {
            var masterValuesTable = new List<MasterValueRecord>();
            masterValuesTable.Add(new MasterValueRecord() { Score = 1, PassiveModifier = 2 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 2, PassiveModifier = 4 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 3, PassiveModifier = 6 });

            var character = new Character(masterValuesTable)
            {
                Prowess = { Ranks = 2 },
                Insight = { Ranks = 3 },

                Might = { Ranks = 1 },
                Vigor = { Ranks = 1 },

                Charisma = { Ranks = 2 },
                Resolve = { Ranks = 2 },
            };

            Assert.That(
                character.Avoidance.TotalScore,
                Is.EqualTo(22),
                "Avoidance should be 12 + Prowess passive + Insight passive.");

            Assert.That(
                character.Fortitude.TotalScore,
                Is.EqualTo(16),
                "Fortitude should be 12 + Might passive + Vigor passive.");

            Assert.That(
                character.Discipline.TotalScore,
                Is.EqualTo(20),
                "Discipline should be 12 + Charisma passive + Resolve passive.");

            Assert.That(character.Stamina.TotalScore, Is.EqualTo(58), "Stamina should be Avoidance + Fortitude + Discipline");
        }
        public void TestDiscipline()
        {
            var masterValuesTable = new List<MasterValueRecord>();
            masterValuesTable.Add(new MasterValueRecord() { Score = 1, PassiveModifier = 2 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 2, PassiveModifier = 4 });
            masterValuesTable.Add(new MasterValueRecord() { Score = 3, PassiveModifier = 6 });

            var character = new Character(masterValuesTable)
            {
                Charisma = { Ranks = 2 },
                Resolve = { Ranks = 2 },
            };

            Assert.That(
                character.Discipline.TotalScore,
                Is.EqualTo(20),
                "Discipline should be 12 + Charisma passive + Resolve passive.");
        }