Battle table now displays "Captured" when attacking a city with no resistance

This commit is contained in:
Yair Morgenstern 2018-06-12 09:10:02 +03:00
parent c27bcb00c4
commit a380f7aa95
4 changed files with 11 additions and 5 deletions

View file

@ -21,8 +21,8 @@ android {
applicationId "com.unciv.game"
minSdkVersion 14
targetSdkVersion 26
versionCode 78
versionName "2.4.8"
versionCode 80
versionName "2.4.10"
}
buildTypes {
release {

View file

@ -163,8 +163,10 @@ class Battle(val gameInfo:GameInfo=UnCivGame.Current.gameInfo) {
conquerCity((defender as CityCombatant).city, attacker)
}
// we're a melee unit and we destroyed\captured an enemy unit
else if (attacker.isMelee() && (defender.isDefeated() || defender.getCivilization()==attacker.getCivilization() )) {
if(attackedTile.civilianUnit!=null)
// we destroyed an enemy military unit and there was a civilian unit in the same tile as well
if(attackedTile.civilianUnit!=null && attackedTile.civilianUnit!!.civInfo != attacker.getCivilization())
captureCivilianUnit(attacker,MapUnitCombatant(attackedTile.civilianUnit!!))
(attacker as MapUnitCombatant).unit.moveToTile(attackedTile)
}
@ -222,7 +224,10 @@ class Battle(val gameInfo:GameInfo=UnCivGame.Current.gameInfo) {
}
fun captureCivilianUnit(attacker: ICombatant, defender: ICombatant){
if(attacker.getCivilization().isBarbarianCivilization()) defender.takeDamage(100) // barbarians don't capture civilians!
if(attacker.getCivilization().isBarbarianCivilization()){
defender.takeDamage(100)
return
} // barbarians don't capture civilians!
val capturedUnit = (defender as MapUnitCombatant).unit
capturedUnit.civInfo.addNotification("Our "+defender.getName()+" was captured by an enemy "+attacker.getName(),
defender.getTile().position, Color.RED)

View file

@ -113,6 +113,7 @@ class MapUnit {
fun startTurn(){
currentMovement = maxMovement.toFloat()
attacksThisTurn=0
doPreTurnAction()
}

View file

@ -98,7 +98,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
else if (damageToDefender>defender.getHealth()) damageToDefender=defender.getHealth()
if(attacker.isMelee() && defender.getUnitType()==UnitType.Civilian) {
if(attacker.isMelee() && (defender.getUnitType()==UnitType.Civilian || defender.getUnitType()==UnitType.City && defender.isDefeated())) {
add("")
add("Captured!")
}