using Frame.Log;
using ProtoMsg;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MobaServer
{
    public class RanMgr
    {
        public static List<int[]> propList = new List<int[]>();
        public static List<int[]> fileList = new List<int[]>();

        public static void Init() {
            SpawnPropList();
            SpawnFileList();
        }

        public static int[] GetPropRange() {
            return propList[GetRandom(0, 19)];
        }

        public static int[] GetFileRange() {
            return fileList[GetRandom(0, 19)];
        }

        public static void SpawnPropList()
        {
            for (int i = 0; i < 20; i++)
            {
                List<int> temp = new List<int>();
                while (temp.Count < 40)
                {
                    int tempInt = GetRandom(0, 99);
                    if (!temp.Contains(tempInt))
                    {
                        temp.Add(tempInt);
                    }
                }
                propList.Add(temp.ToArray());
                string s = "";
                for (int j = 0; j < 40; j++)
                {
                     s += propList[i][j] + " ";
                }
                Debug.Log("道具:第" + i + "组:" + s);
            }
            
        }

        public static void SpawnFileList() {

            for (int i = 0; i < 20; i++)
            {
                List<int> temp = new List<int>();
                
                while (temp.Count<10)
                {
                    int tempInt = GetRandom(0, 135);
                    if (!temp.Contains(tempInt))
                    {
                        temp.Add(tempInt);
                    }
                }
                fileList.Add(temp.ToArray());
                string s = "";
                for (int j = 0; j < 10; j++)
                {
                    s += fileList[i][j] + " ";
                }
                Debug.Log("文件:第" + i + "组:" + s);
            }
           
        }
        
        public static int GetRandom(int min, int max)
        {
            Guid temp = Guid.NewGuid();
            int guidSpeed = BitConverter.ToInt32(temp.ToByteArray(), 0);

            Random random = new Random(guidSpeed);
            int ran = random.Next(min, max);
            return ran;
        }
    }
}