using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test_Merge
{
    public class DriverData
    {
        public bool DRS;        //True = Drs is opened
        public int GapToLeader; //In ms
        public int LapTime;     //In ms
        public string Name;     //Ex: LECLERC
        public int Position;    //Ex: 1
        public int Sector1;     //in ms
        public int Sector2;     //in ms
        public int Sector3;     //in ms
        public Tyre CurrentTyre;//Ex Soft 11 laps

        public DriverData(bool dRS, int gapToLeader, int lapTime, string name, int position, int sector1, int sector2, int sector3, Tyre tyre)
        {
            DRS = dRS;
            GapToLeader = gapToLeader;
            LapTime = lapTime;
            Name = name;
            Position = position;
            Sector1 = sector1;
            Sector2 = sector2;
            Sector3 = sector3;
            CurrentTyre = tyre;
        }
        public DriverData()
        {
            DRS = false;
            GapToLeader = -1;
            LapTime = -1;
            Name = "Unknown";
            Position = -1;
            Sector1 = -1;
            Sector2 = -1;
            Sector3 = -1;
            CurrentTyre = new Tyre(Tyre.Type.Undefined, -1);
        }
        /// <summary>
        /// Method that displays all the data found in a string
        /// </summary>
        /// <returns>string containing all the driver datas</returns>
        public override string ToString()
        {
            string result = "";

            //Position
            result += "Position : " + Position + Environment.NewLine;
            //Gap
            result += "Gap to leader : " + OCRDecoder.ConvertMsToTime(GapToLeader) + Environment.NewLine;
            //LapTime
            result += "Lap time : " + OCRDecoder.ConvertMsToTime(LapTime) + Environment.NewLine;
            //DRS
            result += "DRS : " + DRS + Environment.NewLine;
            //Tyres
            result += "Uses " + CurrentTyre.Coumpound + " tyre " + CurrentTyre.NumberOfLaps + " laps old" + Environment.NewLine;
            //Name
            result += "Driver name : " + Name + Environment.NewLine;
            //Sector 1
            result += "Sector 1 : " + OCRDecoder.ConvertMsToTime(Sector1) + Environment.NewLine;
            //Sector 1
            result += "Sector 2 : " + OCRDecoder.ConvertMsToTime(Sector2) + Environment.NewLine;
            //Sector 1
            result += "Sector 3 : " + OCRDecoder.ConvertMsToTime(Sector3) + Environment.NewLine;

            return result;
        }
    }
    //Structure to store tyres infos
    public struct Tyre
    {
        //If new tyres were to be added you will have to need to change this enum
        public enum Type
        {
            Soft,
            Medium,
            Hard,
            Inter,
            Wet,
            Undefined
        }
        public Type Coumpound;
        public int NumberOfLaps;
        public Tyre(Type type, int laps)
        {
            Coumpound = type;
            NumberOfLaps = laps;
        }
    }
}
