public Treasure GenerateFor(Creature creature, int level)
        {
            var creatureName = GetCreatureNameForTreasure(creature.Name, creature.Description);
            var coinMultiplier = adjustmentSelector.Select<double>(TableNameConstants.TreasureAdjustments, creatureName, TreasureConstants.Coin);
            var goodsMultiplier = adjustmentSelector.Select<double>(TableNameConstants.TreasureAdjustments, creatureName, TreasureConstants.Goods);
            var itemsMultiplier = adjustmentSelector.Select<double>(TableNameConstants.TreasureAdjustments, creatureName, TreasureConstants.Items);

            var treasure = new Treasure();
            treasure.Coin = coinGenerator.GenerateAtLevel(level);

            var rawQuantity = coinMultiplier * treasure.Coin.Quantity;
            treasure.Coin.Quantity = Convert.ToInt32(rawQuantity);

            while (booleanPercentileSelector.SelectFrom(goodsMultiplier--))
            {
                var goods = goodsGenerator.GenerateAtLevel(level);
                treasure.Goods = treasure.Goods.Union(goods);
            }

            while (booleanPercentileSelector.SelectFrom(itemsMultiplier--))
            {
                var items = itemsGenerator.GenerateAtLevel(level);
                treasure.Items = treasure.Items.Union(items);
            }

            var setTreasure = GetSetTreasure(creatureName, creature.Quantity);
            treasure.Items = treasure.Items.Union(setTreasure);

            return treasure;
        }
Пример #2
0
        private Creature GetCreatureWithRandomSubtype(string fullCreatureType, int level, int modifier, string amount, int effectiveLevel)
        {
            var creature = new Creature();
            creature.Name = fullCreatureType;
            creature.Description = GenerateRandomSubtype(fullCreatureType, level, modifier, amount);

            if (creature.Description == null)
                return null;

            var creaturesRequiringSubtypes = collectionSelector.SelectFrom(TableNameConstants.CreatureGroups, GroupConstants.RequiresSubtype);

            if (creaturesRequiringSubtypes.Contains(creature.Description))
            {
                var setChallengeRating = GetSetChallengeRating(fullCreatureType);
                var subSubtype = GenerateRandomSubtype(creature.Description, level, modifier, amount, setChallengeRating);

                creature.Description = string.Format("{0} ({1})", creature.Description, subSubtype);
            }

            creature.Quantity = GetRandomSubtypeQuantity(creature.Description, fullCreatureType, amount, modifier, level);

            return creature;
        }
Пример #3
0
        private Creature GetCreature(string fullCreatureType, string amount, int modifier, int level, int effectiveLevel)
        {
            var creatureType = GetCreatureType(fullCreatureType);
            var setSubtype = GetSubtype(fullCreatureType, effectiveLevel);
            var creaturesRequiringSubtypes = collectionSelector.SelectFrom(TableNameConstants.CreatureGroups, GroupConstants.RequiresSubtype);

            if (creaturesRequiringSubtypes.Contains(creatureType) && string.IsNullOrEmpty(setSubtype))
                return GetCreatureWithRandomSubtype(fullCreatureType, level, modifier, amount, effectiveLevel);

            var creature = new Creature();
            creature.Name = fullCreatureType;
            creature.Description = setSubtype;

            var effectiveRoll = rollSelector.SelectFrom(amount, modifier);
            creature.Quantity = dice.Roll(effectiveRoll);

            return creature;
        }
Пример #4
0
        private IEnumerable<Creature> EditCreatureTypes(IEnumerable<Creature> creatures)
        {
            var newCreatures = new List<Creature>();
            var creaturesToRemove = new List<Creature>();

            foreach (var creature in creatures)
            {
                creature.Name = GetCreatureType(creature.Name);

                if (dice.ContainsRoll(creature.Description, true) == false)
                    continue;

                creaturesToRemove.Add(creature);

                while (creature.Quantity-- > 0)
                {
                    var rolledCreature = new Creature();
                    rolledCreature.Quantity = 1;
                    rolledCreature.Name = creature.Name;
                    rolledCreature.Description = dice.ReplaceExpressionWithTotal(creature.Description, true);

                    newCreatures.Add(rolledCreature);
                }
            }

            return creatures.Union(newCreatures).Except(creaturesToRemove);
        }
