示例#1
0
        public void GetSpecialQualities()
        {
            var feat1 = new SpecialQualitySelection();

            feat1.Feat = "special quality 1";

            var feat2 = new SpecialQualitySelection();

            feat2.Feat  = "special quality 2";
            feat2.Power = 9266;
            feat2.Frequency.Quantity   = 42;
            feat2.Frequency.TimePeriod = "fortnight";

            specialQualitySelections.Add(feat1);
            specialQualitySelections.Add(feat2);

            var specialQualities = featsGenerator.GenerateSpecialQualities("creature", creatureType, hitPoints, abilities, skills, false, "size", alignment);
            var first            = specialQualities.First();
            var last             = specialQualities.Last();

            Assert.That(first.Name, Is.EqualTo("special quality 1"));
            Assert.That(first.Power, Is.Zero);
            Assert.That(first.Frequency.Quantity, Is.Zero);
            Assert.That(first.Frequency.TimePeriod, Is.Empty);

            Assert.That(last.Name, Is.EqualTo("special quality 2"));
            Assert.That(last.Power, Is.EqualTo(9266));
            Assert.That(last.Frequency.Quantity, Is.EqualTo(42));
            Assert.That(last.Frequency.TimePeriod, Is.EqualTo("fortnight"));
        }
示例#2
0
        public void BUG_HalfOrcIsNotSensitiveToLight()
        {
            var feat1 = new SpecialQualitySelection();

            feat1.Feat = "special quality 1";

            var lightSensitivity = new SpecialQualitySelection();

            lightSensitivity.Feat = FeatConstants.SpecialQualities.LightSensitivity;

            var feat2 = new SpecialQualitySelection();

            feat2.Feat  = "special quality 2";
            feat2.Power = 9266;
            feat2.Frequency.Quantity   = 42;
            feat2.Frequency.TimePeriod = "fortnight";

            specialQualitySelections.Add(feat1);
            specialQualitySelections.Add(lightSensitivity);
            specialQualitySelections.Add(feat2);

            mockFeatsSelector.Setup(s => s.SelectSpecialQualities(CreatureConstants.Orc_Half, creatureType)).Returns(specialQualitySelections);

            var specialQualities = featsGenerator.GenerateSpecialQualities(CreatureConstants.Orc_Half, creatureType, hitPoints, abilities, skills, false, "size", alignment);

            Assert.That(specialQualities.Count(), Is.EqualTo(2));
            Assert.That(specialQualities.First().Name, Is.EqualTo("special quality 1"));
            Assert.That(specialQualities.Last().Name, Is.EqualTo("special quality 2"));
        }
示例#3
0
        private IEnumerable <string> GetFoci(SpecialQualitySelection specialQualitySelection, IEnumerable <Skill> skills, Dictionary <string, Ability> abilities)
        {
            if (string.IsNullOrEmpty(specialQualitySelection.FocusType))
            {
                return(Enumerable.Empty <string>());
            }

            var foci = new HashSet <string>();

            var fociQuantity = 1;

            if (specialQualitySelection.RandomFociQuantity.Any())
            {
                var roll = dice.Roll(specialQualitySelection.RandomFociQuantity).AsSum();
                if (roll > fociQuantity)
                {
                    fociQuantity = roll;
                }
            }

            while (fociQuantity > foci.Count)
            {
                var focus = featFocusGenerator.GenerateAllowingFocusOfAllFrom(specialQualitySelection.Feat, specialQualitySelection.FocusType, skills, abilities);
                if (string.IsNullOrEmpty(focus) == false)
                {
                    foci.Add(focus);
                }
            }

            return(foci);
        }
