mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 07:17:50 +07:00
Added unique MayBuyConstructionsInPupets (#10597)
* Uniques: added MayBuyConstructionsInPupets unique for a civ Gives an ability to buy items (units and buildings) in puppet cities * Uniques: clear unnecessary whitespaces * Uniques: typo in a `puppet` word * Uniques: use city's `getMatchingUniques` instead of civ's `hasUnique` during checking the unique
This commit is contained in:
@ -236,6 +236,7 @@ enum class UniqueType(
|
||||
TriggersCulturalVictory("Triggers a Cultural Victory upon completion", UniqueTarget.Global),
|
||||
|
||||
/// Misc.
|
||||
MayBuyConstructionsInPuppets("May buy items in puppet cities", UniqueTarget.Global),
|
||||
MayNotAnnexCities("May not annex cities", UniqueTarget.Global),
|
||||
BorrowsCityNames("\"Borrows\" city names from other civilizations in the game", UniqueTarget.Global),
|
||||
CitiesAreRazedXTimesFaster("Cities are razed [amount] times as fast", UniqueTarget.Global),
|
||||
|
@ -149,7 +149,9 @@ class CityConstructionsTable(private val cityScreen: CityScreen) {
|
||||
|
||||
private fun updateButtons(construction: IConstruction?) {
|
||||
buyButtonsTable.clear()
|
||||
if (!cityScreen.canCityBeChanged()) return
|
||||
if (!cityScreen.canChangeState) return
|
||||
/** [UniqueType.MayBuyConstructionsInPuppets] support - we need a buy button for civs that could buy items in puppets */
|
||||
if (cityScreen.city.isPuppet && !cityScreen.city.getMatchingUniques(UniqueType.MayBuyConstructionsInPuppets).any()) return
|
||||
buyButtonsTable.add(getQueueButton(construction)).padRight(5f)
|
||||
if (construction != null && construction !is PerpetualConstruction)
|
||||
for (button in getBuyButtons(construction as INonPerpetualConstruction))
|
||||
@ -554,6 +556,8 @@ class CityConstructionsTable(private val cityScreen: CityScreen) {
|
||||
selectedQueueEntry = -1
|
||||
cityScreen.update()
|
||||
}
|
||||
if (city.isPuppet)
|
||||
button.disable()
|
||||
} else {
|
||||
button = "Add to queue".toTextButton()
|
||||
if (construction == null
|
||||
@ -717,7 +721,7 @@ class CityConstructionsTable(private val cityScreen: CityScreen) {
|
||||
private fun isConstructionPurchaseAllowed(construction: INonPerpetualConstruction, stat: Stat, constructionBuyCost: Int): Boolean {
|
||||
val city = cityScreen.city
|
||||
return when {
|
||||
city.isPuppet -> false
|
||||
city.isPuppet && !city.getMatchingUniques(UniqueType.MayBuyConstructionsInPuppets).any() -> false
|
||||
!cityScreen.canChangeState -> false
|
||||
city.isInResistance() -> false
|
||||
!construction.isPurchasable(city.cityConstructions) -> false // checks via 'rejection reason'
|
||||
|
@ -740,6 +740,9 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
|
||||
??? example "Triggers a Cultural Victory upon completion"
|
||||
Applicable to: Global
|
||||
|
||||
??? example "May buy items in puppet cities"
|
||||
Applicable to: Global
|
||||
|
||||
??? example "May not annex cities"
|
||||
Applicable to: Global
|
||||
|
||||
|
Reference in New Issue
Block a user