package es.uv.dagarcos.master.domain;

import jakarta.persistence.*;
import java.time.Instant;

@Entity
@Table(name = "master_events",
       indexes = {
           @Index(name = "idx_event_timestamp", columnList = "timestamp")
       })
public class MasterEvent {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(nullable = false)
    private Instant timestamp;

    private String eventType;

    private String action;

    private Integer pointsDelta;

    private Boolean winner;

    @Lob
    private String payload;

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private Shard shard;

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private PlayerGlobal player;

    protected MasterEvent() {}

    public MasterEvent(Shard shard,
                       PlayerGlobal player,
                       Instant timestamp,
                       String eventType,
                       String action,
                       Integer pointsDelta,
                       Boolean winner,
                       String payload) {
        this.shard = shard;
        this.player = player;
        this.timestamp = timestamp;
        this.eventType = eventType;
        this.action = action;
        this.pointsDelta = pointsDelta;
        this.winner = winner;
        this.payload = payload;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Instant getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Instant timestamp) {
        this.timestamp = timestamp;
    }

    public String getEventType() {
        return eventType;
    }

    public void setEventType(String eventType) {
        this.eventType = eventType;
    }

    public String getAction() {
        return action;
    }

    public void setAction(String action) {
        this.action = action;
    }

    public Integer getPointsDelta() {
        return pointsDelta;
    }

    public void setPointsDelta(Integer pointsDelta) {
        this.pointsDelta = pointsDelta;
    }

    public Boolean getWinner() {
        return winner;
    }

    public void setWinner(Boolean winner) {
        this.winner = winner;
    }

    public String getPayload() {
        return payload;
    }

    public void setPayload(String payload) {
        this.payload = payload;
    }

    public Shard getShard() {
        return shard;
    }

    public void setShard(Shard shard) {
        this.shard = shard;
    }

    public PlayerGlobal getPlayer() {
        return player;
    }

    public void setPlayer(PlayerGlobal player) {
        this.player = player;
    }

    
}