Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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"));
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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));
        }
Ejemplo n.º 7
0
        public void AffixGenerationUniqueGroupTest()
        {
            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>();

            var itemAffix = GetTestAffix("test_d1", "duplicate", new Dictionary <string, int>()
            {
                { defaultTag, 100 }
            });
            var duplicate = GetTestAffix("test_d2", "duplicate", new Dictionary <string, int>()
            {
                { defaultTag, 100 }
            });

            allAffixes.Add(itemAffix);
            allAffixes.Add(duplicate);

            for (int i = 0; i < 4; 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;

            for (var i = 0; i < 10; i++)
            {
                var equipmentModifiers = new EquipmentModifiers(new List <Influence>(),
                                                                new List <string>(),
                                                                new List <string>(),
                                                                100,
                                                                new Dictionary <string, int>());

                generated.Add(affixManager.GetAffix(equipmentModifiers, CurrencyModifier(), new List <Affix> {
                    itemAffix
                }, EquipmentRarity.Rare, _random));
            }

            Assert.IsTrue(!generated.Contains(itemAffix));
            Assert.IsTrue(!generated.Contains(duplicate));
        }
Ejemplo n.º 8
0
        public void AffixFossilWeightTest()
        {
            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);

            Fossil fossil = new Fossil();

            fossil.FullName           = "TestFossil";
            fossil.AddedAffixes       = new List <Affix>();
            fossil.ModWeightModifiers = new Dictionary <string, int>()
            {
                { fossilTag, 200 }
            };

            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);

            List <Affix> generated = new List <Affix>();
            IRandom      random    = SetupRandom().Object;

            for (var i = 0; i < 10; i++)
            {
                generated.Add(affixManager.GetAffix(new List <Affix>(), EquipmentRarity.Rare, random, new List <Fossil>()
                {
                    fossil
                }));
            }

            Assert.AreEqual(generated[0], testAffix);
            Assert.AreEqual(generated[1], testAffix);
        }
Ejemplo n.º 9
0
        public void AffixNoPrefixesWhenFullMagicTest()
        {
            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 }
            });

            p1.GenerationType = "prefix";

            var existing = new List <Affix>()
            {
                p1
            };

            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>());

            List <Affix> generated = new List <Affix>();
            IRandom      random    = SetupRandom().Object;

            for (var i = 0; i < 10; i++)
            {
                generated.Add(affixManager.GetAffix(existing, EquipmentRarity.Magic, random));
            }

            Assert.IsFalse(generated.Any(x => x.GenerationType == "prefix"));
        }
Ejemplo n.º 10
0
        public void AffixMasterModNoAttackTest()
        {
            String item       = "Murderous Eye Jewel";
            String defaultTag = "abyss_jewel_melee";
            String attackTag  = "attack";

            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 }, { attackTag, 100 }
            });
            var metamod = GetTestAffix("metamod", "ItemGenerationCannotRollAttackAffixes", new Dictionary <string, int>());

            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, 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>()
                {
                    metamod
                }, EquipmentRarity.Rare, _random));
            }

            Assert.IsFalse(generated.Contains(testAffix));
        }
Ejemplo n.º 11
0
        public void AffixMasterModNoCasterTest()
        {
            String item       = "Murderous Eye Jewel";
            String defaultTag = "abyss_jewel_melee";
            String casterTag  = "caster";

            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 }, { casterTag, 100 }
            });
            var metamod = getTestAffix("metamod", "ItemGenerationCannotRollCasterAffixes", new Dictionary <string, int>());

            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, new List <Affix>());

            List <Affix> generated = new List <Affix>();
            IRandom      random    = SetupRandom().Object;

            for (var i = 0; i < 10; i++)
            {
                generated.Add(affixManager.GetAffix(new List <Affix>()
                {
                    metamod
                }, EquipmentRarity.Rare, random, new List <Fossil>()));
            }

            Assert.IsFalse(generated.Contains(testAffix));
        }