Units now unsleep after moving

This commit is contained in:
Yair Morgenstern 2018-11-23 10:06:16 +02:00
parent e16ea5c803
commit c71f320731
2 changed files with 13 additions and 9 deletions

View File

@ -214,12 +214,15 @@ class CivilizationInfo {
viewableTiles.asSequence().map { it.position }
.filterNot { exploredTiles.contains(it) }.toCollection(exploredTiles)
val viewedCivs = viewableTiles
.flatMap { it.getUnits().map { unit->unit.civInfo }.union(listOf(it.getOwner())) }
// we can meet a civ either by meeting its unit, or its tile
.asSequence().filterNotNull().filterNot { it==this || it.isBarbarianCivilization() }
for(otherCiv in viewedCivs)
val viewedCivs = HashSet<CivilizationInfo>()
for(tile in viewableTiles){
val tileOwner = tile.getOwner()
if(tileOwner!=null) viewedCivs+=tileOwner
for(unit in tile.getUnits()) viewedCivs+=unit.civInfo
}
for(otherCiv in viewedCivs.filterNot { it==this || it.isBarbarianCivilization() })
if(!diplomacy.containsKey(otherCiv.civName)){
meetCivilization(otherCiv)
addNotification("We have encountered [${otherCiv.civName}]!".tr(),null, Color.GOLD)

View File

@ -12,6 +12,7 @@ import com.unciv.ui.utils.getRandom
import java.text.DecimalFormat
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashSet
class MapUnit {
@Transient lateinit var civInfo: CivilizationInfo
@ -63,14 +64,14 @@ class MapUnit {
return movementAlgs().getDistanceToTilesWithinTurn(tile.position,currentMovement)
}
@Transient var tempUniques: List<String> = ArrayList()
@Transient var tempUniques= HashSet<String>()
fun getUniques(): List<String> {
fun getUniques(): HashSet<String> {
return tempUniques
}
fun updateUniques(){
val uniques = ArrayList<String>()
val uniques = HashSet<String>()
val baseUnit = baseUnit()
uniques.addAll(baseUnit.uniques)
uniques.addAll(promotions.promotions.map { GameBasics.UnitPromotions[it]!!.effect })
@ -274,7 +275,7 @@ class MapUnit {
currentMovement -= distanceToTiles[otherTile]!!
if (currentMovement < 0.1) currentMovement = 0f // silly floats which are "almost zero"
if(isFortified() || action=="Set Up") action=null // unfortify/setup after moving
if(isFortified() || action=="Set Up" || action=="Sleep") action=null // unfortify/setup after moving
removeFromTile()
putInTile(otherTile)
}