//
//  PlayerHolder.swift
//  PadelClub
//
//  Created by Razmig Sarkissian on 24/04/2024.
//

import Foundation
import SwiftUI

protocol PlayerHolder {
    
    func getFirstName() -> String
    func getLastName() -> String
    func formattedRank() -> String
    func formattedLicense() -> String
    func getPoints() -> Double?
    func getRank() -> Int?
    func isUnranked() -> Bool
    var male: Bool { get }
    var tournamentPlayed: Int? { get }
    var clubName: String? { get }
    var ligueName: String? { get }
    var assimilation: String? { get }
    var computedAge: Int? { get }
    func getAssimilatedAsMaleRank() -> Int?
    func isNotFromCurrentDate() -> Bool
    func getBirthYear() -> Int?
    func getProgression() -> Int
    func getComputedRank() -> Int?
}

extension PlayerHolder {
    func isNotFromCurrentDate() -> Bool {
        false
    }
    
    var isAssimilated: Bool {
        assimilation == "Oui"
    }
    
    func isAnonymous() -> Bool {
        getFirstName().isEmpty && getLastName().isEmpty
    }
    
    func getProgressionColor(progression: Int) -> Color {
        switch progression {
        case _ where progression > 0:
            return Color.green
        case _ where progression < 0:
            return Color.logoRed
        default:
            return Color.primary
        }

    }
}
