Worker unique is now moddable to other units
This commit is contained in:
parent
c402d63a68
commit
77d741040d
7 changed files with 16 additions and 13 deletions
|
@ -2,6 +2,7 @@ package com.unciv
|
|||
|
||||
object Constants {
|
||||
const val worker = "Worker"
|
||||
const val workerUnique = "Can build improvements on tiles"
|
||||
const val settler = "Settler"
|
||||
const val greatGeneral = "Great General"
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ class MainMenuScreen: CameraStageBaseScreen() {
|
|||
table.add(resumeTable).row()
|
||||
}
|
||||
|
||||
val quickstartTable = getTableBlock("Quickstart", "OtherIcons/Quickstart") { QuickstartNewGame() }
|
||||
val quickstartTable = getTableBlock("Quickstart", "OtherIcons/Quickstart") { quickstartNewGame() }
|
||||
table.add(quickstartTable).row()
|
||||
|
||||
val newGameButton = getTableBlock("Start new game", "OtherIcons/New") {
|
||||
|
@ -181,7 +181,7 @@ class MainMenuScreen: CameraStageBaseScreen() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun QuickstartNewGame() {
|
||||
private fun quickstartNewGame() {
|
||||
val newGame = GameStarter.startNewGame(GameSetupInfo().apply { gameParameters.difficulty = "Chieftain" })
|
||||
game.loadGame(newGame)
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
|||
|
||||
val civUnits = civInfo.getCivUnits()
|
||||
val militaryUnits = civUnits.filter { !it.type.isCivilian()}.count()
|
||||
val workers = civUnits.filter { it.name == Constants.worker }.count().toFloat()
|
||||
val workers = civUnits.filter { it.hasUnique(Constants.workerUnique) }.count().toFloat()
|
||||
val cities = civInfo.cities.size
|
||||
val canBuildWorkboat = cityInfo.cityConstructions.getConstructableUnits().map { it.name }.contains("Work Boats")
|
||||
&& !cityInfo.getTiles().any { it.civilianUnit?.name == "Work Boats" }
|
||||
|
@ -119,15 +119,17 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
|||
}
|
||||
|
||||
private fun addWorkerChoice() {
|
||||
if(!civInfo.gameInfo.ruleSet.units.containsKey(Constants.worker)) return // for mods
|
||||
if(civInfo.getIdleUnits().any { it.name==Constants.worker && it.action== Constants.unitActionAutomation})
|
||||
val workerEquivalents = civInfo.gameInfo.ruleSet.units.values
|
||||
.filter { it.uniques.contains(Constants.workerUnique) && it.isBuildable(cityConstructions) }
|
||||
if (workerEquivalents.isEmpty()) return // for mods with no worker units
|
||||
if (civInfo.getIdleUnits().any { it.action == Constants.unitActionAutomation && it.hasUnique(Constants.workerUnique) })
|
||||
return // If we have automated workers who have no work to do then it's silly to construct new workers.
|
||||
|
||||
val citiesCountedTowardsWorkers = min(5, cities) // above 5 cities, extra cities won't make us want more workers
|
||||
if (workers < citiesCountedTowardsWorkers * 0.6f && civUnits.none { it.name==Constants.worker && it.isIdle() }) {
|
||||
if (workers < citiesCountedTowardsWorkers * 0.6f && civUnits.none { it.hasUnique(Constants.workerUnique) && it.isIdle() }) {
|
||||
var modifier = citiesCountedTowardsWorkers / (workers + 0.1f)
|
||||
if (!cityIsOverAverageProduction) modifier /= 5 // higher production cities will deal with this
|
||||
addChoice(relativeCostEffectiveness, Constants.worker, modifier)
|
||||
addChoice(relativeCostEffectiveness, workerEquivalents.minBy { it.cost }!!.name, modifier)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ object UnitAutomation {
|
|||
if (unit.name == Constants.settler)
|
||||
return SpecificUnitAutomation.automateSettlerActions(unit)
|
||||
|
||||
if (unit.name == Constants.worker)
|
||||
if (unit.hasUnique(Constants.workerUnique))
|
||||
return WorkerAutomation(unit).automateWorkerAction()
|
||||
|
||||
if (unit.name == "Work Boats")
|
||||
|
|
|
@ -306,7 +306,7 @@ object Battle {
|
|||
defender.getTile().position, Color.RED)
|
||||
|
||||
// Apparently in Civ V, captured settlers are converted to workers.
|
||||
if(capturedUnit.name==Constants.settler){
|
||||
if(capturedUnit.name==Constants.settler) {
|
||||
val tile = capturedUnit.getTile()
|
||||
capturedUnit.destroy()
|
||||
attacker.getCivInfo().placeUnitNearTile(tile.position, Constants.worker)
|
||||
|
|
|
@ -196,7 +196,7 @@ class MapUnit {
|
|||
|
||||
fun isIdle(): Boolean {
|
||||
if (currentMovement == 0f) return false
|
||||
if (name == Constants.worker && getTile().improvementInProgress != null) return false
|
||||
if (hasUnique(Constants.workerUnique) && getTile().improvementInProgress != null) return false
|
||||
if (hasUnique("Can construct roads") && currentTile.improvementInProgress=="Road") return false
|
||||
if (isFortified()) return false
|
||||
if (action==Constants.unitActionExplore || isSleeping()
|
||||
|
@ -356,7 +356,7 @@ class MapUnit {
|
|||
}
|
||||
|
||||
private fun doPostTurnAction() {
|
||||
if (name == Constants.worker && getTile().improvementInProgress != null) workOnImprovement()
|
||||
if (hasUnique(Constants.workerUnique) && getTile().improvementInProgress != null) workOnImprovement()
|
||||
if(hasUnique("Can construct roads") && currentTile.improvementInProgress=="Road") workOnImprovement()
|
||||
if(currentMovement == getMaxMovement().toFloat()
|
||||
&& isFortified()){
|
||||
|
@ -579,7 +579,7 @@ class MapUnit {
|
|||
}
|
||||
|
||||
actions.add {
|
||||
val chosenUnit = listOf(Constants.settler, Constants.worker,"Warrior")
|
||||
val chosenUnit = listOf(Constants.settler, Constants.worker, "Warrior")
|
||||
.filter { civInfo.gameInfo.ruleSet.units.containsKey(it) }.random(tileBasedRandom)
|
||||
if (!(civInfo.isCityState() || civInfo.isOneCityChallenger()) || chosenUnit != Constants.settler) { //City-States and OCC don't get settler from ruins
|
||||
civInfo.placeUnitNearTile(tile.position, chosenUnit)
|
||||
|
|
|
@ -391,7 +391,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||
|
||||
displayTutorial(Tutorial.InjuredUnits) { gameInfo.getCurrentPlayerCivilization().getCivUnits().any { it.health < 100 } }
|
||||
|
||||
displayTutorial(Tutorial.Workers) { gameInfo.getCurrentPlayerCivilization().getCivUnits().any { it.name == Constants.worker } }
|
||||
displayTutorial(Tutorial.Workers) { gameInfo.getCurrentPlayerCivilization().getCivUnits().any { it.hasUnique(Constants.workerUnique) } }
|
||||
}
|
||||
|
||||
private fun updateDiplomacyButton(civInfo: CivilizationInfo) {
|
||||
|
|
Loading…
Reference in a new issue