Don't reveal submarine position by city markers (#2643)

This commit is contained in:
Jack Rainy 2020-05-21 12:20:44 +03:00 committed by GitHub
parent 4b405ecc61
commit 98a4c8bf00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View file

@ -435,7 +435,7 @@ open class TileInfo {
turnsToImprovement = 0
}
fun hasEnemySubmarine(viewingCiv: CivilizationInfo): Boolean {
fun hasEnemyInvisibleUnit(viewingCiv: CivilizationInfo): Boolean {
val unitsInTile = getUnits()
if (unitsInTile.none()) return false
if (unitsInTile.first().civInfo != viewingCiv &&

View file

@ -77,13 +77,13 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab
(tile.civilianUnit != null) && direction.epsilonEquals(0f, 1f) ->
insertHiddenUnitMarker(HiddenUnitMarkerPosition.Left)
// detect military under the city
(tile.militaryUnit != null) && direction.epsilonEquals(1f, 1f) ->
(tile.militaryUnit != null && !tile.hasEnemyInvisibleUnit(worldScreen.viewingCiv)) && direction.epsilonEquals(1f, 1f) ->
insertHiddenUnitMarker(HiddenUnitMarkerPosition.Center)
// detect civilian right-below the city
(tile.civilianUnit != null) && direction.epsilonEquals(1f, 0f) ->
insertHiddenUnitMarker(HiddenUnitMarkerPosition.Right)
}
} else if (tile.militaryUnit != null) {
} else if (tile.militaryUnit != null && !tile.hasEnemyInvisibleUnit(worldScreen.viewingCiv)) {
when {
// detect military left from the city
direction.epsilonEquals(0f, 1f) ->

View file

@ -269,7 +269,7 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
fun showMilitaryUnit(viewingCiv: CivilizationInfo) = showEntireMap
|| viewingCiv.viewableInvisibleUnitsTiles.contains(tileInfo)
|| !tileInfo.hasEnemySubmarine(viewingCiv)
|| !tileInfo.hasEnemyInvisibleUnit(viewingCiv)
fun isViewable(viewingCiv: CivilizationInfo) = showEntireMap
|| viewingCiv.viewableTiles.contains(tileInfo)