using Jiaowu.Api.Domain.Academic;

namespace Jiaowu.Api.Infrastructure.Timetables;

public static class FreeClassroomRules
{
    public static bool MatchesWeek(WeekPattern pattern, int week) =>
        pattern == WeekPattern.All ||
        pattern == WeekPattern.Odd && week % 2 == 1 ||
        pattern == WeekPattern.Even && week % 2 == 0;

    public static bool PeriodsOverlap(
        int requestedStart,
        int requestedCount,
        int occupiedStart,
        int occupiedCount) =>
        requestedStart < occupiedStart + occupiedCount &&
        occupiedStart < requestedStart + requestedCount;
}
