Replaced "Diplomatic Incident" with more generic "Popup Alert"
This commit is contained in:
parent
86ed7c2ec3
commit
6cd925cf78
10 changed files with 36 additions and 36 deletions
Binary file not shown.
Before Width: | Height: | Size: 954 KiB After Width: | Height: | Size: 950 KiB |
|
@ -17,7 +17,7 @@ class UnCivGame(val version: String) : Game() {
|
|||
* This exists so that when debugging we can see the entire map.
|
||||
* Remember to turn this to false before commit and upload!
|
||||
*/
|
||||
val viewEntireMapForDebug = true
|
||||
val viewEntireMapForDebug = false
|
||||
|
||||
// For when you need to test something in an advanced game and don't have time to faff around
|
||||
val superchargedForDebug = false
|
||||
|
|
|
@ -28,7 +28,7 @@ class NextTurnAutomation{
|
|||
automateUnits(civInfo)
|
||||
reassignWorkedTiles(civInfo)
|
||||
trainSettler(civInfo)
|
||||
civInfo.diplomaticIncidents.clear()
|
||||
civInfo.popupAlerts.clear()
|
||||
}
|
||||
|
||||
private fun buyBuildingOrUnit(civInfo: CivilizationInfo) {
|
||||
|
|
|
@ -4,8 +4,8 @@ import com.badlogic.gdx.graphics.Color
|
|||
import com.unciv.logic.GameInfo
|
||||
import com.unciv.logic.automation.UnitAutomation
|
||||
import com.unciv.logic.city.CityInfo
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomaticIncident
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomaticIncidentType
|
||||
import com.unciv.logic.civilization.AlertType
|
||||
import com.unciv.logic.civilization.PopupAlert
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.models.gamebasics.unit.UnitType
|
||||
import java.util.*
|
||||
|
@ -194,7 +194,7 @@ class Battle(val gameInfo:GameInfo) {
|
|||
for(civ in gameInfo.civilizations)
|
||||
civ.addNotification("The civilization of [${enemyCiv.civName}] has been destroyed!", null, Color.RED)
|
||||
enemyCiv.getCivUnits().forEach { it.destroy() }
|
||||
attacker.getCivInfo().diplomaticIncidents.add(DiplomaticIncident(enemyCiv.civName,DiplomaticIncidentType.Defeated))
|
||||
attacker.getCivInfo().popupAlerts.add(PopupAlert(AlertType.Defeated,enemyCiv.civName))
|
||||
}
|
||||
else if(enemyCiv.cities.isNotEmpty()){
|
||||
enemyCiv.cities.first().cityConstructions.addBuilding("Palace") // relocate palace
|
||||
|
|
|
@ -7,8 +7,6 @@ import com.unciv.UnCivGame
|
|||
import com.unciv.logic.GameInfo
|
||||
import com.unciv.logic.city.CityInfo
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomacyManager
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomaticIncident
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomaticIncidentType
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
|
||||
import com.unciv.logic.map.BFS
|
||||
import com.unciv.logic.map.MapUnit
|
||||
|
@ -63,7 +61,7 @@ class CivilizationInfo {
|
|||
var victoryManager=VictoryManager()
|
||||
var diplomacy = HashMap<String, DiplomacyManager>()
|
||||
var notifications = ArrayList<Notification>()
|
||||
val diplomaticIncidents = ArrayList<DiplomaticIncident>()
|
||||
val popupAlerts = ArrayList<PopupAlert>()
|
||||
|
||||
// if we only use lists, and change the list each time the cities are changed,
|
||||
// we won't get concurrent modification exceptions.
|
||||
|
@ -296,12 +294,13 @@ class CivilizationInfo {
|
|||
fun meetCivilization(otherCiv: CivilizationInfo) {
|
||||
diplomacy[otherCiv.civName] = DiplomacyManager(this, otherCiv.civName)
|
||||
.apply { diplomaticStatus = DiplomaticStatus.Peace }
|
||||
otherCiv.diplomaticIncidents.add(DiplomaticIncident(civName, DiplomaticIncidentType.FirstContact))
|
||||
|
||||
otherCiv.popupAlerts.add(PopupAlert(AlertType.FirstContact,civName))
|
||||
|
||||
otherCiv.diplomacy[civName] = DiplomacyManager(otherCiv, civName)
|
||||
.apply { diplomaticStatus = DiplomaticStatus.Peace }
|
||||
|
||||
diplomaticIncidents.add(DiplomaticIncident(otherCiv.civName, DiplomaticIncidentType.FirstContact))
|
||||
popupAlerts.add(PopupAlert(AlertType.FirstContact,otherCiv.civName))
|
||||
}
|
||||
|
||||
override fun toString(): String {return civName} // for debug
|
||||
|
|
9
core/src/com/unciv/logic/civilization/PopupAlert.kt
Normal file
9
core/src/com/unciv/logic/civilization/PopupAlert.kt
Normal file
|
@ -0,0 +1,9 @@
|
|||
package com.unciv.logic.civilization
|
||||
|
||||
enum class AlertType{
|
||||
WarDeclaration,
|
||||
Defeated,
|
||||
FirstContact
|
||||
}
|
||||
|
||||
class PopupAlert (val type:AlertType, val value:String)
|
|
@ -1,7 +1,9 @@
|
|||
package com.unciv.logic.civilization.diplomacy
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.unciv.logic.civilization.AlertType
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.civilization.PopupAlert
|
||||
import com.unciv.logic.trade.Trade
|
||||
import com.unciv.logic.trade.TradeType
|
||||
import com.unciv.models.Counter
|
||||
|
@ -97,9 +99,11 @@ class DiplomacyManager() {
|
|||
|
||||
fun declareWar(){
|
||||
diplomaticStatus = DiplomaticStatus.War
|
||||
otherCiv().diplomacy[civInfo.civName]!!.diplomaticStatus = DiplomaticStatus.War
|
||||
otherCiv().addNotification("[${civInfo.civName}] has declared war on us!",null, Color.RED)
|
||||
otherCiv().diplomaticIncidents.add(DiplomaticIncident(civInfo.civName,DiplomaticIncidentType.WarDeclaration))
|
||||
val otherCiv = otherCiv()
|
||||
|
||||
otherCiv.diplomacy[civInfo.civName]!!.diplomaticStatus = DiplomaticStatus.War
|
||||
otherCiv.addNotification("[${civInfo.civName}] has declared war on us!",null, Color.RED)
|
||||
otherCiv.popupAlerts.add(PopupAlert(AlertType.WarDeclaration,civInfo.civName))
|
||||
}
|
||||
//endregion
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
package com.unciv.logic.civilization.diplomacy
|
||||
|
||||
import com.unciv.logic.trade.Trade
|
||||
|
||||
class DiplomaticIncident(val civName:String, val type: DiplomaticIncidentType, val trade: Trade?=null)
|
|
@ -1,7 +0,0 @@
|
|||
package com.unciv.logic.civilization.diplomacy
|
||||
|
||||
enum class DiplomaticIncidentType{
|
||||
WarDeclaration,
|
||||
Defeated,
|
||||
FirstContact
|
||||
}
|
|
@ -8,9 +8,9 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
|
|||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.logic.GameSaver
|
||||
import com.unciv.logic.civilization.AlertType
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomaticIncident
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomaticIncidentType
|
||||
import com.unciv.logic.civilization.PopupAlert
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tile.ResourceType
|
||||
|
@ -171,8 +171,8 @@ class WorldScreen : CameraStageBaseScreen() {
|
|||
else if(currentPlayerCiv.greatPeople.freeGreatPeople>0) game.screen = GreatPersonPickerScreen()
|
||||
|
||||
if(game.screen==this && !tutorials.isTutorialShowing
|
||||
&& currentPlayerCiv.diplomaticIncidents.any() && !DiplomaticIncidentPopup.isOpen){
|
||||
DiplomaticIncidentPopup(this,currentPlayerCiv.diplomaticIncidents.first())
|
||||
&& currentPlayerCiv.popupAlerts.any() && !AlertPopup.isOpen){
|
||||
AlertPopup(this,currentPlayerCiv.popupAlerts.first())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -329,7 +329,7 @@ class WorldScreen : CameraStageBaseScreen() {
|
|||
|
||||
}
|
||||
|
||||
class DiplomaticIncidentPopup(val worldScreen: WorldScreen, val diplomaticIncident: DiplomaticIncident):PopupTable(worldScreen){
|
||||
class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert):PopupTable(worldScreen){
|
||||
fun getCloseButton(text:String): TextButton {
|
||||
val button = TextButton(text.tr(), skin)
|
||||
button.onClick { close() }
|
||||
|
@ -337,25 +337,25 @@ class DiplomaticIncidentPopup(val worldScreen: WorldScreen, val diplomaticIncide
|
|||
}
|
||||
|
||||
init {
|
||||
val otherCiv = worldScreen.gameInfo.getCivilization(diplomaticIncident.civName)
|
||||
val otherCiv = worldScreen.gameInfo.getCivilization(popupAlert.value)
|
||||
val translatedNation = otherCiv.getTranslatedNation()
|
||||
val otherCivLeaderName = "[${translatedNation.leaderName}] of [${translatedNation.getNameTranslation()}]".tr()
|
||||
add(otherCivLeaderName.toLabel())
|
||||
addSeparator()
|
||||
|
||||
when(diplomaticIncident.type){
|
||||
DiplomaticIncidentType.WarDeclaration -> {
|
||||
when(popupAlert.type){
|
||||
AlertType.WarDeclaration -> {
|
||||
addGoodSizedLabel(translatedNation.declaringWar).row()
|
||||
val responseTable = Table()
|
||||
responseTable.add(getCloseButton("You'll pay for this!"))
|
||||
responseTable.add(getCloseButton("Very well."))
|
||||
add(responseTable)
|
||||
}
|
||||
DiplomaticIncidentType.Defeated -> {
|
||||
AlertType.Defeated -> {
|
||||
addGoodSizedLabel(translatedNation.defeated).row()
|
||||
add(getCloseButton("Farewell."))
|
||||
}
|
||||
DiplomaticIncidentType.FirstContact -> {
|
||||
AlertType.FirstContact -> {
|
||||
addGoodSizedLabel(translatedNation.introduction).row()
|
||||
add(getCloseButton("A pleasure to meet you."))
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ class DiplomaticIncidentPopup(val worldScreen: WorldScreen, val diplomaticIncide
|
|||
}
|
||||
|
||||
fun close(){
|
||||
worldScreen.currentPlayerCiv.diplomaticIncidents.remove(diplomaticIncident)
|
||||
worldScreen.currentPlayerCiv.popupAlerts.remove(popupAlert)
|
||||
isOpen = false
|
||||
remove()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue