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); }
public static Reward SpawnerReward(ChanceTag chance, Mobs mob) { var tagList = new List <TagBase>(); string mobName = char.ToUpper(mob.ToString()[0]) + mob.ToString().Substring(1); tagList.Add(new DisplayTag() { Item = "mob_spawner", Amount = 1, Name = $"&e{mobName} Spawner" }); tagList.Add(new CommandTag($"spawner {mob} 1 %player%")); return(new Reward(chance, tagList.ToArray())); }
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); }