Exemple #1
0
        private void UpdateCreatureSpeeds(Creature creature)
        {
            var celestialSpeeds = speedsGenerator.Generate(CreatureConstants.Templates.HalfCelestial);

            if (creature.Speeds.ContainsKey(SpeedConstants.Land) && !creature.Speeds.ContainsKey(SpeedConstants.Fly))
            {
                creature.Speeds[SpeedConstants.Fly]       = celestialSpeeds[SpeedConstants.Fly];
                creature.Speeds[SpeedConstants.Fly].Value = creature.Speeds[SpeedConstants.Land].Value * 2;
            }
        }
        private void UpdateCreatureSpeeds(Creature creature)
        {
            var fiendSpeeds = speedsGenerator.Generate(CreatureConstants.Templates.HalfFiend);

            if (creature.Speeds.ContainsKey(SpeedConstants.Land) &&
                (!creature.Speeds.ContainsKey(SpeedConstants.Fly) ||
                 creature.Speeds[SpeedConstants.Land].Value > creature.Speeds[SpeedConstants.Fly].Value))
            {
                creature.Speeds[SpeedConstants.Fly]       = fiendSpeeds[SpeedConstants.Fly];
                creature.Speeds[SpeedConstants.Fly].Value = creature.Speeds[SpeedConstants.Land].Value;
            }
        }
Exemple #3
0
        public void GenerateCreatureSpeeds()
        {
            var speedSelections = new[]
            {
                new TypeAndAmountSelection {
                    Type = "on foot", Amount = 1234
                },
                new TypeAndAmountSelection {
                    Type = "in a car", Amount = 2345
                },
            };

            mockTypeAndAmountSelector.Setup(s => s.Select(TableNameConstants.Collection.Speeds, "creature")).Returns(speedSelections);

            var speeds = speedsGenerator.Generate("creature");

            Assert.That(speeds["on foot"].Unit, Is.EqualTo("feet per round"));
            Assert.That(speeds["on foot"].Value, Is.EqualTo(1234));
            Assert.That(speeds["on foot"].Description, Is.Empty);
            Assert.That(speeds["in a car"].Unit, Is.EqualTo("feet per round"));
            Assert.That(speeds["in a car"].Value, Is.EqualTo(2345));
            Assert.That(speeds["in a car"].Description, Is.Empty);
            Assert.That(speeds.Count, Is.EqualTo(2));
        }
Exemple #4
0
        private void UpdateCreatureSpeeds(Creature creature)
        {
            var sizes      = SizeConstants.GetOrdered();
            var largeIndex = Array.IndexOf(sizes, SizeConstants.Large);
            var sizeIndex  = Array.IndexOf(sizes, creature.Size);

            if (sizeIndex >= largeIndex &&
                creature.Speeds.ContainsKey(SpeedConstants.Land) &&
                !creature.Speeds.ContainsKey(SpeedConstants.Fly))
            {
                var dragonSpeeds = speedsGenerator.Generate(DragonSpecies);

                var dragonFlySpeedValue = Math.Min(120, creature.Speeds[SpeedConstants.Land].Value * 2);
                creature.Speeds[SpeedConstants.Fly]       = dragonSpeeds[SpeedConstants.Fly];
                creature.Speeds[SpeedConstants.Fly].Value = dragonFlySpeedValue;
            }
        }
        private void UpdateCreatureSpeeds(Creature creature)
        {
            var ghostSpeeds = speedsGenerator.Generate(CreatureConstants.Templates.Ghost);

            foreach (var kvp in ghostSpeeds)
            {
                if (!creature.Speeds.ContainsKey(kvp.Key))
                {
                    creature.Speeds[kvp.Key] = kvp.Value;
                }

                if (creature.Speeds[kvp.Key].Value < kvp.Value.Value)
                {
                    creature.Speeds[kvp.Key].Value = kvp.Value.Value;
                }

                creature.Speeds[kvp.Key].Description = kvp.Value.Description;
            }
        }
