Ejemplo n.º 1
0
 public MagicGenerator(
     ISpellsGenerator spellsGenerator,
     ICollectionSelector collectionsSelector,
     IAdjustmentsSelector adjustmentsSelector,
     ITypeAndAmountSelector typeAndAmountSelector)
 {
     this.spellsGenerator       = spellsGenerator;
     this.collectionsSelector   = collectionsSelector;
     this.adjustmentsSelector   = adjustmentsSelector;
     this.typeAndAmountSelector = typeAndAmountSelector;
 }
Ejemplo n.º 2
0
        public void Setup()
        {
            mockAdjustmentsSelector = new Mock<IAdjustmentsSelector>();
            mockCollectionsSelector = new Mock<ICollectionsSelector>();
            mockBooleanPercentileSelector = new Mock<IBooleanPercentileSelector>();
            spellsGenerator = new SpellsGenerator(mockCollectionsSelector.Object, mockAdjustmentsSelector.Object, mockBooleanPercentileSelector.Object);
            characterClass = new CharacterClass();
            spellcasters = new List<string>();
            stats = new Dictionary<string, Stat>();
            spellsPerDayForClass = new Dictionary<string, int>();
            spellsKnownForClass = new Dictionary<string, int>();
            classSpells = new List<string>();
            spellLevels = new Dictionary<string, int>();
            divineCasters = new List<string>();

            characterClass.Name = "class name";
            characterClass.Level = 9266;
            spellcasters.Add(characterClass.Name);
            spellcasters.Add("other class");
            spellsPerDayForClass["0"] = 90210;
            spellsPerDayForClass["1"] = 42;
            spellsKnownForClass["0"] = 2;
            spellsKnownForClass["1"] = 1;
            stats["stat"] = new Stat("stat");
            stats["stat"].Value = 11;
            stats["other stat"] = new Stat("other stat");
            stats["other stat"].Value = 11;
            classSpells.Add("spell 1");
            classSpells.Add("spell 2");
            classSpells.Add("spell 3");
            classSpells.Add("spell 4");
            spellLevels[classSpells[0]] = 0;
            spellLevels[classSpells[1]] = 0;
            spellLevels[classSpells[2]] = 1;
            spellLevels[classSpells[3]] = 1;
            divineCasters.Add("other divine class");

            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.ClassNameGroups, GroupConstants.Spellcasters)).Returns(spellcasters);
            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.ClassNameGroups, SpellConstants.Sources.Divine)).Returns(divineCasters);
            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.StatGroups, characterClass.Name + GroupConstants.Spellcasters)).Returns(new[] { "stat" });

            var tableName = string.Format(TableNameConstants.Formattable.Adjustments.LevelXCLASSSpellsPerDay, characterClass.Level, characterClass.Name);
            mockAdjustmentsSelector.Setup(s => s.SelectFrom(tableName)).Returns(spellsPerDayForClass);

            tableName = string.Format(TableNameConstants.Formattable.Adjustments.LevelXCLASSKnownSpells, characterClass.Level, characterClass.Name);
            mockAdjustmentsSelector.Setup(s => s.SelectFrom(tableName)).Returns(spellsKnownForClass);

            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.SpellGroups, characterClass.Name)).Returns(classSpells);
            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.SpellGroups, "domain 1")).Returns(new[] { classSpells[0], classSpells[2] });
            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Set.Collection.SpellGroups, "domain 2")).Returns(new[] { classSpells[1], classSpells[3] });

            tableName = string.Format(TableNameConstants.Formattable.Adjustments.CLASSSpellLevels, characterClass.Name);
            mockAdjustmentsSelector.Setup(s => s.SelectFrom(tableName)).Returns(spellLevels);

            var index = 0;
            mockCollectionsSelector.Setup(s => s.SelectRandomFrom(It.IsAny<IEnumerable<string>>())).Returns((IEnumerable<string> c) => c.ElementAt(index++ % c.Count()));
            mockCollectionsSelector.Setup(s => s.SelectRandomFrom(It.IsAny<IEnumerable<Spell>>())).Returns((IEnumerable<Spell> c) => c.ElementAt(index++ % c.Count()));
        }