mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-25 21:03:15 -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.worldmap.WorldMapHolder
|
||||||
import com.unciv.ui.screens.worldscreen.WorldScreen
|
import com.unciv.ui.screens.worldscreen.WorldScreen
|
||||||
import com.unciv.ui.screens.worldscreen.unit.UnitTable
|
import com.unciv.ui.screens.worldscreen.unit.UnitTable
|
||||||
|
import yairm210.purity.annotations.Readonly
|
||||||
|
|
||||||
object GUI {
|
object GUI {
|
||||||
|
|
||||||
@ -24,6 +25,7 @@ object GUI {
|
|||||||
UncivGame.Current.resetToWorldScreen()
|
UncivGame.Current.resetToWorldScreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Readonly
|
||||||
fun getSettings(): GameSettings {
|
fun getSettings(): GameSettings {
|
||||||
return UncivGame.Current.settings
|
return UncivGame.Current.settings
|
||||||
}
|
}
|
||||||
|
@ -88,12 +88,14 @@ class DiplomacyFunctions(val civInfo: Civilization) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Readonly
|
||||||
fun canSignDeclarationOfFriendshipWith(otherCiv: Civilization): Boolean {
|
fun canSignDeclarationOfFriendshipWith(otherCiv: Civilization): Boolean {
|
||||||
return otherCiv.isMajorCiv() && !otherCiv.isAtWarWith(civInfo)
|
return otherCiv.isMajorCiv() && !otherCiv.isAtWarWith(civInfo)
|
||||||
&& !civInfo.getDiplomacyManager(otherCiv)!!.hasFlag(DiplomacyFlags.Denunciation)
|
&& !civInfo.getDiplomacyManager(otherCiv)!!.hasFlag(DiplomacyFlags.Denunciation)
|
||||||
&& !civInfo.getDiplomacyManager(otherCiv)!!.hasFlag(DiplomacyFlags.DeclarationOfFriendship)
|
&& !civInfo.getDiplomacyManager(otherCiv)!!.hasFlag(DiplomacyFlags.DeclarationOfFriendship)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Readonly
|
||||||
fun canSignResearchAgreement(): Boolean {
|
fun canSignResearchAgreement(): Boolean {
|
||||||
if (!civInfo.isMajorCiv()) return false
|
if (!civInfo.isMajorCiv()) return false
|
||||||
if (!civInfo.hasUnique(UniqueType.EnablesResearchAgreements)) return false
|
if (!civInfo.hasUnique(UniqueType.EnablesResearchAgreements)) return false
|
||||||
@ -101,6 +103,7 @@ class DiplomacyFunctions(val civInfo: Civilization) {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Readonly
|
||||||
fun canSignResearchAgreementNoCostWith (otherCiv: Civilization): Boolean {
|
fun canSignResearchAgreementNoCostWith (otherCiv: Civilization): Boolean {
|
||||||
val diplomacyManager = civInfo.getDiplomacyManager(otherCiv)!!
|
val diplomacyManager = civInfo.getDiplomacyManager(otherCiv)!!
|
||||||
return canSignResearchAgreement() && otherCiv.diplomacyFunctions.canSignResearchAgreement()
|
return canSignResearchAgreement() && otherCiv.diplomacyFunctions.canSignResearchAgreement()
|
||||||
@ -109,12 +112,14 @@ class DiplomacyFunctions(val civInfo: Civilization) {
|
|||||||
&& !diplomacyManager.otherCivDiplomacy().hasFlag(DiplomacyFlags.ResearchAgreement)
|
&& !diplomacyManager.otherCivDiplomacy().hasFlag(DiplomacyFlags.ResearchAgreement)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Readonly
|
||||||
fun canSignResearchAgreementsWith(otherCiv: Civilization): Boolean {
|
fun canSignResearchAgreementsWith(otherCiv: Civilization): Boolean {
|
||||||
val cost = getResearchAgreementCost(otherCiv)
|
val cost = getResearchAgreementCost(otherCiv)
|
||||||
return canSignResearchAgreementNoCostWith(otherCiv)
|
return canSignResearchAgreementNoCostWith(otherCiv)
|
||||||
&& civInfo.gold >= cost && otherCiv.gold >= cost
|
&& civInfo.gold >= cost && otherCiv.gold >= cost
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Readonly
|
||||||
fun getResearchAgreementCost(otherCiv: Civilization): Int {
|
fun getResearchAgreementCost(otherCiv: Civilization): Int {
|
||||||
// https://forums.civfanatics.com/resources/research-agreements-bnw.25568/
|
// https://forums.civfanatics.com/resources/research-agreements-bnw.25568/
|
||||||
return ( max(civInfo.getEra().researchAgreementCost, otherCiv.getEra().researchAgreementCost)
|
return ( max(civInfo.getEra().researchAgreementCost, otherCiv.getEra().researchAgreementCost)
|
||||||
@ -122,12 +127,14 @@ class DiplomacyFunctions(val civInfo: Civilization) {
|
|||||||
).toInt()
|
).toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Readonly
|
||||||
fun canSignDefensivePact(): Boolean {
|
fun canSignDefensivePact(): Boolean {
|
||||||
if (!civInfo.isMajorCiv()) return false
|
if (!civInfo.isMajorCiv()) return false
|
||||||
if (!civInfo.hasUnique(UniqueType.EnablesDefensivePacts)) return false
|
if (!civInfo.hasUnique(UniqueType.EnablesDefensivePacts)) return false
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Readonly
|
||||||
fun canSignDefensivePactWith(otherCiv: Civilization): Boolean {
|
fun canSignDefensivePactWith(otherCiv: Civilization): Boolean {
|
||||||
val diplomacyManager = civInfo.getDiplomacyManager(otherCiv)!!
|
val diplomacyManager = civInfo.getDiplomacyManager(otherCiv)!!
|
||||||
return canSignDefensivePact() && otherCiv.diplomacyFunctions.canSignDefensivePact()
|
return canSignDefensivePact() && otherCiv.diplomacyFunctions.canSignDefensivePact()
|
||||||
|
@ -189,6 +189,7 @@ class TechManager : IsPartOfGameInfoSerialization {
|
|||||||
return tech.prerequisites.all { isResearched(it) }
|
return tech.prerequisites.all { isResearched(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Readonly @Suppress("purity") // should be autorecognized
|
||||||
fun allTechsAreResearched() = allTechsAreResearched
|
fun allTechsAreResearched() = allTechsAreResearched
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
Loading…
x
Reference in New Issue
Block a user