public void GenerateCustomStaff()
        {
            var name                = Guid.NewGuid().ToString();
            var template            = itemVerifier.CreateRandomTemplate(name);
            var specialAbilityNames = template.Magic.SpecialAbilities.Select(a => a.Name);

            var abilities = new[]
            {
                new SpecialAbility {
                    Name = specialAbilityNames.First()
                },
                new SpecialAbility {
                    Name = specialAbilityNames.Last()
                }
            };

            mockSpecialAbilitiesGenerator.Setup(p => p.GenerateFor(specialAbilityNames)).Returns(abilities);

            var staff = staffGenerator.Generate(template);

            itemVerifier.AssertMagicalItemFromTemplate(staff, template);
            Assert.That(staff.ItemType, Is.EqualTo(ItemTypeConstants.Staff));
            Assert.That(staff.Attributes, Contains.Item(AttributeConstants.Charged));
            Assert.That(staff.Attributes, Contains.Item(AttributeConstants.OneTimeUse));
            Assert.That(staff.Attributes.Count(), Is.EqualTo(2));
            Assert.That(staff.Quantity, Is.EqualTo(1));
        }
Ejemplo n.º 2
0
        public void GenerateCustomArmor()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

            var attributes = new[] { "type 1", "type 2" };
            var tableName  = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, ItemTypeConstants.Armor);

            mockCollectionsSelector.Setup(p => p.SelectFrom(tableName, name)).Returns(attributes);

            var specialAbilityNames = template.Magic.SpecialAbilities.Select(a => a.Name);
            var abilities           = new[]
            {
                new SpecialAbility {
                    Name = specialAbilityNames.First()
                },
                new SpecialAbility {
                    Name = specialAbilityNames.Last()
                }
            };

            mockSpecialAbilitiesGenerator.Setup(p => p.GenerateFor(specialAbilityNames)).Returns(abilities);

            var armor = magicalArmorGenerator.Generate(template);

            itemVerifier.AssertMagicalItemFromTemplate(armor, template);
            Assert.That(armor.Quantity, Is.EqualTo(1));
            Assert.That(armor.ItemType, Is.EqualTo(ItemTypeConstants.Armor));
            Assert.That(armor.Attributes, Is.EquivalentTo(attributes));
            Assert.That(armor.Magic.SpecialAbilities, Is.EquivalentTo(abilities));
        }
Ejemplo n.º 3
0
        public void GenerateCustomAlchemicalItem()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

            var item = generator.Generate(template);

            itemVerifier.AssertMundaneItemFromTemplate(item, template);
            Assert.That(item.ItemType, Is.EqualTo(ItemTypeConstants.AlchemicalItem));
        }
Ejemplo n.º 4
0
        public void GenerateCustomTool()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

            var tool = generator.Generate(template);

            itemVerifier.AssertMundaneItemFromTemplate(tool, template);
            Assert.That(tool.ItemType, Is.EqualTo(ItemTypeConstants.Tool));
            Assert.That(tool.Attributes, Is.Empty);
            Assert.That(tool.IsMagical, Is.False);
            Assert.That(tool.Quantity, Is.EqualTo(1));
        }
        public void TemplateHasCurse()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

            var cursedItems = new[] { "other cursed item", name };

            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Collections.Set.ItemGroups, CurseConstants.SpecificCursedItem)).Returns(cursedItems);

            var isCursed = curseGenerator.IsSpecificCursedItem(template);

            Assert.That(isCursed, Is.True);
        }
Ejemplo n.º 6
0
        public void TemplateIsAmmunition()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

            var ammunitions = new[] { "other ammunition", name };

            mockPercentileSelector.Setup(s => s.SelectAllFrom(TableNameConstants.Percentiles.Set.Ammunitions)).Returns(ammunitions);

            var isAmmunition = ammunitionGenerator.TemplateIsAmmunition(template);

            Assert.That(isAmmunition, Is.True);
        }
