mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-14 01:39:40 +07:00
chore: city settle action readability
This commit is contained in:
@ -66,24 +66,26 @@ object UnitActionsFromUniques {
|
|||||||
if (unit.civ.playerType == PlayerType.AI)
|
if (unit.civ.playerType == PlayerType.AI)
|
||||||
return UnitAction(UnitActionType.FoundCity, action = foundAction)
|
return UnitAction(UnitActionType.FoundCity, action = foundAction)
|
||||||
|
|
||||||
return UnitAction(
|
val title =
|
||||||
type = UnitActionType.FoundCity,
|
|
||||||
title =
|
|
||||||
if (hasActionModifiers) UnitActionModifiers.actionTextWithSideEffects(
|
if (hasActionModifiers) UnitActionModifiers.actionTextWithSideEffects(
|
||||||
UnitActionType.FoundCity.value,
|
UnitActionType.FoundCity.value,
|
||||||
unique,
|
unique,
|
||||||
unit
|
unit
|
||||||
)
|
)
|
||||||
else UnitActionType.FoundCity.value,
|
else UnitActionType.FoundCity.value
|
||||||
|
|
||||||
|
return UnitAction(
|
||||||
|
type = UnitActionType.FoundCity,
|
||||||
|
title = title,
|
||||||
uncivSound = UncivSound.Chimes,
|
uncivSound = UncivSound.Chimes,
|
||||||
action = {
|
action = {
|
||||||
// check if we would be breaking a promise
|
// check if we would be breaking a promise
|
||||||
val leaders = testPromiseNotToSettle(unit.civ, tile)
|
val leadersPromisedNotToSettleNear = getLeadersWePromisedNotToSettleNear(unit.civ, tile)
|
||||||
if (leaders == null)
|
if (leadersPromisedNotToSettleNear == null)
|
||||||
foundAction()
|
foundAction()
|
||||||
else {
|
else {
|
||||||
// ask if we would be breaking a promise
|
// ask if we would be breaking a promise
|
||||||
val text = "Do you want to break your promise to [$leaders]?"
|
val text = "Do you want to break your promise to [$leadersPromisedNotToSettleNear]?"
|
||||||
ConfirmPopup(
|
ConfirmPopup(
|
||||||
GUI.getWorldScreen(),
|
GUI.getWorldScreen(),
|
||||||
text,
|
text,
|
||||||
@ -101,18 +103,18 @@ object UnitActionsFromUniques {
|
|||||||
* @param tile The tile where the new city would go
|
* @param tile The tile where the new city would go
|
||||||
* @return null if no promises broken, else a String listing the leader(s) we would p* off.
|
* @return null if no promises broken, else a String listing the leader(s) we would p* off.
|
||||||
*/
|
*/
|
||||||
private fun testPromiseNotToSettle(civInfo: Civilization, tile: Tile): String? {
|
private fun getLeadersWePromisedNotToSettleNear(civInfo: Civilization, tile: Tile): String? {
|
||||||
val brokenPromises = HashSet<String>()
|
val leadersWePromisedNotToSettleNear = HashSet<String>()
|
||||||
for (otherCiv in civInfo.getKnownCivs().filter { it.isMajorCiv() && !civInfo.isAtWarWith(it) }) {
|
for (otherCiv in civInfo.getKnownCivs().filter { it.isMajorCiv() && !civInfo.isAtWarWith(it) }) {
|
||||||
val diplomacyManager = otherCiv.getDiplomacyManager(civInfo)
|
val diplomacyManager = otherCiv.getDiplomacyManager(civInfo)
|
||||||
if (diplomacyManager.hasFlag(DiplomacyFlags.AgreedToNotSettleNearUs)) {
|
if (diplomacyManager.hasFlag(DiplomacyFlags.AgreedToNotSettleNearUs)) {
|
||||||
val citiesWithin6Tiles = otherCiv.cities
|
val citiesWithin6Tiles = otherCiv.cities
|
||||||
.filter { it.getCenterTile().aerialDistanceTo(tile) <= 6 }
|
.filter { it.getCenterTile().aerialDistanceTo(tile) <= 6 }
|
||||||
.filter { otherCiv.hasExplored(it.getCenterTile()) }
|
.filter { otherCiv.hasExplored(it.getCenterTile()) }
|
||||||
if (citiesWithin6Tiles.isNotEmpty()) brokenPromises += otherCiv.getLeaderDisplayName()
|
if (citiesWithin6Tiles.isNotEmpty()) leadersWePromisedNotToSettleNear += otherCiv.getLeaderDisplayName()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return if(brokenPromises.isEmpty()) null else brokenPromises.joinToString(", ")
|
return if(leadersWePromisedNotToSettleNear.isEmpty()) null else leadersWePromisedNotToSettleNear.joinToString(", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getSetupActions(unit: MapUnit, tile: Tile): List<UnitAction> {
|
fun getSetupActions(unit: MapUnit, tile: Tile): List<UnitAction> {
|
||||||
|
Reference in New Issue
Block a user