using SGModule.Common.Helper;
using SGModule.Common.Interface;

namespace SGModule.Common.Extensions {
    public static class ArrayExtensions {
        public static T Random<T>(this T[] items, T fallback = default) where T : class, IWeighted {
            if (items == null || items.Length == 0) {
                return fallback;
            }

            return RandomHelper.RandomByWeight(items, fallback);
        }
    }
}