Пример #5
0
 public void Setup()
 {
     creature = new Creature();
 }
        public void Setup()
        {
            mockCoinGenerator = new Mock<ICoinGenerator>();
            mockGoodsGenerator = new Mock<IGoodsGenerator>();
            mockItemsGenerator = new Mock<IItemsGenerator>();
            mockAdjustmentSelector = new Mock<IAdjustmentSelector>();
            mockBooleanPercentileSelector = new Mock<IBooleanPercentileSelector>();
            mockCollectionSelector = new Mock<ICollectionSelector>();
            mockMagicalItemGeneratorFactory = new Mock<IMagicalItemGeneratorRuntimeFactory>();
            mockMundaneItemGeneratorFactory = new Mock<IMundaneItemGeneratorRuntimeFactory>();

            encounterTreasureGenerator = new EncounterTreasureGenerator(mockCoinGenerator.Object, mockGoodsGenerator.Object, mockItemsGenerator.Object,
                mockAdjustmentSelector.Object, mockBooleanPercentileSelector.Object, mockCollectionSelector.Object, mockMagicalItemGeneratorFactory.Object, mockMundaneItemGeneratorFactory.Object);

            creature = new Creature();
            usesSubtypeForTreasure = new List<string>();

            level = 9266;
            creature.Name = "creature";
            creature.Description = "subtype";
            creature.Quantity = 1;
            coinMultiplier = 1;
            goodsMultiplier = 1;
            itemsMultiplier = 1;
            goods = new List<Good>() { new Good(), new Good() };
            items = new List<Item>() { new Item(), new Item() };
            coin = new Coin { Currency = "currency", Quantity = 600 };

            mockBooleanPercentileSelector.Setup(s => s.SelectFrom(It.IsAny<double>())).Returns((double d) => d > 0);

            mockAdjustmentSelector.Setup(s => s.Select<double>(TableNameConstants.TreasureAdjustments, creature.Name, TreasureConstants.Coin)).Returns(() => coinMultiplier);
            mockAdjustmentSelector.Setup(s => s.Select<double>(TableNameConstants.TreasureAdjustments, creature.Name, TreasureConstants.Goods)).Returns(() => goodsMultiplier);
            mockAdjustmentSelector.Setup(s => s.Select<double>(TableNameConstants.TreasureAdjustments, creature.Name, TreasureConstants.Items)).Returns(() => itemsMultiplier);

            mockCoinGenerator.Setup(g => g.GenerateAtLevel(level)).Returns(coin);
            mockGoodsGenerator.Setup(g => g.GenerateAtLevel(level)).Returns(goods);
            mockItemsGenerator.Setup(g => g.GenerateAtLevel(level)).Returns(items);

            mockCollectionSelector.Setup(s => s.SelectFrom(TableNameConstants.CreatureGroups, GroupConstants.UseSubtypeForTreasure)).Returns(usesSubtypeForTreasure);
        }
        private Character GenerateCharacter(Creature creature)
        {
            var characterCreatureType = GetCharacterCreatureType(creature);

            setLevelRandomizer.SetLevel = GetCharacterLevel(creature.Name);
            setLevelRandomizer.AllowAdjustments = true;

            var undeadNPCCreatures = collectionSelector.SelectFrom(TableNameConstants.CreatureGroups, GroupConstants.UndeadNPC);
            if (undeadNPCCreatures.Contains(characterCreatureType))
            {
                setMetaraceRandomizer.SetMetarace = characterCreatureType;
                setLevelRandomizer.AllowAdjustments = false;

                return characterGenerator.GenerateWith(alignmentRandomizer, anyPlayerClassNameRandomizer, setLevelRandomizer, baseRaceRandomizer, setMetaraceRandomizer, statsRandomizer);
            }

            if (characterCreatureType == CreatureConstants.Character)
                return characterGenerator.GenerateWith(alignmentRandomizer, anyPlayerClassNameRandomizer, setLevelRandomizer, baseRaceRandomizer, metaraceRandomizer, statsRandomizer);

            if (characterCreatureType == CreatureConstants.NPC)
                return characterGenerator.GenerateWith(alignmentRandomizer, anyNPCClassNameRandomizer, setLevelRandomizer, baseRaceRandomizer, metaraceRandomizer, statsRandomizer);

            setClassNameRandomizer.SetClassName = characterCreatureType;
            return characterGenerator.GenerateWith(alignmentRandomizer, setClassNameRandomizer, setLevelRandomizer, baseRaceRandomizer, metaraceRandomizer, statsRandomizer);
        }
        private string GetCharacterCreatureType(Creature creature)
        {
            var creatureType = GetCreatureTypeCharacter(creature.Name);

            if (string.IsNullOrEmpty(creatureType))
                return GetCreatureTypeCharacter(creature.Description);

            return creatureType;
        }