mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 15:01:09 -04:00
Code cleanup and bug fix.
This commit is contained in:
parent
a2764d7b91
commit
730111993e
@ -289,7 +289,7 @@ class UnitAutomation{
|
|||||||
fun tryBombardEnemy(city: CityInfo): Boolean {
|
fun tryBombardEnemy(city: CityInfo): Boolean {
|
||||||
val target = chooseBombardTarget(city)
|
val target = chooseBombardTarget(city)
|
||||||
if (target == null) return false
|
if (target == null) return false
|
||||||
if (city.attacksThisTurn == 0) {
|
if (city.canAttack()) {
|
||||||
val enemy = Battle(city.civInfo.gameInfo).getMapCombatantOfTile(target)!!
|
val enemy = Battle(city.civInfo.gameInfo).getMapCombatantOfTile(target)!!
|
||||||
Battle(city.civInfo.gameInfo).attack(CityCombatant(city), enemy)
|
Battle(city.civInfo.gameInfo).attack(CityCombatant(city), enemy)
|
||||||
return true
|
return true
|
||||||
|
@ -85,6 +85,7 @@ class CityInfo {
|
|||||||
toReturn.workedTiles = workedTiles
|
toReturn.workedTiles = workedTiles
|
||||||
toReturn.isBeingRazed=isBeingRazed
|
toReturn.isBeingRazed=isBeingRazed
|
||||||
toReturn.isConnectedToCapital = isConnectedToCapital
|
toReturn.isConnectedToCapital = isConnectedToCapital
|
||||||
|
toReturn.attacksThisTurn = attacksThisTurn
|
||||||
return toReturn
|
return toReturn
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,5 +235,9 @@ class CityInfo {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun canAttack(): Boolean {
|
||||||
|
return (attacksThisTurn == 0)
|
||||||
|
}
|
||||||
//endregion
|
//endregion
|
||||||
}
|
}
|
@ -140,14 +140,14 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
|||||||
}
|
}
|
||||||
else if (attacker is CityCombatant)
|
else if (attacker is CityCombatant)
|
||||||
{
|
{
|
||||||
canAttack = (attacker.city.attacksThisTurn == 0)
|
canAttack = (attacker.city.canAttack())
|
||||||
&& UnitAutomation().containsBombardableEnemy(defender.getTile(), attacker.city)
|
&& UnitAutomation().getBombardTargets(attacker.city).contains(defender.getTile())
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!canAttack) attackButton.disable()
|
if(!canAttack) attackButton.disable()
|
||||||
else {
|
else {
|
||||||
//var attackSound = attacker.unit.baseUnit.attackSound
|
//var attackSound = attacker.unit.baseUnit.attackSound
|
||||||
//if(attackSound==null) attackSound="click"
|
//if(attackSound==null) attackSound="click"`
|
||||||
//attackButton.onClick(attackSound) {
|
//attackButton.onClick(attackSound) {
|
||||||
attackButton.onClick {
|
attackButton.onClick {
|
||||||
if (attacker is MapUnitCombatant) {
|
if (attacker is MapUnitCombatant) {
|
||||||
|
@ -3,6 +3,7 @@ package com.unciv.ui.worldscreen.unit
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
|
import com.unciv.logic.battle.CityCombatant
|
||||||
import com.unciv.logic.city.CityInfo
|
import com.unciv.logic.city.CityInfo
|
||||||
import com.unciv.logic.map.MapUnit
|
import com.unciv.logic.map.MapUnit
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
@ -103,13 +104,16 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
}
|
}
|
||||||
else if (selectedCity != null) {
|
else if (selectedCity != null) {
|
||||||
separator.isVisible=true
|
separator.isVisible=true
|
||||||
val unit = selectedCity!!
|
val city = selectedCity!!
|
||||||
var nameLabelText = unit.name.tr()
|
var nameLabelText = city.name.tr()
|
||||||
if(unit.health<unit.getMaxHealth()) nameLabelText+=" ("+unit.health+")"
|
if(city.health<city.getMaxHealth()) nameLabelText+=" ("+city.health+")"
|
||||||
unitNameLabel.setText(nameLabelText)
|
unitNameLabel.setText(nameLabelText)
|
||||||
|
|
||||||
unitDescriptionTable.clear()
|
unitDescriptionTable.clear()
|
||||||
unitDescriptionTable.defaults().pad(2f).padRight(5f)
|
unitDescriptionTable.defaults().pad(2f).padRight(5f)
|
||||||
|
unitDescriptionTable.add("Strength".tr())
|
||||||
|
unitDescriptionTable.add(CityCombatant(city).getCityStrength().toString()).row()
|
||||||
|
|
||||||
selectedUnitHasChanged = true
|
selectedUnitHasChanged = true
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user