Ejemplo n.º 7
0
        public void GenerateCustomPotion()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

            var potion = potionGenerator.Generate(template);

            itemVerifier.AssertMagicalItemFromTemplate(potion, template);
            Assert.That(potion.BaseNames.Single(), Is.EqualTo(name));
            Assert.That(potion.Attributes, Contains.Item(AttributeConstants.OneTimeUse));
            Assert.That(potion.IsMagical, Is.True);
            Assert.That(potion.ItemType, Is.EqualTo(ItemTypeConstants.Potion));
            Assert.That(potion.Quantity, Is.EqualTo(1));
        }
        public void GenerateSpecificCursedCustomItem()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

            var cursedItem = itemVerifier.CreateRandomTemplate(name);

            mockCurseGenerator.Setup(g => g.IsSpecificCursedItem(template)).Returns(true);
            mockCurseGenerator.Setup(g => g.GenerateSpecificCursedItem(template)).Returns(cursedItem);

            var decoratedItem = decorator.Generate(template, allowRandomDecoration: true);

            Assert.That(decoratedItem, Is.EqualTo(cursedItem));
            mockInnerGenerator.Verify(g => g.Generate(It.IsAny <Item>(), It.IsAny <bool>()), Times.Never);
        }
Ejemplo n.º 9
0
        public void GenerateCustomScroll()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

            var scroll = scrollGenerator.Generate(template);

            itemVerifier.AssertMagicalItemFromTemplate(scroll, template);
            Assert.That(scroll.ItemType, Is.EqualTo(ItemTypeConstants.Scroll));
            Assert.That(scroll.IsMagical, Is.True);
            Assert.That(scroll.Attributes.Single(), Is.EqualTo(AttributeConstants.OneTimeUse));
            Assert.That(scroll.Quantity, Is.EqualTo(1));
            Assert.That(scroll.Magic.Bonus, Is.EqualTo(0));
            Assert.That(scroll.Magic.Charges, Is.EqualTo(0));
            Assert.That(scroll.Magic.SpecialAbilities, Is.Empty);
        }
Ejemplo n.º 10
0
        public void GenerateCustomWand()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

            var wand = wandGenerator.Generate(template);

            itemVerifier.AssertMagicalItemFromTemplate(wand, template);
            Assert.That(wand.Name, Is.EqualTo(name));
            Assert.That(wand.ItemType, Is.EqualTo(ItemTypeConstants.Wand));
            Assert.That(wand.IsMagical, Is.True);
            Assert.That(wand.Attributes, Contains.Item(AttributeConstants.Charged));
            Assert.That(wand.Attributes, Contains.Item(AttributeConstants.OneTimeUse));
            Assert.That(wand.Quantity, Is.EqualTo(1));
            Assert.That(wand.Contents, Is.Empty);
        }
        public void GenerateCustomWondrousItem()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

            var attributes = new[] { "type 1", "type 2" };
            var tableName  = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, ItemTypeConstants.WondrousItem);

            mockAttributesSelector.Setup(p => p.SelectFrom(tableName, name)).Returns(attributes);

            var wondrousItem = wondrousItemGenerator.Generate(template);

            itemVerifier.AssertMagicalItemFromTemplate(wondrousItem, template);
            Assert.That(wondrousItem.Name, Is.EqualTo(name));
            Assert.That(wondrousItem.ItemType, Is.EqualTo(ItemTypeConstants.WondrousItem));
            Assert.That(wondrousItem.IsMagical, Is.True);
            Assert.That(wondrousItem.Attributes, Is.EqualTo(attributes));
        }
