diff --git a/core/src/com/unciv/logic/GameInfo.kt b/core/src/com/unciv/logic/GameInfo.kt index 5400ed41..1d5359d2 100644 --- a/core/src/com/unciv/logic/GameInfo.kt +++ b/core/src/com/unciv/logic/GameInfo.kt @@ -1,5 +1,6 @@ package com.unciv.logic +import com.badlogic.gdx.graphics.Color import com.unciv.logic.automation.Automation import com.unciv.logic.city.CityInfo import com.unciv.logic.civilization.CivilizationInfo @@ -23,6 +24,7 @@ class GameInfo { fun nextTurn() { notifications.clear() + val player = getPlayerCivilization() for (civInfo in civilizations){ if(civInfo.tech.techsToResearch.isEmpty()){ // should belong in automation? yes/no? @@ -36,7 +38,7 @@ class GameInfo { // We need to update the stats after ALL the cities are done updating because // maybe one of them has a wonder that affects the stats of all the rest of the cities - for (civInfo in civilizations.filterNot { it.isPlayerCivilization() }){ + for (civInfo in civilizations.filterNot { it==player }){ civInfo.startTurn() Automation().automateCivMoves(civInfo) } @@ -47,7 +49,14 @@ class GameInfo { // Start our turn immediately before the player can made decisions - affects whether our units can commit automated actions and then be attacked immediately etc. - getPlayerCivilization().startTurn() + player.startTurn() + + val enemyUnitsCloseToTerritory = player.getViewableTiles().filter { it.militaryUnit!=null && it.militaryUnit!!.civInfo!=player + && (it.getOwner()==player || it.neighbors.any { neighbor -> neighbor.getOwner()==player }) } + for(enemyUnitTile in enemyUnitsCloseToTerritory) { + val inOrNear = if(enemyUnitTile.getOwner()==player) "in" else "near" + player.addNotification("Enemy spotted $inOrNear our territory!", enemyUnitTile.position, Color.RED) + } turns++ } diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index c18ef555..4c250cc6 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -190,7 +190,7 @@ class CivilizationInfo { viewablePositions += getCivUnits() .flatMap { it.getViewableTiles()} // Tiles within 2 tiles of units viewablePositions.map { it.position }.filterNot { exploredTiles.contains(it) }.toCollection(exploredTiles) - return viewablePositions + return viewablePositions.distinct() } fun addNotification(text: String, location: Vector2?,color: Color) { diff --git a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt index 5a070174..81ce39f1 100644 --- a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt +++ b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt @@ -87,11 +87,15 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap: } internal fun updateTiles() { - val civViewableTiles = civInfo.getViewableTiles().toHashSet() + val playerViewableTiles = civInfo.getViewableTiles().toHashSet() for (WG in tileGroups.values){ - WG.update(civViewableTiles.contains(WG.tileInfo)) - } + WG.update(playerViewableTiles.contains(WG.tileInfo)) + val unitsInTile = WG.tileInfo.getUnits() + if(playerViewableTiles.contains(WG.tileInfo) + && unitsInTile.isNotEmpty() && unitsInTile.first().civInfo!=civInfo) + WG.showCircle(Color.RED) + } // Display ALL viewable enemies ewith a red circle so that users don't need to go "hunting" for enemy units if(worldScreen.bottomBar.unitTable.selectedUnit!=null){ val unit = worldScreen.bottomBar.unitTable.selectedUnit!! @@ -112,7 +116,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap: for (tile in attackableTiles.filter { it.getUnits().isNotEmpty() && it.getUnits().first().owner != unit.owner - && civViewableTiles.contains(it)}) { + && playerViewableTiles.contains(it)}) { if(unit.getBaseUnit().unitType== UnitType.Civilian) tileGroups[tile]!!.hideCircle() else tileGroups[tile]!!.showCircle(colorFromRGB(237, 41, 57)) }