Added specific icons to certain notification types
BIN
android/Images/NotificationIcons/Construction.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
android/Images/NotificationIcons/Culture.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
android/Images/NotificationIcons/Growth.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
android/Images/NotificationIcons/Science.png
Normal file
After Width: | Height: | Size: 8.4 KiB |
BIN
android/Images/NotificationIcons/Trade.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
android/Images/NotificationIcons/War.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 866 KiB After Width: | Height: | Size: 874 KiB |
@ -4,7 +4,6 @@ import java.util.*
|
|||||||
plugins {
|
plugins {
|
||||||
id("com.android.application")
|
id("com.android.application")
|
||||||
id("kotlin-android")
|
id("kotlin-android")
|
||||||
id("kotlin-android-extensions")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
@ -171,11 +171,11 @@ class GameInfo {
|
|||||||
if (tiles.size < 3) {
|
if (tiles.size < 3) {
|
||||||
for (tile in tiles) {
|
for (tile in tiles) {
|
||||||
val unitName = tile.militaryUnit!!.name
|
val unitName = tile.militaryUnit!!.name
|
||||||
thisPlayer.addNotification("An enemy [$unitName] was spotted $inOrNear our territory", tile.position, Color.RED)
|
thisPlayer.addNotification("An enemy [$unitName] was spotted $inOrNear our territory", tile.position, NotificationType.War)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val positions = tiles.map { it.position }
|
val positions = tiles.map { it.position }
|
||||||
thisPlayer.addNotification("[${positions.size}] enemy units were spotted $inOrNear our territory", Color.RED, LocationAction(positions))
|
thisPlayer.addNotification("[${positions.size}] enemy units were spotted $inOrNear our territory", NotificationType.War, LocationAction(positions))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import com.unciv.UncivGame
|
|||||||
import com.unciv.logic.city.CityConstructions
|
import com.unciv.logic.city.CityConstructions
|
||||||
import com.unciv.logic.city.PerpetualConstruction
|
import com.unciv.logic.city.PerpetualConstruction
|
||||||
import com.unciv.logic.civilization.CityAction
|
import com.unciv.logic.civilization.CityAction
|
||||||
|
import com.unciv.logic.civilization.NotificationType
|
||||||
import com.unciv.logic.civilization.PlayerType
|
import com.unciv.logic.civilization.PlayerType
|
||||||
import com.unciv.logic.map.BFS
|
import com.unciv.logic.map.BFS
|
||||||
import com.unciv.models.ruleset.Building
|
import com.unciv.models.ruleset.Building
|
||||||
@ -86,7 +87,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
|||||||
// Nobody can plan 30 turns ahead, I don't care how cost-efficient you are.
|
// Nobody can plan 30 turns ahead, I don't care how cost-efficient you are.
|
||||||
else theChosenOne = relativeCostEffectiveness.minBy { it.remainingWork }!!.choice
|
else theChosenOne = relativeCostEffectiveness.minBy { it.remainingWork }!!.choice
|
||||||
|
|
||||||
civInfo.addNotification("Work has started on [$theChosenOne]", Color.BROWN, CityAction(cityInfo.location))
|
civInfo.addNotification("Work has started on [$theChosenOne]", NotificationType.Construction, CityAction(cityInfo.location))
|
||||||
cityConstructions.currentConstructionFromQueue = theChosenOne
|
cityConstructions.currentConstructionFromQueue = theChosenOne
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import com.unciv.UncivGame
|
|||||||
import com.unciv.logic.city.CityInfo
|
import com.unciv.logic.city.CityInfo
|
||||||
import com.unciv.logic.civilization.AlertType
|
import com.unciv.logic.civilization.AlertType
|
||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
|
import com.unciv.logic.civilization.NotificationType
|
||||||
import com.unciv.logic.civilization.PopupAlert
|
import com.unciv.logic.civilization.PopupAlert
|
||||||
import com.unciv.logic.civilization.diplomacy.DiplomaticModifiers
|
import com.unciv.logic.civilization.diplomacy.DiplomaticModifiers
|
||||||
import com.unciv.logic.map.RoadStatus
|
import com.unciv.logic.map.RoadStatus
|
||||||
@ -173,7 +174,7 @@ object Battle {
|
|||||||
else " [" + defender.getName() + "]"
|
else " [" + defender.getName() + "]"
|
||||||
else " our [" + defender.getName() + "]"
|
else " our [" + defender.getName() + "]"
|
||||||
val notificationString = attackerString + whatHappenedString + defenderString
|
val notificationString = attackerString + whatHappenedString + defenderString
|
||||||
defender.getCivInfo().addNotification(notificationString, attackedTile.position, Color.RED)
|
defender.getCivInfo().addNotification(notificationString, attackedTile.position, NotificationType.War)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,7 +289,7 @@ object Battle {
|
|||||||
private fun conquerCity(city: CityInfo, attacker: ICombatant) {
|
private fun conquerCity(city: CityInfo, attacker: ICombatant) {
|
||||||
val attackerCiv = attacker.getCivInfo()
|
val attackerCiv = attacker.getCivInfo()
|
||||||
|
|
||||||
attackerCiv.addNotification("We have conquered the city of [${city.name}]!", city.location, Color.RED)
|
attackerCiv.addNotification("We have conquered the city of [${city.name}]!", city.location, NotificationType.War)
|
||||||
|
|
||||||
city.getCenterTile().apply {
|
city.getCenterTile().apply {
|
||||||
if (militaryUnit != null) militaryUnit!!.destroy()
|
if (militaryUnit != null) militaryUnit!!.destroy()
|
||||||
@ -334,7 +335,7 @@ object Battle {
|
|||||||
|
|
||||||
val capturedUnit = defender.unit
|
val capturedUnit = defender.unit
|
||||||
capturedUnit.civInfo.addNotification("An enemy [" + attacker.getName() + "] has captured our [" + defender.getName() + "]",
|
capturedUnit.civInfo.addNotification("An enemy [" + attacker.getName() + "] has captured our [" + defender.getName() + "]",
|
||||||
defender.getTile().position, Color.RED)
|
defender.getTile().position, NotificationType.War)
|
||||||
|
|
||||||
// Apparently in Civ V, captured settlers are converted to workers.
|
// Apparently in Civ V, captured settlers are converted to workers.
|
||||||
if (capturedUnit.name == Constants.settler) {
|
if (capturedUnit.name == Constants.settler) {
|
||||||
@ -432,17 +433,17 @@ object Battle {
|
|||||||
if (attacker.isDefeated()) {
|
if (attacker.isDefeated()) {
|
||||||
attacker.getCivInfo()
|
attacker.getCivInfo()
|
||||||
.addNotification("Our [$attackerName] was destroyed by an intercepting [$interceptorName]",
|
.addNotification("Our [$attackerName] was destroyed by an intercepting [$interceptorName]",
|
||||||
Color.RED)
|
NotificationType.War)
|
||||||
defender.getCivInfo()
|
defender.getCivInfo()
|
||||||
.addNotification("Our [$interceptorName] intercepted and destroyed an enemy [$attackerName]",
|
.addNotification("Our [$interceptorName] intercepted and destroyed an enemy [$attackerName]",
|
||||||
interceptor.currentTile.position, Color.RED)
|
interceptor.currentTile.position, NotificationType.War)
|
||||||
} else {
|
} else {
|
||||||
attacker.getCivInfo()
|
attacker.getCivInfo()
|
||||||
.addNotification("Our [$attackerName] was attacked by an intercepting [$interceptorName]",
|
.addNotification("Our [$attackerName] was attacked by an intercepting [$interceptorName]",
|
||||||
Color.RED)
|
NotificationType.War)
|
||||||
defender.getCivInfo()
|
defender.getCivInfo()
|
||||||
.addNotification("Our [$interceptorName] intercepted and attacked an enemy [$attackerName]",
|
.addNotification("Our [$interceptorName] intercepted and attacked an enemy [$attackerName]",
|
||||||
interceptor.currentTile.position, Color.RED)
|
interceptor.currentTile.position, NotificationType.War)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -497,8 +498,8 @@ object Battle {
|
|||||||
// and count 1 attack for attacker but leave it in place
|
// and count 1 attack for attacker but leave it in place
|
||||||
reduceAttackerMovementPointsAndAttacks(attacker, defender)
|
reduceAttackerMovementPointsAndAttacks(attacker, defender)
|
||||||
val notificationString = "[" + defendBaseUnit.name + "] withdrew from a [" + attackBaseUnit.name + "]"
|
val notificationString = "[" + defendBaseUnit.name + "] withdrew from a [" + attackBaseUnit.name + "]"
|
||||||
defender.getCivInfo().addNotification(notificationString, toTile.position, Color.GREEN)
|
defender.getCivInfo().addNotification(notificationString, toTile.position, NotificationType.War)
|
||||||
attacker.getCivInfo().addNotification(notificationString, toTile.position, Color.RED)
|
attacker.getCivInfo().addNotification(notificationString, toTile.position, NotificationType.War)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package com.unciv.logic.city
|
|||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.unciv.logic.automation.ConstructionAutomation
|
import com.unciv.logic.automation.ConstructionAutomation
|
||||||
import com.unciv.logic.civilization.AlertType
|
import com.unciv.logic.civilization.AlertType
|
||||||
|
import com.unciv.logic.civilization.NotificationType
|
||||||
import com.unciv.logic.civilization.PopupAlert
|
import com.unciv.logic.civilization.PopupAlert
|
||||||
import com.unciv.models.ruleset.Building
|
import com.unciv.models.ruleset.Building
|
||||||
import com.unciv.models.ruleset.UniqueMap
|
import com.unciv.models.ruleset.UniqueMap
|
||||||
@ -312,7 +313,7 @@ class CityConstructions {
|
|||||||
civ.addNotification("[${construction.name}] has been built in a faraway land", null, Color.BROWN)
|
civ.addNotification("[${construction.name}] has been built in a faraway land", null, Color.BROWN)
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
cityInfo.civInfo.addNotification("[${construction.name}] has been built in [" + cityInfo.name + "]", cityInfo.location, Color.BROWN)
|
cityInfo.civInfo.addNotification("[${construction.name}] has been built in [" + cityInfo.name + "]", cityInfo.location, NotificationType.Construction)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addBuilding(buildingName: String) {
|
fun addBuilding(buildingName: String) {
|
||||||
|
@ -2,6 +2,7 @@ package com.unciv.logic.city
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.unciv.logic.automation.Automation
|
import com.unciv.logic.automation.Automation
|
||||||
|
import com.unciv.logic.civilization.NotificationType
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.ui.utils.withItem
|
import com.unciv.ui.utils.withItem
|
||||||
import com.unciv.ui.utils.withoutItem
|
import com.unciv.ui.utils.withoutItem
|
||||||
@ -142,10 +143,8 @@ class CityExpansionManager {
|
|||||||
|
|
||||||
fun nextTurn(culture: Float) {
|
fun nextTurn(culture: Float) {
|
||||||
cultureStored += culture.toInt()
|
cultureStored += culture.toInt()
|
||||||
if (cultureStored >= getCultureToNextTile()) {
|
if (cultureStored >= getCultureToNextTile() && addNewTileWithCulture())
|
||||||
if (addNewTileWithCulture())
|
cityInfo.civInfo.addNotification("[" + cityInfo.name + "] has expanded its borders!", cityInfo.location, NotificationType.Culture)
|
||||||
cityInfo.civInfo.addNotification("[" + cityInfo.name + "] has expanded its borders!", cityInfo.location, Color.PURPLE)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setTransients() {
|
fun setTransients() {
|
||||||
|
@ -2,6 +2,7 @@ package com.unciv.logic.city
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.unciv.logic.automation.Automation
|
import com.unciv.logic.automation.Automation
|
||||||
|
import com.unciv.logic.civilization.NotificationType
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.models.Counter
|
import com.unciv.models.Counter
|
||||||
import com.unciv.ui.utils.withItem
|
import com.unciv.ui.utils.withItem
|
||||||
@ -64,7 +65,7 @@ class PopulationManager {
|
|||||||
foodStored += (getFoodToNextPopulation() * percentOfFoodCarriedOver / 100f).toInt()
|
foodStored += (getFoodToNextPopulation() * percentOfFoodCarriedOver / 100f).toInt()
|
||||||
population++
|
population++
|
||||||
autoAssignPopulation()
|
autoAssignPopulation()
|
||||||
cityInfo.civInfo.addNotification("[${cityInfo.name}] has grown!", cityInfo.location, Color.GREEN)
|
cityInfo.civInfo.addNotification("[${cityInfo.name}] has grown!", cityInfo.location, NotificationType.Growth)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,11 +553,22 @@ class CivilizationInfo {
|
|||||||
addNotification(text, color, LocationAction(locations))
|
addNotification(text, color, LocationAction(locations))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun addNotification(text: String, location: Vector2?, notificationType: NotificationType) {
|
||||||
|
val locations = if (location != null) listOf(location) else emptyList()
|
||||||
|
addNotification(text, notificationType, LocationAction(locations))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fun addNotification(text: String, color: Color, action: NotificationAction? = null) {
|
fun addNotification(text: String, color: Color, action: NotificationAction? = null) {
|
||||||
if (playerType == PlayerType.AI) return // no point in lengthening the saved game info if no one will read it
|
if (playerType == PlayerType.AI) return // no point in lengthening the saved game info if no one will read it
|
||||||
notifications.add(Notification(text, color, action))
|
notifications.add(Notification(text, color, action))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun addNotification(text: String, notificationType: NotificationType, action: NotificationAction? = null) {
|
||||||
|
if (playerType == PlayerType.AI) return // no point in lengthening the saved game info if no one will read it
|
||||||
|
notifications.add(Notification(text, notificationType, action))
|
||||||
|
}
|
||||||
|
|
||||||
fun addUnit(unitName: String, city: CityInfo? = null) {
|
fun addUnit(unitName: String, city: CityInfo? = null) {
|
||||||
if (cities.isEmpty()) return
|
if (cities.isEmpty()) return
|
||||||
val cityToAddTo = city ?: cities.random()
|
val cityToAddTo = city ?: cities.random()
|
||||||
|
@ -7,16 +7,41 @@ import com.unciv.ui.pickerscreens.TechPickerScreen
|
|||||||
import com.unciv.ui.trade.DiplomacyScreen
|
import com.unciv.ui.trade.DiplomacyScreen
|
||||||
import com.unciv.ui.worldscreen.WorldScreen
|
import com.unciv.ui.worldscreen.WorldScreen
|
||||||
|
|
||||||
|
enum class NotificationType {
|
||||||
|
Culture,
|
||||||
|
Construction,
|
||||||
|
Growth,
|
||||||
|
War,
|
||||||
|
Trade,
|
||||||
|
Science
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [action] is not realized as lambda, as it would be too easy to introduce references to objects
|
* [action] is not realized as lambda, as it would be too easy to introduce references to objects
|
||||||
* there that should not be serialized to the saved game.
|
* there that should not be serialized to the saved game.
|
||||||
*/
|
*/
|
||||||
open class Notification (
|
open class Notification() {
|
||||||
// default parameters necessary for json deserialization
|
|
||||||
var text: String = "",
|
var text: String=""
|
||||||
var color: Color = Color.BLACK,
|
var color: Color?=null
|
||||||
|
var notificationType:NotificationType?=null
|
||||||
var action: NotificationAction? = null
|
var action: NotificationAction? = null
|
||||||
)
|
|
||||||
|
// default parameters necessary for json deserialization
|
||||||
|
constructor(text: String, color: Color, action: NotificationAction?) : this() {
|
||||||
|
this.text = text
|
||||||
|
this.color = color
|
||||||
|
this.action = action
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(text: String, notificationType: NotificationType, action: NotificationAction? = null) : this() {
|
||||||
|
this.text = text
|
||||||
|
this.notificationType = notificationType
|
||||||
|
this.action = action
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/** defines what to do if the user clicks on a notification */
|
/** defines what to do if the user clicks on a notification */
|
||||||
interface NotificationAction {
|
interface NotificationAction {
|
||||||
|
@ -257,7 +257,7 @@ class TechManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (it in getRuleset().policyBranches.values.filter { it.era == currentEra }) {
|
for (it in getRuleset().policyBranches.values.filter { it.era == currentEra }) {
|
||||||
civInfo.addNotification("[" + it.name + "] policy branch unlocked!", null, Color.PURPLE)
|
civInfo.addNotification("[" + it.name + "] policy branch unlocked!", NotificationType.Culture)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,46 +68,51 @@ class DiplomacyManager() {
|
|||||||
const val MINIMUM_INFLUENCE = -60f
|
const val MINIMUM_INFLUENCE = -60f
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transient lateinit var civInfo: CivilizationInfo
|
@Transient
|
||||||
// since this needs to be checked a lot during travel, putting it in a transient is a good performance booster
|
lateinit var civInfo: CivilizationInfo
|
||||||
@Transient var hasOpenBorders=false
|
|
||||||
|
|
||||||
lateinit var otherCivName:String
|
// since this needs to be checked a lot during travel, putting it in a transient is a good performance booster
|
||||||
|
@Transient
|
||||||
|
var hasOpenBorders = false
|
||||||
|
|
||||||
|
lateinit var otherCivName: String
|
||||||
var trades = ArrayList<Trade>()
|
var trades = ArrayList<Trade>()
|
||||||
var diplomaticStatus = DiplomaticStatus.War
|
var diplomaticStatus = DiplomaticStatus.War
|
||||||
|
|
||||||
/** Contains various flags (declared war, promised to not settle, declined luxury trade) and the number of turns in which they will expire.
|
/** Contains various flags (declared war, promised to not settle, declined luxury trade) and the number of turns in which they will expire.
|
||||||
* The JSON serialize/deserialize REFUSES to deserialize hashmap keys as Enums, so I'm forced to use strings instead =(
|
* The JSON serialize/deserialize REFUSES to deserialize hashmap keys as Enums, so I'm forced to use strings instead =(
|
||||||
* This is so sad Alexa play Despacito */
|
* This is so sad Alexa play Despacito */
|
||||||
private var flagsCountdown = HashMap<String,Int>()
|
private var flagsCountdown = HashMap<String, Int>()
|
||||||
|
|
||||||
/** For AI. Positive is good relations, negative is bad.
|
/** For AI. Positive is good relations, negative is bad.
|
||||||
* Baseline is 1 point for each turn of peace - so declaring a war upends 40 years of peace, and e.g. capturing a city can be another 30 or 40.
|
* Baseline is 1 point for each turn of peace - so declaring a war upends 40 years of peace, and e.g. capturing a city can be another 30 or 40.
|
||||||
* 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. Influence is saved in the CITY STATE -> major civ Diplomacy, NOT in the major civ -> cty state diplomacy.
|
/** For city-states. Influence is saved in the CITY STATE -> major civ Diplomacy, NOT in the major civ -> cty state diplomacy.
|
||||||
* Won't go below [MINIMUM_INFLUENCE] */
|
* Won't go below [MINIMUM_INFLUENCE] */
|
||||||
var influence = 0f
|
var influence = 0f
|
||||||
set(value) { field = max(value, MINIMUM_INFLUENCE) }
|
set(value) {
|
||||||
get() = if(civInfo.isAtWarWith(otherCiv())) MINIMUM_INFLUENCE else field
|
field = max(value, MINIMUM_INFLUENCE)
|
||||||
|
}
|
||||||
|
get() = if (civInfo.isAtWarWith(otherCiv())) MINIMUM_INFLUENCE else field
|
||||||
|
|
||||||
/** Total of each turn Science during Research Agreement */
|
/** Total of each turn Science during Research Agreement */
|
||||||
var totalOfScienceDuringRA = 0
|
var totalOfScienceDuringRA = 0
|
||||||
|
|
||||||
fun clone(): DiplomacyManager {
|
fun clone(): DiplomacyManager {
|
||||||
val toReturn = DiplomacyManager()
|
val toReturn = DiplomacyManager()
|
||||||
toReturn.otherCivName=otherCivName
|
toReturn.otherCivName = otherCivName
|
||||||
toReturn.diplomaticStatus=diplomaticStatus
|
toReturn.diplomaticStatus = diplomaticStatus
|
||||||
toReturn.trades.addAll(trades.map { it.clone() })
|
toReturn.trades.addAll(trades.map { it.clone() })
|
||||||
toReturn.influence = influence
|
toReturn.influence = influence
|
||||||
toReturn.flagsCountdown.putAll(flagsCountdown)
|
toReturn.flagsCountdown.putAll(flagsCountdown)
|
||||||
toReturn.diplomaticModifiers.putAll(diplomaticModifiers)
|
toReturn.diplomaticModifiers.putAll(diplomaticModifiers)
|
||||||
toReturn.totalOfScienceDuringRA=totalOfScienceDuringRA
|
toReturn.totalOfScienceDuringRA = totalOfScienceDuringRA
|
||||||
return toReturn
|
return toReturn
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(civilizationInfo: CivilizationInfo, OtherCivName:String) : this() {
|
constructor(civilizationInfo: CivilizationInfo, OtherCivName: String) : this() {
|
||||||
civInfo = civilizationInfo
|
civInfo = civilizationInfo
|
||||||
otherCivName = OtherCivName
|
otherCivName = OtherCivName
|
||||||
updateHasOpenBorders()
|
updateHasOpenBorders()
|
||||||
@ -118,26 +123,26 @@ class DiplomacyManager() {
|
|||||||
fun otherCivDiplomacy() = otherCiv().getDiplomacyManager(civInfo)
|
fun otherCivDiplomacy() = otherCiv().getDiplomacyManager(civInfo)
|
||||||
|
|
||||||
fun turnsToPeaceTreaty(): Int {
|
fun turnsToPeaceTreaty(): Int {
|
||||||
for(trade in trades)
|
for (trade in trades)
|
||||||
for(offer in trade.ourOffers)
|
for (offer in trade.ourOffers)
|
||||||
if(offer.name == Constants.peaceTreaty && offer.duration > 0) return offer.duration
|
if (offer.name == Constants.peaceTreaty && offer.duration > 0) return offer.duration
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
fun opinionOfOtherCiv() = diplomaticModifiers.values.sum()
|
fun opinionOfOtherCiv() = diplomaticModifiers.values.sum()
|
||||||
|
|
||||||
fun relationshipLevel(): RelationshipLevel {
|
fun relationshipLevel(): RelationshipLevel {
|
||||||
if(civInfo.isPlayerCivilization() && otherCiv().isPlayerCivilization())
|
if (civInfo.isPlayerCivilization() && otherCiv().isPlayerCivilization())
|
||||||
return RelationshipLevel.Neutral // People make their own choices.
|
return RelationshipLevel.Neutral // People make their own choices.
|
||||||
|
|
||||||
if(civInfo.isPlayerCivilization())
|
if (civInfo.isPlayerCivilization())
|
||||||
return otherCiv().getDiplomacyManager(civInfo).relationshipLevel()
|
return otherCiv().getDiplomacyManager(civInfo).relationshipLevel()
|
||||||
|
|
||||||
if(civInfo.isCityState()) {
|
if (civInfo.isCityState()) {
|
||||||
if(influence <= -30 || civInfo.isAtWarWith(otherCiv())) return RelationshipLevel.Unforgivable
|
if (influence <= -30 || civInfo.isAtWarWith(otherCiv())) return RelationshipLevel.Unforgivable
|
||||||
if(influence < 0) return RelationshipLevel.Enemy
|
if (influence < 0) return RelationshipLevel.Enemy
|
||||||
if(influence >= 60 && civInfo.getAllyCiv() == otherCivName) return RelationshipLevel.Ally
|
if (influence >= 60 && civInfo.getAllyCiv() == otherCivName) return RelationshipLevel.Ally
|
||||||
if(influence >= 30) return RelationshipLevel.Friend
|
if (influence >= 30) return RelationshipLevel.Friend
|
||||||
return RelationshipLevel.Neutral
|
return RelationshipLevel.Neutral
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +181,7 @@ class DiplomacyManager() {
|
|||||||
// To be run from City-State DiplomacyManager, which holds the influence. Resting point for every major civ can be different.
|
// To be run from City-State DiplomacyManager, which holds the influence. Resting point for every major civ can be different.
|
||||||
fun getCityStateInfluenceRestingPoint(): Float {
|
fun getCityStateInfluenceRestingPoint(): Float {
|
||||||
var restingPoint = 0f
|
var restingPoint = 0f
|
||||||
for(unique in otherCiv().getMatchingUniques("Resting point for Influence with City-States is increased by []"))
|
for (unique in otherCiv().getMatchingUniques("Resting point for Influence with City-States is increased by []"))
|
||||||
restingPoint += unique.params[0].toInt()
|
restingPoint += unique.params[0].toInt()
|
||||||
return restingPoint
|
return restingPoint
|
||||||
}
|
}
|
||||||
@ -226,13 +231,14 @@ class DiplomacyManager() {
|
|||||||
return max(0f, increment) * max(0f, modifier)
|
return max(0f, increment) * max(0f, modifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun canDeclareWar() = turnsToPeaceTreaty()==0 && diplomaticStatus != DiplomaticStatus.War
|
fun canDeclareWar() = turnsToPeaceTreaty() == 0 && diplomaticStatus != DiplomaticStatus.War
|
||||||
//Used for nuke
|
|
||||||
fun canAttack() = turnsToPeaceTreaty()==0
|
|
||||||
|
|
||||||
fun goldPerTurn():Int{
|
//Used for nuke
|
||||||
|
fun canAttack() = turnsToPeaceTreaty() == 0
|
||||||
|
|
||||||
|
fun goldPerTurn(): Int {
|
||||||
var goldPerTurnForUs = 0
|
var goldPerTurnForUs = 0
|
||||||
for(trade in trades) {
|
for (trade in trades) {
|
||||||
for (offer in trade.ourOffers.filter { it.type == TradeType.Gold_Per_Turn })
|
for (offer in trade.ourOffers.filter { it.type == TradeType.Gold_Per_Turn })
|
||||||
goldPerTurnForUs -= offer.amount
|
goldPerTurnForUs -= offer.amount
|
||||||
for (offer in trade.theirOffers.filter { it.type == TradeType.Gold_Per_Turn })
|
for (offer in trade.theirOffers.filter { it.type == TradeType.Gold_Per_Turn })
|
||||||
@ -241,7 +247,7 @@ class DiplomacyManager() {
|
|||||||
return goldPerTurnForUs
|
return goldPerTurnForUs
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sciencefromResearchAgreement(){
|
fun sciencefromResearchAgreement() {
|
||||||
// https://forums.civfanatics.com/resources/research-agreements-bnw.25568/
|
// https://forums.civfanatics.com/resources/research-agreements-bnw.25568/
|
||||||
val scienceFromResearchAgreement = min(totalOfScienceDuringRA, otherCivDiplomacy().totalOfScienceDuringRA)
|
val scienceFromResearchAgreement = min(totalOfScienceDuringRA, otherCivDiplomacy().totalOfScienceDuringRA)
|
||||||
civInfo.tech.scienceFromResearchAgreements += scienceFromResearchAgreement
|
civInfo.tech.scienceFromResearchAgreements += scienceFromResearchAgreement
|
||||||
@ -253,8 +259,10 @@ class DiplomacyManager() {
|
|||||||
fun resourcesFromTrade(): ResourceSupplyList {
|
fun resourcesFromTrade(): ResourceSupplyList {
|
||||||
val counter = ResourceSupplyList()
|
val counter = ResourceSupplyList()
|
||||||
val resourcesMap = civInfo.gameInfo.ruleSet.tileResources
|
val resourcesMap = civInfo.gameInfo.ruleSet.tileResources
|
||||||
val isResourceFilter: (TradeOffer) -> Boolean = { (it.type == TradeType.Strategic_Resource || it.type == TradeType.Luxury_Resource)
|
val isResourceFilter: (TradeOffer) -> Boolean = {
|
||||||
&& civInfo.gameInfo.ruleSet.tileResources.containsKey(it.name) }
|
(it.type == TradeType.Strategic_Resource || it.type == TradeType.Luxury_Resource)
|
||||||
|
&& civInfo.gameInfo.ruleSet.tileResources.containsKey(it.name)
|
||||||
|
}
|
||||||
for (trade in trades) {
|
for (trade in trades) {
|
||||||
for (offer in trade.ourOffers.filter(isResourceFilter))
|
for (offer in trade.ourOffers.filter(isResourceFilter))
|
||||||
counter.add(resourcesMap[offer.name]!!, -offer.amount, "Trade")
|
counter.add(resourcesMap[offer.name]!!, -offer.amount, "Trade")
|
||||||
@ -299,8 +307,8 @@ class DiplomacyManager() {
|
|||||||
trades.remove(trade)
|
trades.remove(trade)
|
||||||
val otherCivTrades = otherCiv().getDiplomacyManager(civInfo).trades
|
val otherCivTrades = otherCiv().getDiplomacyManager(civInfo).trades
|
||||||
otherCivTrades.removeAll { it.equals(trade.reverse()) }
|
otherCivTrades.removeAll { it.equals(trade.reverse()) }
|
||||||
civInfo.addNotification("One of our trades with [$otherCivName] has been cut short", null, Color.GOLD)
|
civInfo.addNotification("One of our trades with [$otherCivName] has been cut short", NotificationType.Trade)
|
||||||
otherCiv().addNotification("One of our trades with [${civInfo.civName}] has been cut short", null, Color.GOLD)
|
otherCiv().addNotification("One of our trades with [${civInfo.civName}] has been cut short", NotificationType.Trade)
|
||||||
civInfo.updateDetailedCivResources()
|
civInfo.updateDetailedCivResources()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -323,7 +331,7 @@ class DiplomacyManager() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nextTurn(){
|
fun nextTurn() {
|
||||||
nextTurnTrades()
|
nextTurnTrades()
|
||||||
removeUntenebleTrades()
|
removeUntenebleTrades()
|
||||||
updateHasOpenBorders()
|
updateHasOpenBorders()
|
||||||
@ -355,7 +363,7 @@ class DiplomacyManager() {
|
|||||||
influence = min(restingPoint, influence + increment)
|
influence = min(restingPoint, influence + increment)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!civInfo.isDefeated()) { // don't display city state relationship notifications when the city state is currently defeated
|
if (!civInfo.isDefeated()) { // don't display city state relationship notifications when the city state is currently defeated
|
||||||
val civCapitalLocation = if (civInfo.cities.isNotEmpty()) civInfo.getCapital().location else null
|
val civCapitalLocation = if (civInfo.cities.isNotEmpty()) civInfo.getCapital().location else null
|
||||||
if (getTurnsToRelationshipChange() == 1)
|
if (getTurnsToRelationshipChange() == 1)
|
||||||
otherCiv().addNotification("Your relationship with [${civInfo.civName}] is about to degrade", civCapitalLocation, Color.GOLD)
|
otherCiv().addNotification("Your relationship with [${civInfo.civName}] is about to degrade", civCapitalLocation, Color.GOLD)
|
||||||
@ -409,8 +417,8 @@ class DiplomacyManager() {
|
|||||||
trades.remove(trade)
|
trades.remove(trade)
|
||||||
for (offer in trade.ourOffers.union(trade.theirOffers).filter { it.duration == 0 }) { // this was a timed trade
|
for (offer in trade.ourOffers.union(trade.theirOffers).filter { it.duration == 0 }) { // this was a timed trade
|
||||||
if (offer in trade.theirOffers)
|
if (offer in trade.theirOffers)
|
||||||
civInfo.addNotification("[${offer.name}] from [$otherCivName] has ended", null, Color.GOLD)
|
civInfo.addNotification("[${offer.name}] from [$otherCivName] has ended", NotificationType.Trade)
|
||||||
else civInfo.addNotification("[${offer.name}] to [$otherCivName] has ended", null, Color.GOLD)
|
else civInfo.addNotification("[${offer.name}] to [$otherCivName] has ended", NotificationType.Trade)
|
||||||
|
|
||||||
civInfo.updateStatsForNextTurn() // if they were bringing us gold per turn
|
civInfo.updateStatsForNextTurn() // if they were bringing us gold per turn
|
||||||
civInfo.updateDetailedCivResources() // if they were giving us resources
|
civInfo.updateDetailedCivResources() // if they were giving us resources
|
||||||
@ -457,46 +465,46 @@ class DiplomacyManager() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Everything that happens to both sides equally when war is delcared by one side on the other */
|
/** Everything that happens to both sides equally when war is delcared by one side on the other */
|
||||||
private fun onWarDeclared(){
|
private fun onWarDeclared() {
|
||||||
diplomaticStatus = DiplomaticStatus.War
|
diplomaticStatus = DiplomaticStatus.War
|
||||||
|
|
||||||
// Cancel all trades.
|
// Cancel all trades.
|
||||||
for(trade in trades)
|
for (trade in trades)
|
||||||
for(offer in trade.theirOffers.filter { it.duration>0 })
|
for (offer in trade.theirOffers.filter { it.duration > 0 })
|
||||||
civInfo.addNotification("["+offer.name+"] from [$otherCivName] has ended",null, Color.GOLD)
|
civInfo.addNotification("[" + offer.name + "] from [$otherCivName] has ended", NotificationType.Trade)
|
||||||
trades.clear()
|
trades.clear()
|
||||||
updateHasOpenBorders()
|
updateHasOpenBorders()
|
||||||
|
|
||||||
setFlag(DiplomacyFlags.DeclinedPeace,10)/// AI won't propose peace for 10 turns
|
setFlag(DiplomacyFlags.DeclinedPeace, 10)/// AI won't propose peace for 10 turns
|
||||||
setFlag(DiplomacyFlags.DeclaredWar,10) // AI won't agree to trade for 10 turns
|
setFlag(DiplomacyFlags.DeclaredWar, 10) // AI won't agree to trade for 10 turns
|
||||||
removeFlag(DiplomacyFlags.BorderConflict)
|
removeFlag(DiplomacyFlags.BorderConflict)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun declareWar(){
|
fun declareWar() {
|
||||||
val otherCiv = otherCiv()
|
val otherCiv = otherCiv()
|
||||||
val otherCivDiplomacy = otherCivDiplomacy()
|
val otherCivDiplomacy = otherCivDiplomacy()
|
||||||
|
|
||||||
onWarDeclared()
|
onWarDeclared()
|
||||||
otherCivDiplomacy.onWarDeclared()
|
otherCivDiplomacy.onWarDeclared()
|
||||||
|
|
||||||
otherCiv.addNotification("[${civInfo.civName}] has declared war on us!",null, Color.RED)
|
otherCiv.addNotification("[${civInfo.civName}] has declared war on us!", NotificationType.War)
|
||||||
otherCiv.popupAlerts.add(PopupAlert(AlertType.WarDeclaration,civInfo.civName))
|
otherCiv.popupAlerts.add(PopupAlert(AlertType.WarDeclaration, civInfo.civName))
|
||||||
|
|
||||||
getCommonKnownCivs().forEach {
|
getCommonKnownCivs().forEach {
|
||||||
it.addNotification("[${civInfo.civName}] has declared war on [${otherCiv().civName}]!", null, Color.RED)
|
it.addNotification("[${civInfo.civName}] has declared war on [${otherCiv().civName}]!", NotificationType.War)
|
||||||
}
|
}
|
||||||
|
|
||||||
otherCivDiplomacy.setModifier(DiplomaticModifiers.DeclaredWarOnUs,-20f)
|
otherCivDiplomacy.setModifier(DiplomaticModifiers.DeclaredWarOnUs, -20f)
|
||||||
if(otherCiv.isCityState()) otherCivDiplomacy.influence -= 60
|
if (otherCiv.isCityState()) otherCivDiplomacy.influence -= 60
|
||||||
|
|
||||||
for(thirdCiv in civInfo.getKnownCivs()) {
|
for (thirdCiv in civInfo.getKnownCivs()) {
|
||||||
if (thirdCiv.isAtWarWith(otherCiv)) {
|
if (thirdCiv.isAtWarWith(otherCiv)) {
|
||||||
if (thirdCiv.isCityState()) thirdCiv.getDiplomacyManager(civInfo).influence += 10
|
if (thirdCiv.isCityState()) thirdCiv.getDiplomacyManager(civInfo).influence += 10
|
||||||
else thirdCiv.getDiplomacyManager(civInfo).addModifier(DiplomaticModifiers.SharedEnemy, 5f)
|
else thirdCiv.getDiplomacyManager(civInfo).addModifier(DiplomaticModifiers.SharedEnemy, 5f)
|
||||||
} else thirdCiv.getDiplomacyManager(civInfo).addModifier(DiplomaticModifiers.WarMongerer, -5f)
|
} else thirdCiv.getDiplomacyManager(civInfo).addModifier(DiplomaticModifiers.WarMongerer, -5f)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasFlag(DiplomacyFlags.DeclarationOfFriendship)) {
|
if (hasFlag(DiplomacyFlags.DeclarationOfFriendship)) {
|
||||||
removeFlag(DiplomacyFlags.DeclarationOfFriendship)
|
removeFlag(DiplomacyFlags.DeclarationOfFriendship)
|
||||||
otherCivDiplomacy.removeModifier(DiplomaticModifiers.DeclarationOfFriendship)
|
otherCivDiplomacy.removeModifier(DiplomaticModifiers.DeclarationOfFriendship)
|
||||||
for (knownCiv in civInfo.getKnownCivs()) {
|
for (knownCiv in civInfo.getKnownCivs()) {
|
||||||
@ -507,7 +515,7 @@ class DiplomacyManager() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
otherCivDiplomacy.removeFlag(DiplomacyFlags.DeclarationOfFriendship)
|
otherCivDiplomacy.removeFlag(DiplomacyFlags.DeclarationOfFriendship)
|
||||||
if(hasFlag(DiplomacyFlags.ResearchAgreement)) {
|
if (hasFlag(DiplomacyFlags.ResearchAgreement)) {
|
||||||
removeFlag(DiplomacyFlags.ResearchAgreement)
|
removeFlag(DiplomacyFlags.ResearchAgreement)
|
||||||
totalOfScienceDuringRA = 0
|
totalOfScienceDuringRA = 0
|
||||||
otherCivDiplomacy.totalOfScienceDuringRA = 0
|
otherCivDiplomacy.totalOfScienceDuringRA = 0
|
||||||
@ -567,24 +575,29 @@ class DiplomacyManager() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hasFlag(flag:DiplomacyFlags) = flagsCountdown.containsKey(flag.name)
|
fun hasFlag(flag: DiplomacyFlags) = flagsCountdown.containsKey(flag.name)
|
||||||
fun setFlag(flag: DiplomacyFlags, amount: Int){ flagsCountdown[flag.name]=amount}
|
fun setFlag(flag: DiplomacyFlags, amount: Int) {
|
||||||
fun getFlag(flag: DiplomacyFlags) = flagsCountdown[flag.name]!!
|
flagsCountdown[flag.name] = amount
|
||||||
fun removeFlag(flag: DiplomacyFlags){ flagsCountdown.remove(flag.name)}
|
|
||||||
|
|
||||||
fun addModifier(modifier: DiplomaticModifiers, amount:Float){
|
|
||||||
val modifierString = modifier.name
|
|
||||||
if(!hasModifier(modifier)) setModifier(modifier,0f)
|
|
||||||
diplomaticModifiers[modifierString] = diplomaticModifiers[modifierString]!!+amount
|
|
||||||
if(diplomaticModifiers[modifierString]==0f) diplomaticModifiers.remove(modifierString)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setModifier(modifier: DiplomaticModifiers, amount: Float){
|
fun getFlag(flag: DiplomacyFlags) = flagsCountdown[flag.name]!!
|
||||||
|
fun removeFlag(flag: DiplomacyFlags) {
|
||||||
|
flagsCountdown.remove(flag.name)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addModifier(modifier: DiplomaticModifiers, amount: Float) {
|
||||||
|
val modifierString = modifier.name
|
||||||
|
if (!hasModifier(modifier)) setModifier(modifier, 0f)
|
||||||
|
diplomaticModifiers[modifierString] = diplomaticModifiers[modifierString]!! + amount
|
||||||
|
if (diplomaticModifiers[modifierString] == 0f) diplomaticModifiers.remove(modifierString)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setModifier(modifier: DiplomaticModifiers, amount: Float) {
|
||||||
diplomaticModifiers[modifier.name] = amount
|
diplomaticModifiers[modifier.name] = amount
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getModifier(modifier: DiplomaticModifiers): Float {
|
fun getModifier(modifier: DiplomaticModifiers): Float {
|
||||||
if(!hasModifier(modifier)) return 0f
|
if (!hasModifier(modifier)) return 0f
|
||||||
return diplomaticModifiers[modifier.name]!!
|
return diplomaticModifiers[modifier.name]!!
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,18 +605,18 @@ class DiplomacyManager() {
|
|||||||
fun hasModifier(modifier: DiplomaticModifiers) = diplomaticModifiers.containsKey(modifier.name)
|
fun hasModifier(modifier: DiplomaticModifiers) = diplomaticModifiers.containsKey(modifier.name)
|
||||||
|
|
||||||
/** @param amount always positive, so you don't need to think about it */
|
/** @param amount always positive, so you don't need to think about it */
|
||||||
fun revertToZero(modifier: DiplomaticModifiers, amount: Float){
|
fun revertToZero(modifier: DiplomaticModifiers, amount: Float) {
|
||||||
if(!hasModifier(modifier)) return
|
if (!hasModifier(modifier)) return
|
||||||
val currentAmount = getModifier(modifier)
|
val currentAmount = getModifier(modifier)
|
||||||
if(currentAmount > 0) addModifier(modifier,-amount)
|
if (currentAmount > 0) addModifier(modifier, -amount)
|
||||||
else addModifier(modifier,amount)
|
else addModifier(modifier, amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun signDeclarationOfFriendship(){
|
fun signDeclarationOfFriendship() {
|
||||||
setModifier(DiplomaticModifiers.DeclarationOfFriendship,35f)
|
setModifier(DiplomaticModifiers.DeclarationOfFriendship, 35f)
|
||||||
otherCivDiplomacy().setModifier(DiplomaticModifiers.DeclarationOfFriendship,35f)
|
otherCivDiplomacy().setModifier(DiplomaticModifiers.DeclarationOfFriendship, 35f)
|
||||||
setFlag(DiplomacyFlags.DeclarationOfFriendship,30)
|
setFlag(DiplomacyFlags.DeclarationOfFriendship, 30)
|
||||||
otherCivDiplomacy().setFlag(DiplomacyFlags.DeclarationOfFriendship,30)
|
otherCivDiplomacy().setFlag(DiplomacyFlags.DeclarationOfFriendship, 30)
|
||||||
if (otherCiv().playerType == PlayerType.Human)
|
if (otherCiv().playerType == PlayerType.Human)
|
||||||
otherCiv().addNotification("[${civInfo.civName}] and [${otherCiv().civName}] have signed the Declaration of Friendship!", null, Color.WHITE)
|
otherCiv().addNotification("[${civInfo.civName}] and [${otherCiv().civName}] have signed the Declaration of Friendship!", null, Color.WHITE)
|
||||||
|
|
||||||
@ -613,10 +626,10 @@ class DiplomacyManager() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setFriendshipBasedModifier(){
|
fun setFriendshipBasedModifier() {
|
||||||
removeModifier(DiplomaticModifiers.DeclaredFriendshipWithOurAllies)
|
removeModifier(DiplomaticModifiers.DeclaredFriendshipWithOurAllies)
|
||||||
removeModifier(DiplomaticModifiers.DeclaredFriendshipWithOurEnemies)
|
removeModifier(DiplomaticModifiers.DeclaredFriendshipWithOurEnemies)
|
||||||
for(thirdCiv in getCommonKnownCivs()
|
for (thirdCiv in getCommonKnownCivs()
|
||||||
.filter { it.getDiplomacyManager(civInfo).hasFlag(DiplomacyFlags.DeclarationOfFriendship) }) {
|
.filter { it.getDiplomacyManager(civInfo).hasFlag(DiplomacyFlags.DeclarationOfFriendship) }) {
|
||||||
val otherCivRelationshipWithThirdCiv = otherCiv().getDiplomacyManager(thirdCiv).relationshipLevel()
|
val otherCivRelationshipWithThirdCiv = otherCiv().getDiplomacyManager(thirdCiv).relationshipLevel()
|
||||||
when (otherCivRelationshipWithThirdCiv) {
|
when (otherCivRelationshipWithThirdCiv) {
|
||||||
@ -628,11 +641,11 @@ class DiplomacyManager() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun denounce(){
|
fun denounce() {
|
||||||
setModifier(DiplomaticModifiers.Denunciation,-35f)
|
setModifier(DiplomaticModifiers.Denunciation, -35f)
|
||||||
otherCivDiplomacy().setModifier(DiplomaticModifiers.Denunciation,-35f)
|
otherCivDiplomacy().setModifier(DiplomaticModifiers.Denunciation, -35f)
|
||||||
setFlag(DiplomacyFlags.Denunceation,30)
|
setFlag(DiplomacyFlags.Denunceation, 30)
|
||||||
otherCivDiplomacy().setFlag(DiplomacyFlags.Denunceation,30)
|
otherCivDiplomacy().setFlag(DiplomacyFlags.Denunceation, 30)
|
||||||
|
|
||||||
otherCiv().addNotification("[${civInfo.civName}] has denounced us!", Color.RED)
|
otherCiv().addNotification("[${civInfo.civName}] has denounced us!", Color.RED)
|
||||||
|
|
||||||
@ -640,25 +653,25 @@ class DiplomacyManager() {
|
|||||||
getCommonKnownCivs().filter { it.isMajorCiv() }.forEach { thirdCiv ->
|
getCommonKnownCivs().filter { it.isMajorCiv() }.forEach { thirdCiv ->
|
||||||
thirdCiv.addNotification("[${civInfo.civName}] has denounced [${otherCiv().civName}]!", null, Color.RED)
|
thirdCiv.addNotification("[${civInfo.civName}] has denounced [${otherCiv().civName}]!", null, Color.RED)
|
||||||
val thirdCivRelationshipWithOtherCiv = thirdCiv.getDiplomacyManager(otherCiv()).relationshipLevel()
|
val thirdCivRelationshipWithOtherCiv = thirdCiv.getDiplomacyManager(otherCiv()).relationshipLevel()
|
||||||
when(thirdCivRelationshipWithOtherCiv){
|
when (thirdCivRelationshipWithOtherCiv) {
|
||||||
RelationshipLevel.Unforgivable -> addModifier(DiplomaticModifiers.DenouncedOurEnemies,15f)
|
RelationshipLevel.Unforgivable -> addModifier(DiplomaticModifiers.DenouncedOurEnemies, 15f)
|
||||||
RelationshipLevel.Enemy -> addModifier(DiplomaticModifiers.DenouncedOurEnemies,5f)
|
RelationshipLevel.Enemy -> addModifier(DiplomaticModifiers.DenouncedOurEnemies, 5f)
|
||||||
RelationshipLevel.Friend -> addModifier(DiplomaticModifiers.DenouncedOurAllies,-5f)
|
RelationshipLevel.Friend -> addModifier(DiplomaticModifiers.DenouncedOurAllies, -5f)
|
||||||
RelationshipLevel.Ally -> addModifier(DiplomaticModifiers.DenouncedOurAllies,-15f)
|
RelationshipLevel.Ally -> addModifier(DiplomaticModifiers.DenouncedOurAllies, -15f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun agreeNotToSettleNear(){
|
fun agreeNotToSettleNear() {
|
||||||
otherCivDiplomacy().setFlag(DiplomacyFlags.AgreedToNotSettleNearUs,100)
|
otherCivDiplomacy().setFlag(DiplomacyFlags.AgreedToNotSettleNearUs, 100)
|
||||||
addModifier(DiplomaticModifiers.UnacceptableDemands,-10f)
|
addModifier(DiplomaticModifiers.UnacceptableDemands, -10f)
|
||||||
otherCiv().addNotification("[${civInfo.civName}] agreed to stop settling cities near us!", Color.MAROON)
|
otherCiv().addNotification("[${civInfo.civName}] agreed to stop settling cities near us!", Color.MAROON)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun refuseDemandNotToSettleNear(){
|
fun refuseDemandNotToSettleNear() {
|
||||||
addModifier(DiplomaticModifiers.UnacceptableDemands,-20f)
|
addModifier(DiplomaticModifiers.UnacceptableDemands, -20f)
|
||||||
otherCivDiplomacy().setFlag(DiplomacyFlags.IgnoreThemSettlingNearUs,100)
|
otherCivDiplomacy().setFlag(DiplomacyFlags.IgnoreThemSettlingNearUs, 100)
|
||||||
otherCivDiplomacy().addModifier(DiplomaticModifiers.RefusedToNotSettleCitiesNearUs,-15f)
|
otherCivDiplomacy().addModifier(DiplomaticModifiers.RefusedToNotSettleCitiesNearUs, -15f)
|
||||||
otherCiv().addNotification("[${civInfo.civName}] refused to stop settling cities near us!", Color.MAROON)
|
otherCiv().addNotification("[${civInfo.civName}] refused to stop settling cities near us!", Color.MAROON)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import com.unciv.UncivGame
|
|||||||
import com.unciv.logic.automation.UnitAutomation
|
import com.unciv.logic.automation.UnitAutomation
|
||||||
import com.unciv.logic.automation.WorkerAutomation
|
import com.unciv.logic.automation.WorkerAutomation
|
||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
|
import com.unciv.logic.civilization.NotificationType
|
||||||
import com.unciv.models.ruleset.Ruleset
|
import com.unciv.models.ruleset.Ruleset
|
||||||
import com.unciv.models.ruleset.Unique
|
import com.unciv.models.ruleset.Unique
|
||||||
import com.unciv.models.ruleset.unit.BaseUnit
|
import com.unciv.models.ruleset.unit.BaseUnit
|
||||||
@ -615,7 +616,7 @@ class MapUnit {
|
|||||||
val city = civInfo.cities.random(tileBasedRandom)
|
val city = civInfo.cities.random(tileBasedRandom)
|
||||||
city.population.population++
|
city.population.population++
|
||||||
city.population.autoAssignPopulation()
|
city.population.autoAssignPopulation()
|
||||||
civInfo.addNotification("We have found survivors in the ruins - population added to [" + city.name + "]", tile.position, Color.GREEN)
|
civInfo.addNotification("We have found survivors in the ruins - population added to [" + city.name + "]", tile.position, NotificationType.Growth)
|
||||||
}
|
}
|
||||||
val researchableAncientEraTechs = tile.tileMap.gameInfo.ruleSet.technologies.values
|
val researchableAncientEraTechs = tile.tileMap.gameInfo.ruleSet.technologies.values
|
||||||
.filter {
|
.filter {
|
||||||
@ -627,7 +628,7 @@ class MapUnit {
|
|||||||
actions.add {
|
actions.add {
|
||||||
val tech = researchableAncientEraTechs.random(tileBasedRandom).name
|
val tech = researchableAncientEraTechs.random(tileBasedRandom).name
|
||||||
civInfo.tech.addTechnology(tech)
|
civInfo.tech.addTechnology(tech)
|
||||||
civInfo.addNotification("We have discovered the lost technology of [$tech] in the ruins!", tile.position, Color.BLUE)
|
civInfo.addNotification("We have discovered the lost technology of [$tech] in the ruins!", tile.position, NotificationType.Science)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -656,7 +657,7 @@ class MapUnit {
|
|||||||
|
|
||||||
actions.add {
|
actions.add {
|
||||||
civInfo.policies.addCulture(20)
|
civInfo.policies.addCulture(20)
|
||||||
civInfo.addNotification("We have discovered cultural artifacts in the ruins! (+20 Culture)", tile.position, Color.GOLD)
|
civInfo.addNotification("We have discovered cultural artifacts in the ruins! (+20 Culture)", tile.position, NotificationType.Culture)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map of the surrounding area
|
// Map of the surrounding area
|
||||||
|
@ -12,7 +12,7 @@ import kotlin.math.min
|
|||||||
|
|
||||||
class NotificationsScroll(internal val worldScreen: WorldScreen) : ScrollPane(null) {
|
class NotificationsScroll(internal val worldScreen: WorldScreen) : ScrollPane(null) {
|
||||||
|
|
||||||
var notificationsHash : Int = 0
|
var notificationsHash: Int = 0
|
||||||
|
|
||||||
private var notificationsTable = Table()
|
private var notificationsTable = Table()
|
||||||
|
|
||||||
@ -24,17 +24,19 @@ class NotificationsScroll(internal val worldScreen: WorldScreen) : ScrollPane(nu
|
|||||||
internal fun update(notifications: MutableList<Notification>) {
|
internal fun update(notifications: MutableList<Notification>) {
|
||||||
|
|
||||||
// no news? - keep our list as it is, especially don't reset scroll position
|
// no news? - keep our list as it is, especially don't reset scroll position
|
||||||
if(notificationsHash == notifications.hashCode())
|
if (notificationsHash == notifications.hashCode())
|
||||||
return
|
return
|
||||||
notificationsHash = notifications.hashCode()
|
notificationsHash = notifications.hashCode()
|
||||||
|
|
||||||
notificationsTable.clearChildren()
|
notificationsTable.clearChildren()
|
||||||
for (notification in notifications.toList().reversed()) { // toList to avoid concurrency problems
|
for (notification in notifications.toList().reversed()) { // toList to avoid concurrency problems
|
||||||
val label = notification.text.toLabel(Color.BLACK,30)
|
val label = notification.text.toLabel(Color.BLACK, 30)
|
||||||
val listItem = Table()
|
val listItem = Table()
|
||||||
|
|
||||||
listItem.add(ImageGetter.getCircle()
|
if (notification.notificationType != null)
|
||||||
.apply { color=notification.color }).size(20f).padRight(5f)
|
listItem.add(ImageGetter.getImage("NotificationIcons/" + notification.notificationType!!.name)).size(20f).padRight(5f)
|
||||||
|
else listItem.add(ImageGetter.getCircle()
|
||||||
|
.apply { color = notification.color }).size(20f).padRight(5f)
|
||||||
listItem.background = ImageGetter.getRoundedEdgeTableBackground().apply { setScale(0.5f) }
|
listItem.background = ImageGetter.getRoundedEdgeTableBackground().apply { setScale(0.5f) }
|
||||||
listItem.add(label)
|
listItem.add(label)
|
||||||
|
|
||||||
@ -52,7 +54,7 @@ class NotificationsScroll(internal val worldScreen: WorldScreen) : ScrollPane(nu
|
|||||||
}
|
}
|
||||||
notificationsTable.pack()
|
notificationsTable.pack()
|
||||||
pack()
|
pack()
|
||||||
height = min(notificationsTable.height,worldScreen.stage.height * 2 / 3 - 15f)
|
height = min(notificationsTable.height, worldScreen.stage.height * 2 / 3 - 15f)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|