package de.szut.casino.lootboxes;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@Entity
@Getter
@Setter
@NoArgsConstructor
public class LootBoxEntity {

    public LootBoxEntity(String name, BigDecimal price, List<RewardEntity> rewards) {
        this.name = name;
        this.price = price;
        this.rewards = rewards;
    }

    @Id
    @GeneratedValue
    private Long id;

    private String name;

    @Column(precision = 19, scale = 2)
    private BigDecimal price;

    @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
    @JoinTable(
            name = "lootbox_reward",
            joinColumns = @JoinColumn(name = "lootbox_id"),
            inverseJoinColumns = @JoinColumn(name = "reward_id")
    )
    private List<RewardEntity> rewards = new ArrayList<>();
}
