Пример #1
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);
        }
Пример #2
0
        public void ParseData()
        {
            var data = helper.ParseEntry("this#is#my#data");

            Assert.That(data, Is.EqualTo(new[] { "this", "is", "my", "data" }));
        }