package com.dowstats.data.entities.weapon

import com.dowstats.data.dto.controllers.ArmorPiercingDto
import com.dowstats.data.entities.ArmorType
import com.fasterxml.jackson.annotation.JsonIgnore
import java.math.BigDecimal
import jakarta.persistence.*


@Entity
@Table(name = "weapons_armors_piercing")
class WeaponArmorPiercing {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    var id: Long? = null

    @ManyToOne
    @JsonIgnore
    @JoinColumn(name = "weapon_id")
    var weapon: Weapon? = null

    @ManyToOne
    @JoinColumn(name = "armor_type_id")
    var armorType: ArmorType? = null

    var piercingValue: BigDecimal? = null

    fun toDto() = ArmorPiercingDto(
        armorType?.toDto(),
        piercingValue?:BigDecimal.ZERO,
    )
}
