Exemplo n.º 1
0
        public ItemStats(int itemId, int rarity)
        {
            BasicAttributes = new List <ItemStat>();
            BonusAttributes = new List <ItemStat>();
            Gemstones       = new List <Gemstone>();
            if (rarity == 0)
            {
                return;
            }

            if (ItemStatsMetadataStorage.GetBasic(itemId, out List <ItemOptions> basicList))
            {
                ItemOptions itemoption = basicList.Find(options => options.Rarity == rarity);
                if (itemoption != null)
                {
                    AddStat(BasicAttributes, itemoption.Stats);
                }
            }

            if (ItemStatsMetadataStorage.GetRandomBonus(itemId, out List <ItemOptions> randomBonusList))
            {
                ItemOptions itemoption = randomBonusList.Find(options => options.Rarity == rarity && options.Slots > 0);
                if (itemoption != null)
                {
                    List <Stat> indexes = GetRandomOptions(itemoption, itemoption.Slots);
                    AddStat(BonusAttributes, indexes);
                }
            }
        }
Exemplo n.º 2
0
        public ItemStats(int itemId, int grade)
        {
            BasicAttributes = new List <ItemStat>();
            BonusAttributes = new List <ItemStat>();
            Gemstones       = new List <Gemstone>();
            if (grade == 0)
            {
                return;
            }
            if (ItemStatsMetadataStorage.GetConstantStat(itemId, out List <ItemOptions> constantList))
            {
                foreach (ItemOptions item in constantList)
                {
                    if (item.Grade != grade)
                    {
                        continue;
                    }
                    foreach (Stat i in item.Stats)
                    {
                        if (i.Value != 0)
                        {
                            BasicAttributes.Add(ItemStat.Of(i.Type, i.Value)); // TODO: add randomness to value
                        }
                        else
                        {
                            BasicAttributes.Add(ItemStat.Of(i.Type, i.Percentage)); // TODO: add randomness to value
                        }
                    }
                }
            }

            if (ItemStatsMetadataStorage.GetRandomStat(itemId, out List <ItemOptions> randomList))
            {
                foreach (ItemOptions item in randomList)
                {
                    if (item.Grade != grade)
                    {
                        continue;
                    }
                    if (item.OptionNumPick == 0)
                    {
                        continue;
                    }
                    List <int> indexes = GetRandomOptions(item.OptionNumPick, item.Stats.Count);
                    foreach (int i in indexes)
                    {
                        if (item.Stats[i].Value != 0)
                        {
                            BonusAttributes.Add(ItemStat.Of(item.Stats[i].Type, item.Stats[i].Value)); // TODO: add randomness to value
                        }
                        else
                        {
                            BonusAttributes.Add(ItemStat.Of(item.Stats[i].Type, item.Stats[i].Percentage)); // TODO: add randomness to value
                        }
                    }
                }
            }
        }