This commit is contained in:
Yair Morgenstern 2019-03-14 21:33:38 +02:00
commit 456f524601
3 changed files with 115 additions and 16 deletions

View File

@ -504,6 +504,68 @@
unique:"Melee units cost 50% less maintenance, and all units require 25% less experience to earn their next promotion.",
cities:["Ulundi","Umugungundlovu","Nobamba","Bulawayo","KwaDukuza","Nongoma","oNdini","Nodwengu","Ndonakusuka","Babanango","Khangela","KwaHlomendlini","Hlobane","eThekwini","Mlambongwenya","Eziqwaqweni","eMangweni","Isiphezi","Masotsheni","Mtunzini","Nyakamubi","Dumazulu","Hlatikulu","Mthonjaneni","Empangeni","Pongola","Tugela","Kwamashi","Ingwavuma","Hluhluwe","Matubatuba","Mhlahlandlela","Mthatha","Maseru","Lobamba","Qunu"]
},
{
name:"Mongolia",
leaderName:"Genghis Khan",
startIntroPart1: ""
startIntroPart2: ""
declaringWar:"You stand in the way of my armies. Let us solve this like warriors!"
attacked:"No more words. Today, Mongolia charges toward your defeat."
defeated:"You have hobbled the Mongolian clans. My respect for you nearly matches the loathing. I am waiting for my execution."
introduction:"I am Temuujin, conqueror of cities and countries. Before me lie future Mongolian lands. Behind me is the only cavalry that matters."
neutralHello:"Hello."
neutralLetsHearIt:["I'm listening.","What?"]
neutralNo:["No.","Of course not!"]
neutralYes:["Good.","That works.","Of course!"]
hateHello:"So what now?"
hateLetsHearIt:["And then?","Continue..."]
hateNo:["Stop playing around.","This is not to be tolerated!"]
hateYes:["Very well...","Fine!"]
afterPeace:"It seems I have underestimate you. Very well... I won't take you head for now."
tradeRequest:"I am not always this generous, but we hope you take this rare opportunity we give you."
mainColor:[51,0,0],
secondaryColor:[0,204,102],
unique:"All mounted units have +1 Movement. +30% when assaulting cities,",
cities:["Karakorum","Beshbalik","Turfan","Hsia","Old Sarai","New Sarai","Tabriz","Tiflis","Otrar","Sanchu","Kazan","Almarikh","Ulaanbaatar","Hovd","Darhan","Dalandzadgad","Mandalgovi","Choybalsan","Erdenet","Tsetserieg","Baruun-Urt","Ereen","Batshireet","Choyr","Ulaangom","Tosontsengel","Atlay","Uliastay","Bayanhongor","Har-Ayrag","Nalayh","Tes"]
},
{
name:"Celts",
leaderName:"Boudicca",
startIntroPart1: ""
startIntroPart2: ""
declaringWar:"How dare you?! I will be the one owning your head!"
attacked:"I have been preparing for war for a long time! To arms, patriots! We march to war!"
defeated:"You, awful king! You realized that you "won" this war in mane only?"
introduction:"I am Boudicca, Queen of the Celts. Let no-one underestimate me!"
neutralHello:"The Heavens have given good to you."
neutralLetsHearIt:["We are all ears...","Well?"]
neutralNo:["We must decline.","No.","We refuse."]
neutralYes:["Sure, it shall be so.","Fine...","Acceptable."]
hateHello:"Well?"
hateLetsHearIt:["Speak!","And?"]
hateNo:["Unacceptable!","A thousand times no!","Never!"]
hateYes:["Disgusting... Fine!","If I have to..."]
afterPeace:"Well played, fellow warrior."
tradeRequest:"Let us unite our armies, and profit from the reaping of the rewards."
mainColor:[0,51,25],
secondaryColor:[255,255,255],
unique:"+1 Culture per city with an adjacent unimproved Forest. Bonus increased to +2 Culture in Cities with 3 or more adjacent unimproved Forest tiles.",
cities:["Edinburgh","Dublin","Cardiff","Truro","Nantes","Douglas","Glasgow","Cork","Aberystwyth","Penzance","Rennes","Ramsey","Inverness","Limerick","Swansea","St. Ives","Brest","Peel","Aberdeen","Belfast","Caernarfon","Newquay","Saint- Nazaire","Castletown","Stirling","Galway","Conwy","St. Austell","Saint-Malo","Onchan","Dundee","Londonberry","Llanfairpwllgwyngyll","Falmouth","Lorient","St. John's"]
},
{
name:"Incan",
leaderName:"Pachacuti",

View File

@ -6,6 +6,7 @@ import com.unciv.logic.map.MapUnit
import com.unciv.logic.trade.TradeLogic
import com.unciv.logic.trade.TradeOffer
import com.unciv.logic.trade.TradeType
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.tech.Technology
import com.unciv.models.gamebasics.tr
@ -15,6 +16,7 @@ import kotlin.math.min
class NextTurnAutomation{
fun automateCivMoves(civInfo: CivilizationInfo) {
peaceTreaty(civInfo)
exchangeTechs(civInfo)
chooseTechToResearch(civInfo)
adoptPolicy(civInfo)
@ -143,22 +145,57 @@ class NextTurnAutomation{
return civ1.cities.map { city -> civ2.cities.map { it.getCenterTile().arialDistanceTo(city.getCenterTile()) }.min()!! }.min()!!
}
private fun declareWar(civInfo: CivilizationInfo) {
if (civInfo.cities.isNotEmpty() && civInfo.diplomacy.isNotEmpty()
&& !civInfo.isAtWar()
&& civInfo.getCivUnits().filter { !it.type.isCivilian() }.size > civInfo.cities.size * 2) {
val enemyCivsByDistanceToOurs = civInfo.diplomacy.values.map { it.otherCiv() }
.filterNot { it == civInfo || it.cities.isEmpty() || !civInfo.diplomacy[it.civName]!!.canDeclareWar() }
.groupBy { getMinDistanceBetweenCities(civInfo, it) }
.toSortedMap()
private fun peaceTreaty(civInfo: CivilizationInfo) {
if (civInfo.cities.isNotEmpty() && civInfo.diplomacy.isNotEmpty()) {
val ourMilitaryUnits = civInfo.getCivUnits().filter { !it.type.isCivilian() }.size
val ourCombatStrength = Automation().evaluteCombatStrength(civInfo)
for (group in enemyCivsByDistanceToOurs) {
if (group.key > 7) break
for (otherCiv in group.value) {
if (Automation().evaluteCombatStrength(otherCiv) * 2 < ourCombatStrength) {
civInfo.diplomacy[otherCiv.civName]!!.declareWar()
break
if (civInfo.isAtWar()) { //evaluate peace
val enemiesCiv = civInfo.diplomacy.filter{ it.value.diplomaticStatus == DiplomaticStatus.War }
.map{ it.value.otherCiv() }
.filterNot{ it == civInfo || it.isPlayerCivilization() || it.isBarbarianCivilization() || it.cities.isEmpty() }
for (enemy in enemiesCiv) {
val enemiesStrength = Automation().evaluteCombatStrength(enemy)
if (enemiesStrength < ourCombatStrength * 2) {
continue //Loser can still fight. Refuse peace.
}
if (enemy.getCivUnits().filter { !it.type.isCivilian() }.size > enemy.cities.size
&& enemy.happiness > 0) {
continue //Winner has too large army and happiness. Continue to fight for profit.
}
//pay for peace
val tradeLogic = TradeLogic(civInfo, enemy)
var moneyWeNeedToPay = -tradeLogic.evaluatePeaceCostForThem()
if (moneyWeNeedToPay > tradeLogic.ourAvailableOffers.first { it.type == TradeType.Gold }.amount) {
moneyWeNeedToPay = tradeLogic.ourAvailableOffers.first { it.type == TradeType.Gold }.amount
}
tradeLogic.currentTrade.ourOffers.add(TradeOffer("Peace Treaty", TradeType.Treaty, 20))
tradeLogic.currentTrade.theirOffers.add(TradeOffer("Peace Treaty", TradeType.Treaty, 20))
tradeLogic.currentTrade.ourOffers.add(TradeOffer("Gold".tr(), TradeType.Gold, 0, moneyWeNeedToPay))
tradeLogic.acceptTrade()
}
}
}
}
private fun declareWar(civInfo: CivilizationInfo) {
if (civInfo.cities.isNotEmpty() && civInfo.diplomacy.isNotEmpty()) {
val ourMilitaryUnits = civInfo.getCivUnits().filter { !it.type.isCivilian() }.size
if (!civInfo.isAtWar() && civInfo.happiness > 5
&& ourMilitaryUnits >= civInfo.cities.size * 2) { //evaluate war
val ourCombatStrength = Automation().evaluteCombatStrength(civInfo)
val enemyCivsByDistanceToOurs = civInfo.diplomacy.values.map { it.otherCiv() }
.filterNot { it == civInfo || it.cities.isEmpty() || !civInfo.diplomacy[it.civName]!!.canDeclareWar() }
.groupBy { getMinDistanceBetweenCities(civInfo, it) }
.toSortedMap()
for (group in enemyCivsByDistanceToOurs) {
if (group.key > 7) break
for (otherCiv in group.value) {
if (Automation().evaluteCombatStrength(otherCiv) * 2 < ourCombatStrength) {
civInfo.diplomacy[otherCiv.civName]!!.declareWar()
return
}
}
}
}

View File

@ -36,7 +36,7 @@ class DiplomacyManager() {
return 0
}
fun canDeclareWar() = turnsToPeaceTreaty()==0
fun canDeclareWar() = (turnsToPeaceTreaty()==0 && diplomaticStatus != DiplomaticStatus.War)
fun otherCiv() = civInfo.gameInfo.getCivilization(otherCivName)