public BlockInitializer(string block_type, int week_count, string template_path, MainWorkouts main_workouts)
 {
     this.block_type    = block_type;
     this.week_count    = week_count;
     this.template_path = template_path;
     this.main_workouts = main_workouts;
 }
        public TrainingWeek(string template_path, string block_type, int fatique, MainWorkouts main_workouts)
        {
            this.fatique       = fatique;
            this.block_type    = block_type;
            this.training_days = new List <TrainingDay>();


            StreamReader  sr   = new StreamReader(template_path);
            string        line = sr.ReadLine();
            List <string> template_exercises = new List <string>();
            int           exercise_count;  Int32.TryParse(line, out exercise_count);

            line = sr.ReadLine();

            string week_day = "";

            while (line != null)
            {
                if (line == "mon" || line == "tue" || line == "wed" || line == "thu" || line == "fri" || line == "sat" || line == "sun")
                {
                    week_day = line;
                }
                else if (line == "X")
                {
                    training_days.Add(new TrainingDay(week_day, template_exercises, block_type, fatique / exercise_count, main_workouts));
                    template_exercises.Clear();
                }
                else
                {
                    template_exercises.Add(line);
                }
                //Read the next line
                line = sr.ReadLine();
            }
            sr.Close();
        }
        public TrainingDay(string week_day, List <string> template_exercises, string block_type, int fatique, MainWorkouts main_workouts)
        {
            this.exercises = new List <exercise>();
            this.week_day  = week_day;
            List <string> available_exercises = new List <string>();

            int           rep_min, rep_max;
            List <double> RPE       = new List <double>();
            List <string> protocols = new List <string>();

            if (block_type == "Volume")
            {
                RPE.Add(8.0); RPE.Add(8.5); RPE.Add(9.0);
                rep_min = 3;
                rep_max = 5;
                protocols.Add("ld");
                protocols.Add("ld");
                protocols.Add("ldg");
            }
            else if (block_type == "Intensity")
            {
                RPE.Add(9.0); RPE.Add(9.5); RPE.Add(10.0);
                rep_min = 1;
                rep_max = 3;
                protocols.Add("ldg");
                protocols.Add("ldg");
                protocols.Add("ld");
            }
            else
            {
                RPE.Add(8.0); RPE.Add(8.5); RPE.Add(9.0); RPE.Add(9.5); RPE.Add(10.0);
                rep_min = 2;
                rep_max = 8;
                protocols.Add("ldg");
                protocols.Add("ld");
            }

            foreach (string element in template_exercises)
            {
                string file = "templates\\";
                if (element.Split('_').Length - 1 == 1)
                {
                    file += element;
                    goto file_read;
                }
                if (element.Contains("bench"))
                {
                    string exercise_target = element.Substring(0, element.IndexOf('_'));
                    string exercise        = element.Substring(element.IndexOf('_') + 1);
                    if (exercise_target == "primary")
                    {
                        file += main_workouts.bench_primary + '_' + exercise;
                    }
                    else
                    {
                        file += main_workouts.bench_secondary + '_' + exercise;
                    }
                }
                else if (element.Contains("deadlift"))
                {
                    string exercise_target = element.Substring(0, element.IndexOf('_'));
                    string exercise        = element.Substring(element.IndexOf('_') + 1);
                    if (exercise_target == "primary")
                    {
                        file += main_workouts.deadlift_primary + '_' + exercise;
                    }
                    else
                    {
                        file += main_workouts.deadlift_secondary + '_' + exercise;
                    }
                }
                else if (element.Contains("squat"))
                {
                    string exercise_target = element.Substring(0, element.IndexOf('_'));
                    string exercise        = element.Substring(element.IndexOf('_') + 1);
                    if (exercise_target == "primary")
                    {
                        file += main_workouts.squat_primary + '_' + exercise;
                    }
                    else
                    {
                        file += main_workouts.squat_secondary + '_' + exercise;
                    }
                }
                else
                {
                    this.exercises.Add(new exercise(element));
                    return;
                }

file_read:
                StreamReader sr = new StreamReader(file + ".WORKOUT");
                string line = sr.ReadLine();

                while (line != null)
                {
                    available_exercises.Add(line);
                    line = sr.ReadLine();
                }

                if (file.Contains("supplement"))
                {
                    this.exercises.Add(new exercise(available_exercises[random.Next(available_exercises.Count)], random.Next(5, 8), random.Next(4, 7)));
                }
                else
                {
                    this.exercises.Add(new exercise(available_exercises[random.Next(available_exercises.Count)], random.Next(rep_min, rep_max + 1), fatique, RPE[random.Next(RPE.Count)], protocols[random.Next(protocols.Count)]));
                }
                available_exercises = new List <string>();

                sr.Close();
            }
        }
        public TrainingBlock(string block_type, int week_count, string template_path, MainWorkouts main_workouts)
        {
            this.template_path  = template_path;
            this.training_weeks = new List <TrainingWeek>();
            List <int> starting_fatique   = new List <int>(); starting_fatique.Add(24); starting_fatique.Add(40); starting_fatique.Add(56);
            List <int> available_fatiques = new List <int>(); available_fatiques.Add(24); available_fatiques.Add(40); available_fatiques.Add(56); available_fatiques.Add(72);

            this.block_type = block_type;

            training_weeks.Add(new TrainingWeek(template_path, block_type, starting_fatique[TrainingDay.random.Next(starting_fatique.Count)], main_workouts));
            for (int i = 1; i < week_count; i++)
            {
                training_weeks.Add(new TrainingWeek(template_path, block_type, available_fatiques[TrainingDay.random.Next(available_fatiques.Count)], main_workouts));
            }
        }