Ejemplo n.º 1
0
        private Item GenerateMundaneItem(string itemType, string itemName = null, params string[] traits)
        {
            var generator = justInTimeFactory.Build <MundaneItemGenerator>(itemType);

            if (string.IsNullOrEmpty(itemName))
            {
                return(generator.GenerateRandom());
            }

            return(generator.Generate(itemName, traits));
        }
Ejemplo n.º 2
0
        private Item GetItemFrom(Item template)
        {
            if (template.IsMagical)
            {
                var magicalGenerator = justInTimeFactory.Build <MagicalItemGenerator>(template.ItemType);
                return(magicalGenerator.Generate(template, false));
            }

            var mundaneGenerator = justInTimeFactory.Build <MundaneItemGenerator>(template.ItemType);

            return(mundaneGenerator.Generate(template, false));
        }
Ejemplo n.º 3
0
        private Armor GenerateFromPrototype(Armor prototype)
        {
            if (specificGearGenerator.IsSpecific(prototype))
            {
                var specificArmor = specificGearGenerator.GenerateFrom(prototype);
                specificArmor.Quantity = 1;

                return(specificArmor as Armor);
            }

            var mundaneArmorGenerator = justInTimeFactory.Build <MundaneItemGenerator>(ItemTypeConstants.Armor);
            var armor = mundaneArmorGenerator.Generate(prototype);

            armor.Magic.Bonus            = prototype.Magic.Bonus;
            armor.Magic.Charges          = prototype.Magic.Charges;
            armor.Magic.Curse            = prototype.Magic.Curse;
            armor.Magic.Intelligence     = prototype.Magic.Intelligence;
            armor.Magic.SpecialAbilities = prototype.Magic.SpecialAbilities;

            if (armor.IsMagical)
            {
                armor.Traits.Add(TraitConstants.Masterwork);
            }

            return(armor as Armor);
        }
Ejemplo n.º 4
0
        private Armor GetArmor(Item gear)
        {
            var name = gear.BaseNames.First();

            var mundaneArmorGenerator = justInTimeFactory.Build <MundaneItemGenerator>(ItemTypeConstants.Armor);
            var armor = mundaneArmorGenerator.Generate(name, gear.Traits.ToArray()) as Armor;

            gear.CloneInto(armor);

            if (armor.IsMagical)
            {
                armor.Traits.Add(TraitConstants.Masterwork);
            }

            armor.Traits.Remove(armor.Size);

            return(armor);
        }
        public void FactoryBuilds()
        {
            var mockGenerator = new Mock <IPercentileSelector>();

            kernel.Bind <IPercentileSelector>().ToMethod(c => mockGenerator.Object);

            var generator = justInTimeFactory.Build <IPercentileSelector>();

            Assert.That(generator, Is.Not.Null);
            Assert.That(generator, Is.EqualTo(mockGenerator.Object));
        }
Ejemplo n.º 6
0
        private Creature Generate(string creatureName, string template, bool asCharacter)
        {
            var compatible = creatureVerifier.CanBeCharacter(creatureName);

            if (!compatible && asCharacter)
            {
                throw new IncompatibleCreatureAsCharacterException(creatureName);
            }

            compatible = creatureVerifier.VerifyCompatibility(creatureName, template);
            if (!compatible)
            {
                throw new IncompatibleCreatureAndTemplateException(creatureName, template);
            }

            var creature = GeneratePrototype(creatureName, asCharacter);

            var templateApplicator = justInTimeFactory.Build <TemplateApplicator>(template);

            creature = templateApplicator.ApplyTo(creature);

            return(creature);
        }
Ejemplo n.º 7
0
        private Weapon GenerateFromPrototype(Item prototype, bool allowDecoration)
        {
            if (specificGearGenerator.IsSpecific(prototype))
            {
                var specificWeapon = specificGearGenerator.GenerateFrom(prototype);
                return(specificWeapon as Weapon);
            }

            var mundaneWeaponGenerator = justInTimeFactory.Build <MundaneItemGenerator>(ItemTypeConstants.Weapon);
            var weapon = mundaneWeaponGenerator.Generate(prototype, allowDecoration);

            weapon.Magic.Bonus            = prototype.Magic.Bonus;
            weapon.Magic.Charges          = prototype.Magic.Charges;
            weapon.Magic.Curse            = prototype.Magic.Curse;
            weapon.Magic.Intelligence     = prototype.Magic.Intelligence;
            weapon.Magic.SpecialAbilities = prototype.Magic.SpecialAbilities;

            if (weapon.Attributes.Contains(AttributeConstants.Ammunition))
            {
                weapon.Magic.Intelligence = new Intelligence();
            }

            if (weapon.IsMagical)
            {
                weapon.Traits.Add(TraitConstants.Masterwork);
            }

            var magicWeapon = weapon as Weapon;

            if (!magicWeapon.IsDoubleWeapon)
            {
                return(magicWeapon);
            }

            var sameEnhancement = percentileSelector.SelectFrom(.5);

            if (!sameEnhancement)
            {
                magicWeapon.SecondaryMagicBonus   = weapon.Magic.Bonus - 1;
                magicWeapon.SecondaryHasAbilities = false;

                return(magicWeapon);
            }

            magicWeapon.SecondaryMagicBonus   = weapon.Magic.Bonus;
            magicWeapon.SecondaryHasAbilities = true;

            return(magicWeapon);
        }
