From 9dd38f5d08dc390cf14a1c0391e3112d18af3411 Mon Sep 17 00:00:00 2001 From: Emandac <121508218+Emandac@users.noreply.github.com> Date: Tue, 22 Oct 2024 21:27:28 +0200 Subject: [PATCH 01/19] Settler settle best tile when not escort and dangerous Tiles instead of running away Settler unit will now settle on best tile in dangerous Tiles without escort instead of running away. --- .../logic/automation/unit/SpecificUnitAutomation.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/src/com/unciv/logic/automation/unit/SpecificUnitAutomation.kt b/core/src/com/unciv/logic/automation/unit/SpecificUnitAutomation.kt index 20241c0cbf9aa..da1c6ac410070 100644 --- a/core/src/com/unciv/logic/automation/unit/SpecificUnitAutomation.kt +++ b/core/src/com/unciv/logic/automation/unit/SpecificUnitAutomation.kt @@ -192,6 +192,16 @@ object SpecificUnitAutomation { } unit.movement.headTowards(bestCityLocation) + + // This if setement is to check if settler is on the bast tile and has no escort unit and its in a dangerous Tiles and can still move. + // then settle there + if (bestTilesInfo.tileRankMap.containsKey(unit.getTile()) && unit.getOtherEscortUnit() == null && dangerousTiles.contains(unit.getTile()) + && unit.hasMovement()) { + foundCityAction.action.invoke() + return + } + + if (unit.getTile() == bestCityLocation && unit.hasMovement()) foundCityAction.action.invoke() } From 919a08269e94f1ca34d01b7692d0c0c94d660510 Mon Sep 17 00:00:00 2001 From: Emandac <121508218+Emandac@users.noreply.github.com> Date: Wed, 30 Oct 2024 19:43:47 +0100 Subject: [PATCH 02/19] Update WorkerAutomation.kt --- .../com/unciv/logic/automation/unit/WorkerAutomation.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt b/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt index dfb125254efd7..ec042aecca01a 100644 --- a/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt +++ b/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt @@ -232,7 +232,7 @@ class WorkerAutomation( if (!tile.hasViewableResource(civInfo) && tile.getTilesInDistance(civInfo.gameInfo.ruleset.modOptions.constants.cityWorkRange) .none { it.isCityCenter() && it.getCity()?.civ == civInfo } ) return false - if (tile.getTileImprovement()?.hasUnique(UniqueType.AutomatedUnitsWillNotReplace) == true) return false + if (tile.getTileImprovement()?.hasUnique(UniqueType.AutomatedUnitsWillNotReplace) == true && !tile.isPillaged()) return false return true } @@ -248,6 +248,7 @@ class WorkerAutomation( var priority = 0f if (tile.getOwner() == civInfo) { priority += Automation.rankStatsValue(tile.stats.getTerrainStatsBreakdown().toStats(), civInfo) + if (tile.providesYield()) priority += 2 if (tile.isPillaged()) priority += 1 if (tile.hasFalloutEquivalent()) priority += 1 @@ -270,8 +271,6 @@ class WorkerAutomation( tileRankings[tile] = TileImprovementRank(priority) return priority + unitSpecificPriority } - - /** * Calculates the priority building the improvement on the tile */ @@ -296,6 +295,7 @@ class WorkerAutomation( if (tile.improvement != null && tile.isPillaged() && tile.owningCity != null) { // Value repairing higher when it is quicker and is in progress + var repairBonusPriority = tile.getImprovementToRepair()!!.getTurnsToBuild(unit.civ,unit) - UnitActionsFromUniques.getRepairTurns(unit) if (tile.improvementInProgress == Constants.repair) repairBonusPriority += UnitActionsFromUniques.getRepairTurns(unit) - tile.turnsToImprovement @@ -307,6 +307,7 @@ class WorkerAutomation( } } } + // A better tile than this unit can build might have been stored in the cache if (!rank.repairImprovment!! && (rank.bestImprovement == null || !unit.canBuildImprovement(rank.bestImprovement!!, tile))) return -100f From ed21943b2c9285b415164529d309ad87c5274793 Mon Sep 17 00:00:00 2001 From: Emandac <121508218+Emandac@users.noreply.github.com> Date: Wed, 30 Oct 2024 20:29:08 +0100 Subject: [PATCH 03/19] Update SpecificUnitAutomation.kt --- .../logic/automation/unit/SpecificUnitAutomation.kt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/core/src/com/unciv/logic/automation/unit/SpecificUnitAutomation.kt b/core/src/com/unciv/logic/automation/unit/SpecificUnitAutomation.kt index da1c6ac410070..f399c90116137 100644 --- a/core/src/com/unciv/logic/automation/unit/SpecificUnitAutomation.kt +++ b/core/src/com/unciv/logic/automation/unit/SpecificUnitAutomation.kt @@ -190,18 +190,8 @@ object SpecificUnitAutomation { throw Exception("City within distance") return } - unit.movement.headTowards(bestCityLocation) - // This if setement is to check if settler is on the bast tile and has no escort unit and its in a dangerous Tiles and can still move. - // then settle there - if (bestTilesInfo.tileRankMap.containsKey(unit.getTile()) && unit.getOtherEscortUnit() == null && dangerousTiles.contains(unit.getTile()) - && unit.hasMovement()) { - foundCityAction.action.invoke() - return - } - - if (unit.getTile() == bestCityLocation && unit.hasMovement()) foundCityAction.action.invoke() } From b9a832a1ed94dfdcc26f3215ee43275bedf4815f Mon Sep 17 00:00:00 2001 From: General_E <121508218+Emandac@users.noreply.github.com> Date: Wed, 30 Oct 2024 20:32:22 +0100 Subject: [PATCH 04/19] Update WorkerAutomation.kt --- core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt b/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt index ec042aecca01a..efa4befd77288 100644 --- a/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt +++ b/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt @@ -248,7 +248,6 @@ class WorkerAutomation( var priority = 0f if (tile.getOwner() == civInfo) { priority += Automation.rankStatsValue(tile.stats.getTerrainStatsBreakdown().toStats(), civInfo) - if (tile.providesYield()) priority += 2 if (tile.isPillaged()) priority += 1 if (tile.hasFalloutEquivalent()) priority += 1 @@ -295,7 +294,6 @@ class WorkerAutomation( if (tile.improvement != null && tile.isPillaged() && tile.owningCity != null) { // Value repairing higher when it is quicker and is in progress - var repairBonusPriority = tile.getImprovementToRepair()!!.getTurnsToBuild(unit.civ,unit) - UnitActionsFromUniques.getRepairTurns(unit) if (tile.improvementInProgress == Constants.repair) repairBonusPriority += UnitActionsFromUniques.getRepairTurns(unit) - tile.turnsToImprovement @@ -307,7 +305,6 @@ class WorkerAutomation( } } } - // A better tile than this unit can build might have been stored in the cache if (!rank.repairImprovment!! && (rank.bestImprovement == null || !unit.canBuildImprovement(rank.bestImprovement!!, tile))) return -100f From 5edf4b7c911ba663b95ca6793c1804ffbcef7349 Mon Sep 17 00:00:00 2001 From: General_E <121508218+Emandac@users.noreply.github.com> Date: Wed, 30 Oct 2024 20:33:25 +0100 Subject: [PATCH 05/19] Update SpecificUnitAutomation.kt --- .../com/unciv/logic/automation/unit/SpecificUnitAutomation.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/com/unciv/logic/automation/unit/SpecificUnitAutomation.kt b/core/src/com/unciv/logic/automation/unit/SpecificUnitAutomation.kt index f399c90116137..9104fe1be8d27 100644 --- a/core/src/com/unciv/logic/automation/unit/SpecificUnitAutomation.kt +++ b/core/src/com/unciv/logic/automation/unit/SpecificUnitAutomation.kt @@ -191,7 +191,6 @@ object SpecificUnitAutomation { return } unit.movement.headTowards(bestCityLocation) - if (unit.getTile() == bestCityLocation && unit.hasMovement()) foundCityAction.action.invoke() } From aaabab0dcf2e023d294b882fc30cdb040f15eaa9 Mon Sep 17 00:00:00 2001 From: Emandac <121508218+Emandac@users.noreply.github.com> Date: Mon, 30 Dec 2024 23:40:50 +0100 Subject: [PATCH 06/19] Now city states get mad when you steal their Lands --- core/src/com/unciv/logic/civilization/PopupAlert.kt | 1 + .../civilization/diplomacy/CityStateFunctions.kt | 11 +++++++++++ .../logic/civilization/diplomacy/DiplomacyManager.kt | 1 + .../com/unciv/ui/screens/worldscreen/AlertPopup.kt | 9 +++++++++ 4 files changed, 22 insertions(+) diff --git a/core/src/com/unciv/logic/civilization/PopupAlert.kt b/core/src/com/unciv/logic/civilization/PopupAlert.kt index 86ccefc16e2fd..18bddc61ba17d 100644 --- a/core/src/com/unciv/logic/civilization/PopupAlert.kt +++ b/core/src/com/unciv/logic/civilization/PopupAlert.kt @@ -11,6 +11,7 @@ enum class AlertType : IsPartOfGameInfoSerialization { CityConquered, CityTraded, BorderConflict, + BorderOccupation, DemandToStopSettlingCitiesNear, CitySettledNearOtherCivDespiteOurPromise, diff --git a/core/src/com/unciv/logic/civilization/diplomacy/CityStateFunctions.kt b/core/src/com/unciv/logic/civilization/diplomacy/CityStateFunctions.kt index 1c97c9fbe6862..691fa4f42268a 100644 --- a/core/src/com/unciv/logic/civilization/diplomacy/CityStateFunctions.kt +++ b/core/src/com/unciv/logic/civilization/diplomacy/CityStateFunctions.kt @@ -540,6 +540,17 @@ class CityStateFunctions(val civInfo: Civilization) { diplomacy.setFlag(DiplomacyFlags.BorderConflict, 10) } } + + // If citystate gets tile stolen from another civ, then the civ gets a diplomacy Influence debuffer. + if (diplomacy.hasModifier(DiplomaticModifiers.StealingTerritory) && diplomacy.isRelationshipLevelLT(RelationshipLevel.Friend)) { + diplomacy.addInfluence(-25f) + if (!diplomacy.hasFlag(DiplomacyFlags.BorderOccupation)) { + otherCiv.popupAlerts.add(PopupAlert(AlertType.BorderOccupation, civInfo.civName)) + + // to only show popup once. + diplomacy.setFlag(DiplomacyFlags.BorderOccupation, -1) + } + } } } diff --git a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt index 2b1b4c04b8b9c..0cb06977023f0 100644 --- a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt +++ b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt @@ -52,6 +52,7 @@ enum class DiplomacyFlags { DeclinedJoinWarOffer, ResearchAgreement, BorderConflict, + BorderOccupation, SettledCitiesNearUs, AgreedToNotSettleNearUs, diff --git a/core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt b/core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt index ac60c032b259f..8826c222850eb 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt @@ -91,6 +91,7 @@ class AlertPopup( AlertType.CityConquered -> addCityConquered() AlertType.CityTraded -> addCityTraded() AlertType.BorderConflict -> addBorderConflict() + AlertType.BorderOccupation -> addBorderOccupation() AlertType.DemandToStopSettlingCitiesNear -> addDemandToStopSettlingCitiesNear() AlertType.CitySettledNearOtherCivDespiteOurPromise -> addCitySettledNearOtherCivDespiteOurPromise() AlertType.DemandToStopSpreadingReligion -> addDemandToStopSpreadingReligion() @@ -118,6 +119,14 @@ class AlertPopup( addCloseButton("Sorry.", KeyboardBinding.Confirm) addCloseButton("Never!", KeyboardBinding.Cancel) } + + private fun addBorderOccupation() { + val civInfo = getCiv(popupAlert.value) + addLeaderName(civInfo) + addGoodSizedLabel("You are occupying our territory!") + addCloseButton("Yes.", KeyboardBinding.Confirm) + addCloseButton("No.", KeyboardBinding.Cancel) + } private fun addBulliedOrAttackedProtectedOrAlliedMinor() { val involvedCivs = popupAlert.value.split('@') From cb96cff37015fc981c7e80a8078ba89c07368412 Mon Sep 17 00:00:00 2001 From: Emandac <121508218+Emandac@users.noreply.github.com> Date: Tue, 31 Dec 2024 12:01:58 +0100 Subject: [PATCH 07/19] new version --- core/src/com/unciv/logic/civilization/PopupAlert.kt | 2 +- .../civilization/diplomacy/CityStateFunctions.kt | 11 ----------- .../logic/civilization/diplomacy/DiplomacyManager.kt | 2 +- .../models/ruleset/unique/UniqueTriggerActivation.kt | 11 +++++++++++ .../com/unciv/ui/screens/worldscreen/AlertPopup.kt | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/core/src/com/unciv/logic/civilization/PopupAlert.kt b/core/src/com/unciv/logic/civilization/PopupAlert.kt index 18bddc61ba17d..787d691327b74 100644 --- a/core/src/com/unciv/logic/civilization/PopupAlert.kt +++ b/core/src/com/unciv/logic/civilization/PopupAlert.kt @@ -11,7 +11,7 @@ enum class AlertType : IsPartOfGameInfoSerialization { CityConquered, CityTraded, BorderConflict, - BorderOccupation, + TilesStolen, DemandToStopSettlingCitiesNear, CitySettledNearOtherCivDespiteOurPromise, diff --git a/core/src/com/unciv/logic/civilization/diplomacy/CityStateFunctions.kt b/core/src/com/unciv/logic/civilization/diplomacy/CityStateFunctions.kt index 691fa4f42268a..1c97c9fbe6862 100644 --- a/core/src/com/unciv/logic/civilization/diplomacy/CityStateFunctions.kt +++ b/core/src/com/unciv/logic/civilization/diplomacy/CityStateFunctions.kt @@ -540,17 +540,6 @@ class CityStateFunctions(val civInfo: Civilization) { diplomacy.setFlag(DiplomacyFlags.BorderConflict, 10) } } - - // If citystate gets tile stolen from another civ, then the civ gets a diplomacy Influence debuffer. - if (diplomacy.hasModifier(DiplomaticModifiers.StealingTerritory) && diplomacy.isRelationshipLevelLT(RelationshipLevel.Friend)) { - diplomacy.addInfluence(-25f) - if (!diplomacy.hasFlag(DiplomacyFlags.BorderOccupation)) { - otherCiv.popupAlerts.add(PopupAlert(AlertType.BorderOccupation, civInfo.civName)) - - // to only show popup once. - diplomacy.setFlag(DiplomacyFlags.BorderOccupation, -1) - } - } } } diff --git a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt index 0cb06977023f0..2349e23958cf8 100644 --- a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt +++ b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt @@ -52,7 +52,7 @@ enum class DiplomacyFlags { DeclinedJoinWarOffer, ResearchAgreement, BorderConflict, - BorderOccupation, + TilesStolen, SettledCitiesNearUs, AgreedToNotSettleNearUs, diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt b/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt index 22f86e8fe1498..fe048ce67bd7c 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt @@ -16,6 +16,7 @@ import com.unciv.logic.civilization.NotificationIcon import com.unciv.logic.civilization.PolicyAction import com.unciv.logic.civilization.PopupAlert import com.unciv.logic.civilization.TechAction +import com.unciv.logic.civilization.diplomacy.DiplomacyFlags import com.unciv.logic.civilization.diplomacy.DiplomaticModifiers import com.unciv.logic.civilization.managers.ReligionState import com.unciv.logic.map.mapgenerator.NaturalWonderGenerator @@ -1107,6 +1108,16 @@ object UniqueTriggerActivation { otherCiv.getDiplomacyManagerOrMeet(civInfo).addModifier(DiplomaticModifiers.StealingTerritory, -10f) civsToNotify.add(otherCiv) } + // check if civ has steal a tile from a citystate + if (otherCiv != null && otherCiv.isCityState) { + // create this varibale diplomacyCityState for more readability + val diplomacyCityState = otherCiv.getDiplomacyManager(civInfo)!! + diplomacyCityState.addInfluence(-15f) + + if (!diplomacyCityState.hasFlag(DiplomacyFlags.TilesStolen)) { + civInfo.popupAlerts.add(PopupAlert(AlertType.TilesStolen, otherCiv.civName)) + } + } cityToAddTo.expansion.takeOwnership(tileToTakeOver) } diff --git a/core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt b/core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt index 8826c222850eb..543d5487a50ce 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt @@ -91,7 +91,7 @@ class AlertPopup( AlertType.CityConquered -> addCityConquered() AlertType.CityTraded -> addCityTraded() AlertType.BorderConflict -> addBorderConflict() - AlertType.BorderOccupation -> addBorderOccupation() + AlertType.TilesStolen -> addTilesStolen() AlertType.DemandToStopSettlingCitiesNear -> addDemandToStopSettlingCitiesNear() AlertType.CitySettledNearOtherCivDespiteOurPromise -> addCitySettledNearOtherCivDespiteOurPromise() AlertType.DemandToStopSpreadingReligion -> addDemandToStopSpreadingReligion() @@ -120,10 +120,10 @@ class AlertPopup( addCloseButton("Never!", KeyboardBinding.Cancel) } - private fun addBorderOccupation() { + private fun addTilesStolen() { val civInfo = getCiv(popupAlert.value) addLeaderName(civInfo) - addGoodSizedLabel("You are occupying our territory!") + addGoodSizedLabel("You stole some of our territory!") addCloseButton("Yes.", KeyboardBinding.Confirm) addCloseButton("No.", KeyboardBinding.Cancel) } From e400964ef185cc023e88b35f9e29a52f5a84b7b9 Mon Sep 17 00:00:00 2001 From: Emandac <121508218+Emandac@users.noreply.github.com> Date: Tue, 31 Dec 2024 13:41:10 +0100 Subject: [PATCH 08/19] change to getDiplomacyManagerOrMeet --- .../com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt b/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt index fe048ce67bd7c..a33748ce375ae 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt @@ -1111,7 +1111,7 @@ object UniqueTriggerActivation { // check if civ has steal a tile from a citystate if (otherCiv != null && otherCiv.isCityState) { // create this varibale diplomacyCityState for more readability - val diplomacyCityState = otherCiv.getDiplomacyManager(civInfo)!! + val diplomacyCityState = otherCiv.getDiplomacyManagerOrMeet(civInfo) diplomacyCityState.addInfluence(-15f) if (!diplomacyCityState.hasFlag(DiplomacyFlags.TilesStolen)) { From 61f90fac4a460969105b414139eca5332e1f1f54 Mon Sep 17 00:00:00 2001 From: Emandac <121508218+Emandac@users.noreply.github.com> Date: Tue, 31 Dec 2024 13:55:17 +0100 Subject: [PATCH 09/19] added text to template.properties and changed AlertPopup.kt --- android/assets/jsons/translations/template.properties | 3 ++- core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index d451fb0053465..ebaca7579d40c 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -1597,7 +1597,8 @@ Destroying the city instantly razes the city to the ground. = Keep it = Remove your troops in our border immediately! = Sorry. = -Never! = +Never! = +Those lands were not yours to take. This has not gone unnoticed = Offer Declaration of Friendship ([30] turns) = My friend, shall we declare our friendship to the world? = diff --git a/core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt b/core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt index 543d5487a50ce..288bec727cb39 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt @@ -123,9 +123,8 @@ class AlertPopup( private fun addTilesStolen() { val civInfo = getCiv(popupAlert.value) addLeaderName(civInfo) - addGoodSizedLabel("You stole some of our territory!") - addCloseButton("Yes.", KeyboardBinding.Confirm) - addCloseButton("No.", KeyboardBinding.Cancel) + addGoodSizedLabel("Those lands were not yours to take. This has not gone unnoticed") + addCloseButton() } private fun addBulliedOrAttackedProtectedOrAlliedMinor() { From ff67bb76ec5183d7cca3d63accd277bf2e107e50 Mon Sep 17 00:00:00 2001 From: Emandac <121508218+Emandac@users.noreply.github.com> Date: Tue, 31 Dec 2024 14:07:13 +0100 Subject: [PATCH 10/19] Update template.properties --- android/assets/jsons/translations/template.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index ebaca7579d40c..fd1a9c205419a 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -1597,7 +1597,7 @@ Destroying the city instantly razes the city to the ground. = Keep it = Remove your troops in our border immediately! = Sorry. = -Never! = +Never! = Those lands were not yours to take. This has not gone unnoticed = Offer Declaration of Friendship ([30] turns) = From 467e7257c7112d718c259836466666e11f561e6f Mon Sep 17 00:00:00 2001 From: Emandac <121508218+Emandac@users.noreply.github.com> Date: Tue, 31 Dec 2024 14:51:13 +0100 Subject: [PATCH 11/19] with period at the end :b --- android/assets/jsons/translations/template.properties | 2 +- core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index fd1a9c205419a..1b6fa4cd492a9 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -1598,7 +1598,7 @@ Keep it = Remove your troops in our border immediately! = Sorry. = Never! = -Those lands were not yours to take. This has not gone unnoticed = +Those lands were not yours to take. This has not gone unnoticed. = Offer Declaration of Friendship ([30] turns) = My friend, shall we declare our friendship to the world? = diff --git a/core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt b/core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt index 288bec727cb39..9f4eb12b45600 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt @@ -123,7 +123,7 @@ class AlertPopup( private fun addTilesStolen() { val civInfo = getCiv(popupAlert.value) addLeaderName(civInfo) - addGoodSizedLabel("Those lands were not yours to take. This has not gone unnoticed") + addGoodSizedLabel("Those lands were not yours to take. This has not gone unnoticed.") addCloseButton() } From aa532e944dd7c13ebf73090e1648f0e5a5ed14b1 Mon Sep 17 00:00:00 2001 From: Emandac <121508218+Emandac@users.noreply.github.com> Date: Wed, 1 Jan 2025 14:28:34 +0100 Subject: [PATCH 12/19] add flag now --- .../com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt b/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt index a33748ce375ae..f7e67c0108663 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt @@ -1114,8 +1114,11 @@ object UniqueTriggerActivation { val diplomacyCityState = otherCiv.getDiplomacyManagerOrMeet(civInfo) diplomacyCityState.addInfluence(-15f) + + if (!diplomacyCityState.hasFlag(DiplomacyFlags.TilesStolen)) { civInfo.popupAlerts.add(PopupAlert(AlertType.TilesStolen, otherCiv.civName)) + diplomacyCityState.setFlag(DiplomacyFlags.TilesStolen, 1) } } cityToAddTo.expansion.takeOwnership(tileToTakeOver) From b300c51772cbe9c31a7daae569dd91bb51a1f5af Mon Sep 17 00:00:00 2001 From: Emandac <121508218+Emandac@users.noreply.github.com> Date: Thu, 2 Jan 2025 23:25:52 +0100 Subject: [PATCH 13/19] Made Option to declare war when a city state is bullied unavailable --- core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt b/core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt index 9f4eb12b45600..edbb7da80e52e 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/AlertPopup.kt @@ -146,13 +146,14 @@ class AlertPopup( "I thought you might like to know that I've launched an invasion of one of your little pet states.\nThe lands of [${cityState.civName}] will make a fine addition to my own." } addGoodSizedLabel(text).row() - - addCloseButton("THIS MEANS WAR!", KeyboardBinding.Confirm) { + + if (!player.isAtWarWith(bullyOrAttacker)) { + addCloseButton("THIS MEANS WAR!", KeyboardBinding.Confirm) { player.getDiplomacyManager(bullyOrAttacker)!!.sideWithCityState() val warReason = if (popupAlert.type == AlertType.AttackedAllyMinor) WarType.AlliedCityStateWar else WarType.ProtectedCityStateWar player.getDiplomacyManager(bullyOrAttacker)!!.declareWar(DeclareWarReason(warReason, cityState)) cityState.getDiplomacyManager(player)!!.influence += 20f // You went to war for us!! - }.row() + }.row()} addCloseButton("You'll pay for this!", KeyboardBinding.Confirm) { player.getDiplomacyManager(bullyOrAttacker)!!.sideWithCityState() From 1623290ad6384b76759aa2e26dbf901c015e486e Mon Sep 17 00:00:00 2001 From: Emandac <121508218+Emandac@users.noreply.github.com> Date: Sat, 11 Jan 2025 18:46:46 +0100 Subject: [PATCH 14/19] added option to change the Maximum Autosave turns stored --- .../jsons/translations/template.properties | 1 + core/src/com/unciv/logic/files/UncivFiles.kt | 6 +++++- .../com/unciv/models/metadata/GameSettings.kt | 1 + .../unciv/ui/popups/options/AdvancedTab.kt | 19 +++++++++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index 2755282893cce..9cf0c4f13f7de 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -887,6 +887,7 @@ Could not download music! = ## Advanced tab Advanced = Turns between autosaves = +Maximum Autosave turns stored = Screen orientation = Landscape (fixed) = diff --git a/core/src/com/unciv/logic/files/UncivFiles.kt b/core/src/com/unciv/logic/files/UncivFiles.kt index 7d92fe1449592..9e7ac5f1e7a16 100644 --- a/core/src/com/unciv/logic/files/UncivFiles.kt +++ b/core/src/com/unciv/logic/files/UncivFiles.kt @@ -469,6 +469,9 @@ class Autosaves(val files: UncivFiles) { } fun autoSave(gameInfo: GameInfo, nextTurn: Boolean = false) { + // get GameSettings to check the maxAutosavesStored in the autoSave function + val settings = files.getGeneralSettings() + try { files.saveGame(gameInfo, AUTOSAVE_FILE_NAME) } catch (oom: OutOfMemoryError) { @@ -486,7 +489,8 @@ class Autosaves(val files: UncivFiles) { fun getAutosaves(): Sequence { return files.getSaves().filter { it.name().startsWith(AUTOSAVE_FILE_NAME) } } - while (getAutosaves().count() > 10) { + // added the plus 1 to avoid player choosing 6,11,21,51,101, etc.. in options. + while (getAutosaves().count() > settings.maxAutosavesStored+1) { val saveToDelete = getAutosaves().minByOrNull { it.lastModified() }!! files.deleteSave(saveToDelete.name()) } diff --git a/core/src/com/unciv/models/metadata/GameSettings.kt b/core/src/com/unciv/models/metadata/GameSettings.kt index 8a817ede95aa8..e0dc830091ad2 100644 --- a/core/src/com/unciv/models/metadata/GameSettings.kt +++ b/core/src/com/unciv/models/metadata/GameSettings.kt @@ -56,6 +56,7 @@ class GameSettings { var pauseBetweenTracks = 10 var turnsBetweenAutosaves = 1 + var maxAutosavesStored = 10 var tileSet: String = Constants.defaultTileset var unitSet: String? = Constants.defaultUnitset var skin: String = Constants.defaultSkin diff --git a/core/src/com/unciv/ui/popups/options/AdvancedTab.kt b/core/src/com/unciv/ui/popups/options/AdvancedTab.kt index a8704104feabb..3a8d9f7df9e94 100644 --- a/core/src/com/unciv/ui/popups/options/AdvancedTab.kt +++ b/core/src/com/unciv/ui/popups/options/AdvancedTab.kt @@ -51,6 +51,8 @@ class AdvancedTab( init { pad(10f) defaults().pad(5f) + + addmaxAutosavesStored() addAutosaveTurnsSelectBox() addSeparator() @@ -92,6 +94,23 @@ class AdvancedTab( optionsPopup.reopenAfterDisplayLayoutChange() } } + + private fun addmaxAutosavesStored() { + add("Maximum Autosave turns stored".toLabel()).left().fillX() + + val maxAutosavesStoredSelectBox = SelectBox(skin) + val maxAutosavesStoredArray = Array() + maxAutosavesStoredArray.addAll(1,2,5,10,15,20,35,50,100,150,200,250,500,1000) + maxAutosavesStoredSelectBox.items = maxAutosavesStoredArray + maxAutosavesStoredSelectBox.selected = settings.maxAutosavesStored + + add(maxAutosavesStoredSelectBox).pad(10f).row() + + maxAutosavesStoredSelectBox.onChange { + settings.maxAutosavesStored = maxAutosavesStoredSelectBox.selected + println(settings.maxAutosavesStored) + } + } private fun addAutosaveTurnsSelectBox() { From 4edcd248e7aa6fd8b4771aab3cc3a6c8e2a1a788 Mon Sep 17 00:00:00 2001 From: Emandac <121508218+Emandac@users.noreply.github.com> Date: Sat, 11 Jan 2025 18:51:58 +0100 Subject: [PATCH 15/19] remove print --- core/src/com/unciv/ui/popups/options/AdvancedTab.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/com/unciv/ui/popups/options/AdvancedTab.kt b/core/src/com/unciv/ui/popups/options/AdvancedTab.kt index 3a8d9f7df9e94..592c113ee7c4c 100644 --- a/core/src/com/unciv/ui/popups/options/AdvancedTab.kt +++ b/core/src/com/unciv/ui/popups/options/AdvancedTab.kt @@ -108,7 +108,6 @@ class AdvancedTab( maxAutosavesStoredSelectBox.onChange { settings.maxAutosavesStored = maxAutosavesStoredSelectBox.selected - println(settings.maxAutosavesStored) } } From 0d5295e9f43a3b95332783c1b9dfc1caa805bd84 Mon Sep 17 00:00:00 2001 From: Emandac <121508218+Emandac@users.noreply.github.com> Date: Sat, 11 Jan 2025 19:10:39 +0100 Subject: [PATCH 16/19] change letter --- android/assets/jsons/translations/template.properties | 2 +- core/src/com/unciv/ui/popups/options/AdvancedTab.kt | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index 9cf0c4f13f7de..e440236d6666b 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -887,7 +887,7 @@ Could not download music! = ## Advanced tab Advanced = Turns between autosaves = -Maximum Autosave turns stored = +Maximum autosave turns stored = Screen orientation = Landscape (fixed) = diff --git a/core/src/com/unciv/ui/popups/options/AdvancedTab.kt b/core/src/com/unciv/ui/popups/options/AdvancedTab.kt index 592c113ee7c4c..a471ffc88543f 100644 --- a/core/src/com/unciv/ui/popups/options/AdvancedTab.kt +++ b/core/src/com/unciv/ui/popups/options/AdvancedTab.kt @@ -96,7 +96,7 @@ class AdvancedTab( } private fun addmaxAutosavesStored() { - add("Maximum Autosave turns stored".toLabel()).left().fillX() + add("Maximum autosave turns stored".toLabel()).left().fillX() val maxAutosavesStoredSelectBox = SelectBox(skin) val maxAutosavesStoredArray = Array() @@ -111,7 +111,6 @@ class AdvancedTab( } } - private fun addAutosaveTurnsSelectBox() { add("Turns between autosaves".toLabel()).left().fillX() From 1599dd2864db7c0856012cfd48da40bdf931c57b Mon Sep 17 00:00:00 2001 From: Emandac <121508218+Emandac@users.noreply.github.com> Date: Sat, 11 Jan 2025 19:32:01 +0100 Subject: [PATCH 17/19] should fix issue with building test --- android/assets/jsons/translations/template.properties | 3 ++- core/src/com/unciv/ui/popups/options/AdvancedTab.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index e440236d6666b..69977e8e3ab4f 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -886,8 +886,9 @@ Could not download music! = ## Advanced tab Advanced = -Turns between autosaves = Maximum autosave turns stored = +Turns between autosaves = + Screen orientation = Landscape (fixed) = diff --git a/core/src/com/unciv/ui/popups/options/AdvancedTab.kt b/core/src/com/unciv/ui/popups/options/AdvancedTab.kt index a471ffc88543f..57b57f785ba78 100644 --- a/core/src/com/unciv/ui/popups/options/AdvancedTab.kt +++ b/core/src/com/unciv/ui/popups/options/AdvancedTab.kt @@ -100,7 +100,7 @@ class AdvancedTab( val maxAutosavesStoredSelectBox = SelectBox(skin) val maxAutosavesStoredArray = Array() - maxAutosavesStoredArray.addAll(1,2,5,10,15,20,35,50,100,150,200,250,500,1000) + maxAutosavesStoredArray.addAll(1,2,5,10,15,20,35,50,100,150,200,250) maxAutosavesStoredSelectBox.items = maxAutosavesStoredArray maxAutosavesStoredSelectBox.selected = settings.maxAutosavesStored From eab98f29cf260ae0f7df79e07eb45b05d7110fe9 Mon Sep 17 00:00:00 2001 From: Emandac <121508218+Emandac@users.noreply.github.com> Date: Sat, 11 Jan 2025 20:45:53 +0100 Subject: [PATCH 18/19] update with changes --- android/assets/jsons/translations/template.properties | 2 +- core/src/com/unciv/logic/files/UncivFiles.kt | 3 +++ core/src/com/unciv/ui/popups/options/AdvancedTab.kt | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index 69977e8e3ab4f..bfe4a1283af07 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -886,7 +886,7 @@ Could not download music! = ## Advanced tab Advanced = -Maximum autosave turns stored = +Number of autosave files stored = Turns between autosaves = diff --git a/core/src/com/unciv/logic/files/UncivFiles.kt b/core/src/com/unciv/logic/files/UncivFiles.kt index 9e7ac5f1e7a16..11b04e8677bb7 100644 --- a/core/src/com/unciv/logic/files/UncivFiles.kt +++ b/core/src/com/unciv/logic/files/UncivFiles.kt @@ -490,6 +490,9 @@ class Autosaves(val files: UncivFiles) { return files.getSaves().filter { it.name().startsWith(AUTOSAVE_FILE_NAME) } } // added the plus 1 to avoid player choosing 6,11,21,51,101, etc.. in options. +// // with the old version with 10 has example, it would start overriding after 9 instead of 10. + // like from autosave-1 to autosave-9 after the autosave-9 the autosave-1 would override to autosave-2. + // For me it should be after autosave-10 that it should start overriding old autosaves. while (getAutosaves().count() > settings.maxAutosavesStored+1) { val saveToDelete = getAutosaves().minByOrNull { it.lastModified() }!! files.deleteSave(saveToDelete.name()) diff --git a/core/src/com/unciv/ui/popups/options/AdvancedTab.kt b/core/src/com/unciv/ui/popups/options/AdvancedTab.kt index 57b57f785ba78..ef416ca0cce13 100644 --- a/core/src/com/unciv/ui/popups/options/AdvancedTab.kt +++ b/core/src/com/unciv/ui/popups/options/AdvancedTab.kt @@ -52,7 +52,7 @@ class AdvancedTab( pad(10f) defaults().pad(5f) - addmaxAutosavesStored() + addMaxAutosavesStored() addAutosaveTurnsSelectBox() addSeparator() @@ -95,8 +95,8 @@ class AdvancedTab( } } - private fun addmaxAutosavesStored() { - add("Maximum autosave turns stored".toLabel()).left().fillX() + private fun addMaxAutosavesStored() { + add("Number of autosave files stored".toLabel()).left().fillX() val maxAutosavesStoredSelectBox = SelectBox(skin) val maxAutosavesStoredArray = Array() From 4fadce64e0a2b4fda632b551171b7e01dd6cbf8f Mon Sep 17 00:00:00 2001 From: Emandac <121508218+Emandac@users.noreply.github.com> Date: Sun, 19 Jan 2025 18:31:38 +0100 Subject: [PATCH 19/19] Added UniqueType.FoundPuppetCity with "Founds a new puppet city" in "uniques" of an unit in Units.json. Making it so you can now settle a puppet city. --- .../unciv/models/ruleset/unique/UniqueType.kt | 1 + .../unit/actions/UnitActionsFromUniques.kt | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index b0c8c55b49035..fad01c5e73f49 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -348,6 +348,7 @@ enum class UniqueType( // Unit actions should look like: "Can {action description}, to allow them to be combined with modifiers FoundCity("Founds a new city", UniqueTarget.UnitAction), + FoundPuppetCity("Founds a new puppet city", UniqueTarget.UnitAction), ConstructImprovementInstantly("Can instantly construct a [improvementFilter] improvement", UniqueTarget.UnitAction), // TODO: Should be replaced by "Can instantly construct a [] improvement " CreateWaterImprovements("May create improvements on water resources", UniqueTarget.Unit), diff --git a/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionsFromUniques.kt b/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionsFromUniques.kt index 33d94c5454601..1129eb988ce63 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionsFromUniques.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionsFromUniques.kt @@ -39,8 +39,11 @@ object UnitActionsFromUniques { * (no movement left, too close to another city). */ internal fun getFoundCityAction(unit: MapUnit, tile: Tile): UnitAction? { - val unique = UnitActionModifiers.getUsableUnitActionUniques(unit, UniqueType.FoundCity) - .firstOrNull() ?: return null + // FoundPuppetCity is to found a puppet city for modding. + val unique = UnitActionModifiers.getUsableUnitActionUniques(unit, + UniqueType.FoundCity).firstOrNull() ?: + UnitActionModifiers.getUsableUnitActionUniques(unit, + UniqueType.FoundPuppetCity).firstOrNull() ?: return null if (tile.isWater || tile.isImpassible()) return null // Spain should still be able to build Conquistadors in a one city challenge - but can't settle them @@ -54,12 +57,19 @@ object UnitActionsFromUniques { ) == true } val foundAction = { if (unit.civ.playerType != PlayerType.AI) - UncivGame.Current.settings.addCompletedTutorialTask("Found city") - unit.civ.addCity(tile.position, unit) + // Now takes on the text of the unique. + UncivGame.Current.settings.addCompletedTutorialTask( + unique.text) + // Get the city to be able to change it into puppet, for modding. + val city = unit.civ.addCity(tile.position, unit) if (hasActionModifiers) UnitActionModifiers.activateSideEffects(unit, unique) else unit.destroy() GUI.setUpdateWorldOnNextRender() // Set manually, since this could be triggered from the ConfirmPopup and not from the UnitActionsTable + // If unit has FoundPuppetCity make it into a puppet city. + if (unique.type == UniqueType.FoundPuppetCity) { + city.isPuppet = true + } } if (unit.civ.playerType == PlayerType.AI)