From 2cbc0e93e05491667b9330b73081c6b7b2982d7f Mon Sep 17 00:00:00 2001 From: Jack Rainy Date: Sun, 15 Mar 2020 18:24:52 +0200 Subject: [PATCH] Ice is impassible for all except submarines (#2158) * Ice is impassible for all except submarines * Using "unique" property + simplified call of functions --- android/assets/jsons/Units.json | 2 +- .../jsons/translations/Russian.properties | 1 + .../jsons/translations/Ukrainian.properties | 1 + .../jsons/translations/template.properties | 1 + .../unciv/logic/map/UnitMovementAlgorithms.kt | 4 ++ .../com/unciv/models/ruleset/unit/UnitType.kt | 62 +++++++------------ 6 files changed, 31 insertions(+), 40 deletions(-) diff --git a/android/assets/jsons/Units.json b/android/assets/jsons/Units.json index 78adf5d3..6e739a87 100644 --- a/android/assets/jsons/Units.json +++ b/android/assets/jsons/Units.json @@ -1098,7 +1098,7 @@ "rangedStrength": 60, "cost": 325, "requiredTech": "Refrigeration", - "uniques": ["Bonus as Attacker [75]%", "Invisible to others", "Can only attack water", "Can attack submarines"], + "uniques": ["Bonus as Attacker [75]%", "Invisible to others", "Can only attack water", "Can attack submarines", "Can enter ice tiles"], "hurryCostModifier": 20 }, { diff --git a/android/assets/jsons/translations/Russian.properties b/android/assets/jsons/translations/Russian.properties index 6d4095b0..35c95b71 100644 --- a/android/assets/jsons/translations/Russian.properties +++ b/android/assets/jsons/translations/Russian.properties @@ -1586,6 +1586,7 @@ Submarine = Подводная лодка Bonus as Attacker [amount]% = Бонус при атаке +[amount]% Invisible to others = Невидим остальным Can only attack water = Может атаковать только морские юниты +Can enter ice tiles = Может проходить через лёд Carrier = Авианосец Triplane = Триплан [percent]% chance to intercept air attacks = [percent]% шанс перехвата воздушных атак diff --git a/android/assets/jsons/translations/Ukrainian.properties b/android/assets/jsons/translations/Ukrainian.properties index 5ffae79a..9188f601 100644 --- a/android/assets/jsons/translations/Ukrainian.properties +++ b/android/assets/jsons/translations/Ukrainian.properties @@ -1566,6 +1566,7 @@ Submarine = Субмарина Bonus as Attacker [amount]% = Перевага у нападі +[amount]% Invisible to others = Інші не бачать Can only attack water = Може атакувати тільки на воді +Can enter ice tiles = Може проходити крізь лід Carrier = Авіаносець Triplane = Триплан [percent]% chance to intercept air attacks = Можливе перехоплення повітряних атак [percent]% diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index 293cadcf..02ebbf94 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -1564,6 +1564,7 @@ Submarine = Bonus as Attacker [amount]% = Invisible to others = Can only attack water = +Can enter ice tiles = Carrier = Triplane = [percent]% chance to intercept air attacks = diff --git a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt index 9af05d9e..d0366bec 100644 --- a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt +++ b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt @@ -318,6 +318,10 @@ class UnitMovementAlgorithms(val unit:MapUnit) { && !(tile.isCityCenter() && tile.isCoastalTile())) return false + if (tile.terrainFeature == Constants.ice + && !unit.baseUnit.uniques.contains("Can enter ice tiles")) + return false + if (tile.isWater && unit.type.isLandUnit()) { if (!unit.civInfo.tech.unitsCanEmbark) return false if (tile.isOcean && !unit.civInfo.tech.embarkedUnitsCanEnterOcean) diff --git a/core/src/com/unciv/models/ruleset/unit/UnitType.kt b/core/src/com/unciv/models/ruleset/unit/UnitType.kt index 2a9a87b4..0aebcb7c 100644 --- a/core/src/com/unciv/models/ruleset/unit/UnitType.kt +++ b/core/src/com/unciv/models/ruleset/unit/UnitType.kt @@ -21,66 +21,50 @@ enum class UnitType{ Bomber, Missile; - fun isMelee(): Boolean { - return this == Melee + fun isMelee() = + this == Melee || this == Mounted || this == Armor || this == Scout || this == WaterMelee - } - fun isRanged(): Boolean { - return this == Ranged + + fun isRanged() = + this == Ranged || this == Siege || this == WaterRanged || this == WaterSubmarine || this == City || this.isAirUnit() - } - fun isLandUnit(): Boolean { - return this == Civilian + fun isLandUnit() = + this == Civilian || this == Melee || this == Mounted || this == Armor || this == Scout || this == Ranged || this == Siege - } - fun isCivilian(): Boolean { - return this == Civilian - || this == WaterCivilian - } + fun isCivilian() = this == Civilian || this == WaterCivilian - fun isMilitary(): Boolean { - return this != Civilian - && this != WaterCivilian - } + fun isMilitary() = this != Civilian && this != WaterCivilian - fun isWaterUnit(): Boolean { - return this==WaterSubmarine - || this==WaterRanged - || this==WaterMelee - || this==WaterCivilian - || this==WaterAircraftCarrier - || this==WaterMissileCarrier - } + fun isWaterUnit() = + this == WaterSubmarine + || this == WaterRanged + || this == WaterMelee + || this == WaterCivilian + || this == WaterAircraftCarrier + || this == WaterMissileCarrier - fun isAirUnit():Boolean{ - return this==Bomber - || this==Fighter - || this==Missile - } + fun isAirUnit() = + this == Bomber + || this == Fighter + || this == Missile - fun isMissile():Boolean{ - return this == Missile - } + fun isMissile() = this == Missile - fun isAircraftCarrierUnit():Boolean{ - return this == WaterAircraftCarrier - } + fun isAircraftCarrierUnit() = this == WaterAircraftCarrier - fun isMissileCarrierUnit():Boolean{ - return this == WaterMissileCarrier - } + fun isMissileCarrierUnit() = this == WaterMissileCarrier } \ No newline at end of file