mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-06 16:28:40 +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"
|
applicationId "com.unciv.game"
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 32
|
versionCode 33
|
||||||
versionName "1.3.5"
|
versionName "1.4"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
@ -86,10 +86,11 @@ class GameInfo {
|
|||||||
if(unit.health < 50) continue // do nothing but heal
|
if(unit.health < 50) continue // do nothing but heal
|
||||||
|
|
||||||
// if there is an attackable unit in the vicinity, attack!
|
// 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 distanceToTiles = unit.getDistanceToTiles()
|
||||||
val unitTileToAttack = distanceToTiles.keys.firstOrNull{ tilesViewableToCiv.contains(it) &&
|
val unitTileToAttack = distanceToTiles.keys.firstOrNull{ attackableTiles.contains(it)}
|
||||||
it.unit != null && it.unit!!.owner != civInfo.civName && !it.isCityCenter }
|
|
||||||
if(unitTileToAttack!=null){
|
if(unitTileToAttack!=null){
|
||||||
val unitToAttack =unitTileToAttack.unit!!
|
val unitToAttack =unitTileToAttack.unit!!
|
||||||
if(unitToAttack.getBaseUnit().unitType == UnitType.Civilian){ // kill
|
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
|
// 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)
|
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){
|
if(closestUnit!=null){
|
||||||
unit.headTowards(closestUnit.position)
|
unit.headTowards(closestUnit.position)
|
||||||
|
@ -51,7 +51,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
|||||||
row()
|
row()
|
||||||
|
|
||||||
var damageToDefender = battle.calculateDamageToDefender(attacker,defender)
|
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
|
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