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() {
|
||||
if (!UncivGame.Current.settings.autoAssignCityProduction
|
||||
&& civInfo.playerType== PlayerType.Human && !cityInfo.isPuppet)
|
||||
&& civInfo.playerType == PlayerType.Human && !cityInfo.isPuppet
|
||||
)
|
||||
return
|
||||
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()
|
||||
addOtherBuildingChoice()
|
||||
|
||||
if(!cityInfo.isPuppet) {
|
||||
if (!cityInfo.isPuppet) {
|
||||
addWondersChoice()
|
||||
addWorkerChoice()
|
||||
addWorkBoatChoice()
|
||||
addMilitaryUnitChoice()
|
||||
}
|
||||
|
||||
|
||||
val production = cityInfo.cityStats.currentCityStats.production
|
||||
|
||||
val theChosenOne: String
|
||||
if (relativeCostEffectiveness.isEmpty()) { // choose one of the special constructions instead
|
||||
// add science!
|
||||
if (PerpetualConstruction.science.isBuildable(cityConstructions) && !allTechsAreResearched)
|
||||
theChosenOne = "Science"
|
||||
else if (PerpetualConstruction.gold.isBuildable(cityConstructions))
|
||||
theChosenOne = "Gold"
|
||||
else theChosenOne = "Nothing"
|
||||
} else if (relativeCostEffectiveness.any { it.remainingWork < production * 30 }) {
|
||||
relativeCostEffectiveness.removeAll { it.remainingWork >= production * 30 }
|
||||
theChosenOne = 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.
|
||||
// Nobody can plan 30 turns ahead, I don't care how cost-efficient you are.
|
||||
else theChosenOne = relativeCostEffectiveness.minByOrNull { it.remainingWork }!!.choice
|
||||
val chosenConstruction: String =
|
||||
if (relativeCostEffectiveness.isEmpty()) { // choose one of the special constructions instead
|
||||
// add science!
|
||||
when {
|
||||
PerpetualConstruction.science.isBuildable(cityConstructions) && !allTechsAreResearched -> PerpetualConstruction.science.name
|
||||
PerpetualConstruction.gold.isBuildable(cityConstructions) -> PerpetualConstruction.gold.name
|
||||
else -> PerpetualConstruction.idle.name
|
||||
}
|
||||
} else if (relativeCostEffectiveness.any { it.remainingWork < production * 30 }) {
|
||||
relativeCostEffectiveness.removeAll { it.remainingWork >= production * 30 }
|
||||
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.
|
||||
// Nobody can plan 30 turns ahead, I don't care how cost-efficient you are.
|
||||
else relativeCostEffectiveness.minByOrNull { it.remainingWork }!!.choice
|
||||
|
||||
civInfo.addNotification("Work has started on [$theChosenOne]", CityAction(cityInfo.location), NotificationIcon.Construction)
|
||||
cityConstructions.currentConstructionFromQueue = theChosenOne
|
||||
civInfo.addNotification(
|
||||
"Work has started on [$chosenConstruction]",
|
||||
CityAction(cityInfo.location),
|
||||
NotificationIcon.Construction
|
||||
)
|
||||
cityConstructions.currentConstructionFromQueue = chosenConstruction
|
||||
}
|
||||
|
||||
private fun addMilitaryUnitChoice() {
|
||||
|
@ -936,12 +936,12 @@ class MapUnit {
|
||||
fun isTransportTypeOf(mapUnit: MapUnit): Boolean {
|
||||
// Currently, only missiles and airplanes can be carried
|
||||
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 {
|
||||
return (getMatchingUniques("Can carry [] [] units")
|
||||
+ getMatchingUniques("Can carry [] extra [] units"))
|
||||
return (getMatchingUniques(UniqueType.CarryAirUnits)
|
||||
+ getMatchingUniques(UniqueType.CarryExtraAirUnits))
|
||||
.filter { unit.matchesFilter(it.params[1]) }
|
||||
.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),
|
||||
|
||||
|
||||
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
|
||||
DoubleMovementOnTerrain("Double movement in [terrainFilter]", UniqueTarget.Unit),
|
||||
@Deprecated("As of 3.17.1", ReplaceWith("Double movement in [terrainFilter]"), DeprecationLevel.WARNING)
|
||||
|
Loading…
Reference in New Issue
Block a user