Implemented a cap for the production boost of great engineers (#4966)

* Implemented a cap for the production boost of great engineers

* Added a hybrid solution

* Adding production now shows the amount of production added
This commit is contained in:
Xander Lenstra
2021-08-23 19:21:28 +02:00
committed by GitHub
parent 213e648517
commit 15c4b67781
6 changed files with 47 additions and 10 deletions

View File

@ -1494,7 +1494,7 @@
{
"name": "Great Engineer",
"unitType": "Civilian",
"uniques": ["Can speed up construction of a wonder", "Can construct [Manufactory]", "Great Person - [Production]", "Unbuildable", "Uncapturable"],
"uniques": ["Can speed up construction of a building", "Can construct [Manufactory]", "Great Person - [Production]", "Unbuildable", "Uncapturable"],
"movement": 2
},
{

View File

@ -824,6 +824,7 @@ Hurry Research = Versnel Onderzoek
Conduct Trade Mission = Voer handelsmissie uit
Your trade mission to [civName] has earned you [goldAmount] gold and [influenceAmount] influence! = Jouw handelsmissie naar [civName] heeft je [goldAmount] goud en [influenceAmount] invloed opgeleverd!
Hurry Wonder = Versnel Wonder
Hurry Construction = Versnel Constructie
Spread Religion = Verkondig Religie
Spread [religionName] = Verkondig [religionName]
Found a Religion = Begin een religie

View File

@ -731,6 +731,8 @@ Hurry Research =
Conduct Trade Mission =
Your trade mission to [civName] has earned you [goldAmount] gold and [influenceAmount] influence! =
Hurry Wonder =
Hurry Construction =
Hurry Construction (+[productionAmount]) =
Spread Religion =
Spread [religionName] =
Found a Religion =

View File

@ -25,7 +25,7 @@ import kotlin.math.roundToInt
* City constructions manager.
*
* @property cityInfo the city it refers to
* @property currentConstructionFromQueue the name of the construction is currently worked
* @property currentConstructionFromQueue name of the construction that is currently being produced
* @property currentConstructionIsUserSet a flag indicating if the [currentConstructionFromQueue] has been set by the user or by the AI
* @property constructionQueue a list of constructions names enqueued
*/

View File

@ -122,6 +122,8 @@ enum class UnitActionType(
{ ImageGetter.getUnitIcon("Great Artist") }, 'g', UncivSound.Chimes),
HurryWonder("Hurry Wonder",
{ ImageGetter.getUnitIcon("Great Engineer") }, 'g', UncivSound.Chimes),
HurryBuilding("Hurry Construction",
{ ImageGetter.getUnitIcon("Great Engineer") }, 'g', UncivSound.Chimes),
ConductTradeMission("Conduct Trade Mission",
{ ImageGetter.getUnitIcon("Great Merchant") }, 'g', UncivSound.Chimes),
FoundReligion("Found a Religion",

View File

@ -22,6 +22,7 @@ import com.unciv.ui.pickerscreens.PromotionPickerScreen
import com.unciv.ui.utils.YesNoPopup
import com.unciv.ui.utils.hasOpenPopups
import com.unciv.ui.worldscreen.WorldScreen
import kotlin.math.min
object UnitActions {
@ -406,24 +407,55 @@ object UnitActions {
}.takeIf { unit.currentTile.getOwner() != null && unit.currentTile.getOwner() == unit.civInfo }
)
}
"Can speed up construction of a wonder" -> {
val canHurryWonder = if (!tile.isCityCenter()) false
else {
val currentConstruction = tile.getCity()!!.cityConstructions.getCurrentConstruction()
if (currentConstruction !is Building) false
else currentConstruction.isAnyWonder()
}
"Can speed up the construction of a wonder" -> {
val canHurryWonder =
if (!tile.isCityCenter()) false
else tile.getCity()!!.cityConstructions.isBuildingWonder()
actionList += UnitAction(UnitActionType.HurryWonder,
action = {
tile.getCity()!!.cityConstructions.apply {
addProductionPoints(300 + 30 * tile.getCity()!!.population.population) //http://civilization.wikia.com/wiki/Great_engineer_(Civ5)
//http://civilization.wikia.com/wiki/Great_engineer_(Civ5)
addProductionPoints(((300 + 30 * tile.getCity()!!.population.population) * unit.civInfo.gameInfo.gameParameters.gameSpeed.modifier).toInt())
constructIfEnough()
}
addGoldPerGreatPersonUsage(unit.civInfo)
unit.destroy()
}.takeIf { canHurryWonder }
)
}
"Can speed up construction of a building" -> {
if (!tile.isCityCenter()) {
actionList += UnitAction(UnitActionType.HurryBuilding, action = null)
continue
}
val canHurryConstruction = tile.getCity()!!.cityConstructions.getCurrentConstruction() is Building
val cityConstructions = tile.getCity()!!.cityConstructions
//http://civilization.wikia.com/wiki/Great_engineer_(Civ5)
val productionPointsToAdd = min(
(300 + 30 * tile.getCity()!!.population.population) * unit.civInfo.gameInfo.gameParameters.gameSpeed.modifier,
cityConstructions.getRemainingWork(cityConstructions.currentConstructionFromQueue).toFloat() - 1
).toInt()
actionList += UnitAction(UnitActionType.HurryBuilding,
title = "Hurry Construction (+[$productionPointsToAdd]⚙)",
action = {
cityConstructions.apply {
addProductionPoints(productionPointsToAdd)
constructIfEnough()
}
addGoldPerGreatPersonUsage(unit.civInfo)
unit.destroy()
}.takeIf { canHurryConstruction }
)
}
"Can undertake a trade mission with City-State, giving a large sum of gold and [] Influence" -> {
val canConductTradeMission = tile.owningCity?.civInfo?.isCityState() == true
&& tile.owningCity?.civInfo?.isAtWarWith(unit.civInfo) == false