mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-11 18:39:43 +07:00
Added unique types for air unit transportation
This commit is contained in:
parent
10a00eed3a
commit
39114ff8f4
@ -46,7 +46,8 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
|||||||
|
|
||||||
fun chooseNextConstruction() {
|
fun chooseNextConstruction() {
|
||||||
if (!UncivGame.Current.settings.autoAssignCityProduction
|
if (!UncivGame.Current.settings.autoAssignCityProduction
|
||||||
&& civInfo.playerType== PlayerType.Human && !cityInfo.isPuppet)
|
&& civInfo.playerType == PlayerType.Human && !cityInfo.isPuppet
|
||||||
|
)
|
||||||
return
|
return
|
||||||
if (cityConstructions.getCurrentConstruction() !is PerpetualConstruction) return // don't want to be stuck on these forever
|
if (cityConstructions.getCurrentConstruction() !is PerpetualConstruction) return // don't want to be stuck on these forever
|
||||||
|
|
||||||
@ -61,33 +62,37 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
|||||||
addSpaceshipPartChoice()
|
addSpaceshipPartChoice()
|
||||||
addOtherBuildingChoice()
|
addOtherBuildingChoice()
|
||||||
|
|
||||||
if(!cityInfo.isPuppet) {
|
if (!cityInfo.isPuppet) {
|
||||||
addWondersChoice()
|
addWondersChoice()
|
||||||
addWorkerChoice()
|
addWorkerChoice()
|
||||||
addWorkBoatChoice()
|
addWorkBoatChoice()
|
||||||
addMilitaryUnitChoice()
|
addMilitaryUnitChoice()
|
||||||
}
|
}
|
||||||
|
|
||||||
val production = cityInfo.cityStats.currentCityStats.production
|
val production = cityInfo.cityStats.currentCityStats.production
|
||||||
|
|
||||||
val theChosenOne: String
|
val chosenConstruction: String =
|
||||||
if (relativeCostEffectiveness.isEmpty()) { // choose one of the special constructions instead
|
if (relativeCostEffectiveness.isEmpty()) { // choose one of the special constructions instead
|
||||||
// add science!
|
// add science!
|
||||||
if (PerpetualConstruction.science.isBuildable(cityConstructions) && !allTechsAreResearched)
|
when {
|
||||||
theChosenOne = "Science"
|
PerpetualConstruction.science.isBuildable(cityConstructions) && !allTechsAreResearched -> PerpetualConstruction.science.name
|
||||||
else if (PerpetualConstruction.gold.isBuildable(cityConstructions))
|
PerpetualConstruction.gold.isBuildable(cityConstructions) -> PerpetualConstruction.gold.name
|
||||||
theChosenOne = "Gold"
|
else -> PerpetualConstruction.idle.name
|
||||||
else theChosenOne = "Nothing"
|
}
|
||||||
} else if (relativeCostEffectiveness.any { it.remainingWork < production * 30 }) {
|
} else if (relativeCostEffectiveness.any { it.remainingWork < production * 30 }) {
|
||||||
relativeCostEffectiveness.removeAll { it.remainingWork >= production * 30 }
|
relativeCostEffectiveness.removeAll { it.remainingWork >= production * 30 }
|
||||||
theChosenOne = relativeCostEffectiveness.minByOrNull { it.remainingWork / it.choiceModifier }!!.choice
|
relativeCostEffectiveness.minByOrNull { it.remainingWork / it.choiceModifier }!!.choice
|
||||||
}
|
}
|
||||||
// it's possible that this is a new city and EVERYTHING is way expensive - ignore modifiers, go for the cheapest.
|
// it's possible that this is a new city and EVERYTHING is way expensive - ignore modifiers, go for the cheapest.
|
||||||
// Nobody can plan 30 turns ahead, I don't care how cost-efficient you are.
|
// Nobody can plan 30 turns ahead, I don't care how cost-efficient you are.
|
||||||
else theChosenOne = relativeCostEffectiveness.minByOrNull { it.remainingWork }!!.choice
|
else relativeCostEffectiveness.minByOrNull { it.remainingWork }!!.choice
|
||||||
|
|
||||||
civInfo.addNotification("Work has started on [$theChosenOne]", CityAction(cityInfo.location), NotificationIcon.Construction)
|
civInfo.addNotification(
|
||||||
cityConstructions.currentConstructionFromQueue = theChosenOne
|
"Work has started on [$chosenConstruction]",
|
||||||
|
CityAction(cityInfo.location),
|
||||||
|
NotificationIcon.Construction
|
||||||
|
)
|
||||||
|
cityConstructions.currentConstructionFromQueue = chosenConstruction
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addMilitaryUnitChoice() {
|
private fun addMilitaryUnitChoice() {
|
||||||
|
@ -936,12 +936,12 @@ class MapUnit {
|
|||||||
fun isTransportTypeOf(mapUnit: MapUnit): Boolean {
|
fun isTransportTypeOf(mapUnit: MapUnit): Boolean {
|
||||||
// Currently, only missiles and airplanes can be carried
|
// Currently, only missiles and airplanes can be carried
|
||||||
if (!mapUnit.baseUnit.movesLikeAirUnits()) return false
|
if (!mapUnit.baseUnit.movesLikeAirUnits()) return false
|
||||||
return getMatchingUniques("Can carry [] [] units").any { mapUnit.matchesFilter(it.params[1]) }
|
return getMatchingUniques(UniqueType.CarryAirUnits).any { mapUnit.matchesFilter(it.params[1]) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun carryCapacity(unit: MapUnit): Int {
|
private fun carryCapacity(unit: MapUnit): Int {
|
||||||
return (getMatchingUniques("Can carry [] [] units")
|
return (getMatchingUniques(UniqueType.CarryAirUnits)
|
||||||
+ getMatchingUniques("Can carry [] extra [] units"))
|
+ getMatchingUniques(UniqueType.CarryExtraAirUnits))
|
||||||
.filter { unit.matchesFilter(it.params[1]) }
|
.filter { unit.matchesFilter(it.params[1]) }
|
||||||
.sumOf { it.params[0].toInt() }
|
.sumOf { it.params[0].toInt() }
|
||||||
}
|
}
|
||||||
|
@ -183,6 +183,10 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) {
|
|||||||
SpreadReligionStrengthUnits("[amount]% Spread Religion Strength for [mapUnitFilter] units", UniqueTarget.Global),
|
SpreadReligionStrengthUnits("[amount]% Spread Religion Strength for [mapUnitFilter] units", UniqueTarget.Global),
|
||||||
|
|
||||||
|
|
||||||
|
CarryAirUnits("Can carry [amount] [mapUnitFilter] units", UniqueTarget.Unit),
|
||||||
|
CarryExtraAirUnits("Can carry [amount] extra [mapUnitFilter] units", UniqueTarget.Unit),
|
||||||
|
CannotBeCarriedBy("Cannot be carried by [mapUnitFilter] units", UniqueTarget.Unit),
|
||||||
|
|
||||||
// The following block gets cached in MapUnit for faster getMovementCostBetweenAdjacentTiles
|
// The following block gets cached in MapUnit for faster getMovementCostBetweenAdjacentTiles
|
||||||
DoubleMovementOnTerrain("Double movement in [terrainFilter]", UniqueTarget.Unit),
|
DoubleMovementOnTerrain("Double movement in [terrainFilter]", UniqueTarget.Unit),
|
||||||
@Deprecated("As of 3.17.1", ReplaceWith("Double movement in [terrainFilter]"), DeprecationLevel.WARNING)
|
@Deprecated("As of 3.17.1", ReplaceWith("Double movement in [terrainFilter]"), DeprecationLevel.WARNING)
|
||||||
|
Loading…
Reference in New Issue
Block a user