diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 423bf38e11..48ee4c8ced 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -133,6 +133,7 @@ class CivilizationInfo { fun isCurrentPlayer() = gameInfo.getCurrentPlayerCivilization()==this fun isBarbarianCivilization() = civName=="Barbarians" fun isCityState(): Boolean = getNation().isCityState() + fun getCityStateType(): CityStateType = getNation().cityStateType!! fun isMajorCiv() = !isBarbarianCivilization() && !isCityState() fun getStatsForNextTurn():Stats = getStatMapForNextTurn().values.toList().reduce{a,b->a+b} diff --git a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt index 6c05bd141c..e67efd68b2 100644 --- a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt +++ b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt @@ -53,7 +53,7 @@ class DiplomacyManager() { * As for why it's String and not DiplomaticModifier see FlagsCountdown comment */ var diplomaticModifiers = HashMap() - /** For city states */ + /** For city-states */ var influence = 0f fun clone(): DiplomacyManager { diff --git a/core/src/com/unciv/models/gamebasics/Building.kt b/core/src/com/unciv/models/gamebasics/Building.kt index dd0a0503ee..35f7bb64a3 100644 --- a/core/src/com/unciv/models/gamebasics/Building.kt +++ b/core/src/com/unciv/models/gamebasics/Building.kt @@ -211,7 +211,7 @@ class Building : NamedStats(), IConstruction{ return "Wonder is being built elsewhere" if(civInfo.isCityState()) - return "No world wonders for city state" + return "No world wonders for city-states" } @@ -225,7 +225,7 @@ class Building : NamedStats(), IConstruction{ if (civInfo.cities.any {it!=construction.cityInfo && it.cityConstructions.isBeingConstructed(name) }) return "Wonder is being built elsewhere" if(civInfo.isCityState()) - return "No world wonders for city state" + return "No world wonders for city-states" } if (requiredBuilding != null && !construction.containsBuildingOrEquivalent(requiredBuilding!!)) diff --git a/core/src/com/unciv/models/gamebasics/Nation.kt b/core/src/com/unciv/models/gamebasics/Nation.kt index 1ef8c378e9..112031e085 100644 --- a/core/src/com/unciv/models/gamebasics/Nation.kt +++ b/core/src/com/unciv/models/gamebasics/Nation.kt @@ -36,7 +36,7 @@ class Nation : INamed { return colorFromRGB(secondaryColor!![0], secondaryColor!![1], secondaryColor!![2]) } - fun isCityState()=cityStateType != null + fun isCityState()= cityStateType != null lateinit var cities: List } diff --git a/core/src/com/unciv/models/gamebasics/unit/BaseUnit.kt b/core/src/com/unciv/models/gamebasics/unit/BaseUnit.kt index fd4b82ab08..75de7d765c 100644 --- a/core/src/com/unciv/models/gamebasics/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/gamebasics/unit/BaseUnit.kt @@ -132,7 +132,7 @@ class BaseUnit : INamed, IConstruction, ICivilopedia { if (uniqueTo!=null && uniqueTo!=civInfo.civName) return "Unique to $uniqueTo" if (GameBasics.Units.values.any { it.uniqueTo==civInfo.civName && it.replaces==name }) return "Our unique unit replaces this" if (requiredResource!=null && !civInfo.hasResource(requiredResource!!)) return "Requires $requiredResource" - if (name == Constants.settler && civInfo.isCityState()) return "No settler for city state" + if (name == Constants.settler && civInfo.isCityState()) return "No settler for city-states" return "" } diff --git a/core/src/com/unciv/ui/trade/DiplomacyScreen.kt b/core/src/com/unciv/ui/trade/DiplomacyScreen.kt index 6111ff59fd..db7bd59595 100644 --- a/core/src/com/unciv/ui/trade/DiplomacyScreen.kt +++ b/core/src/com/unciv/ui/trade/DiplomacyScreen.kt @@ -6,13 +6,16 @@ import com.badlogic.gdx.scenes.scene2d.ui.SplitPane import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.TextButton import com.unciv.UnCivGame +import com.unciv.logic.civilization.CityStateType import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.diplomacy.DiplomaticModifiers import com.unciv.logic.civilization.diplomacy.RelationshipLevel import com.unciv.models.gamebasics.tr +import com.unciv.models.stats.Stat import com.unciv.ui.utils.* import com.unciv.ui.worldscreen.optionstable.PopupTable import com.unciv.ui.worldscreen.optionstable.YesNoPopupTable +import javax.xml.soap.Text class DiplomacyScreen:CameraStageBaseScreen() { @@ -68,20 +71,41 @@ class DiplomacyScreen:CameraStageBaseScreen() { return tradeTable } + fun giveGoldGift(otherCiv: CivilizationInfo) { + val currentPlayerCiv = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization() + currentPlayerCiv.gold -= 50 + otherCiv.getDiplomacyManager(currentPlayerCiv).influence += 5 + rightSideTable.clear() + rightSideTable.add(getDiplomacyTable(otherCiv)) + } + private fun getDiplomacyTable(otherCiv: CivilizationInfo): Table { val currentPlayerCiv = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization() val diplomacyTable = Table() diplomacyTable.defaults().pad(10f) val leaderName: String if (otherCiv.isCityState()) { - leaderName = "City state [" + otherCiv.civName + "]" + leaderName = "City-state of [" + otherCiv.civName + "]" + diplomacyTable.add(leaderName.toLabel()).row() + diplomacyTable.add(("Type : " + otherCiv.getCityStateType().toString()).toLabel()).row() + diplomacyTable.add(("Influence : " + otherCiv.getDiplomacyManager(currentPlayerCiv).influence.toInt().toString()).toLabel()).row() + if (otherCiv.getDiplomacyManager(currentPlayerCiv).influence > 60) { + if (otherCiv.getCityStateType() == CityStateType.Cultured) { + diplomacyTable.add(("Providing " + (5.0f * currentPlayerCiv.getEra().ordinal).toString() + " culture each turn").toLabel()) + } + } } else { leaderName = "[" + otherCiv.getNation().leaderName + "] of [" + otherCiv.civName + "]" + diplomacyTable.add(leaderName.toLabel()) } - diplomacyTable.add(leaderName.toLabel()) diplomacyTable.addSeparator() - if(!otherCiv.isCityState()) { + if(otherCiv.isCityState()) { + val giftButton = TextButton("Give 50 gold".tr(), skin) + giftButton.onClick{ giveGoldGift(otherCiv) } + diplomacyTable.add(giftButton).row() + if (currentPlayerCiv.gold < 1) giftButton.disable() + } else { val tradeButton = TextButton("Trade".tr(), skin) tradeButton.onClick { setTrade(otherCiv) } diplomacyTable.add(tradeButton).row() @@ -104,7 +128,7 @@ class DiplomacyScreen:CameraStageBaseScreen() { val responsePopup = PopupTable(this) val otherCivLeaderName: String if (otherCiv.isCityState()) { - otherCivLeaderName = "City state [" + otherCiv.civName + "]" + otherCivLeaderName = "City-state [" + otherCiv.civName + "]" } else { otherCivLeaderName = "[" + otherCiv.getNation().leaderName + "] of [" + otherCiv.civName + "]" } diff --git a/core/src/com/unciv/ui/worldscreen/AlertPopup.kt b/core/src/com/unciv/ui/worldscreen/AlertPopup.kt index 1a94e390f5..fdb0a89833 100644 --- a/core/src/com/unciv/ui/worldscreen/AlertPopup.kt +++ b/core/src/com/unciv/ui/worldscreen/AlertPopup.kt @@ -21,7 +21,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu fun addLeaderName(translatedNation: Nation){ val otherCivLeaderName: String if (translatedNation.isCityState()) { - otherCivLeaderName = "City state [${translatedNation.getNameTranslation()}]".tr() + otherCivLeaderName = "City-state [${translatedNation.getNameTranslation()}]".tr() } else { otherCivLeaderName = "[${translatedNation.leaderName}] of [${translatedNation.getNameTranslation()}]".tr() }