Exemple #6
0
        private void UpdateCreatureSpeeds(Creature creature)
        {
            var animalSpeeds = speedsGenerator.Generate(AnimalSpecies);

            foreach (var kvp in animalSpeeds)
            {
                if (creature.Speeds.ContainsKey(kvp.Key))
                {
                    var bonus = Convert.ToInt32(kvp.Value.Value - creature.Speeds[kvp.Key].Value);
                    creature.Speeds[kvp.Key].AddBonus(bonus, "In Animal Form");
                }
                else
                {
                    creature.Speeds.Add(kvp.Key, kvp.Value);

                    if (!string.IsNullOrEmpty(kvp.Value.Description))
                    {
                        kvp.Value.Description += ", ";
                    }

                    kvp.Value.Description += "In Animal Form";
                }
            }
        }
        private Creature GeneratePrototype(string creatureName, bool asCharacter)
        {
            var creature = new Creature();

            creature.Name = creatureName;

            var creatureData = creatureDataSelector.SelectFor(creatureName);

            creature.Size            = creatureData.Size;
            creature.Space.Value     = creatureData.Space;
            creature.Reach.Value     = creatureData.Reach;
            creature.CanUseEquipment = creatureData.CanUseEquipment;
            creature.ChallengeRating = creatureData.ChallengeRating;
            creature.LevelAdjustment = creatureData.LevelAdjustment;
            creature.CasterLevel     = creatureData.CasterLevel;
            creature.NumberOfHands   = creatureData.NumberOfHands;

            creature.Type      = GetCreatureType(creatureName);
            creature.Abilities = abilitiesGenerator.GenerateFor(creatureName);

            if (advancementSelector.IsAdvanced(creatureName))
            {
                var advancement = advancementSelector.SelectRandomFor(creatureName, creature.Type, creature.Size, creature.ChallengeRating);

                creature.IsAdvanced        = true;
                creature.Size              = advancement.Size;
                creature.Space.Value       = advancement.Space;
                creature.Reach.Value       = advancement.Reach;
                creature.CasterLevel      += advancement.CasterLevelAdjustment;
                creature.ChallengeRating   = advancement.AdjustedChallengeRating;
                creatureData.NaturalArmor += advancement.NaturalArmorAdjustment;

                creature.Abilities[AbilityConstants.Strength].AdvancementAdjustment     += advancement.StrengthAdjustment;
                creature.Abilities[AbilityConstants.Dexterity].AdvancementAdjustment    += advancement.DexterityAdjustment;
                creature.Abilities[AbilityConstants.Constitution].AdvancementAdjustment += advancement.ConstitutionAdjustment;

                creature.HitPoints = hitPointsGenerator.GenerateFor(
                    creatureName,
                    creature.Type,
                    creature.Abilities[AbilityConstants.Constitution],
                    creature.Size,
                    advancement.AdditionalHitDice, asCharacter);
            }
            else
            {
                creature.HitPoints = hitPointsGenerator.GenerateFor(
                    creatureName,
                    creature.Type,
                    creature.Abilities[AbilityConstants.Constitution],
                    creature.Size,
                    asCharacter: asCharacter);
            }

            if (creature.HitPoints.HitDiceQuantity == 0)
            {
                creature.ChallengeRating = ChallengeRatingConstants.Zero;
            }

            creature.Alignment = alignmentGenerator.Generate(creatureName);
            creature.Skills    = skillsGenerator.GenerateFor(creature.HitPoints, creatureName, creature.Type, creature.Abilities, creature.CanUseEquipment, creature.Size);
            creature.Languages = languageGenerator.GenerateWith(creatureName, creature.Abilities, creature.Skills);

            creature.SpecialQualities = featsGenerator.GenerateSpecialQualities(
                creatureName,
                creature.Type,
                creature.HitPoints,
                creature.Abilities,
                creature.Skills,
                creature.CanUseEquipment,
                creature.Size,
                creature.Alignment);

            creature.BaseAttackBonus = attacksGenerator.GenerateBaseAttackBonus(creature.Type, creature.HitPoints);
            creature.Attacks         = attacksGenerator.GenerateAttacks(
                creatureName,
                creatureData.Size,
                creature.Size,
                creature.BaseAttackBonus,
                creature.Abilities,
                creature.HitPoints.RoundedHitDiceQuantity);

            creature.Feats = featsGenerator.GenerateFeats(
                creature.HitPoints,
                creature.BaseAttackBonus,
                creature.Abilities,
                creature.Skills,
                creature.Attacks,
                creature.SpecialQualities,
                creature.CasterLevel,
                creature.Speeds,
                creatureData.NaturalArmor,
                creature.NumberOfHands,
                creature.Size,
                creature.CanUseEquipment);

            creature.Skills    = skillsGenerator.ApplyBonusesFromFeats(creature.Skills, creature.Feats, creature.Abilities);
            creature.HitPoints = hitPointsGenerator.RegenerateWith(creature.HitPoints, creature.Feats);

            creature.GrappleBonus = attacksGenerator.GenerateGrappleBonus(
                creatureName,
                creature.Size,
                creature.BaseAttackBonus,
                creature.Abilities[AbilityConstants.Strength]);

            var allFeats = creature.Feats.Union(creature.SpecialQualities);

            creature.Attacks   = attacksGenerator.ApplyAttackBonuses(creature.Attacks, allFeats, creature.Abilities);
            creature.Attacks   = equipmentGenerator.AddAttacks(allFeats, creature.Attacks, creature.NumberOfHands);
            creature.Equipment = equipmentGenerator.Generate(
                creature.Name,
                creature.CanUseEquipment,
                allFeats,
                creature.HitPoints.RoundedHitDiceQuantity,
                creature.Attacks,
                creature.Abilities,
                creature.Size);

            creature.Abilities = abilitiesGenerator.SetMaxBonuses(creature.Abilities, creature.Equipment);
            creature.Skills    = skillsGenerator.SetArmorCheckPenalties(creature.Name, creature.Skills, creature.Equipment);

            creature.InitiativeBonus = ComputeInitiativeBonus(creature.Feats);
            creature.Speeds          = speedsGenerator.Generate(creature.Name);
            creature.ArmorClass      = armorClassGenerator.GenerateWith(
                creature.Abilities,
                creature.Size,
                creatureName,
                creature.Type,
                allFeats,
                creatureData.NaturalArmor,
                creature.Equipment);
            creature.Saves = savesGenerator.GenerateWith(creature.Name, creature.Type, creature.HitPoints, allFeats, creature.Abilities);

            creature.Magic = magicGenerator.GenerateWith(creature.Name, creature.Alignment, creature.Abilities, creature.Equipment);

            return(creature);
        }