From b5c12ec17c666555c2e983cb2df57cb5d30d7a51 Mon Sep 17 00:00:00 2001 From: lishaoxia1985 <49801619+lishaoxia1985@users.noreply.github.com> Date: Wed, 24 Mar 2021 02:20:38 +0800 Subject: [PATCH] Carrier cannot attack, AS update to 4.1.3 (#3700) --- .../assets/jsons/Civ V - Vanilla/Units.json | 3 +- build.gradle.kts | 2 +- core/src/com/unciv/models/ruleset/Ruleset.kt | 2 +- .../ui/worldscreen/bottombar/BattleTable.kt | 29 +++++-------------- 4 files changed, 11 insertions(+), 25 deletions(-) diff --git a/android/assets/jsons/Civ V - Vanilla/Units.json b/android/assets/jsons/Civ V - Vanilla/Units.json index 6094cf1724..e31619dcd3 100644 --- a/android/assets/jsons/Civ V - Vanilla/Units.json +++ b/android/assets/jsons/Civ V - Vanilla/Units.json @@ -869,10 +869,9 @@ "unitType": "WaterAircraftCarrier", "movement": 5, "strength": 40, - "rangedStrength": 40, "cost": 375, "requiredTech": "Electronics", - "uniques": ["Can carry 2 aircraft"] + "uniques": ["Cannot attack","Can carry 2 aircraft"] }, { "name": "Triplane", diff --git a/build.gradle.kts b/build.gradle.kts index e2d0f10eb8..4f7c965cd7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,7 +20,7 @@ buildscript { dependencies { classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${com.unciv.build.BuildConfig.kotlinVersion}") classpath("de.richsource.gradle.plugins:gwt-gradle-plugin:0.6") - classpath("com.android.tools.build:gradle:4.1.2") + classpath("com.android.tools.build:gradle:4.1.3") classpath("com.mobidevelop.robovm:robovm-gradle-plugin:2.3.1") // This is for wrapping the .jar file into a standalone executable diff --git a/core/src/com/unciv/models/ruleset/Ruleset.kt b/core/src/com/unciv/models/ruleset/Ruleset.kt index ea30d63bb5..859c97dbde 100644 --- a/core/src/com/unciv/models/ruleset/Ruleset.kt +++ b/core/src/com/unciv/models/ruleset/Ruleset.kt @@ -227,7 +227,7 @@ class Ruleset { lines += "${unit.name} upgrades to itself!" if (!unit.unitType.isCivilian() && unit.strength == 0) lines += "${unit.name} is a military unit but has no assigned strength!" - if (unit.unitType.isRanged() && unit.rangedStrength == 0) + if (unit.unitType.isRanged() && unit.rangedStrength == 0 && "Cannot attack" !in unit.uniques) lines += "${unit.name} is a ranged unit but has no assigned rangedStrength!" } diff --git a/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt b/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt index efa39ec3e7..e8c2375896 100644 --- a/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt +++ b/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt @@ -61,14 +61,13 @@ class BattleTable(val worldScreen: WorldScreen): Table() { private fun tryGetAttacker(): ICombatant? { val unitTable = worldScreen.bottomUnitTable - if (unitTable.selectedUnit != null - && !unitTable.selectedUnit!!.type.isCivilian()) { - return MapUnitCombatant(unitTable.selectedUnit!!) - } else if (unitTable.selectedCity != null) { - return CityCombatant(unitTable.selectedCity!!) - } else { - return null // no attacker - } + return if (unitTable.selectedUnit != null + && !unitTable.selectedUnit!!.type.isCivilian() + && !unitTable.selectedUnit!!.hasUnique("Cannot attack")) + MapUnitCombatant(unitTable.selectedUnit!!) + else if (unitTable.selectedCity != null) + CityCombatant(unitTable.selectedCity!!) + else null // no attacker } private fun tryGetDefender(): ICombatant? { @@ -243,9 +242,8 @@ class BattleTable(val worldScreen: WorldScreen): Table() { val canAttackDefenderCiv = attackerCiv.getDiplomacyManager(defenderTileCiv).canAttack() canNuke = canNuke && canAttackDefenderCiv } - val defender = tryGetDefenderAtTile(tile, true) + val defender = tryGetDefenderAtTile(tile, true) ?: continue - if (defender == null) continue val defenderUnitCiv = defender.getCivInfo() if( defenderUnitCiv.knows(attackerCiv)) @@ -295,17 +293,6 @@ class BattleTable(val worldScreen: WorldScreen): Table() { setPosition(worldScreen.stage.width/2-width/2, 5f) } - private fun openBugReportPopup() { - val battleBugPopup = Popup(worldScreen) - battleBugPopup.addGoodSizedLabel("You've encountered a bug that I've been looking for for a while!").row() - battleBugPopup.addGoodSizedLabel("If you could copy your game data (\"Copy saved game to clipboard\" - ").row() - battleBugPopup.addGoodSizedLabel(" paste into an email to yairm210@hotmail.com)").row() - battleBugPopup.addGoodSizedLabel("It would help me figure out what went wrong, since this isn't supposed to happen!").row() - battleBugPopup.addGoodSizedLabel("If you could tell me which unit was selected and which unit you tried to attack,").row() - battleBugPopup.addGoodSizedLabel(" that would be even better!").row() - battleBugPopup.open() - } - private fun getHealthBar(currentHealth: Int, maxHealth: Int, expectedDamage:Int): Table { val healthBar = Table() val totalWidth = 100f