Correct response building addons
- add addons response - add max repair param to units
This commit is contained in:
parent
8f14dd9e62
commit
07ce631871
@ -1,14 +1,9 @@
|
|||||||
package com.dowstats.controllers
|
package com.dowstats.controllers
|
||||||
|
|
||||||
import com.dowstats.data.dto.controllers.BuildingFullDto
|
import com.dowstats.data.dto.controllers.building.BuildingFullDto
|
||||||
import com.dowstats.data.dto.controllers.RaceBuildings
|
import com.dowstats.data.dto.controllers.building.RaceBuildings
|
||||||
import com.dowstats.data.dto.controllers.RaceUnits
|
|
||||||
import com.dowstats.data.entities.Building
|
|
||||||
import com.dowstats.data.entities.DowUnit
|
|
||||||
import com.dowstats.data.repositories.BuildingRepository
|
import com.dowstats.data.repositories.BuildingRepository
|
||||||
import com.dowstats.data.repositories.UnitRepository
|
|
||||||
import com.dowstats.service.datamaps.DowBuildingMappingService
|
import com.dowstats.service.datamaps.DowBuildingMappingService
|
||||||
import com.dowstats.service.datamaps.DowUnitMappingService
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping
|
import org.springframework.web.bind.annotation.DeleteMapping
|
||||||
import org.springframework.web.bind.annotation.GetMapping
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
|
|||||||
@ -37,6 +37,7 @@ data class UnitFullDto(
|
|||||||
val reinforceCostFaith: Int?,
|
val reinforceCostFaith: Int?,
|
||||||
val reinforceCostSouls: Int?,
|
val reinforceCostSouls: Int?,
|
||||||
val reinforceTime: Int?,
|
val reinforceTime: Int?,
|
||||||
|
val repairMax: Int?,
|
||||||
val maxSergeants: Int?,
|
val maxSergeants: Int?,
|
||||||
val icon: String?,
|
val icon: String?,
|
||||||
val modId: Long,
|
val modId: Long,
|
||||||
|
|||||||
@ -0,0 +1,8 @@
|
|||||||
|
package com.dowstats.data.dto.controllers.building
|
||||||
|
|
||||||
|
data class AddonModifierDto (
|
||||||
|
val id: Long,
|
||||||
|
val reference: String?,
|
||||||
|
val usageType: String?,
|
||||||
|
val value: Double?,
|
||||||
|
)
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
package com.dowstats.data.dto.controllers.building
|
||||||
|
|
||||||
|
data class AddonRequirementDto (
|
||||||
|
val id: Long,
|
||||||
|
val reference: String?,
|
||||||
|
val replaceWhenDone: Boolean,
|
||||||
|
val value: Double?,
|
||||||
|
)
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.dowstats.data.dto.controllers
|
package com.dowstats.data.dto.controllers.building
|
||||||
|
|
||||||
data class BuildingAddonDto(
|
data class BuildingAddonDto(
|
||||||
val id: Long?,
|
val id: Long?,
|
||||||
@ -11,5 +11,7 @@ data class BuildingAddonDto(
|
|||||||
val addonCostFaith: Double?,
|
val addonCostFaith: Double?,
|
||||||
val addonCostSouls: Double?,
|
val addonCostSouls: Double?,
|
||||||
val addonCostTime: Int?,
|
val addonCostTime: Int?,
|
||||||
|
val addonModifiers: Set<AddonModifierDto>,
|
||||||
|
val addonRequirements: Set<AddonRequirementDto>,
|
||||||
val icon: String?,
|
val icon: String?,
|
||||||
)
|
)
|
||||||
@ -1,4 +1,8 @@
|
|||||||
package com.dowstats.data.dto.controllers
|
package com.dowstats.data.dto.controllers.building
|
||||||
|
|
||||||
|
import com.dowstats.data.dto.controllers.ArmorTypeDto
|
||||||
|
import com.dowstats.data.dto.controllers.RaceDto
|
||||||
|
import com.dowstats.data.dto.controllers.WeaponSlotDto
|
||||||
|
|
||||||
data class BuildingFullDto(
|
data class BuildingFullDto(
|
||||||
var id: Long?,
|
var id: Long?,
|
||||||
@ -21,6 +25,6 @@ data class BuildingFullDto(
|
|||||||
var repairMax: Int?,
|
var repairMax: Int?,
|
||||||
var icon: String?,
|
var icon: String?,
|
||||||
var modId: Long?,
|
var modId: Long?,
|
||||||
var addons: MutableSet<BuildingAddonDto>?,
|
var addons: Set<BuildingAddonDto>?,
|
||||||
val weapons: Set<WeaponSlotDto>?,
|
val weapons: Set<WeaponSlotDto>?,
|
||||||
)
|
)
|
||||||
@ -1,4 +1,6 @@
|
|||||||
package com.dowstats.data.dto.controllers
|
package com.dowstats.data.dto.controllers.building
|
||||||
|
|
||||||
|
import com.dowstats.data.dto.controllers.RaceDto
|
||||||
|
|
||||||
data class RaceBuildings(
|
data class RaceBuildings(
|
||||||
val race: RaceDto,
|
val race: RaceDto,
|
||||||
@ -1,5 +1,6 @@
|
|||||||
package com.dowstats.data.entities
|
package com.dowstats.data.entities
|
||||||
|
|
||||||
|
import com.dowstats.data.dto.controllers.building.AddonModifierDto
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||||
import jakarta.persistence.*
|
import jakarta.persistence.*
|
||||||
|
|
||||||
@ -20,4 +21,13 @@ class AddonModifiers {
|
|||||||
var reference: String? = null
|
var reference: String? = null
|
||||||
var usageType: String? = null
|
var usageType: String? = null
|
||||||
var value: Double? = null
|
var value: Double? = null
|
||||||
|
|
||||||
|
fun toDto(): AddonModifierDto {
|
||||||
|
return AddonModifierDto(
|
||||||
|
id = id!!,
|
||||||
|
reference = reference,
|
||||||
|
usageType = usageType,
|
||||||
|
value = value
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.dowstats.data.entities
|
package com.dowstats.data.entities
|
||||||
|
|
||||||
|
import com.dowstats.data.dto.controllers.building.AddonRequirementDto
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||||
import jakarta.persistence.*
|
import jakarta.persistence.*
|
||||||
|
|
||||||
@ -19,4 +20,13 @@ class AddonRequirements {
|
|||||||
var reference: String? = null
|
var reference: String? = null
|
||||||
var replaceWhenDone: Boolean = false
|
var replaceWhenDone: Boolean = false
|
||||||
var value: Double? = null
|
var value: Double? = null
|
||||||
|
|
||||||
|
fun toDto(): AddonRequirementDto {
|
||||||
|
return AddonRequirementDto(
|
||||||
|
id = id!!,
|
||||||
|
reference = reference,
|
||||||
|
replaceWhenDone = replaceWhenDone,
|
||||||
|
value = value
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
package com.dowstats.data.entities
|
package com.dowstats.data.entities
|
||||||
|
|
||||||
import com.dowstats.data.dto.controllers.BuildingFullDto
|
import com.dowstats.data.dto.controllers.building.BuildingFullDto
|
||||||
import jakarta.persistence.*
|
import jakarta.persistence.*
|
||||||
|
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ class Building {
|
|||||||
repairMax,
|
repairMax,
|
||||||
icon,
|
icon,
|
||||||
modId!!,
|
modId!!,
|
||||||
mutableSetOf(),
|
addons?.map { it.toDto() }?.toSet(),
|
||||||
weapons?.map { it.toWeaponSlotDto() }?.toSet(),
|
weapons?.map { it.toWeaponSlotDto() }?.toSet(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.dowstats.data.entities
|
package com.dowstats.data.entities
|
||||||
|
|
||||||
|
import com.dowstats.data.dto.controllers.building.BuildingAddonDto
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||||
import jakarta.persistence.*
|
import jakarta.persistence.*
|
||||||
|
|
||||||
@ -35,4 +36,20 @@ class BuildingAddon {
|
|||||||
|
|
||||||
var icon: String? = null
|
var icon: String? = null
|
||||||
|
|
||||||
|
fun toDto(): BuildingAddonDto = BuildingAddonDto(
|
||||||
|
id = id,
|
||||||
|
name = name,
|
||||||
|
description = description,
|
||||||
|
filename = filename,
|
||||||
|
addonCostRequisition = addonCostRequisition,
|
||||||
|
addonCostPower = addonCostPower,
|
||||||
|
addonCostPopulation = addonCostPopulation,
|
||||||
|
addonCostFaith = addonCostFaith,
|
||||||
|
addonCostSouls = addonCostSouls,
|
||||||
|
addonCostTime = addonCostTime,
|
||||||
|
addonModifiers = addonModifiers?.map { it.toDto() }?.toSet() ?: emptySet(),
|
||||||
|
addonRequirements = addonRequirements?.map { it.toDto() }?.toSet() ?: emptySet(),
|
||||||
|
icon = icon
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,6 +41,7 @@ class DowUnit {
|
|||||||
var health: Int? = null
|
var health: Int? = null
|
||||||
var healthRegeneration: Double? = null
|
var healthRegeneration: Double? = null
|
||||||
var moraleDeathPenalty: Int? = null
|
var moraleDeathPenalty: Int? = null
|
||||||
|
var repairMax: Int? = null
|
||||||
var moraleMax: Int? = null
|
var moraleMax: Int? = null
|
||||||
var moraleBroken: Int? = null
|
var moraleBroken: Int? = null
|
||||||
var moraleRegeneration: Int? = null
|
var moraleRegeneration: Int? = null
|
||||||
@ -103,6 +104,7 @@ class DowUnit {
|
|||||||
reinforceCostFaith,
|
reinforceCostFaith,
|
||||||
reinforceCostSouls,
|
reinforceCostSouls,
|
||||||
reinforceTime,
|
reinforceTime,
|
||||||
|
repairMax,
|
||||||
maxSergeants,
|
maxSergeants,
|
||||||
icon,
|
icon,
|
||||||
modId!!,
|
modId!!,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
package com.dowstats.service.datamaps
|
package com.dowstats.service.datamaps
|
||||||
|
|
||||||
import com.dowstats.data.dto.controllers.BuildingShortDto
|
import com.dowstats.data.dto.controllers.building.BuildingShortDto
|
||||||
import com.dowstats.data.dto.controllers.RaceBuildings
|
import com.dowstats.data.dto.controllers.building.RaceBuildings
|
||||||
import com.dowstats.data.entities.Building
|
import com.dowstats.data.entities.Building
|
||||||
import com.dowstats.data.repositories.BuildingRepository
|
import com.dowstats.data.repositories.BuildingRepository
|
||||||
import com.dowstats.data.repositories.RaceRepository
|
import com.dowstats.data.repositories.RaceRepository
|
||||||
|
|||||||
@ -87,6 +87,7 @@ class BuildingAddonRgdExtractService @Autowired constructor(
|
|||||||
it.addon = addon
|
it.addon = addon
|
||||||
it.reference = rTable.getStringByName("\$REF")
|
it.reference = rTable.getStringByName("\$REF")
|
||||||
it.replaceWhenDone = rTable.getBooleanByName("replace_when_done") == true
|
it.replaceWhenDone = rTable.getBooleanByName("replace_when_done") == true
|
||||||
|
// TODO - что-то придумать с этим
|
||||||
it.value =
|
it.value =
|
||||||
if (it.reference == "requirements\\required_total_pop.lua") rTable.getDoubleByName("population_required") else null
|
if (it.reference == "requirements\\required_total_pop.lua") rTable.getDoubleByName("population_required") else null
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import com.dowstats.data.dto.UnitDataToSave
|
|||||||
import com.dowstats.data.dto.WeaponsData
|
import com.dowstats.data.dto.WeaponsData
|
||||||
import com.dowstats.data.entities.*
|
import com.dowstats.data.entities.*
|
||||||
import com.dowstats.data.rgd.RgdData
|
import com.dowstats.data.rgd.RgdData
|
||||||
|
import com.dowstats.data.rgd.RgdDataUtil.getBooleanByName
|
||||||
import com.dowstats.data.rgd.RgdDataUtil.getDoubleByName
|
import com.dowstats.data.rgd.RgdDataUtil.getDoubleByName
|
||||||
import com.dowstats.data.rgd.RgdDataUtil.getIntByName
|
import com.dowstats.data.rgd.RgdDataUtil.getIntByName
|
||||||
import com.dowstats.data.rgd.RgdDataUtil.getRgdTableByName
|
import com.dowstats.data.rgd.RgdDataUtil.getRgdTableByName
|
||||||
@ -29,6 +30,7 @@ class UnitRgdExtractService @Autowired constructor(
|
|||||||
val hitpoints: Double?,
|
val hitpoints: Double?,
|
||||||
val regeneration: Double?,
|
val regeneration: Double?,
|
||||||
val moraleDeathPenalty: Double?,
|
val moraleDeathPenalty: Double?,
|
||||||
|
val maxRepairers: Int?,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class MoraleData(
|
data class MoraleData(
|
||||||
@ -99,6 +101,7 @@ class UnitRgdExtractService @Autowired constructor(
|
|||||||
unit.health = healthData.hitpoints?.toInt()
|
unit.health = healthData.hitpoints?.toInt()
|
||||||
unit.healthRegeneration = healthData.regeneration
|
unit.healthRegeneration = healthData.regeneration
|
||||||
unit.moraleDeathPenalty = healthData.moraleDeathPenalty?.toInt()
|
unit.moraleDeathPenalty = healthData.moraleDeathPenalty?.toInt()
|
||||||
|
unit.repairMax = healthData.maxRepairers
|
||||||
|
|
||||||
val moraleData = getMoraleData(squadData)
|
val moraleData = getMoraleData(squadData)
|
||||||
unit.moraleMax = moraleData.max?.toInt()
|
unit.moraleMax = moraleData.max?.toInt()
|
||||||
@ -122,6 +125,8 @@ class UnitRgdExtractService @Autowired constructor(
|
|||||||
unit.reinforceCostSouls = getReinforceSouls(reinforceCostData)
|
unit.reinforceCostSouls = getReinforceSouls(reinforceCostData)
|
||||||
unit.reinforceTime = getReinforceTime(reinforceData)
|
unit.reinforceTime = getReinforceTime(reinforceData)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
val sergeantsData = getSergeantsData(squadData)
|
val sergeantsData = getSergeantsData(squadData)
|
||||||
|
|
||||||
val sergeantsEntities: List<Pair<Sergeant, Set<Weapon>>>? = sergeantsData.first?.mapNotNull { sergeantData ->
|
val sergeantsEntities: List<Pair<Sergeant, Set<Weapon>>>? = sergeantsData.first?.mapNotNull { sergeantData ->
|
||||||
@ -215,17 +220,12 @@ class UnitRgdExtractService @Autowired constructor(
|
|||||||
|
|
||||||
val descriptionRefs = uiInfo?.getRgdTableByName("help_text_list")
|
val descriptionRefs = uiInfo?.getRgdTableByName("help_text_list")
|
||||||
?.map { (it.value as String).replace("$", "") }
|
?.map { (it.value as String).replace("$", "") }
|
||||||
?.filter { it != "0" && it != "tables\\text_table.lua" && it != "" }
|
?.filter { it != "0" && it != "tables\\text_table.lua" && it != "" && it.toIntOrNull() != null }
|
||||||
?.sortedBy {
|
?.sortedBy { it.toInt() }
|
||||||
try {
|
|
||||||
it.toInt()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val description = try {
|
val description = try {
|
||||||
descriptionRefs?.map { modDictionary[it.toInt()] }?.joinToString("\n")
|
descriptionRefs?.map {
|
||||||
|
modDictionary[it.toInt()] }?.joinToString("\n")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
log.warn("Error parsing ui description", e)
|
log.warn("Error parsing ui description", e)
|
||||||
null
|
null
|
||||||
@ -270,10 +270,12 @@ class UnitRgdExtractService @Autowired constructor(
|
|||||||
|
|
||||||
private fun getHealthAndMoraleDeathPenaltyData(unitData: List<RgdData>): HealthAndMoraleDeathData {
|
private fun getHealthAndMoraleDeathPenaltyData(unitData: List<RgdData>): HealthAndMoraleDeathData {
|
||||||
val healthExt = unitData.getRgdTableByName("health_ext")
|
val healthExt = unitData.getRgdTableByName("health_ext")
|
||||||
|
val canRepair = healthExt?.getBooleanByName("can_be_repaired")
|
||||||
return HealthAndMoraleDeathData(
|
return HealthAndMoraleDeathData(
|
||||||
healthExt?.getDoubleByName("hitpoints"),
|
healthExt?.getDoubleByName("hitpoints"),
|
||||||
healthExt?.getDoubleByName("regeneration_rate"),
|
healthExt?.getDoubleByName("regeneration_rate"),
|
||||||
healthExt?.getDoubleByName("morale_death")
|
healthExt?.getDoubleByName("morale_death"),
|
||||||
|
canRepair?.let { if (it) healthExt.getIntByName("max_repairers") else null }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
25
src/main/resources/db/0.0.2/schema/units.json
Normal file
25
src/main/resources/db/0.0.2/schema/units.json
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"databaseChangeLog": [
|
||||||
|
{
|
||||||
|
"changeSet": {
|
||||||
|
"id": "Add repair_max column to units",
|
||||||
|
"author": "anibus",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"addColumn": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"column": {
|
||||||
|
"name": "repair_max",
|
||||||
|
"type": "int"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tableName": "units"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -77,6 +77,10 @@
|
|||||||
"include": {
|
"include": {
|
||||||
"file": "db/0.0.2/schema/addon.json"
|
"file": "db/0.0.2/schema/addon.json"
|
||||||
}
|
}
|
||||||
|
},{
|
||||||
|
"include": {
|
||||||
|
"file": "db/0.0.2/schema/units.json"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user