package com.dowstats.data.entities import com.dowstats.data.dto.controllers.BuildingFullDto import jakarta.persistence.* @Entity @Table(name = "buildings") class Building { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = null @ManyToOne @JoinColumn(name = "race_id", nullable = false) var race: Race? = null @ManyToOne @JoinColumn(name = "armour_type_id", nullable = false) var armorType: ArmorType? = null @ManyToOne @JoinColumn(name = "armour_type_2_id") var armorType2: ArmorType? = null var name: String? = null var description: String? = null var filename: String? = null var buildCostRequisition: Double? = null var buildCostPower: Double? = null var buildCostPopulation: Double? = null var buildCostFaith: Double? = null var buildCostSouls: Double? = null var buildCostTime: Int? = null var health: Int? = null var healthRegeneration: Double? = null var sightRadius: Int? = null var detectRadius: Int? = null var repairMax: Int? = null var icon: String? = null var modId: Long? = null @OneToMany(mappedBy = "building", cascade = [CascadeType.ALL]) var addons: MutableSet? = null @OneToMany(mappedBy = "building", cascade = [CascadeType.ALL]) var weapons: MutableSet? = null fun toDto(): BuildingFullDto = BuildingFullDto( id!!, race?.toDto(), armorType?.toDto(), armorType2?.toDto(), name, description, filename!!, buildCostRequisition, buildCostPower, buildCostPopulation, buildCostFaith, buildCostSouls, buildCostTime, health, healthRegeneration, sightRadius, detectRadius, repairMax, icon, modId!!, mutableSetOf(), weapons?.map { it.toWeaponSlotDto() }?.toSet(), ) }