Exemple #1
0
        public SkillSelection SelectFor(string skill)
        {
            var data = innerSelector.SelectFrom(TableNameConstants.Set.Collection.SkillData, skill);

            var selection = new SkillSelection();
            selection.BaseStatName = data.Single();

            return selection;
        }
 public void Setup()
 {
     selection = new SkillSelection();
 }
        public void IfCharacterDoesNotHaveBaseStat_CannotGetSkill()
        {
            classSkills.Add("skill 1");
            classSkills.Add("skill 2");
            crossClassSkills.Add("skill 3");
            crossClassSkills.Add("skill 4");
            specialistSkills.Add("skill 5");
            specialistSkills.Add("skill 6");

            var intelligenceSelection = new SkillSelection { BaseStatName = StatConstants.Intelligence };
            var constitutionSelection = new SkillSelection { BaseStatName = StatConstants.Constitution };
            mockSkillSelector.Setup(s => s.SelectFor("skill 1")).Returns(intelligenceSelection);
            mockSkillSelector.Setup(s => s.SelectFor("skill 3")).Returns(intelligenceSelection);
            mockSkillSelector.Setup(s => s.SelectFor("skill 5")).Returns(intelligenceSelection);
            mockSkillSelector.Setup(s => s.SelectFor("skill 2")).Returns(constitutionSelection);
            mockSkillSelector.Setup(s => s.SelectFor("skill 4")).Returns(constitutionSelection);
            mockSkillSelector.Setup(s => s.SelectFor("skill 6")).Returns(constitutionSelection);

            var skills = skillsGenerator.GenerateWith(characterClass, race, stats);
            Assert.That(skills.Keys, Contains.Item("skill 1"));
            Assert.That(skills.Keys, Contains.Item("skill 3"));
            Assert.That(skills.Keys, Contains.Item("skill 5"));
            Assert.That(skills.Keys, Is.All.Not.EqualTo("skill 2"));
            Assert.That(skills.Keys, Is.All.Not.EqualTo("skill 4"));
            Assert.That(skills.Keys, Is.All.Not.EqualTo("skill 6"));
            Assert.That(skills.Count, Is.EqualTo(3));
        }
        public void DoNotAssignSkillPointsToCrossClassSkillsThatTheCharacterDoesNotHaveDueToNotHavingTheBaseStat()
        {
            skillPoints[characterClass.Name] = 1;
            characterClass.Level = 2;

            crossClassSkills.Add("skill 3");
            crossClassSkills.Add("skill 4");

            var intelligenceSelection = new SkillSelection { BaseStatName = StatConstants.Intelligence };
            var constitutionSelection = new SkillSelection { BaseStatName = StatConstants.Constitution };
            mockSkillSelector.Setup(s => s.SelectFor("skill 3")).Returns(intelligenceSelection);
            mockSkillSelector.Setup(s => s.SelectFor("skill 4")).Returns(constitutionSelection);

            mockBooleanPercentileSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.TrueOrFalse.AssignPointToCrossClassSkill))
                .Returns(true);
            mockCollectionsSelector.SetupSequence(s => s.SelectRandomFrom(It.Is<IEnumerable<string>>(ss => ss.Count() == 1)))
                .Returns("skill 3")
                .Returns("skill 3")
                .Returns("skill 3")
                .Returns("skill 3")
                .Returns("skill 3");

            var skills = skillsGenerator.GenerateWith(characterClass, race, stats);

            Assert.That(skills["skill 3"].Ranks, Is.EqualTo(5));
            Assert.That(skills["skill 3"].EffectiveRanks, Is.EqualTo(2.5));
        }
        public void DoNotAssignMonsterSkillPointsToMonsterSkillsIfCharacterDoesNotHaveRequiredBaseStat()
        {
            race.BaseRace = "baserace";
            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.BaseRaceGroups, GroupConstants.Monsters))
                .Returns(new[] { "baserace", "otherbaserace" });

            characterClass.Level = 20;
            skillPoints[characterClass.Name] = 0;
            stats[StatConstants.Intelligence].Value = 10;

            var monsterClassSkills = new List<string>();
            monsterClassSkills.Add("skill 1");
            monsterClassSkills.Add("skill 2");
            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.ClassSkills, race.BaseRace)).Returns(monsterClassSkills);

            var intelligenceSelection = new SkillSelection { BaseStatName = StatConstants.Intelligence };
            var constitutionSelection = new SkillSelection { BaseStatName = StatConstants.Constitution };
            mockSkillSelector.Setup(s => s.SelectFor("skill 1")).Returns(constitutionSelection);
            mockSkillSelector.Setup(s => s.SelectFor("skill 2")).Returns(intelligenceSelection);

            var monsterHitDice = new Dictionary<string, int>();
            monsterHitDice["monster"] = 1234;
            monsterHitDice[race.BaseRace] = 2;
            mockAdjustmentsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Adjustments.MonsterHitDice)).Returns(monsterHitDice);

            var skills = skillsGenerator.GenerateWith(characterClass, race, stats);
            Assert.That(skills["skill 2"].Ranks, Is.EqualTo(5));
            Assert.That(skills["skill 2"].RanksMaxedOut, Is.True);
            Assert.That(skills.Keys, Is.All.Not.EqualTo("skill 1"));
            Assert.That(skills.Count, Is.EqualTo(1));
        }
        public void AssignStatsToSkills()
        {
            classSkills.Add("class skill");
            crossClassSkills.Add("cross class skill");
            specialistSkills.Add("specialist skill");

            var classSkillSelection = new SkillSelection();
            classSkillSelection.BaseStatName = "stat 1";

            var crossClassSkillSelection = new SkillSelection();
            crossClassSkillSelection.BaseStatName = "stat 2";

            var specialistSkillSelection = new SkillSelection();
            specialistSkillSelection.BaseStatName = "stat 3";

            mockSkillSelector.Setup(s => s.SelectFor("class skill")).Returns(classSkillSelection);
            mockSkillSelector.Setup(s => s.SelectFor("cross class skill")).Returns(crossClassSkillSelection);
            mockSkillSelector.Setup(s => s.SelectFor("specialist skill")).Returns(specialistSkillSelection);

            stats["stat 1"] = new Stat("stat 1");
            stats["stat 2"] = new Stat("stat 2");
            stats["stat 3"] = new Stat("stat 3");

            var skills = skillsGenerator.GenerateWith(characterClass, race, stats);
            Assert.That(skills["class skill"].BaseStat, Is.EqualTo(stats["stat 1"]));
            Assert.That(skills["cross class skill"].BaseStat, Is.EqualTo(stats["stat 2"]));
            Assert.That(skills["specialist skill"].BaseStat, Is.EqualTo(stats["stat 3"]));
        }
        public void Setup()
        {
            mockAdjustmentsSelector = new Mock<IAdjustmentsSelector>();
            mockCollectionsSelector = new Mock<ICollectionsSelector>();
            mockSkillSelector = new Mock<ISkillSelector>();
            mockBooleanPercentileSelector = new Mock<IBooleanPercentileSelector>();
            skillsGenerator = new SkillsGenerator(mockSkillSelector.Object, mockCollectionsSelector.Object, mockAdjustmentsSelector.Object,
                mockBooleanPercentileSelector.Object);
            characterClass = new CharacterClass();
            stats = new Dictionary<string, Stat>();
            classSkills = new List<string>();
            crossClassSkills = new List<string>();
            stats[StatConstants.Intelligence] = new Stat(StatConstants.Intelligence);
            race = new Race();
            specialistSkills = new List<string>();
            allSkills = new List<string>();

            characterClass.Name = "class name";
            characterClass.Level = 5;
            characterClass.SpecialistFields = new[] { "specialist field" };

            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.ClassSkills, "class name")).Returns(classSkills);
            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.CrossClassSkills, "class name")).Returns(crossClassSkills);
            var selection = new SkillSelection { BaseStatName = StatConstants.Intelligence };
            mockSkillSelector.Setup(s => s.SelectFor(It.IsAny<string>())).Returns(selection);

            var emptyAdjustments = new Dictionary<string, int>();
            mockAdjustmentsSelector.Setup(s => s.SelectFrom(It.IsAny<string>())).Returns(emptyAdjustments);

            skillPoints = new Dictionary<string, int>();
            skillPoints[characterClass.Name] = 0;
            mockAdjustmentsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Adjustments.SkillPointsForClasses)).Returns(skillPoints);
            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.SkillGroups, "specialist field")).Returns(specialistSkills);
            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.SkillGroups, GroupConstants.Skills)).Returns(allSkills);
            mockCollectionsSelector.Setup(s => s.SelectRandomFrom(It.IsAny<IEnumerable<string>>())).Returns((IEnumerable<string> ss) => ss.First());
        }