Fixed Ottomans naval capture unique

This commit is contained in:
Yair Morgenstern 2019-07-05 12:23:58 +03:00
parent 32a45968aa
commit 8d79cca70d
3 changed files with 28 additions and 17 deletions

View File

@ -501,7 +501,7 @@
mainColor:[18,84,30], mainColor:[18,84,30],
secondaryColor:[245,248,185], secondaryColor:[245,248,185],
uniqueName:"Barbary Corsairs" uniqueName:"Barbary Corsairs"
unique:"Pay only one third the usual cost for naval unit maintenance. All melee naval units have the Prize Ships promotion, allowing them to capture defeated ships.", unique:"Pay only one third the usual cost for naval unit maintenance. Melee naval units have a 1/3 chance to capture defeated naval units.",
cities:["Istanbul","Edirne","Ankara","Bursa","Konya","Samsun","Gaziantep","Diyabakir","Izmir","Kayseri","Malatya", cities:["Istanbul","Edirne","Ankara","Bursa","Konya","Samsun","Gaziantep","Diyabakir","Izmir","Kayseri","Malatya",
"Marsin","Antalya","Zonguldak","Denizli","Ordu","Mugia","Eskishehir","Inebolu","Sinop","Adana","Artuin", "Marsin","Antalya","Zonguldak","Denizli","Ordu","Mugia","Eskishehir","Inebolu","Sinop","Adana","Artuin",
"Bodrum","Eregli","Silifke","Sivas","Amasya","Marmaris","Trabzon","Erzurum","Urfa","Izmit","Afyonkarhisar", "Bodrum","Eregli","Silifke","Sivas","Amasya","Marmaris","Trabzon","Erzurum","Urfa","Izmit","Afyonkarhisar",

View File

@ -838,6 +838,7 @@
hurryCostModifier:20, hurryCostModifier:20,
attackSound:"shot" attackSound:"shot"
}, },
/*
{ {
name:"Triplane", name:"Triplane",
unitType:"AirFighter", unitType:"AirFighter",
@ -848,6 +849,7 @@
hurryCostModifier:20, hurryCostModifier:20,
attackSound:"shot" attackSound:"shot"
}, },
*/
/* /*
{ {
name:"Norvegian Ski Infantry", name:"Norvegian Ski Infantry",

View File

@ -108,6 +108,13 @@ class Battle(val gameInfo:GameInfo) {
attacker.getCivInfo().addNotification("A barbarian [${defender.getName()}] has joined us!",attackedTile.position, Color.RED) attacker.getCivInfo().addNotification("A barbarian [${defender.getName()}] has joined us!",attackedTile.position, Color.RED)
} }
// Similarly, Ottoman unique
if(defender.isDefeated() && defender.getUnitType().isWaterUnit()
&& attacker.getCivInfo().getNation().unique== "Pay only one third the usual cost for naval unit maintenance. Melee naval units have a 1/3 chance to capture defeated naval units."
&& Random().nextDouble() > 0.33){
attacker.getCivInfo().placeUnitNearTile(attackedTile.position, defender.getName())
}
// we're a melee unit and we destroyed\captured an enemy unit // we're a melee unit and we destroyed\captured an enemy unit
else if (attacker.isMelee() else if (attacker.isMelee()
&& (defender.isDefeated() || defender.getCivInfo()==attacker.getCivInfo()) && (defender.isDefeated() || defender.getCivInfo()==attacker.getCivInfo())
@ -135,23 +142,7 @@ class Battle(val gameInfo:GameInfo) {
attacker.city.attackedThisTurn = true attacker.city.attackedThisTurn = true
} }
// XP!
fun addXp(thisCombatant:ICombatant, amount:Int, otherCombatant:ICombatant){
if(thisCombatant !is MapUnitCombatant) return
if(thisCombatant.unit.promotions.totalXpProduced() >= 30 && otherCombatant.getCivInfo().isBarbarianCivilization())
return
var amountToAdd = amount
if(thisCombatant.getCivInfo().policies.isAdopted("Military Tradition")) amountToAdd = (amountToAdd * 1.5f).toInt()
thisCombatant.unit.promotions.XP += amountToAdd
if(thisCombatant.getCivInfo().getNation().unique
== "Great general provides double combat bonus, and spawns 50% faster")
amountToAdd = (amountToAdd * 1.5f).toInt()
if(thisCombatant.unit.hasUnique("Combat very likely to create Great Generals"))
amountToAdd *= 2
thisCombatant.getCivInfo().greatPeople.greatGeneralPoints += amountToAdd
}
if(attacker.isMelee()){ if(attacker.isMelee()){
if(!defender.getUnitType().isCivilian()) // unit was not captured but actually attacked if(!defender.getUnitType().isCivilian()) // unit was not captured but actually attacked
@ -186,6 +177,24 @@ class Battle(val gameInfo:GameInfo) {
attacker.unit.action=null attacker.unit.action=null
} }
// XP!
fun addXp(thisCombatant:ICombatant, amount:Int, otherCombatant:ICombatant){
if(thisCombatant !is MapUnitCombatant) return
if(thisCombatant.unit.promotions.totalXpProduced() >= 30 && otherCombatant.getCivInfo().isBarbarianCivilization())
return
var amountToAdd = amount
if(thisCombatant.getCivInfo().policies.isAdopted("Military Tradition")) amountToAdd = (amountToAdd * 1.5f).toInt()
thisCombatant.unit.promotions.XP += amountToAdd
if(thisCombatant.getCivInfo().getNation().unique
== "Great general provides double combat bonus, and spawns 50% faster")
amountToAdd = (amountToAdd * 1.5f).toInt()
if(thisCombatant.unit.hasUnique("Combat very likely to create Great Generals"))
amountToAdd *= 2
thisCombatant.getCivInfo().greatPeople.greatGeneralPoints += amountToAdd
}
private fun conquerCity(city: CityInfo, attacker: ICombatant) { private fun conquerCity(city: CityInfo, attacker: ICombatant) {
val cityCiv = city.civInfo val cityCiv = city.civInfo
val attackerCiv = attacker.getCivInfo() val attackerCiv = attacker.getCivInfo()