Beispiel #1
0
        private IEnumerable<SpellQuantity> GetSpellsPerDay(CharacterClass characterClass, Dictionary<string, Stat> stats)
        {
            var tableName = string.Format(TableNameConstants.Formattable.Adjustments.LevelXCLASSSpellsPerDay, characterClass.Level, characterClass.Name);
            var spellsForClass = adjustmentsSelector.SelectFrom(tableName);

            var spellStat = collectionsSelector.SelectFrom(TableNameConstants.Set.Collection.StatGroups, characterClass.Name + GroupConstants.Spellcasters).Single();
            var maxSpellLevel = stats[spellStat].Value - 10;
            var spellsForCharacter = spellsForClass.Where(kvp => Convert.ToInt32(kvp.Key) <= maxSpellLevel);

            var spellsPerDay = new List<SpellQuantity>();

            foreach (var kvp in spellsForCharacter)
            {
                var spellQuantity = new SpellQuantity();
                spellQuantity.Level = Convert.ToInt32(kvp.Key);
                spellQuantity.Quantity = kvp.Value;
                spellQuantity.HasDomainSpell = characterClass.SpecialistFields.Any() && spellQuantity.Level > 0;

                if (spellQuantity.Level > 0 && spellQuantity.Level <= stats[spellStat].Bonus)
                {
                    var bonusSpells = (stats[spellStat].Bonus - spellQuantity.Level) / 4 + 1;
                    spellQuantity.Quantity += bonusSpells;
                }

                spellsPerDay.Add(spellQuantity);
            }

            return spellsPerDay;
        }
Beispiel #2
0
        private IEnumerable<Spell> GetRandomKnownSpellsForLevel(SpellQuantity spellQuantity, CharacterClass characterClass)
        {
            var spellNames = GetSpellNames(characterClass, spellQuantity.Level);
            var knownSpells = new HashSet<Spell>();

            if (spellQuantity.Quantity >= spellNames.Count())
            {
                foreach (var spellName in spellNames)
                {
                    var spell = BuildSpell(spellName, spellQuantity.Level);
                    knownSpells.Add(spell);
                }

                return knownSpells;
            }

            while (spellQuantity.Quantity > knownSpells.Count)
            {
                var spellName = collectionsSelector.SelectRandomFrom(spellNames);
                var spell = BuildSpell(spellName, spellQuantity.Level);
                knownSpells.Add(spell);
            }

            var specialistSpellsForLevel = GetSpellNamesForFields(characterClass.SpecialistFields, spellQuantity.Level);
            var knownSpellNames = knownSpells.Select(s => s.Name);
            var unknownSpecialistSpells = specialistSpellsForLevel.Except(knownSpellNames);

            if (spellQuantity.HasDomainSpell && unknownSpecialistSpells.Any())
            {
                while (spellQuantity.Quantity + 1 > knownSpells.Count)
                {
                    var spellName = collectionsSelector.SelectRandomFrom(specialistSpellsForLevel);
                    var spell = BuildSpell(spellName, spellQuantity.Level);

                    knownSpells.Add(spell);
                }
            }
            else if (spellQuantity.HasDomainSpell)
            {
                while (spellQuantity.Quantity + 1 > knownSpells.Count)
                {
                    var spellName = collectionsSelector.SelectRandomFrom(spellNames);
                    var spell = BuildSpell(spellName, spellQuantity.Level);
                    knownSpells.Add(spell);
                }
            }

            return knownSpells;
        }
Beispiel #3
0
        private IEnumerable<SpellQuantity> GetKnownSpellQuantities(CharacterClass characterClass, Dictionary<string, Stat> stats)
        {
            var tableName = string.Format(TableNameConstants.Formattable.Adjustments.LevelXCLASSKnownSpells, characterClass.Level, characterClass.Name);
            var spellsForClass = adjustmentsSelector.SelectFrom(tableName);

            var spellStat = collectionsSelector.SelectFrom(TableNameConstants.Set.Collection.StatGroups, characterClass.Name + GroupConstants.Spellcasters).Single();
            var maxSpellLevel = stats[spellStat].Value - 10;
            var spellQuantitiesForCharacter = spellsForClass.Where(kvp => Convert.ToInt32(kvp.Key) <= maxSpellLevel);

            var spellQuantities = new List<SpellQuantity>();
            var knowsMoreSpellsTableName = string.Format(TableNameConstants.Formattable.TrueOrFalse.CLASSKnowsAdditionalSpells, characterClass.Name);

            foreach (var kvp in spellQuantitiesForCharacter)
            {
                var spellQuantity = new SpellQuantity();
                spellQuantity.Level = Convert.ToInt32(kvp.Key);
                spellQuantity.HasDomainSpell = characterClass.SpecialistFields.Any() && spellQuantity.Level > 0;
                spellQuantity.Quantity = kvp.Value;

                while (booleanPercentileSelector.SelectFrom(knowsMoreSpellsTableName))
                    spellQuantity.Quantity++;

                spellQuantities.Add(spellQuantity);
            }

            return spellQuantities;
        }
Beispiel #4
0
        private IEnumerable<Spell> GetPreparedSpellsForLevel(SpellQuantity spellQuantity, IEnumerable<Spell> knownSpells, CharacterClass characterClass)
        {
            var preparedSpells = new List<Spell>();
            var knownSpellsForLevel = knownSpells.Where(s => s.Level == spellQuantity.Level);

            while (spellQuantity.Quantity > preparedSpells.Count)
            {
                var spell = collectionsSelector.SelectRandomFrom(knownSpellsForLevel);
                preparedSpells.Add(spell);
            }

            if (spellQuantity.HasDomainSpell)
            {
                var specialistSpells = GetSpellNamesForFields(characterClass.SpecialistFields);
                var specialistSpellsForLevel = knownSpellsForLevel.Where(s => specialistSpells.Contains(s.Name));
                var spell = collectionsSelector.SelectRandomFrom(specialistSpellsForLevel);

                preparedSpells.Add(spell);
            }

            return preparedSpells;
        }
 public void Setup()
 {
     spellQuantity = new SpellQuantity();
 }