示例#4
0
        public IEnumerable <SpecialQualitySelection> SelectSpecialQualities(string creature, CreatureType creatureType)
        {
            var specialQualitiesWithSource = new Dictionary <string, IEnumerable <string> >();

            specialQualitiesWithSource[creature]          = collectionsSelector.SelectFrom(TableNameConstants.Collection.SpecialQualityData, creature);
            specialQualitiesWithSource[creatureType.Name] = collectionsSelector.SelectFrom(TableNameConstants.Collection.SpecialQualityData, creatureType.Name);

            foreach (var subtype in creatureType.SubTypes)
            {
                specialQualitiesWithSource[subtype] = collectionsSelector.SelectFrom(TableNameConstants.Collection.SpecialQualityData, subtype);
            }

            if (!specialQualitiesWithSource.SelectMany(kvp => kvp.Value).Any())
            {
                return(Enumerable.Empty <SpecialQualitySelection>());
            }

            var specialQualitySelections = new List <SpecialQualitySelection>();
            var usedSpecialQualities     = new List <string>();

            foreach (var specialQualityKvp in specialQualitiesWithSource)
            {
                var source              = specialQualityKvp.Key;
                var specialQualities    = specialQualityKvp.Value;
                var newSpecialQualities = specialQualityKvp.Value.Except(usedSpecialQualities).ToArray();

                foreach (var specialQuality in newSpecialQualities)
                {
                    var data = helper.ParseEntry(specialQuality);

                    var specialQualitySelection = new SpecialQualitySelection();
                    specialQualitySelection.Feat                 = data[DataIndexConstants.SpecialQualityData.FeatNameIndex];
                    specialQualitySelection.Power                = Convert.ToInt32(data[DataIndexConstants.SpecialQualityData.PowerIndex]);
                    specialQualitySelection.FocusType            = data[DataIndexConstants.SpecialQualityData.FocusIndex];
                    specialQualitySelection.Frequency.Quantity   = Convert.ToInt32(data[DataIndexConstants.SpecialQualityData.FrequencyQuantityIndex]);
                    specialQualitySelection.Frequency.TimePeriod = data[DataIndexConstants.SpecialQualityData.FrequencyTimePeriodIndex];
                    specialQualitySelection.RandomFociQuantity   = data[DataIndexConstants.SpecialQualityData.RandomFociQuantityIndex];
                    specialQualitySelection.RequiresEquipment    = Convert.ToBoolean(data[DataIndexConstants.SpecialQualityData.RequiresEquipmentIndex]);
                    specialQualitySelection.Save                 = data[DataIndexConstants.SpecialQualityData.SaveIndex];
                    specialQualitySelection.SaveAbility          = data[DataIndexConstants.SpecialQualityData.SaveAbilityIndex];
                    specialQualitySelection.SaveBaseValue        = Convert.ToInt32(data[DataIndexConstants.SpecialQualityData.SaveBaseValueIndex]);
                    specialQualitySelection.MinHitDice           = Convert.ToInt32(data[DataIndexConstants.SpecialQualityData.MinHitDiceIndex]);
                    specialQualitySelection.MaxHitDice           = Convert.ToInt32(data[DataIndexConstants.SpecialQualityData.MaxHitDiceIndex]);

                    var requirementKey = helper.BuildKey(source, data);
                    specialQualitySelection.RequiredFeats      = GetRequiredFeats(requirementKey);
                    specialQualitySelection.MinimumAbilities   = GetRequiredAbilities(requirementKey);
                    specialQualitySelection.RequiredSizes      = GetRequiredSizes(requirementKey);
                    specialQualitySelection.RequiredAlignments = GetRequiredAlignments(requirementKey);

                    specialQualitySelections.Add(specialQualitySelection);
                    usedSpecialQualities.Add(specialQuality);
                }
            }

            return(specialQualitySelections);
        }
示例#5
0
        public void DoNotGetSpecialQualityThatDoNotMeetRequirements()
        {
            var specialQualitySelection = new SpecialQualitySelection();

            specialQualitySelection.Feat = "base race feat";
            specialQualitySelection.MinimumAbilities[AbilityConstants.Intelligence] = 11;
            specialQualitySelections.Add(specialQualitySelection);

            var specialQualities = featsGenerator.GenerateSpecialQualities("creature", creatureType, hitPoints, abilities, skills, false, "size", alignment);

            Assert.That(specialQualities, Is.Empty);
        }
示例#6
0
        public void DoNotGetSpecialQualityRequiringSize()
        {
            var specialQualitySelection = new SpecialQualitySelection();

            specialQualitySelection.Feat          = "special quality";
            specialQualitySelection.RequiredSizes = new[] { "size" };

            specialQualitySelections.Add(specialQualitySelection);

            var specialQualities = featsGenerator.GenerateSpecialQualities("creature", creatureType, hitPoints, abilities, skills, false, "wrong size", alignment);

            Assert.That(specialQualities, Is.Empty);
        }
示例#7
0
        public void GetSpecialQualityRequiringNoSize()
        {
            var specialQualitySelection = new SpecialQualitySelection();

            specialQualitySelection.Feat          = "special quality";
            specialQualitySelection.RequiredSizes = Enumerable.Empty <string>();

            specialQualitySelections.Add(specialQualitySelection);

            var specialQualities = featsGenerator.GenerateSpecialQualities("creature", creatureType, hitPoints, abilities, skills, false, "size", alignment);

            Assert.That(specialQualities.Count(), Is.EqualTo(1));
        }
示例#8
0
        public void GetSpecialQualityNotRequiringCanUseEquipment()
        {
            var specialQualitySelection = new SpecialQualitySelection();

            specialQualitySelection.Feat = "special quality";
            specialQualitySelection.RequiresEquipment = false;

            specialQualitySelections.Add(specialQualitySelection);

            var specialQualities = featsGenerator.GenerateSpecialQualities("creature", creatureType, hitPoints, abilities, skills, false, "size", alignment);

            Assert.That(specialQualities.Count(), Is.EqualTo(1));
        }
