From 42ed4e57497bb8351508b1e80d1cfd5f616bdf81 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Wed, 18 Apr 2018 15:33:53 +0300 Subject: [PATCH] No longer displays red circle in attackable tiles (from range) but not viewed - gave away enemy positions! --- core/src/com/unciv/UnCivGame.kt | 9 +++++---- core/src/com/unciv/logic/GameInfo.kt | 11 +++++++++-- core/src/com/unciv/ui/tilegroups/TileGroup.kt | 6 +++--- core/src/com/unciv/ui/worldscreen/TileMapHolder.kt | 5 +++-- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/core/src/com/unciv/UnCivGame.kt b/core/src/com/unciv/UnCivGame.kt index 01929d14cc..24505d5d13 100644 --- a/core/src/com/unciv/UnCivGame.kt +++ b/core/src/com/unciv/UnCivGame.kt @@ -50,13 +50,14 @@ class UnCivGame : Game() { else gameInfo = GameInfo() gameInfo.tileMap = TileMap(20) - gameInfo.civilizations.add(CivilizationInfo("Babylon", Vector2.Zero, gameInfo)) - - gameInfo.civilizations.add(CivilizationInfo("Greece", Vector2(3f,5f), gameInfo)) + gameInfo.civilizations.add(CivilizationInfo("Babylon", Vector2.Zero, gameInfo)) // first one is player civ val barbarianCivilization = CivilizationInfo() + gameInfo.civilizations.add(barbarianCivilization)// second is barbarian civ + + gameInfo.civilizations.add(CivilizationInfo("Greece", Vector2(3f,5f), gameInfo)) // all the rest whatever + barbarianCivilization.civName = "Barbarians" - gameInfo.civilizations.add(barbarianCivilization) (1..5).forEach { gameInfo.placeBarbarianUnit() } gameInfo.setTransients() diff --git a/core/src/com/unciv/logic/GameInfo.kt b/core/src/com/unciv/logic/GameInfo.kt index 42db493a33..e0cb43084c 100644 --- a/core/src/com/unciv/logic/GameInfo.kt +++ b/core/src/com/unciv/logic/GameInfo.kt @@ -7,6 +7,7 @@ import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.Notification import com.unciv.logic.map.TileMap import com.unciv.logic.map.UnitType +import com.unciv.models.gamebasics.GameBasics import com.unciv.ui.utils.getRandom import com.unciv.ui.worldscreen.unit.UnitActions @@ -34,11 +35,11 @@ class GameInfo { // maybe one of them has a wonder that affects the stats of all the rest of the cities for (civInfo in civilizations){ + if(!civInfo.isPlayerCivilization()) + automateMoves(civInfo) for (city in civInfo.cities) city.cityStats.update() civInfo.happiness = civInfo.getHappinessForNextTurn() - if(!civInfo.isPlayerCivilization()) - automateMoves(civInfo) } if(turns%10 == 0){ // every 10 turns add a barbarian in a random place @@ -74,6 +75,12 @@ class GameInfo { private fun automateMoves(civInfo: CivilizationInfo) { + if(civInfo.tech.techsToResearch.isEmpty()) { + val researchableTechs = GameBasics.Technologies.values.filter { civInfo.tech.canBeResearched(it.name) } + val techToResearch = researchableTechs.minBy { it.cost } + civInfo.tech.techsResearched.add(techToResearch!!.name) + } + for(unit in civInfo.getCivUnits()){ if(unit.name=="Settler") { diff --git a/core/src/com/unciv/ui/tilegroups/TileGroup.kt b/core/src/com/unciv/ui/tilegroups/TileGroup.kt index ca3e753513..bb340e85cd 100644 --- a/core/src/com/unciv/ui/tilegroups/TileGroup.kt +++ b/core/src/com/unciv/ui/tilegroups/TileGroup.kt @@ -149,9 +149,9 @@ open class TileGroup(var tileInfo: TileInfo) : Group() { // This is some crazy voodoo magic so I'll explain. - image.setSize(40f, 2f) - image.moveBy(this.width/2-image.width/2, - this.height/2-image.height/2) + image.setSize(35f, 2f) + image.moveBy(width/2-image.width/2, // center + height/2-image.height/2) // in addTiles, we set the position of groups by relative world position *0.8*groupSize, filter groupSize = 50 // Here, we want to have the borders start HALFWAY THERE and extend towards the tiles, so we give them a position of 0.8*25. // BUT, we don't actually want it all the way out there, because we want to display the borders of 2 different civs! diff --git a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt index a5deea9604..8877f5a780 100644 --- a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt +++ b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt @@ -89,7 +89,8 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap: WG.update(false) } - for (string in civInfo.getViewableTiles() + val civViewableTiles = civInfo.getViewableTiles() + for (string in civViewableTiles .filter { tileGroups.containsKey(it) }) { tileGroups[string]!!.run { @@ -112,7 +113,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap: UnitType.Ranged -> attackableTiles = unit.getTile().getTilesInDistance(2) } - for (tile in attackableTiles.filter { it.unit!=null && it.unit!!.owner != unit.owner }) + for (tile in attackableTiles.filter { it.unit!=null && it.unit!!.owner != unit.owner && civViewableTiles.contains(it)}) tileGroups[tile]!!.showCircle(Color(237/255f,41/255f,57/255f,1f)) } }