diff --git a/core/src/com/unciv/GUI.kt b/core/src/com/unciv/GUI.kt index a7c26ee538..40dcb7f30f 100644 --- a/core/src/com/unciv/GUI.kt +++ b/core/src/com/unciv/GUI.kt @@ -9,6 +9,7 @@ import com.unciv.ui.screens.worldscreen.UndoHandler.Companion.clearUndoCheckpoin import com.unciv.ui.screens.worldscreen.worldmap.WorldMapHolder import com.unciv.ui.screens.worldscreen.WorldScreen import com.unciv.ui.screens.worldscreen.unit.UnitTable +import yairm210.purity.annotations.Readonly object GUI { @@ -24,6 +25,7 @@ object GUI { UncivGame.Current.resetToWorldScreen() } + @Readonly fun getSettings(): GameSettings { return UncivGame.Current.settings } diff --git a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyFunctions.kt b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyFunctions.kt index 9bab07e909..f33a4d32a4 100644 --- a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyFunctions.kt +++ b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyFunctions.kt @@ -87,13 +87,15 @@ class DiplomacyFunctions(val civInfo: Civilization) { } } } - + + @Readonly fun canSignDeclarationOfFriendshipWith(otherCiv: Civilization): Boolean { return otherCiv.isMajorCiv() && !otherCiv.isAtWarWith(civInfo) && !civInfo.getDiplomacyManager(otherCiv)!!.hasFlag(DiplomacyFlags.Denunciation) && !civInfo.getDiplomacyManager(otherCiv)!!.hasFlag(DiplomacyFlags.DeclarationOfFriendship) } + @Readonly fun canSignResearchAgreement(): Boolean { if (!civInfo.isMajorCiv()) return false if (!civInfo.hasUnique(UniqueType.EnablesResearchAgreements)) return false @@ -101,6 +103,7 @@ class DiplomacyFunctions(val civInfo: Civilization) { return true } + @Readonly fun canSignResearchAgreementNoCostWith (otherCiv: Civilization): Boolean { val diplomacyManager = civInfo.getDiplomacyManager(otherCiv)!! return canSignResearchAgreement() && otherCiv.diplomacyFunctions.canSignResearchAgreement() @@ -109,12 +112,14 @@ class DiplomacyFunctions(val civInfo: Civilization) { && !diplomacyManager.otherCivDiplomacy().hasFlag(DiplomacyFlags.ResearchAgreement) } + @Readonly fun canSignResearchAgreementsWith(otherCiv: Civilization): Boolean { val cost = getResearchAgreementCost(otherCiv) return canSignResearchAgreementNoCostWith(otherCiv) && civInfo.gold >= cost && otherCiv.gold >= cost } + @Readonly fun getResearchAgreementCost(otherCiv: Civilization): Int { // https://forums.civfanatics.com/resources/research-agreements-bnw.25568/ return ( max(civInfo.getEra().researchAgreementCost, otherCiv.getEra().researchAgreementCost) @@ -122,12 +127,14 @@ class DiplomacyFunctions(val civInfo: Civilization) { ).toInt() } + @Readonly fun canSignDefensivePact(): Boolean { if (!civInfo.isMajorCiv()) return false if (!civInfo.hasUnique(UniqueType.EnablesDefensivePacts)) return false return true } + @Readonly fun canSignDefensivePactWith(otherCiv: Civilization): Boolean { val diplomacyManager = civInfo.getDiplomacyManager(otherCiv)!! return canSignDefensivePact() && otherCiv.diplomacyFunctions.canSignDefensivePact() diff --git a/core/src/com/unciv/logic/civilization/managers/TechManager.kt b/core/src/com/unciv/logic/civilization/managers/TechManager.kt index b4b0e2ce6e..b95e014aa6 100644 --- a/core/src/com/unciv/logic/civilization/managers/TechManager.kt +++ b/core/src/com/unciv/logic/civilization/managers/TechManager.kt @@ -189,6 +189,7 @@ class TechManager : IsPartOfGameInfoSerialization { return tech.prerequisites.all { isResearched(it) } } + @Readonly @Suppress("purity") // should be autorecognized fun allTechsAreResearched() = allTechsAreResearched //endregion