﻿namespace JLGames.RocketDriver.Games.RpgMaterial.Common
{
    public static class DataRandomUtils
    {
        public static DataNum[] RandToDataNums<T>(this T[] source) where T : IDataRandomable
        {
            if (null == source || source.Length == 0) return null;
            var rs = new DataNum[source.Length];
            for (var index = 0; index < rs.Length; index++)
            {
                rs[index] = source[index].RandToDataNum();
            }

            return rs;
        }

        public static DataOffset[] RandToDataOffsets<T>(this T[] source, bool negative) where T : IDataRandomable
        {
            if (null == source || source.Length == 0) return null;
            var rs = new DataOffset[source.Length];
            for (var index = 0; index < rs.Length; index++)
            {
                rs[index] = source[index].RandToDataOffset(negative);
            }

            return rs;
        }
    }
}