using System.Collections;
using Core.Entities;
using Core.Parsers;
using Core.Utility;

namespace Tests.Parsers;

public static class TestEntityHandler
{
	private const string ContentDirectory = @"Parsers\TestInput\";

	public static EventDefinition[] GetEvents()
	{
		var fileInfo = FileUtility.GetContentFile(ContentDirectory, "2023-24 RMS TSA student & event - Event Definitions.csv");
		var eventRankingsParser = new EventDefinitionParser(fileInfo);
		return eventRankingsParser.Parse();
	}

	public static FileInfo GetEventOccurrenceFileInfo()
	{
		return FileUtility.GetContentFile(ContentDirectory, "2025 TSA Nationals Competition Event Times.txt");
	}

	public static Student[] GetStudents(IList<EventDefinition> events)
	{
		//var studentEventRankingsCsv = "Student Event Rankings.csv";
		var studentEventRankingsCsv = "2023-24 RMS TSA student & event - Student Event Rankings.csv";

		var fileInfo = FileUtility.GetContentFile(ContentDirectory, studentEventRankingsCsv);
		var eventRankingsParser = new StudentParser(fileInfo);
		return eventRankingsParser.Parse();
	}


	public static Team[] GetTeams(IList<EventDefinition> events, IList<Student> students)
	{
		//var studentEventRankingsCsv = "Student Event Rankings.csv";
		var studentEventRankingsCsv = "2023-24 RMS TSA student & event - Teams.csv";

		var fileInfo = FileUtility.GetContentFile(ContentDirectory, studentEventRankingsCsv);
		var eventRankingsParser = new TeamParser(fileInfo);
		var teams = eventRankingsParser.Parse(events, students);

		foreach (var student in students)
		{
			student.Teams = teams.Where(t => t.Students.Contains(student)).ToList();
		}
		return teams;
	}

	public static AssignmentRequirement[] GetEventRequirements(IList<EventDefinition> events, IList<Student> students)
	{
		var fileInfo = FileUtility.GetContentFile(ContentDirectory, "2024-25 RMS TSA student & event - assumptions.csv");
		var assumptionParser = new AssignmentRequirementParser(fileInfo);
		return assumptionParser.Parse(events, students);
	}

    public static StudentEventRanking[] GetStudentEventRankings(Student[] students, EventDefinition[] events)
    {
        var fileInfo = FileUtility.GetContentFile(ContentDirectory, "2024-25 RMS TSA student & event - Student Event Rankings.csv");

        var rankingParser = new StudentEventRankingParser(fileInfo);
        return rankingParser.Parse(students, events);
    }
}