private void generateRandomSet(List <string> coreList, Workout.SetType coreType, Random rnd) { int coreSideRandomIndex = rnd.Next(coreList.Count); switch (coreType) { case Workout.SetType.CoreCenter: SetList.Add(coreList[coreSideRandomIndex]); break; case Workout.SetType.CoreSide: SetList.Add($"{coreList[coreSideRandomIndex]} Right"); SetList.Add($"{coreList[coreSideRandomIndex]} Left"); break; } coreList.RemoveAt(coreSideRandomIndex); }
private void GenerateWorkout(Workout workout) { workout.SetTimeText = $"{Math.Floor((decimal)(Workout.SetDuration % (60 * 60)) / 60)}m {Math.Floor((decimal)(Workout.SetDuration % 60))}s"; List <string> coreCenter = GetSets("CoreCenter"); List <string> coreSide = GetSets("CoreSide"); Random rnd = new Random(); while (SetList.Count < workout.NumberOfSets) { if (SetList.Count + 1 != workout.NumberOfSets) // Prevents extra set when selecting coreSide { Workout.SetType setType = (Workout.SetType)rnd.Next(1, 3); generateRandomSet(setType == Workout.SetType.CoreCenter ? coreCenter : coreSide, setType, rnd); } else { generateRandomSet(coreCenter, Workout.SetType.CoreCenter, rnd); } } }