mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-25 12:54:06 -04:00
chore: purity diplomacyFunctions
This commit is contained in:
parent
237e286d4d
commit
c6c820afa3
@ -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
|
||||
}
|
||||
|
@ -88,12 +88,14 @@ 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()
|
||||
|
@ -189,6 +189,7 @@ class TechManager : IsPartOfGameInfoSerialization {
|
||||
return tech.prerequisites.all { isResearched(it) }
|
||||
}
|
||||
|
||||
@Readonly @Suppress("purity") // should be autorecognized
|
||||
fun allTechsAreResearched() = allTechsAreResearched
|
||||
|
||||
//endregion
|
||||
|
Loading…
x
Reference in New Issue
Block a user