mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 23:40:01 +07:00
No longer attempts to attack city that contains a unit
Battle visualization bug fixed
This commit is contained in:
@ -21,8 +21,8 @@ android {
|
||||
applicationId "com.unciv.game"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 26
|
||||
versionCode 32
|
||||
versionName "1.3.5"
|
||||
versionCode 33
|
||||
versionName "1.4"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
@ -86,10 +86,11 @@ class GameInfo {
|
||||
if(unit.health < 50) continue // do nothing but heal
|
||||
|
||||
// if there is an attackable unit in the vicinity, attack!
|
||||
val tilesViewableToCiv = civInfo.getViewableTiles().toHashSet()
|
||||
val attackableTiles = civInfo.getViewableTiles()
|
||||
.filter { it.unit != null && it.unit!!.owner != civInfo.civName && !it.isCityCenter }.toHashSet()
|
||||
val distanceToTiles = unit.getDistanceToTiles()
|
||||
val unitTileToAttack = distanceToTiles.keys.firstOrNull{ tilesViewableToCiv.contains(it) &&
|
||||
it.unit != null && it.unit!!.owner != civInfo.civName && !it.isCityCenter }
|
||||
val unitTileToAttack = distanceToTiles.keys.firstOrNull{ attackableTiles.contains(it)}
|
||||
|
||||
if(unitTileToAttack!=null){
|
||||
val unitToAttack =unitTileToAttack.unit!!
|
||||
if(unitToAttack.getBaseUnit().unitType == UnitType.Civilian){ // kill
|
||||
@ -118,7 +119,7 @@ class GameInfo {
|
||||
|
||||
// else, find the closest enemy unit that we know of within 5 spaces and advance towards it
|
||||
val closestUnit = tileMap.getTilesInDistance(unit.getTile().position, 5)
|
||||
.firstOrNull{ tilesViewableToCiv.contains(it) && it.unit!=null && it.unit!!.owner!=civInfo.civName }
|
||||
.firstOrNull{ attackableTiles.contains(it) }
|
||||
|
||||
if(closestUnit!=null){
|
||||
unit.headTowards(closestUnit.position)
|
||||
|
@ -51,7 +51,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
||||
row()
|
||||
|
||||
var damageToDefender = battle.calculateDamageToDefender(attacker,defender)
|
||||
var damageToAttacker = battle.calculateDamageToAttacker(defender,attacker)
|
||||
var damageToAttacker = battle.calculateDamageToAttacker(attacker,defender)
|
||||
|
||||
|
||||
if (damageToAttacker>attacker.getHealth() && damageToDefender>defender.getHealth() // when damage exceeds health, we don't want to show negative health numbers
|
||||
|
Reference in New Issue
Block a user