Esempio n. 1
0
        private string getRarity(Reward item)
        {
            ChanceTag   itemChance = item.GetChance();
            CrateRarity RarityTag  = null;

            // Get the best rarity match for our tag
            foreach (var rarity in Rarities)
            {
                if (itemChance.Chance <= rarity.Value)
                {
                    if (RarityTag == null)
                    {
                        RarityTag = rarity;
                    }
                    else
                    {
                        // If the new rarity is worse than the current rarity we should use that one instead
                        if (RarityTag.Value >= rarity.Value)
                        {
                            RarityTag.Value = rarity.Value;
                        }
                    }
                }
            }
            if (RarityTag == null)
            {
                return("DunBad");
            }
            return(RarityTag.Name);
        }
Esempio n. 2
0
        public override string ToString()
        {
            if (RaritiesEnabled)
            {
                // Iterate through all of the items and replace our rarities with them!
                foreach (var item in Rewards)
                {
                    ChanceTag   chance    = item.GetChance();
                    CrateRarity RarityTag = null;
                    // Get the best rarity match for our tag
                    foreach (var rarity in Rarities)
                    {
                        // Check if the given rarity applies to our tag
                        if (chance.Chance >= rarity.Value)
                        {
                            if (RarityTag == null)
                            {
                                RarityTag = rarity;
                            }
                            else
                            {
                                // If the new rarity is better than the current rarity we should use that one instead
                                if (RarityTag.Value < rarity.Value)
                                {
                                    RarityTag.Value = rarity.Value;
                                }
                            }
                        }
                    }
                    foreach (var tag in item.RewardTags)
                    {
                        if (tag is ItemTag)
                        {
                            var itemTag = (ItemTag)tag;
                            if (RarityTag != null)
                            {
                                itemTag.Lore.Add(RarityTag.Name);
                            }
                        }
                    }
                }
            }
            string reward = "";

            foreach (var item in Rewards)
            {
                reward += "            - \"" + item.GetReward() + "\"\n";
            }
            return(reward);
        }