Exemplo n.º 1
0
        private IEnumerable <Item> GetAncientSet(int ancientOptionCount, int itemCount)
        {
            var ancientSet = new Mock <ItemSetGroup>();

            ancientSet.Setup(a => a.Items).Returns(new List <ItemOfItemSet>());
            ancientSet.Setup(a => a.Options).Returns(new List <IncreasableItemOption>());
            ancientSet.Object.MinimumItemCount = 2;
            for (int i = 0; i < ancientOptionCount; i++)
            {
                var setOption = this.GetOption(Stats.DefenseBase, i + 10).ItemOption;
                setOption !.Number = i + 1;
                ancientSet.Object.Options.Add(setOption);
            }

            var bonusOption = this.GetOption(Stats.TotalStrength, 5).ItemOption;

            for (int i = 0; i < itemCount; i++)
            {
                var item = this.GetItem();
                item.Definition !.PossibleItemSetGroups.Add(ancientSet.Object);
                item.ItemSetGroups.Add(ancientSet.Object);
                item.ItemOptions.Add(new ItemOptionLink {
                    ItemOption = bonusOption, Level = 1
                });

                ancientSet.Object.Items.Add(new ItemOfItemSet {
                    BonusOption = bonusOption, ItemDefinition = item.Definition
                });
                yield return(item);
            }
        }
Exemplo n.º 2
0
        private static void ReadAncientOption(byte ancientByte, IContext persistenceContext, Item item)
        {
            if ((ancientByte & AncientMask) == 0)
            {
                return;
            }

            var bonusLevel       = (ancientByte & AncientBonusLevelMask) >> 2;
            var setDiscriminator = ancientByte & AncientDiscriminatorMask;
            var ancientSets      = item.Definition !.PossibleItemSetGroups
                                   .Where(set => set.AncientSetDiscriminator == setDiscriminator && set.Options.Any(o => o.OptionType == ItemOptionTypes.AncientOption)).ToList();

            if (ancientSets.Count > 1)
            {
                throw new ArgumentException($"Ambiguous ancient set discriminator: {ancientSets.Count} sets with discriminator {setDiscriminator} found for item definition ({item.Definition.Number}, {item.Definition.Group}).");
            }

            var ancientSet = ancientSets.FirstOrDefault()
                             ?? throw new ArgumentException($"Couldn't find ancient set (discriminator {setDiscriminator}) for item ({item.Definition.Number}, {item.Definition.Group}).");

            item.ItemSetGroups.Add(ancientSet);
            var itemOfSet = ancientSet.Items.First(i => i.ItemDefinition == item.Definition);

            if (bonusLevel > 0)
            {
                var optionLink = persistenceContext.CreateNew <ItemOptionLink>();
                optionLink.ItemOption = itemOfSet.BonusOption;
                optionLink.Level      = bonusLevel;
                item.ItemOptions.Add(optionLink);
            }
        }
Exemplo n.º 3
0
        private IEnumerable <Item> GetDefenseBonusSet(float setBonusDefense, byte minimumLevel, params byte[] levels)
        {
            var armorSet = new Mock <ItemSetGroup>();

            armorSet.Setup(a => a.Items).Returns(new List <ItemOfItemSet>());
            armorSet.Setup(a => a.Options).Returns(new List <IncreasableItemOption>());
            armorSet.Object.MinimumItemCount = levels.Length;
            armorSet.Object.SetLevel         = minimumLevel;
            armorSet.Object.Options.Add(this.GetOption(Stats.DefenseBase, setBonusDefense).ItemOption !);
            foreach (var level in levels)
            {
                var item = this.GetItem();
                item.Definition !.PossibleItemSetGroups.Add(armorSet.Object);
                item.ItemSetGroups.Add(armorSet.Object);
                armorSet.Object.Items.Add(new ItemOfItemSet {
                    ItemDefinition = item.Definition
                });
                item.Level = level;
                yield return(item);
            }
        }