package com.alterdekim.game.entity;

import com.alterdekim.game.component.game.PlayerProperties;
import jakarta.persistence.*;
import lombok.*;

import java.time.LocalDateTime;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name="user_props")
public class UserProperty {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @OneToOne
    @JoinColumn(referencedColumnName = "id")
    private User user;

    @Column(nullable = true)
    private String stringVal;

    @Column(nullable = true)
    private Boolean booleanVal;

    @Column(nullable = true)
    private Integer integerVal;

    @Column(nullable = true)
    private LocalDateTime dateVal;

    @Enumerated(EnumType.STRING)
    private PlayerProperties type;

    public UserProperty(User user, String stringVal, PlayerProperties type) {
        this.user = user;
        this.stringVal = stringVal;
        this.booleanVal = null;
        this.integerVal = null;
        this.dateVal = null;
        this.type = type;
    }

    public UserProperty(User user, Boolean booleanVal, PlayerProperties type) {
        this.user = user;
        this.booleanVal = booleanVal;
        this.integerVal = null;
        this.dateVal = null;
        this.stringVal = null;
        this.type = type;
    }

    public UserProperty(User user, Integer integerVal, PlayerProperties type) {
        this.user = user;
        this.integerVal = integerVal;
        this.booleanVal = null;
        this.stringVal = null;
        this.dateVal = null;
        this.type = type;
    }

    public UserProperty(User user, LocalDateTime dateVal, PlayerProperties type) {
        this.user = user;
        this.dateVal = dateVal;
        this.booleanVal = null;
        this.integerVal = null;
        this.stringVal = null;
        this.type = type;
    }
}
