//
//  SetDescriptor.swift
//  PadelClub
//
//  Created by Razmig Sarkissian on 02/04/2024.
//

import Foundation

struct SetDescriptor: Identifiable, Equatable {
    let id: UUID = UUID()
    var valueTeamOne: Int?
    var valueTeamTwo: Int?
    var tieBreakValueTeamOne: Int?
    var tieBreakValueTeamTwo: Int?
    var setFormat: SetFormat
    
    var hasEnded: Bool {
        if let valueTeamTwo, let valueTeamOne {
            return setFormat.hasEnded(teamOne: valueTeamOne, teamTwo: valueTeamTwo)
        } else {
            return false
        }
    }
    
    var winner: TeamPosition? {
        if let valueTeamTwo, let valueTeamOne {
            return setFormat.winner(teamOne: valueTeamOne, teamTwo: valueTeamTwo)
        } else {
            return nil
        }
    }
}
