Resolved #1839 - Civs no longer declare war and offer things in the same turn

This commit is contained in:
Yair Morgenstern 2020-02-04 09:10:17 +02:00
parent df68ff75f8
commit 748168398e

View File

@ -26,6 +26,7 @@ class NextTurnAutomation{
respondToTradeRequests(civInfo) respondToTradeRequests(civInfo)
if(civInfo.isMajorCiv()) { if(civInfo.isMajorCiv()) {
declareWar(civInfo)
// offerDeclarationOfFriendship(civInfo) // offerDeclarationOfFriendship(civInfo)
offerPeaceTreaty(civInfo) offerPeaceTreaty(civInfo)
offerResearchAgreement(civInfo) offerResearchAgreement(civInfo)
@ -39,7 +40,6 @@ class NextTurnAutomation{
} }
chooseTechToResearch(civInfo) chooseTechToResearch(civInfo)
declareWar(civInfo)
automateCityBombardment(civInfo) automateCityBombardment(civInfo)
useGold(civInfo) useGold(civInfo)
automateUnits(civInfo) automateUnits(civInfo)
@ -330,7 +330,8 @@ class NextTurnAutomation{
private fun offerResearchAgreement(civInfo: CivilizationInfo) { private fun offerResearchAgreement(civInfo: CivilizationInfo) {
// if Civ has researched future tech, they will not want to sign RA. // if Civ has researched future tech, they will not want to sign RA.
if (civInfo.canSignResearchAgreement()){ if (!civInfo.canSignResearchAgreement()) return
val canSignResearchAgreementCiv = civInfo.getKnownCivs() val canSignResearchAgreementCiv = civInfo.getKnownCivs()
.asSequence() .asSequence()
.filter { it.isMajorCiv() } .filter { it.isMajorCiv() }
@ -339,15 +340,17 @@ class NextTurnAutomation{
.filter { !it.getDiplomacyManager(civInfo).hasFlag(DiplomacyFlags.ResearchAgreement) } .filter { !it.getDiplomacyManager(civInfo).hasFlag(DiplomacyFlags.ResearchAgreement) }
.filter { it.canSignResearchAgreement() } .filter { it.canSignResearchAgreement() }
.sortedByDescending { it.statsForNextTurn.science } .sortedByDescending { it.statsForNextTurn.science }
val duration = when(civInfo.gameInfo.gameParameters.gameSpeed) { val duration = when(civInfo.gameInfo.gameParameters.gameSpeed) {
GameSpeed.Quick -> 25 GameSpeed.Quick -> 25
GameSpeed.Standard -> 30 GameSpeed.Standard -> 30
GameSpeed.Epic -> 45 GameSpeed.Epic -> 45
GameSpeed.Marathon -> 90 GameSpeed.Marathon -> 90
} }
for (otherCiv in canSignResearchAgreementCiv) { for (otherCiv in canSignResearchAgreementCiv) {
// Default setting is 5, this will be changed according to different civ. // Default setting is 5, this will be changed according to different civ.
if ((1..10).random()<=5) { if ((1..10).random() > 5) continue
val tradeLogic = TradeLogic(civInfo, otherCiv) val tradeLogic = TradeLogic(civInfo, otherCiv)
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.researchAgreement, TradeType.Treaty, duration, civInfo.getResearchAgreementCost())) tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.researchAgreement, TradeType.Treaty, duration, civInfo.getResearchAgreementCost()))
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.researchAgreement, TradeType.Treaty, duration, civInfo.getResearchAgreementCost())) tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.researchAgreement, TradeType.Treaty, duration, civInfo.getResearchAgreementCost()))
@ -355,8 +358,6 @@ class NextTurnAutomation{
otherCiv.tradeRequests.add(TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse())) otherCiv.tradeRequests.add(TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse()))
} }
} }
}
}
private fun offerPeaceTreaty(civInfo: CivilizationInfo) { private fun offerPeaceTreaty(civInfo: CivilizationInfo) {
if (!civInfo.isAtWar() || civInfo.cities.isEmpty() || civInfo.diplomacy.isEmpty()) return if (!civInfo.isAtWar() || civInfo.cities.isEmpty() || civInfo.diplomacy.isEmpty()) return
@ -419,7 +420,6 @@ class NextTurnAutomation{
} }
private fun declareWar(civInfo: CivilizationInfo) { private fun declareWar(civInfo: CivilizationInfo) {
if (civInfo.isCityState()) return
if (civInfo.victoryType() == VictoryType.Cultural) return if (civInfo.victoryType() == VictoryType.Cultural) return
if (civInfo.cities.isEmpty() || civInfo.diplomacy.isEmpty()) return if (civInfo.cities.isEmpty() || civInfo.diplomacy.isEmpty()) return
if (civInfo.isAtWar() || civInfo.getHappiness() <= 0) return if (civInfo.isAtWar() || civInfo.getHappiness() <= 0) return