Ejemplo n.º 12
0
        public void GenerateCustomRing()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

            var attributes = new[] { "attribute 1", "attribute 2" };
            var tableName  = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, ItemTypeConstants.Ring);

            mockCollectionsSelector.Setup(p => p.SelectFrom(tableName, name)).Returns(attributes);

            var ring = ringGenerator.Generate(template);

            itemVerifier.AssertMagicalItemFromTemplate(ring, template);
            Assert.That(ring.BaseNames.Single(), Is.EqualTo(name));
            Assert.That(ring.Attributes, Is.EquivalentTo(attributes));
            Assert.That(ring.IsMagical, Is.True);
            Assert.That(ring.ItemType, Is.EqualTo(ItemTypeConstants.Ring));
            Assert.That(ring.Quantity, Is.EqualTo(1));
        }
        protected void GenerateAndAssertCustomItem()
        {
            var name     = GetRandomName();
            var template = ItemVerifier.CreateRandomTemplate(name);

            var item = mundaneItemGenerator.Generate(template);

            AssertItem(item);
            Assert.That(item.Name, Is.EqualTo(name));
            ItemVerifier.AssertMundaneItemFromTemplate(item, template);
        }
        protected void StressCustomItem()
        {
            var names    = GetItemNames();
            var name     = GetRandom(names);
            var template = ItemVerifier.CreateRandomTemplate(name);

            var item = mundaneItemGenerator.Generate(template);

            AssertItem(item);
            ItemVerifier.AssertMundaneItemFromTemplate(item, template);
        }
        private Item GetRandomTemplate(string name)
        {
            var template = ItemVerifier.CreateRandomTemplate(name);

            var abilitiesCount = Random.Next(specialAbilities.Count()) + 1;
            var abilityNames   = specialAbilities.Take(abilitiesCount);

            template.Magic.SpecialAbilities = abilityNames.Select(n => new SpecialAbility {
                Name = n
            });

            return(template);
        }
Ejemplo n.º 16
0
        public void GenerateCustomMundaneArmor()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

            var attributes = new[] { "attribute 1", "attribute 2" };
            var tableName  = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, ItemTypeConstants.Armor);

            mockAttributesSelector.Setup(p => p.SelectFrom(tableName, name)).Returns(attributes);

            mockPercentileSelector.Setup(p => p.SelectFrom(TableNameConstants.Percentiles.Set.MundaneGearSizes)).Returns("size");
            mockBooleanPercentileSelector.Setup(p => p.SelectFrom(TableNameConstants.Percentiles.Set.IsMasterwork))
            .Returns(true);

            var armor = mundaneArmorGenerator.Generate(template);

            itemVerifier.AssertMundaneItemFromTemplate(armor, template);
            Assert.That(armor.ItemType, Is.EqualTo(ItemTypeConstants.Armor));
            Assert.That(armor.Attributes, Is.EquivalentTo(attributes));
            Assert.That(armor.Traits, Contains.Item("size"));
            Assert.That(armor.Traits, Is.All.Not.EqualTo(TraitConstants.Masterwork));
            Assert.That(armor.Quantity, Is.EqualTo(1));
        }
        public void GenerateCustomArmor()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

            var specialAbilityNames = template.Magic.SpecialAbilities.Select(a => a.Name);
            var abilities           = new[]
            {
                new SpecialAbility {
                    Name = specialAbilityNames.First()
                },
                new SpecialAbility {
                    Name = specialAbilityNames.Last()
                }
            };

            mockSpecialAbilitiesGenerator.Setup(p => p.GenerateFor(template.Magic.SpecialAbilities)).Returns(abilities);

            var templateMundaneArmor = new Armor();

            templateMundaneArmor.Name = name;
            mockMundaneArmorGenerator.Setup(g => g.Generate(It.Is <Item>(i => i.NameMatches(name)), false)).Returns(templateMundaneArmor);

            var armor = magicalArmorGenerator.Generate(template);

            Assert.That(armor, Is.EqualTo(templateMundaneArmor));
            Assert.That(armor.Quantity, Is.EqualTo(1));
            Assert.That(armor.Magic.Bonus, Is.EqualTo(template.Magic.Bonus));
            Assert.That(armor.Magic.Charges, Is.EqualTo(template.Magic.Charges));
            Assert.That(armor.Magic.Curse, Is.EqualTo(template.Magic.Curse));
            Assert.That(armor.Magic.Intelligence.Ego, Is.EqualTo(template.Magic.Intelligence.Ego));
            Assert.That(armor.Magic.SpecialAbilities, Is.EquivalentTo(abilities));

            //INFO: Custom magic armor should be masterwork
            Assert.That(armor.Traits, Contains.Item(TraitConstants.Masterwork));
        }
        private Item GetRandomTemplate(string name)
        {
            var template = ItemVerifier.CreateRandomTemplate(name);

            var abilitiesCount = Random.Next(10) + 1;
            var abilityNames   = new HashSet <string>();

            while (abilityNames.Count < abilitiesCount)
            {
                var abilityName = GetRandom(specialAbilities);
                abilityNames.Add(abilityName);
            }

            template.Magic.SpecialAbilities = abilityNames.Select(n => new SpecialAbility {
                Name = n
            });

            return(template);
        }