示例#9
0
        public void Setup()
        {
            selection = new SpecialQualitySelection();
            abilities = new Dictionary <string, Ability>();
            feats     = new List <Feat>();
            alignment = new Alignment();
            hitPoints = new HitPoints();

            abilities["ability"]           = new Ability("ability");
            abilities["ability"].BaseScore = 42;

            hitPoints.HitDice.Add(new HitDice {
                Quantity = 1
            });
        }
示例#10
0
        public void DoNotGetEmptyFociStrings()
        {
            var specialQualitySelectionselection = new SpecialQualitySelection();

            specialQualitySelectionselection.Feat      = "special quality";
            specialQualitySelectionselection.FocusType = string.Empty;
            specialQualitySelections.Add(specialQualitySelectionselection);

            mockFeatFocusGenerator.Setup(g => g.GenerateAllowingFocusOfAllFrom("special quality", string.Empty, skills, abilities)).Returns(string.Empty);

            var feats    = featsGenerator.GenerateSpecialQualities("creature", creatureType, hitPoints, abilities, skills, false, "size", alignment);
            var baseFeat = feats.First(f => f.Name == specialQualitySelectionselection.Feat);

            Assert.That(baseFeat.Foci, Is.Empty);
        }
示例#11
0
        public void GetFociForSpecialQualities()
        {
            var specialQualitySelection = new SpecialQualitySelection();

            specialQualitySelection.Feat      = "special quality";
            specialQualitySelection.FocusType = "base focus type";
            specialQualitySelections.Add(specialQualitySelection);

            mockFeatFocusGenerator.Setup(g => g.GenerateAllowingFocusOfAllFrom("special quality", "base focus type", skills, abilities)).Returns("base focus");

            var feats    = featsGenerator.GenerateSpecialQualities("creature", creatureType, hitPoints, abilities, skills, false, "size", alignment);
            var baseFeat = feats.First(f => f.Name == specialQualitySelection.Feat);

            Assert.That(baseFeat.Foci.Single(), Is.EqualTo("base focus"));
        }
示例#12
0
        public void DoNotGetSpecialQualityRequiringAlignment()
        {
            var specialQualitySelection = new SpecialQualitySelection();

            specialQualitySelection.Feat = "special quality";
            specialQualitySelection.RequiredAlignments = new[] { "lawfulness goodness" };

            specialQualitySelections.Add(specialQualitySelection);

            alignment.Goodness   = "wrong goodness";
            alignment.Lawfulness = "wrong lawfulness";

            var specialQualities = featsGenerator.GenerateSpecialQualities("creature", creatureType, hitPoints, abilities, skills, false, "wrong size", alignment);

            Assert.That(specialQualities, Is.Empty);
        }
示例#13
0
        public void DoNotAddHitDiceToPower()
        {
            var specialQualitySelectionselection = new SpecialQualitySelection();

            specialQualitySelectionselection.Feat  = "different feat";
            specialQualitySelectionselection.Power = 10;
            specialQualitySelections.Add(specialQualitySelectionselection);

            hitPoints.HitDice[0].Quantity = 2;

            var feats = featsGenerator.GenerateSpecialQualities("creature", creatureType, hitPoints, abilities, skills, false, "size", alignment);
            var feat  = feats.Single();

            Assert.That(feat.Name, Is.EqualTo("different feat"));
            Assert.That(feat.Power, Is.EqualTo(10));
        }
示例#14
0
        public void BUG_IfBlind_RemoveSightFeats(string blindFeatName)
        {
            var feat1 = new SpecialQualitySelection();

            feat1.Feat = "special quality 1";

            var blindFeat = new SpecialQualitySelection();

            blindFeat.Feat = blindFeatName;

            var feat2 = new SpecialQualitySelection();

            feat2.Feat  = "special quality 2";
            feat2.Power = 9266;
            feat2.Frequency.Quantity   = 42;
            feat2.Frequency.TimePeriod = "fortnight";

            var sightedFeats = new[]
            {
                new SpecialQualitySelection {
                    Feat = FeatConstants.SpecialQualities.AllAroundVision
                },
                new SpecialQualitySelection {
                    Feat = FeatConstants.SpecialQualities.Darkvision
                },
                new SpecialQualitySelection {
                    Feat = FeatConstants.SpecialQualities.LowLightVision
                },
                new SpecialQualitySelection {
                    Feat = FeatConstants.SpecialQualities.LowLightVision_Superior
                },
            };

            specialQualitySelections.Add(feat1);
            specialQualitySelections.AddRange(sightedFeats);
            specialQualitySelections.Add(blindFeat);
            specialQualitySelections.Add(feat2);

            var specialQualities = featsGenerator.GenerateSpecialQualities("creature", creatureType, hitPoints, abilities, skills, false, "size", alignment);
            var array            = specialQualities.ToArray();

            Assert.That(array, Has.Length.EqualTo(3));
            Assert.That(array[0].Name, Is.EqualTo("special quality 1"));
            Assert.That(array[1].Name, Is.EqualTo(blindFeatName));
            Assert.That(array[2].Name, Is.EqualTo("special quality 2"));
        }
