using System.Collections.Generic; using System.Collections.Immutable; using PhoenixLib.Logging; using WingsAPI.Packets.Enums.Shells; namespace WingsEmu.Plugins.BasicImplementations.Algorithms.Shells; public interface IShellLevelEffectConfiguration { IReadOnlyCollection GetEffects(byte shellType, byte rarity); } public class ShellLevelEffectConfiguration : IShellLevelEffectConfiguration { private readonly ImmutableDictionary<(byte, byte), List> _shellEffects; public ShellLevelEffectConfiguration(IEnumerable shellEffects) { var dict = new Dictionary<(byte, byte), List>(); foreach (ShellLevelEffect shellEffect in shellEffects) { foreach (ShellRarityEffect shellRarityEffect in shellEffect.Rarities) { dict.Add(((byte)shellEffect.ShellType, shellRarityEffect.Rarity), shellRarityEffect.PossibleEffects); } } _shellEffects = dict.ToImmutableDictionary(); } public IReadOnlyCollection GetEffects(byte shellType, byte rarity) { if (!_shellEffects.ContainsKey((shellType, rarity))) { Log.Debug($"[ERROR] A configuration for {shellType.ToString()} has not been found."); return null; } return _shellEffects[(shellType, rarity)]; } } public class ShellLevelEffect { public ShellType ShellType { get; set; } public List Rarities { get; set; } } public class ShellRarityEffect { public byte Rarity { get; set; } public List PossibleEffects { get; set; } } public class ShellPossibleCategory { public ShellEffectCategory EffectCategory { get; set; } public bool IsRandom { get; set; } }