public void AffixGenerationDefaultTest() { int count = 10; String item = "Murderous Eye Jewel"; String defaultTag = "abyss_jewel_melee"; var testItem = _itemFactory.Jewel.First(x => x.Name == item); List <Affix> allAffixes = new List <Affix>(); var fossilAffixes = new List <Affix>(); for (int i = 0; i < count; i++) { allAffixes.Add(getTestAffix("test" + i, "test" + i, new Dictionary <string, int>() { { defaultTag, 100 } })); } AffixManager affixManager = new AffixManager(testItem, allAffixes, fossilAffixes); List <Affix> generated = new List <Affix>(); IRandom random = SetupRandom().Object; for (var i = 0; i < count; i++) { generated.Add(affixManager.GetAffix(new List <Affix>(), EquipmentRarity.Rare, random)); } Assert.AreEqual(count, generated.Count); }
public bool CanUseOnNormal(ICurrency currency) { var item = _factory.GetNormal(); AffixManager affixManager = CreateAffixManager(item.ItemBase); return(currency.Execute(item, affixManager)); }
public bool Execute(Equipment item, AffixManager affixManager) { if (item.Corrupted || item.Rarity != EquipmentRarity.Rare) { return(false); } int fourMod = 8; int fiveMod = 3; int sixMod = 1; var sum = fourMod + fiveMod + sixMod; var roll = Random.Next(sum); int modCount = roll < fourMod ? 4 : roll < fourMod + fiveMod ? 5 : 6; item.Stats.Clear(); var mod = _essence.ItemClassToMod[item.ItemBase.ItemClass]; StatFactory.AffixToStat(Random, item, mod); for (int i = 1; i < modCount; i++) { StatFactory.AddExplicit(Random, item, affixManager); } return(true); }
public void AffixNoPrefixesWhenFullNormalTest() { String item = "Murderous Eye Jewel"; String defaultTag = "abyss_jewel_melee"; var testItem = _itemFactory.Jewel.First(x => x.Name == item); List <Affix> allAffixes = new List <Affix>(); for (int i = 0; i < 10; i++) { Affix affix = GetTestAffix("test_" + i, "test" + i, new Dictionary <string, int>() { { defaultTag, 100 } }); affix.GenerationType = i < 5 ? "prefix" : "suffix"; allAffixes.Add(affix); } AffixManager affixManager = new AffixManager(testItem, allAffixes, new List <Affix>(), new Dictionary <Influence, List <Affix> >(), new Dictionary <Influence, string>()); List <Affix> generated = new List <Affix>(); IRandom random = SetupRandom().Object; var equipmentModifiers = new EquipmentModifiers(new List <Influence>(), new List <string>(), new List <string>(), 100, new Dictionary <string, int>()); for (var i = 0; i < 10; i++) { generated.Add(affixManager.GetAffix(equipmentModifiers, CurrencyModifier(), new List <Affix>(), EquipmentRarity.Normal, _random)); } Assert.IsTrue(generated.All(x => x == null)); }
public void IfCraftingStepTrueConditionTest() { Mock <ICraftingStep> mockChildStep = new Mock <ICraftingStep>(); List <ICraftingStep> craftingSteps = new List <ICraftingStep>(); IfCraftingStep ifStep = new IfCraftingStep(); ifStep.Children.Add(mockChildStep.Object); ifStep.Condition = GetTestCondition(); craftingSteps.Add(ifStep); EndCraftingStep endCrafting = new EndCraftingStep(); craftingSteps.Add(endCrafting); Equipment equipment = GetTestEquipment(true); AffixManager affixManager = CreateAffixManager(equipment.ItemBase); CancellationToken token = new CancellationToken(false); mockChildStep.Setup(x => x.ShouldVisitChildren(It.IsAny <Equipment>(), It.IsAny <int>())).Returns(false); mockChildStep.Setup(x => x.Craft(It.IsAny <Equipment>(), It.IsAny <AffixManager>())) .Returns(new Dictionary <string, int>()); _craftManager.Craft(craftingSteps, equipment, affixManager, token, _progressManager); mockChildStep.Verify(x => x.Craft(It.IsAny <Equipment>(), It.IsAny <AffixManager>()), Times.Once); Assert.IsTrue(equipment.Completed); }
public void CurrencyCraftingTest() { Mock <ICraftingStep> mockChildStep = new Mock <ICraftingStep>(); List <ICraftingStep> craftingSteps = new List <ICraftingStep>(); WhileCraftingStep whileStep = new WhileCraftingStep(); whileStep.Children.Add(mockChildStep.Object); whileStep.Condition = GetTestCondition(); craftingSteps.Add(whileStep); EndCraftingStep endCrafting = new EndCraftingStep(); craftingSteps.Add(endCrafting); Equipment equipment = GetTestEquipment(false); AffixManager affixManager = CreateAffixManager(equipment.ItemBase); CancellationToken token = new CancellationToken(false); _craftManager.Craft(craftingSteps, equipment, affixManager, token, _progressManager); mockChildStep.Verify(x => x.Craft(It.IsAny <Equipment>(), It.IsAny <AffixManager>()), Times.Never); Assert.IsTrue(equipment.Completed); }
public void AffixNoSuffixesWhenFullTest() { String item = "Murderous Eye Jewel"; String defaultTag = "abyss_jewel_melee"; var testItem = _itemFactory.Jewel.First(x => x.Name == item); List <Affix> allAffixes = new List <Affix>(); var p1 = GetTestAffix("test_p1", "test_p1", new Dictionary <string, int>() { { defaultTag, 100 } }); var p2 = GetTestAffix("test_p2", "test_p2", new Dictionary <string, int>() { { defaultTag, 100 } }); var p3 = GetTestAffix("test_p3", "test_p3", new Dictionary <string, int>() { { defaultTag, 100 } }); p1.GenerationType = "suffix"; p2.GenerationType = "suffix"; p3.GenerationType = "suffix"; var existing = new List <Affix>() { p1, p2, p3 }; allAffixes.AddRange(existing); for (int i = 0; i < 10; i++) { Affix affix = GetTestAffix("test_" + i, "test" + i, new Dictionary <string, int>() { { defaultTag, 100 } }); affix.GenerationType = i < 5 ? "prefix" : "suffix"; allAffixes.Add(affix); } AffixManager affixManager = new AffixManager(testItem, allAffixes, new List <Affix>(), new Dictionary <Influence, List <Affix> >(), new Dictionary <Influence, string>()); List <Affix> generated = new List <Affix>(); IRandom random = SetupRandom().Object; var equipmentModifiers = new EquipmentModifiers(new List <Influence>(), new List <string>(), new List <string>(), 100, new Dictionary <string, int>()); for (var i = 0; i < 10; i++) { generated.Add(affixManager.GetAffix(equipmentModifiers, CurrencyModifier(), existing, EquipmentRarity.Rare, _random)); } Assert.IsFalse(generated.Any(x => x.GenerationType == "suffix")); }
public bool CanUseOnCorruptedRare(ICurrency currency) { var item = _factory.GetNormal(); AffixManager affixManager = CreateAffixManager(item.ItemBase); _alchemy.Execute(item, affixManager); item.Corrupted = true; return(currency.Execute(item, affixManager)); }
public bool CanUseOnCorruptedMagic(ICurrency currency) { var item = _factory.GetNormal(); AffixManager affixManager = CreateAffixManager(item.ItemBase); _transmutation.Execute(item, affixManager); item.Corrupted = true; return(currency.Execute(item, affixManager)); }
public void VaalNormalTest() { var item = _factory.GetNormal(); AffixManager affixManager = _currencyTestHelper.CreateAffixManager(item.ItemBase); var result = _vaal.Execute(item, affixManager); Assert.IsTrue(result); Assert.IsTrue(item.Corrupted); }
public bool Execute(Equipment item, AffixManager affixManager) { if (item.Corrupted || item.Rarity != EquipmentRarity.Normal) { return(false); } item.Rarity = EquipmentRarity.Rare; return(Chaos.Execute(item, affixManager)); }
public bool Execute(Equipment item, AffixManager affixManager) { if (item.Corrupted || item.Rarity != EquipmentRarity.Rare) { return(false); } var corruptedEssenceChance = Fossils.Max(x => x.CorruptedEssenceChance); bool addCorruptedEssence = false; if (corruptedEssenceChance == 100) { addCorruptedEssence = true; } else if (corruptedEssenceChance > 0) { var chance = Random.Next(100); if (chance >= corruptedEssenceChance) { addCorruptedEssence = true; } } int addedAffixes = 0; if (addCorruptedEssence) { var essence = _corruptionOnlyEssences[Random.Next(_corruptionOnlyEssences.Count)]; StatFactory.AddExplicit(Random, item, essence.ItemClassToMod[item.ItemBase.ItemClass]); addedAffixes = 1; } int fourMod = 8; int fiveMod = 3; int sixMod = 1; var sum = fourMod + fiveMod + sixMod; var roll = Random.Next(sum); int modCount = roll < fourMod ? 4 : roll < fourMod + fiveMod ? 5 : 6; item.Stats.Clear(); for (int i = addedAffixes; i < modCount; i++) { StatFactory.AddExplicit(Random, item, affixManager, Fossils); } return(true); }
public bool Execute(Equipment item, AffixManager affixManager) { if (item.Corrupted || item.Rarity != EquipmentRarity.Magic || item.Prefixes.Count + item.Suffixes.Count != 1) { return(false); } StatFactory.AddExplicit(Random, item, affixManager); return(true); }
public bool Execute(Equipment item, AffixManager affixManager) { if (item.Corrupted || item.Rarity != EquipmentRarity.Normal) { return(false); } item.Rarity = EquipmentRarity.Magic; return(Alteration.Execute(item, affixManager)); }
public void TransmutationSuccessTest() { var item = _factory.GetNormal(); AffixManager affixManager = _currencyTestHelper.CreateAffixManager(item.ItemBase); var result = _transmutation.Execute(item, affixManager); Assert.IsTrue(result); Assert.IsTrue(item.Suffixes.Count + item.Prefixes.Count >= 1); Assert.AreEqual(EquipmentRarity.Magic, item.Rarity); }
public bool Execute(Equipment item, AffixManager affixManager) { if (item.Corrupted || item.Rarity == EquipmentRarity.Normal || item.Rarity == EquipmentRarity.Unique || item.Stats.Count == 0) { return(false); } StatFactory.RemoveExplicit(_random, item); return(true); }
public bool Execute(Equipment equipment, AffixManager affixManager) { var crafted = equipment.Stats.Where(x => x.Affix.GenerationType == "crafted").ToList(); if (!crafted.Any()) { return(false); } equipment.Stats = equipment.Stats.Except(crafted).ToList(); return(true); }
public void ChanceSuccessTest() { var item = _factory.GetNormal(); AffixManager affixManager = _currencyTestHelper.CreateAffixManager(item.ItemBase); var result = _chance.Execute(item, affixManager); Assert.IsTrue(result); Assert.IsTrue(item.Suffixes.Count >= 1); Assert.IsTrue(item.Prefixes.Count >= 1); Assert.AreNotEqual(EquipmentRarity.Normal, item.Rarity); }
public CraftMetadata Craft( List <ICraftingStep> craftingSteps, Equipment equipment, AffixManager affixManager, CancellationToken ct, ProgressManager progressManager) { CraftMetadata metadata = new CraftMetadata(); metadata.Result = equipment; return(this.Craft(craftingSteps, equipment, affixManager, ct, metadata, progressManager)); }
public void CurrencyWeightModifierTest() { String item = "Murderous Eye Jewel"; String defaultTag = "abyss_jewel_melee"; String fossilTag = "abyss_jewel"; var testItem = _itemFactory.Jewel.First(x => x.Name == item); List <Affix> allAffixes = new List <Affix>(); var fossilAffixes = new List <Affix>(); var testAffix = GetTestAffix("test", "test", new Dictionary <string, int>() { { fossilTag, 100 } }); allAffixes.Add(testAffix); for (int i = 0; i < 8; i++) { allAffixes.Add(GetTestAffix("test_" + i, "test" + i, new Dictionary <string, int>() { { defaultTag, 100 } })); } AffixManager affixManager = new AffixManager(testItem, allAffixes, fossilAffixes, new Dictionary <Influence, List <Affix> >(), new Dictionary <Influence, string>()); List <Affix> generated = new List <Affix>(); IRandom random = SetupRandom().Object; CurrencyModifiers currencyModifiers = new CurrencyModifiers( null, new Dictionary <string, double>() { { fossilTag, 200 } }, null, null, null); var equipmentModifiers = new EquipmentModifiers(new List <Influence>(), new List <string>(), new List <string>(), 100, new Dictionary <string, int>()); for (var i = 0; i < 10; i++) { generated.Add(affixManager.GetAffix(equipmentModifiers, currencyModifiers, new List <Affix>(), EquipmentRarity.Rare, random)); } Assert.AreEqual(generated[0], testAffix); Assert.AreEqual(generated[1], testAffix); }
public CraftMetadata Craft( List <ICraftingStep> craftingSteps, Equipment equipment, AffixManager affixManager, CancellationToken ct, double?currencyLimit) { CraftMetadata metadata = new CraftMetadata(); metadata.Result = equipment; return(this.Craft(craftingSteps, equipment, affixManager, ct, metadata, currencyLimit)); }
public void AnullmentInvalidNoAffixesTest() { var item = _factory.GetNormal(); AffixManager affixManager = _currencyTestHelper.CreateAffixManager(item.ItemBase); _transmutation.Execute(item, affixManager); _anullment.Execute(item, affixManager); _anullment.Execute(item, affixManager); var result = _anullment.Execute(item, affixManager); Assert.IsFalse(result); }
public CraftingSimulator( SimBaseItemInfo baseItemInfo, SimFinanceInfo financeInfo, SimCraftingInfo craftingInfo) { _affixFactory = new AffixFactory(); _itemFactory = new ItemFactory(_affixFactory); _fossilFactory = new FossilFactory(_affixFactory); _masterModFactory = new MasterModFactory(_affixFactory, _itemFactory); _essenceFactory = new EssenceFactory(_itemFactory, _affixFactory); var currencyFactory = new CurrencyFactory( new PoeRandom(), _essenceFactory, _fossilFactory, _masterModFactory); var clientToDomainMapper = new ClientToDomainMapper(_itemFactory, currencyFactory); var domainToClientMapper = new DomainToClientMapper(); _clientToDomain = clientToDomainMapper.GenerateMapper(); _domainToClient = domainToClientMapper.GenerateMapper(); _financeInfo = financeInfo; _craftingInfo = craftingInfo; _baseItemInfo = baseItemInfo; _baseItem = _itemFactory.Items.First(x => x.Name == _baseItemInfo.ItemName); var itemAffixes = _affixFactory.GetAffixesForItem( _baseItem.Tags, _baseItem.ItemClass, _baseItemInfo.ItemLevel); var fossilAffixes = _fossilFactory.Fossils .SelectMany(x => x.AddedAffixes) .ToList(); var essenceAffixes = _essenceFactory.GetAffixesByItemClass(_baseItem.ItemClass) .ToList(); var currencyAffixes = fossilAffixes.Union(essenceAffixes).ToList(); var influences = new List <Influence>((Influence[])Enum.GetValues(typeof(Influence))); var affixesByInfluence = _affixFactory.GetAffixesByInfluence(influences, _baseItem.ItemClass, _baseItemInfo.ItemLevel); var influenceSpawnTag = _affixFactory.GetInfluenceSpawnTags(_baseItem.ItemClass); _affixManager = new AffixManager(_baseItem, itemAffixes, currencyAffixes, affixesByInfluence, influenceSpawnTag); _currencyValues = _currencyValueFactory.GetCurrencyValues(financeInfo.League); }
public void AffixGenerationTest() { int count = 1000; int ilvl = 75; var influence = Influence.Shaper; String item = "Murderous Eye Jewel"; List <Affix> affixes = new List <Affix>() { getTestAffix("test", "SpecificWeaponColdDamage", null, "specific_weapon", "mace"), }; List <Fossil> fossils = new List <Fossil>(); var fossilAffixes = new List <Affix>(); var testItem = _itemFactory.Jewel.First(x => x.Name == item); var allAffixes = _affixFactory.GetAffixesForItem(testItem.Tags, testItem.ItemClass, ilvl, new List <Influence> { influence }).ToList(); AffixManager affixManager = new AffixManager(testItem, allAffixes, fossilAffixes); List <Affix> generated = new List <Affix>(); for (int i = 0; i < count; i++) { for (int x = 0; x < 6; x++) { generated.Add(affixManager.GetAffix(affixes, EquipmentRarity.Rare, random)); } } var description = new { Item = item, Faction = Enum.GetName(typeof(Influence), influence), Ilvl = ilvl, Count = count, Affixes = affixes.Select(x => new { x.Group, x.AddsTags }), Fossils = fossils, }; var groups = generated.GroupBy(x => x.Group).ToDictionary(x => x.Key, x => x.Count()).ToList(); var affixNames = generated.GroupBy(x => x.FullName).ToDictionary(x => x.Key, x => x.Count()).ToList(); var bundle = new { Description = description, GroupCount = groups, AffixCount = affixNames }; var bundleJson = JsonConvert.SerializeObject(bundle); // Assert.IsNotNull(groups); }
public bool Execute(Equipment item, AffixManager affixManager) { if (item.Corrupted || item.Rarity != EquipmentRarity.Magic) { return(false); } item.Rarity = EquipmentRarity.Rare; StatFactory.AddExplicit(Random, item, affixManager); return(true); }
public void NoCraftingStepsTest() { List <ICraftingStep> craftingSteps = new List <ICraftingStep>(); Equipment equipment = GetTestEquipment(true); CancellationToken token = new CancellationToken(false); AffixManager affixManager = CreateAffixManager(equipment.ItemBase); _craftManager.Craft(craftingSteps, equipment, affixManager, token, _progressManager); Assert.IsFalse(equipment.Completed); }
public CraftMetadata Craft( List <ICraftingStep> craftingSteps, Equipment equipment, AffixManager affixManager, CancellationToken ct, CraftMetadata metadata, ProgressManager progressManager) { foreach (var craftingStep in craftingSteps) { if (equipment.Completed) { return(metadata); } if (progressManager.Progress >= 100) { return(metadata); } if (ct.IsCancellationRequested) { ct.ThrowIfCancellationRequested(); } var currency = craftingStep.Craft(equipment, affixManager); UpdateMetadataOnCraft(craftingStep, metadata, currency, progressManager); var times = 0; double previousProgress = 0; while (craftingStep.ShouldVisitChildren(equipment, times)) { metadata = Craft(craftingStep.Children, equipment, affixManager, ct, metadata, progressManager); UpdateMetadataOnChildrenVisit(craftingStep, metadata); times++; if (times > 1) { // Check for no crafting steps if (Math.Abs(previousProgress - progressManager.Progress) < double.Epsilon) { throw new ArgumentException("Crafting steps do not spend currency"); } previousProgress = progressManager.Progress; } } } return(metadata); }
public void AddedAffixesTest() { String item = "Murderous Eye Jewel"; String defaultTag = "abyss_jewel_melee"; var testItem = _itemFactory.Jewel.First(x => x.Name == item); List <Affix> allAffixes = new List <Affix>(); var testAffix = GetTestAffix("test", "test", new Dictionary <string, int>() { { defaultTag, 100 } }); var addedAffixes = new List <Affix> { testAffix }; CurrencyModifiers currencyModifiers = new CurrencyModifiers( addedAffixes, null, null, null, null); for (int i = 0; i < 9; i++) { allAffixes.Add(GetTestAffix("test_" + i, "test" + i, new Dictionary <string, int>() { { defaultTag, 100 } })); } AffixManager affixManager = new AffixManager(testItem, allAffixes, addedAffixes, new Dictionary <Influence, List <Affix> >(), new Dictionary <Influence, string>()); List <Affix> generated = new List <Affix>(); IRandom random = SetupRandom().Object; var equipmentModifiers = new EquipmentModifiers(new List <Influence>(), new List <string>(), new List <string>(), 100, new Dictionary <string, int>()); for (var i = 0; i < 10; i++) { generated.Add(affixManager.GetAffix(equipmentModifiers, currencyModifiers, new List <Affix>(), EquipmentRarity.Rare, random)); } Assert.IsTrue(generated.Contains(testAffix)); }
public void ScouringRareSuccessTest() { var item = _factory.GetNormal(); AffixManager affixManager = _currencyTestHelper.CreateAffixManager(item.ItemBase); _alchemy.Execute(item, affixManager); var result = _scouring.Execute(item, affixManager); Assert.IsTrue(result); Assert.AreEqual(0, item.Suffixes.Count); Assert.AreEqual(0, item.Prefixes.Count); Assert.AreEqual(EquipmentRarity.Normal, item.Rarity); }
public void AnullmentRareTest() { var item = _factory.GetNormal(); AffixManager affixManager = _currencyTestHelper.CreateAffixManager(item.ItemBase); _alchemy.Execute(item, affixManager); var oldAffixCount = item.Prefixes.Count + item.Suffixes.Count; var result = _anullment.Execute(item, affixManager); Assert.IsTrue(result); var newAffixCount = item.Prefixes.Count + item.Suffixes.Count; Assert.AreEqual(oldAffixCount, newAffixCount + 1); }