コード例 #1
0
        public bool IsCompatible(string creature)
        {
            var types = collectionSelector.SelectFrom(TableNameConstants.Collection.CreatureTypes, creature);

            if (!creatureTypes.Contains(types.First()))
            {
                return(false);
            }

            if (types.Contains(CreatureConstants.Types.Subtypes.Incorporeal))
            {
                return(false);
            }

            var hasSkeleton = collectionSelector.Explode(TableNameConstants.Collection.CreatureGroups, CreatureConstants.Groups.HasSkeleton);

            if (!hasSkeleton.Contains(creature))
            {
                return(false);
            }

            var hitDice = adjustmentSelector.SelectFrom <double>(TableNameConstants.Adjustments.HitDice, creature);

            if (hitDice > 10)
            {
                return(false);
            }

            return(true);
        }
コード例 #2
0
        public void CreatureTypeMatchesCreatureGroupType(string creature)
        {
            var types = collectionMapper.Map(TableNameConstants.Collection.CreatureTypes);

            Assert.That(types.Keys, Contains.Item(creature));

            if (creature != CreatureConstants.Templates.None)
            {
                Assert.That(types[creature], Is.Not.Empty);

                var type = types[creature].First();

                Assert.That(table.Keys, Contains.Item(type), "Table keys");
                var creaturesOfType = collectionSelector.Explode(TableNameConstants.Collection.CreatureGroups, type);

                Assert.That(creaturesOfType, Contains.Item(creature), type);
            }
            else
            {
                Assert.That(types[creature], Is.Empty);
            }
        }
コード例 #3
0
        public IEnumerable <string> Explode(string tableName, string collectionName)
        {
            var assembly = assemblyLoader.GetRunningAssembly();
            var key      = assembly.FullName + tableName + collectionName;

            lock (myLock)
            {
                if (!cachedExplodedCollections.ContainsKey(key))
                {
                    var explodedCollection = innerSelector.Explode(tableName, collectionName);
                    cachedExplodedCollections.Add(key, explodedCollection);
                }
            }

            return(cachedExplodedCollections[key]);
        }
コード例 #4
0
        private int GetSaveBaseValue(string creatureName, HitPoints hitPoints, string saveName)
        {
            if (hitPoints.RoundedHitDiceQuantity == 0)
            {
                return(0);
            }

            var strongSaves = collectionsSelector.Explode(TableNameConstants.Collection.CreatureGroups, saveName);

            if (strongSaves.Contains(creatureName))
            {
                return(hitPoints.RoundedHitDiceQuantity / 2 + 2);
            }

            return(hitPoints.RoundedHitDiceQuantity / 3);
        }
コード例 #5
0
        public void ExplodeFromTable()
        {
            var explodedCollection = collectionsSelector.Explode("CollectionTable", "collection");

            Assert.That(explodedCollection, Is.Unique.And.EquivalentTo(new[]
            {
                "entry 2",
                "entry 3",
                "entry 4",
                "collection",
                "sub-collection",
            }));
        }
コード例 #6
0
        public void Explode_ReturnsFromInnerSelector()
        {
            mockInnerSelector
            .Setup(s => s.Explode("table name", "my entry"))
            .Returns(new[] { "entry 1", "entry 2" });

            var result = proxy.Explode("table name", "my entry");

            Assert.That(result, Is.EqualTo(new[] { "entry 1", "entry 2" }));
        }
コード例 #7
0
        public void SaveGroupContainsCreature(string save, string creature)
        {
            var saveGroup = collectionSelector.Explode(tableName, save);

            Assert.That(saveGroup, Contains.Item(creature));
        }