Ejemplo n.º 8
0
        public bool VerifyCompatibility(string creatureName, string templateName)
        {
            var applicator = factory.Build <TemplateApplicator>(templateName);

            return(applicator.IsCompatible(creatureName));
        }
Ejemplo n.º 9
0
        private Item GetWeapon(Item rod)
        {
            var weapons         = WeaponConstants.GetAllMelee(false, false);
            var weaponBaseNames = weapons.Intersect(rod.BaseNames);

            if (!weaponBaseNames.Any())
            {
                return(rod);
            }

            var weaponName = weaponBaseNames.First();

            var mundaneWeaponGenerator = justInTimeFactory.Build <MundaneItemGenerator>(ItemTypeConstants.Weapon);
            var mundaneWeapon          = mundaneWeaponGenerator.Generate(weaponName, rod.Traits.ToArray()) as Weapon;

            rod.Attributes = rod.Attributes.Union(mundaneWeapon.Attributes);
            rod.CloneInto(mundaneWeapon);

            if (mundaneWeapon.IsMagical)
            {
                mundaneWeapon.Traits.Add(TraitConstants.Masterwork);
            }

            if (mundaneWeapon.IsDoubleWeapon)
            {
                mundaneWeapon.SecondaryHasAbilities = true;
                mundaneWeapon.SecondaryMagicBonus   = rod.Magic.Bonus;
            }

            foreach (var specialAbility in mundaneWeapon.Magic.SpecialAbilities)
            {
                if (specialAbility.Damages.Any())
                {
                    var damages    = specialAbility.Damages.Select(d => d.Clone()).ToArray();
                    var damageType = mundaneWeapon.Damages[0].Type;

                    foreach (var damage in damages)
                    {
                        if (string.IsNullOrEmpty(damage.Type))
                        {
                            damage.Type = damageType;
                        }
                    }

                    mundaneWeapon.Damages.AddRange(damages);

                    if (mundaneWeapon.SecondaryHasAbilities)
                    {
                        var secondaryDamages    = specialAbility.Damages.Select(d => d.Clone()).ToArray();
                        var secondaryDamageType = mundaneWeapon.SecondaryDamages[0].Type;

                        foreach (var damage in secondaryDamages)
                        {
                            if (string.IsNullOrEmpty(damage.Type))
                            {
                                damage.Type = secondaryDamageType;
                            }
                        }

                        mundaneWeapon.SecondaryDamages.AddRange(secondaryDamages);
                    }
                }

                if (specialAbility.CriticalDamages.Any())
                {
                    var damageType = mundaneWeapon.CriticalDamages[0].Type;
                    foreach (var damage in specialAbility.CriticalDamages[mundaneWeapon.CriticalMultiplier])
                    {
                        if (string.IsNullOrEmpty(damage.Type))
                        {
                            damage.Type = damageType;
                        }
                    }

                    mundaneWeapon.CriticalDamages.AddRange(specialAbility.CriticalDamages[mundaneWeapon.CriticalMultiplier]);

                    if (mundaneWeapon.SecondaryHasAbilities)
                    {
                        foreach (var damage in specialAbility.CriticalDamages[mundaneWeapon.SecondaryCriticalMultiplier])
                        {
                            if (string.IsNullOrEmpty(damage.Type))
                            {
                                damage.Type = damageType;
                            }
                        }

                        mundaneWeapon.SecondaryCriticalDamages.AddRange(specialAbility.CriticalDamages[mundaneWeapon.SecondaryCriticalMultiplier]);
                    }
                }

                if (specialAbility.Name == SpecialAbilityConstants.Keen)
                {
                    mundaneWeapon.ThreatRange *= 2;
                }
            }

            return(mundaneWeapon);
        }