示例#15
0
        public void BUG_GetFociForSpecialQualities_WithZeroRandomFoci_ButPreset()
        {
            var specialQualitySelection = new SpecialQualitySelection();

            specialQualitySelection.Feat               = "special quality";
            specialQualitySelection.FocusType          = "my specific focus";
            specialQualitySelection.RandomFociQuantity = "0";

            specialQualitySelections.Add(specialQualitySelection);

            mockFeatFocusGenerator.Setup(g => g.GenerateAllowingFocusOfAllFrom("special quality", "my specific focus", skills, abilities)).Returns("my focus");
            mockDice.Setup(d => d.Roll("0").AsSum <int>()).Returns(0);

            var feats    = featsGenerator.GenerateSpecialQualities("creature", creatureType, hitPoints, abilities, skills, false, "size", alignment);
            var baseFeat = feats.First(f => f.Name == specialQualitySelection.Feat);

            Assert.That(baseFeat.Foci.Single(), Is.EqualTo("my focus"));
        }
示例#16
0
        public void GetNoRandomFociForSpecialQualityIfNoFocusType()
        {
            var featSelection = new SpecialQualitySelection();

            featSelection.Feat = "special quality";
            featSelection.RandomFociQuantity = "dice roll";

            var count = 1;

            mockFeatFocusGenerator.Setup(g => g.GenerateAllowingFocusOfAllFrom("special quality", "focus type", skills, abilities)).Returns(() => $"focus {count++}");
            mockDice.Setup(d => d.Roll("dice roll").AsSum <int>()).Returns(3);

            specialQualitySelections.Add(featSelection);

            var feats = featsGenerator.GenerateSpecialQualities("creature", creatureType, hitPoints, abilities, skills, false, "size", alignment);
            var feat  = feats.Single();

            Assert.That(feat.Name, Is.EqualTo("special quality"));
            Assert.That(feat.Foci, Is.Empty);
        }
示例#17
0
        public void CanGetSpecialQualitiesWhenNoIntelligence()
        {
            abilities[AbilityConstants.Intelligence].BaseScore = 0;

            var feat1 = new SpecialQualitySelection();

            feat1.Feat = "special quality 1";

            specialQualitySelections.Add(feat1);

            var specialQualities = featsGenerator.GenerateSpecialQualities("creature", creatureType, hitPoints, abilities, skills, false, "size", alignment);

            Assert.That(specialQualities, Is.Not.Empty);

            var specialQuality = specialQualities.Single();

            Assert.That(specialQuality.Name, Is.EqualTo("special quality 1"));
            Assert.That(specialQuality.Power, Is.Zero);
            Assert.That(specialQuality.Frequency.Quantity, Is.Zero);
            Assert.That(specialQuality.Frequency.TimePeriod, Is.Empty);
        }
示例#18
0
        public void GetSpecialQualityWithoutSave()
        {
            var specialQualitySelection = new SpecialQualitySelection();

            specialQualitySelection.Feat          = "special quality";
            specialQualitySelection.SaveAbility   = string.Empty;
            specialQualitySelection.Save          = "save";
            specialQualitySelection.SaveBaseValue = 9266;

            abilities["save ability"] = new Ability("save ability");

            specialQualitySelections.Add(specialQualitySelection);

            var specialQualities = featsGenerator.GenerateSpecialQualities("creature", creatureType, hitPoints, abilities, skills, false, "size", alignment);

            Assert.That(specialQualities.Count(), Is.EqualTo(1));

            var specialQuality = specialQualities.Single();

            Assert.That(specialQuality.Save, Is.Null);
        }
示例#19
0
        public void BUG_GetSpecialQualityThatMeetRequirements_OutOfOrder()
        {
            var specialQualitySelection = new SpecialQualitySelection();

            specialQualitySelection.Feat          = "special quality";
            specialQualitySelection.RequiredFeats = new[]
            {
                new RequiredFeatSelection {
                    Feat = "required feat"
                }
            };
            var requirementSelection = new SpecialQualitySelection();

            requirementSelection.Feat = "required feat";
            specialQualitySelections.Add(specialQualitySelection);
            specialQualitySelections.Add(requirementSelection);

            var specialQualities = featsGenerator.GenerateSpecialQualities("creature", creatureType, hitPoints, abilities, skills, false, "size", alignment);

            Assert.That(specialQualities.Count(), Is.EqualTo(2));
        }