private Item AddSpecialMaterials(Item item) { while (specialMaterialGenerator.CanHaveSpecialMaterial(item.ItemType, item.Attributes, item.Traits)) { var material = specialMaterialGenerator.GenerateFor(item.ItemType, item.Attributes, item.Traits); item.Traits.Add(material); if (material == TraitConstants.SpecialMaterials.Dragonhide) { var metalAndWood = new[] { AttributeConstants.Metal, AttributeConstants.Wood }; item.Attributes = item.Attributes.Except(metalAndWood); } } return(item); }
private Item AddSpecialMaterials(Item item) { while (specialMaterialGenerator.CanHaveSpecialMaterial(item.ItemType, item.Attributes, item.Traits)) { var material = specialMaterialGenerator.GenerateFor(item.ItemType, item.Attributes, item.Traits); item.Traits.Add(material); } var masterworkMaterials = collectionsSelector.SelectFrom(TableNameConstants.Collections.Set.SpecialMaterials, TraitConstants.Masterwork); if (item.Traits.Intersect(masterworkMaterials).Any()) { item.Traits.Add(TraitConstants.Masterwork); } if (item.Traits.Contains(TraitConstants.SpecialMaterials.Dragonhide)) { var metalAndWood = new[] { AttributeConstants.Metal, AttributeConstants.Wood }; item.Attributes = item.Attributes.Except(metalAndWood); } return(item); }
public void GenerateForItemTypeThrowsExceptionIfNotAllowedItemType() { Assert.That(() => specialMaterialsGenerator.GenerateFor("item type", mithralAttributes, traits), Throws.ArgumentException); }
public void CacheMaterialsAndAttributeRequirementsOnConstruction() { foreach (var material in TraitConstants.SpecialMaterials.All()) { mockAttributesSelector.Verify(p => p.SelectFrom(TableNameConstants.Collections.Set.SpecialMaterials, material), Times.Once); } mockAttributesSelector.ResetCalls(); mockBooleanPercentileSelector.Setup(s => s.SelectFrom(TableNameConstants.Percentiles.Set.HasSpecialMaterial)).Returns(true); specialMaterialsGenerator.CanHaveSpecialMaterial(ItemTypeConstants.Armor, mithralAttributes, traits); specialMaterialsGenerator.GenerateFor(ItemTypeConstants.Armor, mithralAttributes, traits); mockAttributesSelector.Verify(s => s.SelectFrom(It.IsAny <string>(), It.IsAny <string>()), Times.Never); }