mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 14:24:43 -04:00
Special diplomacy window for city states.
This commit is contained in:
parent
1865f53c42
commit
4d3e04baa0
@ -133,6 +133,7 @@ class CivilizationInfo {
|
|||||||
fun isCurrentPlayer() = gameInfo.getCurrentPlayerCivilization()==this
|
fun isCurrentPlayer() = gameInfo.getCurrentPlayerCivilization()==this
|
||||||
fun isBarbarianCivilization() = civName=="Barbarians"
|
fun isBarbarianCivilization() = civName=="Barbarians"
|
||||||
fun isCityState(): Boolean = getNation().isCityState()
|
fun isCityState(): Boolean = getNation().isCityState()
|
||||||
|
fun getCityStateType(): CityStateType = getNation().cityStateType!!
|
||||||
fun isMajorCiv() = !isBarbarianCivilization() && !isCityState()
|
fun isMajorCiv() = !isBarbarianCivilization() && !isCityState()
|
||||||
fun getStatsForNextTurn():Stats = getStatMapForNextTurn().values.toList().reduce{a,b->a+b}
|
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 */
|
* As for why it's String and not DiplomaticModifier see FlagsCountdown comment */
|
||||||
var diplomaticModifiers = HashMap<String,Float>()
|
var diplomaticModifiers = HashMap<String,Float>()
|
||||||
|
|
||||||
/** For city states */
|
/** For city-states */
|
||||||
var influence = 0f
|
var influence = 0f
|
||||||
|
|
||||||
fun clone(): DiplomacyManager {
|
fun clone(): DiplomacyManager {
|
||||||
|
@ -211,7 +211,7 @@ class Building : NamedStats(), IConstruction{
|
|||||||
return "Wonder is being built elsewhere"
|
return "Wonder is being built elsewhere"
|
||||||
|
|
||||||
if(civInfo.isCityState())
|
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) })
|
if (civInfo.cities.any {it!=construction.cityInfo && it.cityConstructions.isBeingConstructed(name) })
|
||||||
return "Wonder is being built elsewhere"
|
return "Wonder is being built elsewhere"
|
||||||
if(civInfo.isCityState())
|
if(civInfo.isCityState())
|
||||||
return "No world wonders for city state"
|
return "No world wonders for city-states"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requiredBuilding != null && !construction.containsBuildingOrEquivalent(requiredBuilding!!))
|
if (requiredBuilding != null && !construction.containsBuildingOrEquivalent(requiredBuilding!!))
|
||||||
|
@ -132,7 +132,7 @@ class BaseUnit : INamed, IConstruction, ICivilopedia {
|
|||||||
if (uniqueTo!=null && uniqueTo!=civInfo.civName) return "Unique to $uniqueTo"
|
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 (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 (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 ""
|
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.Table
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||||
import com.unciv.UnCivGame
|
import com.unciv.UnCivGame
|
||||||
|
import com.unciv.logic.civilization.CityStateType
|
||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
import com.unciv.logic.civilization.diplomacy.DiplomaticModifiers
|
import com.unciv.logic.civilization.diplomacy.DiplomaticModifiers
|
||||||
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
||||||
import com.unciv.models.gamebasics.tr
|
import com.unciv.models.gamebasics.tr
|
||||||
|
import com.unciv.models.stats.Stat
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
import com.unciv.ui.worldscreen.optionstable.PopupTable
|
import com.unciv.ui.worldscreen.optionstable.PopupTable
|
||||||
import com.unciv.ui.worldscreen.optionstable.YesNoPopupTable
|
import com.unciv.ui.worldscreen.optionstable.YesNoPopupTable
|
||||||
|
import javax.xml.soap.Text
|
||||||
|
|
||||||
class DiplomacyScreen:CameraStageBaseScreen() {
|
class DiplomacyScreen:CameraStageBaseScreen() {
|
||||||
|
|
||||||
@ -68,20 +71,41 @@ class DiplomacyScreen:CameraStageBaseScreen() {
|
|||||||
return tradeTable
|
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 {
|
private fun getDiplomacyTable(otherCiv: CivilizationInfo): Table {
|
||||||
val currentPlayerCiv = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization()
|
val currentPlayerCiv = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization()
|
||||||
val diplomacyTable = Table()
|
val diplomacyTable = Table()
|
||||||
diplomacyTable.defaults().pad(10f)
|
diplomacyTable.defaults().pad(10f)
|
||||||
val leaderName: String
|
val leaderName: String
|
||||||
if (otherCiv.isCityState()) {
|
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 {
|
} else {
|
||||||
leaderName = "[" + otherCiv.getNation().leaderName + "] of [" + otherCiv.civName + "]"
|
leaderName = "[" + otherCiv.getNation().leaderName + "] of [" + otherCiv.civName + "]"
|
||||||
}
|
|
||||||
diplomacyTable.add(leaderName.toLabel())
|
diplomacyTable.add(leaderName.toLabel())
|
||||||
|
}
|
||||||
diplomacyTable.addSeparator()
|
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)
|
val tradeButton = TextButton("Trade".tr(), skin)
|
||||||
tradeButton.onClick { setTrade(otherCiv) }
|
tradeButton.onClick { setTrade(otherCiv) }
|
||||||
diplomacyTable.add(tradeButton).row()
|
diplomacyTable.add(tradeButton).row()
|
||||||
@ -104,7 +128,7 @@ class DiplomacyScreen:CameraStageBaseScreen() {
|
|||||||
val responsePopup = PopupTable(this)
|
val responsePopup = PopupTable(this)
|
||||||
val otherCivLeaderName: String
|
val otherCivLeaderName: String
|
||||||
if (otherCiv.isCityState()) {
|
if (otherCiv.isCityState()) {
|
||||||
otherCivLeaderName = "City state [" + otherCiv.civName + "]"
|
otherCivLeaderName = "City-state [" + otherCiv.civName + "]"
|
||||||
} else {
|
} else {
|
||||||
otherCivLeaderName = "[" + otherCiv.getNation().leaderName + "] of [" + otherCiv.civName + "]"
|
otherCivLeaderName = "[" + otherCiv.getNation().leaderName + "] of [" + otherCiv.civName + "]"
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
|||||||
fun addLeaderName(translatedNation: Nation){
|
fun addLeaderName(translatedNation: Nation){
|
||||||
val otherCivLeaderName: String
|
val otherCivLeaderName: String
|
||||||
if (translatedNation.isCityState()) {
|
if (translatedNation.isCityState()) {
|
||||||
otherCivLeaderName = "City state [${translatedNation.getNameTranslation()}]".tr()
|
otherCivLeaderName = "City-state [${translatedNation.getNameTranslation()}]".tr()
|
||||||
} else {
|
} else {
|
||||||
otherCivLeaderName = "[${translatedNation.leaderName}] of [${translatedNation.getNameTranslation()}]".tr()
|
otherCivLeaderName = "[${translatedNation.leaderName}] of [${translatedNation.getNameTranslation()}]".tr()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user