package es.uv.dagarcos.master.domain;

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

@Entity
@Table(name = "shard_world_snapshots")
public class ShardWorldSnapshot {

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

    private long totalPlayers;

    private long totalEvents;

    @Column(nullable = false)
    private Instant snapshotAt;

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

    protected ShardWorldSnapshot() {}

    public ShardWorldSnapshot(Shard shard,
                              long totalPlayers,
                              long totalEvents) {
        this.shard = shard;
        this.totalPlayers = totalPlayers;
        this.totalEvents = totalEvents;
        this.snapshotAt = Instant.now();
    }

    public Long getId() {
        return id;
    }

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

    public long getTotalPlayers() {
        return totalPlayers;
    }

    public void setTotalPlayers(long totalPlayers) {
        this.totalPlayers = totalPlayers;
    }

    public long getTotalEvents() {
        return totalEvents;
    }

    public void setTotalEvents(long totalEvents) {
        this.totalEvents = totalEvents;
    }

    public Instant getSnapshotAt() {
        return snapshotAt;
    }

    public void setSnapshotAt(Instant snapshotAt) {
        this.snapshotAt = snapshotAt;
    }

    public Shard getShard() {
        return shard;
    }

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

    
}