using SportsDivision.Domain.Enums;

namespace SportsDivision.Domain.Entities;

public class HighJumpAttempt
{
    public int HighJumpAttemptId { get; set; }
    public int HighJumpHeightId { get; set; }
    public int EventRegistrationId { get; set; }
    public HighJumpAttemptResult? Attempt1 { get; set; }
    public HighJumpAttemptResult? Attempt2 { get; set; }
    public HighJumpAttemptResult? Attempt3 { get; set; }
    public HighJumpHeight HighJumpHeight { get; set; } = null!;
    public EventRegistration EventRegistration { get; set; } = null!;

    public bool IsEliminated =>
        Attempt1 == HighJumpAttemptResult.Fail &&
        Attempt2 == HighJumpAttemptResult.Fail &&
        Attempt3 == HighJumpAttemptResult.Fail;

    public bool HasCleared =>
        Attempt1 == HighJumpAttemptResult.Clear ||
        Attempt2 == HighJumpAttemptResult.Clear ||
        Attempt3 == HighJumpAttemptResult.Clear;

    public int FailCount =>
        (Attempt1 == HighJumpAttemptResult.Fail ? 1 : 0) +
        (Attempt2 == HighJumpAttemptResult.Fail ? 1 : 0) +
        (Attempt3 == HighJumpAttemptResult.Fail ? 1 : 0);
}
