mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-24 22:59:34 +07:00
Special diplomacy window for city states.
This commit is contained in:

committed by
Yair Morgenstern

parent
1865f53c42
commit
4d3e04baa0
@ -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}
|
||||
|
||||
|
@ -53,7 +53,7 @@ class DiplomacyManager() {
|
||||
* As for why it's String and not DiplomaticModifier see FlagsCountdown comment */
|
||||
var diplomaticModifiers = HashMap<String,Float>()
|
||||
|
||||
/** For city states */
|
||||
/** For city-states */
|
||||
var influence = 0f
|
||||
|
||||
fun clone(): DiplomacyManager {
|
||||
|
@ -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!!))
|
||||
|
@ -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<String>
|
||||
}
|
||||
|
@ -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 ""
|
||||
}
|
||||
|
||||
|
@ -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 + "]"
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
|
Reference in New Issue
Block a user