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)); }
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)); }
public Item Generate(string power, string itemName, params string[] traits) { if (curseGenerator.IsSpecificCursedItem(itemName)) { return(curseGenerator.Generate(itemName, traits)); } var item = innerGenerator.Generate(power, itemName, traits); if (curseGenerator.HasCurse(item)) { var canBeSpecific = curseGenerator.CanBeSpecificCursedItem(itemName); do { item.Magic.Curse = curseGenerator.GenerateCurse(); }while (item.Magic.Curse == TableNameConstants.Percentiles.Set.SpecificCursedItems && !canBeSpecific); if (item.Magic.Curse == TableNameConstants.Percentiles.Set.SpecificCursedItems && canBeSpecific) { var cursedItem = curseGenerator.Generate(itemName, traits); return(cursedItem); } } return(item); }
public Item Generate(Item template, bool allowRandomDecoration = false) { var item = innerGenerator.Generate(template, allowRandomDecoration); item = AddSpecialMaterials(item, allowRandomDecoration); return(item); }
public void PassCustomItemThrough() { var template = new Item(); mockInnerGenerator.Setup(g => g.Generate(template, true)).Returns(innerItem); var item = mundaneProxy.Generate(template, true); Assert.That(item, Is.EqualTo(innerItem)); }
public Item Generate(Item template, bool allowRandomDecoration = false) { var item = innerGenerator.Generate(template, allowRandomDecoration); if (allowRandomDecoration) { item = AddTraits(item); } return(item); }
public void DecorateCustomItem() { var template = new Item(); mockInnerGenerator.Setup(g => g.Generate(template, true)).Returns(innerItem); mockCurseGenerator.Setup(g => g.HasCurse(It.IsAny <bool>())).Returns(true); mockCurseGenerator.Setup(g => g.GenerateCurse()).Returns("cursed"); var decoratedItem = decorator.Generate(template, allowRandomDecoration: true); Assert.That(decoratedItem, Is.Not.EqualTo(template)); Assert.That(decoratedItem, Is.EqualTo(innerItem)); Assert.That(decoratedItem.Magic.Curse, Is.EqualTo("cursed")); }
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.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)); Assert.That(potion.Magic.SpecialAbilities, Is.Empty); }
public void DecorateCustomItem() { var template = new Item(); mockInnerGenerator.Setup(g => g.Generate(template, true)).Returns(item); var traits = new[] { "trait 1", "trait 2" }; mockTraitsGenerator.Setup(g => g.GenerateFor(item.ItemType, item.Attributes)).Returns(traits); var decoratedItem = decorator.Generate(template, allowRandomDecoration: true); Assert.That(decoratedItem, Is.Not.EqualTo(template)); Assert.That(decoratedItem, Is.EqualTo(item)); Assert.That(decoratedItem.Traits, Is.EquivalentTo(traits)); }
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 DecorateCustomItem() { var template = new Item(); mockInnerGenerator.Setup(g => g.Generate(template, true)).Returns(innerItem); var intelligence = new Intelligence(); mockIntelligenceGenerator.Setup(g => g.IsIntelligent(innerItem.ItemType, innerItem.Attributes, It.IsAny <bool>())).Returns(true); mockIntelligenceGenerator.Setup(g => g.GenerateFor(It.IsAny <Item>())).Returns(intelligence); var decoratedItem = intelligenceDecorator.Generate(template, allowRandomDecoration: true); Assert.That(decoratedItem, Is.Not.EqualTo(template)); Assert.That(decoratedItem, Is.EqualTo(innerItem)); Assert.That(decoratedItem.Magic.Intelligence, Is.EqualTo(intelligence)); }
public void DecorateCustomItem() { var template = new Item(); mockInnerGenerator.Setup(g => g.Generate(template, true)).Returns(item); mockMaterialGenerator.SetupSequence(g => g.CanHaveSpecialMaterial(It.IsAny <string>(), It.IsAny <IEnumerable <string> >(), It.IsAny <IEnumerable <string> >())) .Returns(true).Returns(false); mockMaterialGenerator.Setup(g => g.GenerateFor(It.IsAny <string>(), It.IsAny <IEnumerable <string> >(), It.IsAny <IEnumerable <string> >())) .Returns("special material"); var decoratedItem = decorator.Generate(template, allowRandomDecoration: true); Assert.That(decoratedItem, Is.Not.EqualTo(template)); Assert.That(decoratedItem, Is.EqualTo(item)); Assert.That(decoratedItem.Traits, Contains.Item("special material")); }
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); }
protected void GenerateAndAssertCustomItem() { var name = GetRandomName(); var template = GetRandomTemplate(name); var allowDecoration = Convert.ToBoolean(Random.Next(2)); var item = magicalItemGenerator.Generate(template, allowDecoration); AssertItem(item); Assert.That(item.ItemType, Is.EqualTo(itemType)); if (!allowDecoration) { ItemVerifier.AssertMagicalItemFromTemplate(item, template); } }
public Item Generate(Item template, bool allowRandomDecoration = false) { var item = innerGenerator.Generate(template, allowRandomDecoration); var canBeIntelligent = intelligenceGenerator.CanBeIntelligent(item.Attributes, item.IsMagical); var isIntelligent = intelligenceGenerator.IsIntelligent(item.ItemType, item.Attributes, item.IsMagical); if (allowRandomDecoration && isIntelligent) { item.Magic.Intelligence = intelligenceGenerator.GenerateFor(item); } else if (!canBeIntelligent) { item.Magic.Intelligence = new Intelligence(); } return(item); }
public Item Generate(Item template, bool allowRandomDecoration = false) { eventQueue.Enqueue("TreasureGen", $"Beginning magical item generation from template: {template.ItemType} {template.Name}"); var item = innerGenerator.Generate(template, allowRandomDecoration); eventQueue.Enqueue("TreasureGen", $"Completed generation of {item.ItemType} {item.Name}"); return(item); }
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)); }
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)); }
public void LogGenerationEventsForTemplate() { var innerItem = new Item(); innerItem.Name = Guid.NewGuid().ToString(); innerItem.ItemType = Guid.NewGuid().ToString(); var template = new Item(); template.Name = Guid.NewGuid().ToString(); template.ItemType = Guid.NewGuid().ToString(); mockInnerGenerator.Setup(g => g.Generate(template, false)).Returns(innerItem); var item = decorator.Generate(template); Assert.That(item, Is.EqualTo(innerItem)); mockEventQueue.Verify(q => q.Enqueue(It.IsAny <string>(), It.IsAny <string>()), Times.Exactly(2)); mockEventQueue.Verify(q => q.Enqueue("TreasureGen", $"Beginning magical item generation from template: {template.ItemType} {template.Name}"), Times.Once); mockEventQueue.Verify(q => q.Enqueue("TreasureGen", $"Completed generation of {innerItem.ItemType} {innerItem.Name}"), Times.Once); }
public Item Generate(Item template, bool allowRandomDecoration = false) { if (curseGenerator.IsSpecificCursedItem(template)) { return(curseGenerator.GenerateSpecificCursedItem(template)); } var item = innerGenerator.Generate(template, allowRandomDecoration); if (allowRandomDecoration && curseGenerator.HasCurse(item.IsMagical)) { do { item.Magic.Curse = curseGenerator.GenerateCurse(); }while (item.Magic.Curse == TableNameConstants.Percentiles.Set.SpecificCursedItems); } return(item); }
public Item Generate(Item template, bool allowRandomDecoration = false) { return(innerGenerator.Generate(template, allowRandomDecoration)); }
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)); }
protected override Item GenerateRandomCustomItem(string name) { var template = GetRandomTemplate(name); return(magicalItemGenerator.Generate(template, allowRandomDecoration: true)); }