mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-30 07:21:34 -04:00
MODDABLE SPECIALISTS ARE GO!
This commit is contained in:
parent
a24dc7cc69
commit
58d651bfe2
@ -4,7 +4,6 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import com.unciv.logic.automation.Automation
|
import com.unciv.logic.automation.Automation
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.models.Counter
|
import com.unciv.models.Counter
|
||||||
import com.unciv.models.ruleset.Specialist
|
|
||||||
import com.unciv.models.stats.Stats
|
import com.unciv.models.stats.Stats
|
||||||
import com.unciv.ui.utils.withItem
|
import com.unciv.ui.utils.withItem
|
||||||
import com.unciv.ui.utils.withoutItem
|
import com.unciv.ui.utils.withoutItem
|
||||||
@ -89,7 +88,7 @@ class PopulationManager {
|
|||||||
val valueBestTile = if (bestTile == null) 0f
|
val valueBestTile = if (bestTile == null) 0f
|
||||||
else Automation.rankTileForCityWork(bestTile, cityInfo, foodWeight)
|
else Automation.rankTileForCityWork(bestTile, cityInfo, foodWeight)
|
||||||
|
|
||||||
val bestJob: String? = getMaxSpecialistsNew()
|
val bestJob: String? = getMaxSpecialists()
|
||||||
.filter { specialistAllocations[it.key]!!<it.value }
|
.filter { specialistAllocations[it.key]!!<it.value }
|
||||||
.map { it.key }
|
.map { it.key }
|
||||||
.maxBy { Automation.rankSpecialist(getStatsOfSpecialist(it), cityInfo) }
|
.maxBy { Automation.rankSpecialist(getStatsOfSpecialist(it), cityInfo) }
|
||||||
@ -117,7 +116,7 @@ class PopulationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// unassign specialists that cannot be (e.g. the city was captured and one of the specialist buildings was destroyed)
|
// unassign specialists that cannot be (e.g. the city was captured and one of the specialist buildings was destroyed)
|
||||||
val maxSpecialists = getMaxSpecialistsNew()
|
val maxSpecialists = getMaxSpecialists()
|
||||||
val specialistsHashmap = specialistAllocations
|
val specialistsHashmap = specialistAllocations
|
||||||
for ((specialistName, amount) in maxSpecialists)
|
for ((specialistName, amount) in maxSpecialists)
|
||||||
if (specialistsHashmap[specialistName]!! > amount)
|
if (specialistsHashmap[specialistName]!! > amount)
|
||||||
@ -157,7 +156,7 @@ class PopulationManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getMaxSpecialistsNew(): Counter<String> {
|
fun getMaxSpecialists(): Counter<String> {
|
||||||
val counter = Counter<String>()
|
val counter = Counter<String>()
|
||||||
for (building in cityInfo.cityConstructions.getBuiltBuildings())
|
for (building in cityInfo.cityConstructions.getBuiltBuildings())
|
||||||
counter.add(building.newSpecialists())
|
counter.add(building.newSpecialists())
|
||||||
|
@ -19,10 +19,19 @@ class Building : NamedStats(), IConstruction {
|
|||||||
var cost: Int = 0
|
var cost: Int = 0
|
||||||
var maintenance = 0
|
var maintenance = 0
|
||||||
private var percentStatBonus: Stats? = null
|
private var percentStatBonus: Stats? = null
|
||||||
var specialistSlots: Stats? = null
|
var specialistSlots: Counter<String>? = null
|
||||||
fun newSpecialists(): Counter<String> {
|
fun newSpecialists(): Counter<String> {
|
||||||
if(specialistSlots==null) return Counter<String>()
|
if (specialistSlots == null) return Counter<String>()
|
||||||
return Specialist.convertStatsToSpecialistHashmap(specialistSlots!!)
|
// Could have old specialist values of "gold", "science" etc - change them to the new specialist names
|
||||||
|
val counter = Counter<String>()
|
||||||
|
for ((entry, amount) in specialistSlots!!) {
|
||||||
|
val equivalentStat = Stat.values().firstOrNull { it.name.toLowerCase() == entry }
|
||||||
|
|
||||||
|
if (equivalentStat != null)
|
||||||
|
counter[Specialist.specialistNameByStat(equivalentStat)] = amount
|
||||||
|
else counter[entry] = amount
|
||||||
|
}
|
||||||
|
return counter
|
||||||
}
|
}
|
||||||
var greatPersonPoints: Stats? = null
|
var greatPersonPoints: Stats? = null
|
||||||
/** Extra cost percentage when purchasing */
|
/** Extra cost percentage when purchasing */
|
||||||
@ -108,13 +117,8 @@ class Building : NamedStats(), IConstruction {
|
|||||||
if (gpp.culture != 0f) stringBuilder.appendln("+" + gpp.culture.toInt() + " "+"[Great Artist] points".tr())
|
if (gpp.culture != 0f) stringBuilder.appendln("+" + gpp.culture.toInt() + " "+"[Great Artist] points".tr())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.specialistSlots != null) {
|
for((specialistName, amount) in newSpecialists())
|
||||||
val ss = this.specialistSlots!!
|
stringBuilder.appendln("+$amount "+"[$specialistName] slots".tr())
|
||||||
if (ss.production != 0f) stringBuilder.appendln("+" + ss.production.toInt() + " " + "[Engineer specialist] slots".tr())
|
|
||||||
if (ss.gold != 0f) stringBuilder.appendln("+" + ss.gold .toInt() + " " + "[Merchant specialist] slots".tr())
|
|
||||||
if (ss.science != 0f) stringBuilder.appendln("+" + ss.science .toInt() + " " + "[Scientist specialist] slots".tr())
|
|
||||||
if (ss.culture != 0f) stringBuilder.appendln("+" + ss.culture .toInt() + " " + "[Artist specialist] slots".tr())
|
|
||||||
}
|
|
||||||
|
|
||||||
if (resourceBonusStats != null) {
|
if (resourceBonusStats != null) {
|
||||||
val resources = ruleset.tileResources.values.filter { name == it.building }.joinToString { it.name.tr() }
|
val resources = ruleset.tileResources.values.filter { name == it.building }.joinToString { it.name.tr() }
|
||||||
@ -394,7 +398,6 @@ class Building : NamedStats(), IConstruction {
|
|||||||
fun isStatRelated(stat: Stat): Boolean {
|
fun isStatRelated(stat: Stat): Boolean {
|
||||||
if (get(stat) > 0) return true
|
if (get(stat) > 0) return true
|
||||||
if (getStatPercentageBonuses(null).get(stat)>0) return true
|
if (getStatPercentageBonuses(null).get(stat)>0) return true
|
||||||
if (specialistSlots!=null && specialistSlots!!.get(stat)>0) return true
|
|
||||||
if(resourceBonusStats!=null && resourceBonusStats!!.get(stat)>0) return true
|
if(resourceBonusStats!=null && resourceBonusStats!!.get(stat)>0) return true
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
|
|||||||
for (building in cityInfo.cityConstructions.getBuiltBuildings()) {
|
for (building in cityInfo.cityConstructions.getBuiltBuildings()) {
|
||||||
when {
|
when {
|
||||||
building.isWonder || building.isNationalWonder -> wonders.add(building)
|
building.isWonder || building.isNationalWonder -> wonders.add(building)
|
||||||
building.specialistSlots != null -> specialistBuildings.add(building)
|
!building.newSpecialists().isEmpty() -> specialistBuildings.add(building)
|
||||||
else -> otherBuildings.add(building)
|
else -> otherBuildings.add(building)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -151,11 +151,10 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
|
|||||||
addBuildingInfo(building, specialistBuildingsTable)
|
addBuildingInfo(building, specialistBuildingsTable)
|
||||||
val specialistIcons = Table()
|
val specialistIcons = Table()
|
||||||
specialistIcons.row().size(20f).pad(5f)
|
specialistIcons.row().size(20f).pad(5f)
|
||||||
for (stat in building.specialistSlots!!.toHashMap()) {
|
for ((specialistName, amount) in building.newSpecialists()) {
|
||||||
if (stat.value == 0f) continue
|
val specialist = cityInfo.getRuleset().specialists[specialistName]
|
||||||
val specialist = cityInfo.getRuleset().specialists[Specialist.specialistNameByStat(stat.key)]
|
|
||||||
if (specialist == null) continue // probably a mod that doesn't have the specialist defined yet
|
if (specialist == null) continue // probably a mod that doesn't have the specialist defined yet
|
||||||
for (i in 0 until stat.value.toInt())
|
for (i in 0 until amount)
|
||||||
specialistIcons.add(ImageGetter.getSpecialistIcon(specialist.colorObject)).size(20f)
|
specialistIcons.add(ImageGetter.getSpecialistIcon(specialist.colorObject)).size(20f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,8 +5,6 @@ import com.badlogic.gdx.scenes.scene2d.Actor
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.utils.Align
|
import com.badlogic.gdx.utils.Align
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.models.ruleset.Specialist
|
|
||||||
import com.unciv.models.stats.Stat
|
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
|
|
||||||
class SpecialistAllocationTable(val cityScreen: CityScreen): Table(CameraStageBaseScreen.skin){
|
class SpecialistAllocationTable(val cityScreen: CityScreen): Table(CameraStageBaseScreen.skin){
|
||||||
@ -15,10 +13,10 @@ class SpecialistAllocationTable(val cityScreen: CityScreen): Table(CameraStageBa
|
|||||||
fun update() {
|
fun update() {
|
||||||
clear()
|
clear()
|
||||||
|
|
||||||
for ((specialistName, amount) in cityInfo.population.getMaxSpecialistsNew()) {
|
for ((specialistName, amount) in cityInfo.population.getMaxSpecialists()) {
|
||||||
val newSpecialists = cityInfo.population.getNewSpecialists()
|
val newSpecialists = cityInfo.population.getNewSpecialists()
|
||||||
val assignedSpecialists = newSpecialists[specialistName]!!
|
val assignedSpecialists = newSpecialists[specialistName]!!
|
||||||
val maxSpecialists = cityInfo.population.getMaxSpecialistsNew()[specialistName]!!
|
val maxSpecialists = cityInfo.population.getMaxSpecialists()[specialistName]!!
|
||||||
|
|
||||||
if (cityScreen.canChangeState) add(getUnassignButton(assignedSpecialists, specialistName))
|
if (cityScreen.canChangeState) add(getUnassignButton(assignedSpecialists, specialistName))
|
||||||
add(getAllocationTable(assignedSpecialists, maxSpecialists, specialistName)).pad(10f)
|
add(getAllocationTable(assignedSpecialists, maxSpecialists, specialistName)).pad(10f)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user