Beispiel #1
0
        public IEnumerable<RacialFeatSelection> SelectRacial(string race)
        {
            var racialFeats = collectionsSelector.SelectFrom(TableNameConstants.Set.Collection.FeatGroups, race);
            var racialFeatSelections = new List<RacialFeatSelection>();

            foreach (var racialFeat in racialFeats)
            {
                var tableName = string.Format(TableNameConstants.Formattable.Collection.RACEFeatData, race);
                var featData = collectionsSelector.SelectFrom(tableName, racialFeat).ToArray();

                var racialFeatSelection = new RacialFeatSelection();
                racialFeatSelection.Feat = featData[DataIndexConstants.RacialFeatData.FeatNameIndex];
                racialFeatSelection.SizeRequirement = featData[DataIndexConstants.RacialFeatData.SizeRequirementIndex];
                racialFeatSelection.Power = Convert.ToInt32(featData[DataIndexConstants.RacialFeatData.PowerIndex]);
                racialFeatSelection.MinimumHitDieRequirement = Convert.ToInt32(featData[DataIndexConstants.RacialFeatData.MinimumHitDiceRequirementIndex]);
                racialFeatSelection.FocusType = featData[DataIndexConstants.RacialFeatData.FocusIndex];
                racialFeatSelection.Frequency.Quantity = Convert.ToInt32(featData[DataIndexConstants.RacialFeatData.FrequencyQuantityIndex]);
                racialFeatSelection.Frequency.TimePeriod = featData[DataIndexConstants.RacialFeatData.FrequencyTimePeriodIndex];
                racialFeatSelection.MaximumHitDieRequirement = Convert.ToInt32(featData[DataIndexConstants.RacialFeatData.MaximumHitDiceRequirementIndex]);

                var statNames = featData[DataIndexConstants.RacialFeatData.RequiredStatIndex].Split(',');
                var statValue = Convert.ToInt32(featData[DataIndexConstants.RacialFeatData.RequiredStatMinimumValueIndex]);

                if (string.IsNullOrEmpty(statNames[0]) == false)
                    for (var i = 0; i < statNames.Length; i++)
                        racialFeatSelection.MinimumStats[statNames[i]] = statValue;

                racialFeatSelections.Add(racialFeatSelection);
            }

            return racialFeatSelections;
        }
        public void DoNotAddMonsterHitDiceToPower()
        {
            var baseRaceFeatSelection = new RacialFeatSelection();
            baseRaceFeatSelection.Feat = "different feat";
            baseRaceFeatSelection.Power = 2;
            baseRaceFeats.Add(baseRaceFeatSelection);

            var metaraceFeat = new RacialFeatSelection();
            metaraceFeat.Feat = "metarace feat";
            metaraceFeat.Power = 10;
            metaraceFeats.Add(metaraceFeat);

            var speciesFeatSelection = new RacialFeatSelection();
            speciesFeatSelection.Feat = "different feat";
            speciesFeatSelection.Power = 3;
            speciesFeats.Add(speciesFeatSelection);

            var monsterHitDice = new Dictionary<string, int>();
            monsterHitDice[race.BaseRace] = 2;
            mockAdjustmentsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Adjustments.MonsterHitDice)).Returns(monsterHitDice);
            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.BaseRaceGroups, GroupConstants.Monsters)).Returns(new[] { race.BaseRace });
            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.FeatGroups, GroupConstants.AddMonsterHitDiceToPower)).Returns(new[] { "different feat" });

            var feats = racialFeatsGenerator.GenerateWith(race, skills, stats);
            var first = feats.First();
            var second = feats.ElementAt(1);
            var third = feats.Last();

            Assert.That(first.Name, Is.EqualTo("different feat"));
            Assert.That(first.Power, Is.EqualTo(2));
            Assert.That(second.Name, Is.EqualTo("metarace feat"));
            Assert.That(second.Power, Is.EqualTo(10));
            Assert.That(third.Name, Is.EqualTo("different feat"));
            Assert.That(third.Power, Is.EqualTo(3));
        }
        public void AddMonsterHitDiceToPower()
        {
            var metaraceFeat = new RacialFeatSelection();
            metaraceFeat.Feat = "metarace feat";
            metaraceFeat.Power = 10;
            metaraceFeats.Add(metaraceFeat);

            var monsterHitDice = new Dictionary<string, int>();
            monsterHitDice[race.BaseRace] = 2;
            mockAdjustmentsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Adjustments.MonsterHitDice)).Returns(monsterHitDice);
            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.BaseRaceGroups, GroupConstants.Monsters)).Returns(new[] { race.BaseRace });
            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.FeatGroups, GroupConstants.AddMonsterHitDiceToPower)).Returns(new[] { metaraceFeat.Feat });

            var feats = racialFeatsGenerator.GenerateWith(race, skills, stats);
            var onlyFeat = feats.Single();

            Assert.That(onlyFeat.Name, Is.EqualTo("metarace feat"));
            Assert.That(onlyFeat.Power, Is.EqualTo(12));
        }
        public void Setup()
        {
            selection = new RacialFeatSelection();
            race = new Race();
            stats = new Dictionary<string, Stat>();

            stats["stat"] = new Stat("stat");
            stats["stat"].Value = 42;
        }
        public void DoNotGetEmptyFoci()
        {
            var baseRaceFeatSelection = new RacialFeatSelection();
            baseRaceFeatSelection.Feat = "racial feat";
            baseRaceFeatSelection.FocusType = string.Empty;
            baseRaceFeats.Add(baseRaceFeatSelection);

            var metaraceFeatSelection = new RacialFeatSelection();
            metaraceFeatSelection.Feat = "metarace feat";
            metaraceFeatSelection.FocusType = string.Empty;
            metaraceFeats.Add(metaraceFeatSelection);

            var speciesFeatSelection = new RacialFeatSelection();
            speciesFeatSelection.Feat = "metarace species feat";
            speciesFeatSelection.FocusType = string.Empty;
            speciesFeats.Add(speciesFeatSelection);

            mockFeatFocusGenerator.Setup(g => g.GenerateAllowingFocusOfAllFrom("racial feat", string.Empty, skills)).Returns(string.Empty);
            mockFeatFocusGenerator.Setup(g => g.GenerateAllowingFocusOfAllFrom("metarace feat", string.Empty, skills)).Returns(string.Empty);
            mockFeatFocusGenerator.Setup(g => g.GenerateAllowingFocusOfAllFrom("metarace species feat", string.Empty, skills)).Returns(string.Empty);

            var feats = racialFeatsGenerator.GenerateWith(race, skills, stats);
            var baseFeat = feats.First(f => f.Name == baseRaceFeatSelection.Feat);
            var metaFeat = feats.First(f => f.Name == metaraceFeatSelection.Feat);
            var speciesFeat = feats.First(f => f.Name == speciesFeatSelection.Feat);

            Assert.That(baseFeat.Foci, Is.Empty);
            Assert.That(metaFeat.Foci, Is.Empty);
            Assert.That(speciesFeat.Foci, Is.Empty);
        }
        public void IfNotMonster_Add1ToPower()
        {
            var metaraceFeat = new RacialFeatSelection();
            metaraceFeat.Feat = "metarace feat";
            metaraceFeat.Power = 10;
            metaraceFeats.Add(metaraceFeat);

            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.BaseRaceGroups, GroupConstants.Monsters)).Returns(new[] { "monster" });
            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.FeatGroups, GroupConstants.AddMonsterHitDiceToPower)).Returns(new[] { metaraceFeat.Feat });

            var feats = racialFeatsGenerator.GenerateWith(race, skills, stats);
            var onlyFeat = feats.Single();

            Assert.That(onlyFeat.Name, Is.EqualTo("metarace feat"));
            Assert.That(onlyFeat.Power, Is.EqualTo(11));
        }
        public void NonMonstersHaveOneMonsterHitDieForSakeOfHitDiceRequirements()
        {
            var baseRaceFeat = new RacialFeatSelection();
            baseRaceFeat.Feat = "racial feat";
            baseRaceFeat.MinimumHitDieRequirement = 1;
            baseRaceFeats.Add(baseRaceFeat);

            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.BaseRaceGroups, GroupConstants.Monsters)).Returns(new[] { "other base race" });

            var feats = racialFeatsGenerator.GenerateWith(race, skills, stats);
            var onlyFeat = feats.Single();

            Assert.That(onlyFeat.Name, Is.EqualTo("racial feat"));
            mockAdjustmentsSelector.Verify(s => s.SelectFrom(TableNameConstants.Set.Adjustments.MonsterHitDice), Times.Never);
        }
        public void GetRacialFeatThatMeetRequirements()
        {
            var baseRaceFeat = new RacialFeatSelection();
            baseRaceFeat.Feat = "base race feat";
            baseRaceFeat.MinimumHitDieRequirement = 2;
            baseRaceFeats.Add(baseRaceFeat);

            var metaraceFeat = new RacialFeatSelection();
            metaraceFeat.Feat = "metarace feat";
            metaraceFeat.SizeRequirement = "size";
            metaraceFeats.Add(metaraceFeat);

            var speciesFeat = new RacialFeatSelection();
            speciesFeat.Feat = "metarace species feat";
            speciesFeat.MinimumStats["stat"] = 14;
            speciesFeats.Add(speciesFeat);

            race.Size = "size";

            var monsterHitDice = new Dictionary<string, int>();
            monsterHitDice[race.BaseRace] = 2;
            mockAdjustmentsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Adjustments.MonsterHitDice)).Returns(monsterHitDice);
            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.BaseRaceGroups, GroupConstants.Monsters)).Returns(new[] { race.BaseRace });

            var feats = racialFeatsGenerator.GenerateWith(race, skills, stats);
            Assert.That(feats.Count(), Is.EqualTo(3));
        }
        public void GetMetaracialSpeciesFeats()
        {
            var feat1 = new RacialFeatSelection();
            feat1.Feat = "metarace species feat 1";

            var feat2 = new RacialFeatSelection();
            feat2.Feat = "metarace species feat 2";
            feat2.Power = 9266;
            feat2.Frequency.Quantity = 42;
            feat2.Frequency.TimePeriod = "fortnight";

            speciesFeats.Add(feat1);
            speciesFeats.Add(feat2);

            var feats = racialFeatsGenerator.GenerateWith(race, skills, stats);
            var first = feats.First();
            var last = feats.Last();

            Assert.That(first.Name, Is.EqualTo("metarace species feat 1"));
            Assert.That(first.Power, Is.EqualTo(0));
            Assert.That(first.Frequency.Quantity, Is.EqualTo(0));
            Assert.That(first.Frequency.TimePeriod, Is.Empty);

            Assert.That(last.Name, Is.EqualTo("metarace species feat 2"));
            Assert.That(last.Power, Is.EqualTo(9266));
            Assert.That(last.Frequency.Quantity, Is.EqualTo(42));
            Assert.That(last.Frequency.TimePeriod, Is.EqualTo("fortnight"));
        }
        public void GetFociForFeat()
        {
            var baseRaceFeatSelection = new RacialFeatSelection();
            baseRaceFeatSelection.Feat = "racial feat";
            baseRaceFeatSelection.FocusType = "base focus type";
            baseRaceFeats.Add(baseRaceFeatSelection);

            var metaraceFeatSelection = new RacialFeatSelection();
            metaraceFeatSelection.Feat = "metarace feat";
            metaraceFeatSelection.FocusType = "meta focus type";
            metaraceFeats.Add(metaraceFeatSelection);

            var speciesFeatSelection = new RacialFeatSelection();
            speciesFeatSelection.Feat = "metarace species feat";
            speciesFeatSelection.FocusType = "species focus type";
            speciesFeats.Add(speciesFeatSelection);

            mockFeatFocusGenerator.Setup(g => g.GenerateAllowingFocusOfAllFrom("racial feat", "base focus type", skills)).Returns("base focus");
            mockFeatFocusGenerator.Setup(g => g.GenerateAllowingFocusOfAllFrom("metarace feat", "meta focus type", skills)).Returns("meta focus");
            mockFeatFocusGenerator.Setup(g => g.GenerateAllowingFocusOfAllFrom("metarace species feat", "species focus type", skills)).Returns("species focus");

            var feats = racialFeatsGenerator.GenerateWith(race, skills, stats);
            var baseFeat = feats.First(f => f.Name == baseRaceFeatSelection.Feat);
            var metaFeat = feats.First(f => f.Name == metaraceFeatSelection.Feat);
            var speciesFeat = feats.First(f => f.Name == speciesFeatSelection.Feat);

            Assert.That(baseFeat.Foci.Single(), Is.EqualTo("base focus"));
            Assert.That(metaFeat.Foci.Single(), Is.EqualTo("meta focus"));
            Assert.That(speciesFeat.Foci.Single(), Is.EqualTo("species focus"));
        }
        public void GetAllRacialFeats()
        {
            var baseRaceFeat = new RacialFeatSelection();
            baseRaceFeat.Feat = "base race feat";
            baseRaceFeats.Add(baseRaceFeat);

            var metaraceFeat = new RacialFeatSelection();
            metaraceFeat.Feat = "metarace feat";
            metaraceFeats.Add(metaraceFeat);

            var speciesFeat = new RacialFeatSelection();
            speciesFeat.Feat = "metarace species feat";
            speciesFeats.Add(speciesFeat);

            var feats = racialFeatsGenerator.GenerateWith(race, skills, stats);
            Assert.That(feats.Count(), Is.EqualTo(3));
        }
        public void DoNotGetRacialFeatThatDoNotMeetRequirements()
        {
            var baseRaceFeat = new RacialFeatSelection();
            baseRaceFeat.Feat = "base race feat";
            baseRaceFeat.MinimumHitDieRequirement = 2;
            baseRaceFeats.Add(baseRaceFeat);

            var metaraceFeat = new RacialFeatSelection();
            metaraceFeat.Feat = "metarace feat";
            metaraceFeat.SizeRequirement = "size";
            metaraceFeats.Add(metaraceFeat);

            var speciesFeat = new RacialFeatSelection();
            speciesFeat.Feat = "metarace species feat";
            speciesFeat.MinimumStats["stat"] = 15;
            speciesFeats.Add(speciesFeat);

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

            var feats = racialFeatsGenerator.GenerateWith(race, skills, stats);
            Assert.That(feats, Is.Empty);
        }