Ejemplo n.º 19
0
        public void CopyIntelligence()
        {
            intelligence = itemVerifier.CreateRandomTemplate(string.Empty).Magic.Intelligence;

            var copy = intelligence.Clone();

            Assert.That(copy, Is.Not.EqualTo(intelligence));
            Assert.That(copy.Alignment, Is.EqualTo(intelligence.Alignment));
            Assert.That(copy.CharismaStat, Is.EqualTo(intelligence.CharismaStat));
            Assert.That(copy.Communication, Is.EquivalentTo(intelligence.Communication));
            Assert.That(copy.DedicatedPower, Is.EqualTo(intelligence.DedicatedPower));
            Assert.That(copy.Ego, Is.EqualTo(intelligence.Ego));
            Assert.That(copy.IntelligenceStat, Is.EqualTo(intelligence.IntelligenceStat));
            Assert.That(copy.Languages, Is.EquivalentTo(intelligence.Languages));
            Assert.That(copy.Personality, Is.EqualTo(intelligence.Personality));
            Assert.That(copy.Powers, Is.EquivalentTo(intelligence.Powers));
            Assert.That(copy.Senses, Is.EqualTo(intelligence.Senses));
            Assert.That(copy.SpecialPurpose, Is.EqualTo(intelligence.SpecialPurpose));
            Assert.That(copy.WisdomStat, Is.EqualTo(intelligence.WisdomStat));
        }
        public void GenerateCustomMundaneArmorFromNonArmorTemplate()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

            var attributes = new[] { "attribute 1", "attribute 2" };
            var tableName  = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, ItemTypeConstants.Armor);

            mockCollectionsSelector.Setup(p => p.SelectFrom(tableName, name)).Returns(attributes);

            mockPercentileSelector.Setup(p => p.SelectFrom <bool>(TableNameConstants.Percentiles.Set.IsMasterwork)).Returns(true);

            var baseNames = new[] { "base name", "other base name" };

            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Collections.Set.ItemGroups, name)).Returns(baseNames);

            armorSelection.ArmorBonus        = 9266;
            armorSelection.ArmorCheckPenalty = -90210;
            armorSelection.MaxDexterityBonus = 42;
            mockArmorDataSelector.Setup(s => s.Select(name)).Returns(armorSelection);

            var item  = mundaneArmorGenerator.Generate(template);
            var armor = item as Armor;

            itemVerifier.AssertMundaneItemFromTemplate(armor, template);
            Assert.That(armor.ItemType, Is.EqualTo(ItemTypeConstants.Armor));
            Assert.That(armor.Attributes, Is.EquivalentTo(attributes));
            Assert.That(armor.Traits, Is.All.Not.EqualTo("size"));
            Assert.That(armor.Size, Is.EqualTo("size"));
            Assert.That(armor.Traits, Is.All.Not.EqualTo(TraitConstants.Masterwork));
            Assert.That(armor.Quantity, Is.EqualTo(1));
            Assert.That(armor.BaseNames, Is.EqualTo(baseNames));
            Assert.That(armor.ArmorBonus, Is.EqualTo(9266));
            Assert.That(armor.ArmorCheckPenalty, Is.EqualTo(-90210));
            Assert.That(armor.MaxDexterityBonus, Is.EqualTo(42));
        }