package fr.teamflash.fencerjudgeback.entities

import jakarta.persistence.Entity
import jakarta.persistence.GeneratedValue
import jakarta.persistence.GenerationType
import jakarta.persistence.Id
import jakarta.persistence.SequenceGenerator
import jakarta.persistence.Table
import jakarta.validation.constraints.*
import java.util.Date

enum class MatchState {
    ONGOING,
    OVER,
    NOT_STARTED
}

@Entity
@Table(name="matches")
data class MatchBean(

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "match_sequence")
    @SequenceGenerator(name = "match_sequence", sequenceName = "match_seq", allocationSize = 1)
    var id:Long?=null,
    val weapon:String?=null,
    val country:String?=null,
    val city:String?=null,
    @field:NotNull(message = "Player 1 ID must not be null")
    val player1ID:Long?=null,
    @field:NotNull(message = "Player 2 ID must not be null")
    val player2ID:Long?=null,
    val refereeID: Long?=null,
    @field:Min(value = 0, message = "Score must be at least 0")
    var score1:Int=0,
    @field:Min(value = 0, message = "Score must be at least 0")
    var score2:Int=0,
    val date: Date?=null,
    val state: MatchState?=null
)
