Fixed Hanse special ability
This commit is contained in:
parent
418bc140e8
commit
ee1aa61221
3 changed files with 16 additions and 5 deletions
|
@ -213,8 +213,14 @@ class GameInfo {
|
|||
}
|
||||
|
||||
for (civInfo in civilizations){
|
||||
// Since this depends on the cities of ALL civilizations,
|
||||
// we need to wait until we've set the transients of all the cities before we can run this.
|
||||
// Hence why it's not in CivInfo.setTransients().
|
||||
civInfo.setCitiesConnectedToCapitalTransients()
|
||||
|
||||
// We need to determine the GLOBAL happiness state in order to determine the city stats
|
||||
for(cityInfo in civInfo.cities) cityInfo.cityStats.updateCityHappiness()
|
||||
|
||||
for (cityInfo in civInfo.cities) cityInfo.cityStats.update()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ class CivilizationInfo {
|
|||
@Transient private var units=listOf<MapUnit>()
|
||||
@Transient var viewableTiles = setOf<TileInfo>()
|
||||
@Transient var viewableInvisibleUnitsTiles = setOf<TileInfo>()
|
||||
|
||||
/** Contains cities from ALL civilizations connected by trade routes to the capital */
|
||||
@Transient var citiesConnectedToCapital = listOf<CityInfo>()
|
||||
|
||||
|
@ -437,7 +438,6 @@ class CivilizationInfo {
|
|||
cityInfo.civInfo = this // must be before the city's setTransients because it depends on the tilemap, that comes from the currentPlayerCivInfo
|
||||
cityInfo.setTransients()
|
||||
}
|
||||
setCitiesConnectedToCapitalTransients()
|
||||
updateViewableTiles()
|
||||
updateHasActiveGreatWall()
|
||||
updateDetailedCivResources()
|
||||
|
@ -550,8 +550,9 @@ class CivilizationInfo {
|
|||
val citiesReachedToMediums = HashMap<CityInfo,ArrayList<String>>()
|
||||
var citiesToCheck = mutableListOf(getCapital())
|
||||
citiesReachedToMediums[getCapital()] = arrayListOf("Start")
|
||||
val allCivCities = gameInfo.civilizations.flatMap { it.cities }
|
||||
|
||||
while(citiesToCheck.isNotEmpty() && citiesReachedToMediums.size<cities.size){
|
||||
while(citiesToCheck.isNotEmpty() && citiesReachedToMediums.size<allCivCities.size){
|
||||
val newCitiesToCheck = mutableListOf<CityInfo>()
|
||||
for(cityToConnectFrom in citiesToCheck){
|
||||
val reachedMediums = citiesReachedToMediums[cityToConnectFrom]!!
|
||||
|
@ -561,7 +562,7 @@ class CivilizationInfo {
|
|||
|
||||
val roadBfs = BFS(cityToConnectFrom.getCenterTile()){it.roadStatus!=RoadStatus.None}
|
||||
roadBfs.stepToEnd()
|
||||
val reachedCities = cities.filter { roadBfs.tilesReached.containsKey(it.getCenterTile())}
|
||||
val reachedCities = allCivCities.filter { roadBfs.tilesReached.containsKey(it.getCenterTile())}
|
||||
for(reachedCity in reachedCities){
|
||||
if(!citiesReachedToMediums.containsKey(reachedCity)){
|
||||
newCitiesToCheck.add(reachedCity)
|
||||
|
@ -578,7 +579,7 @@ class CivilizationInfo {
|
|||
&& cityToConnectFrom.cityConstructions.containsBuildingOrEquivalent("Harbor")){
|
||||
val seaBfs = BFS(cityToConnectFrom.getCenterTile()){it.isWater || it.isCityCenter()}
|
||||
seaBfs.stepToEnd()
|
||||
val reachedCities = cities.filter { seaBfs.tilesReached.containsKey(it.getCenterTile())}
|
||||
val reachedCities = allCivCities.filter { seaBfs.tilesReached.containsKey(it.getCenterTile())}
|
||||
for(reachedCity in reachedCities){
|
||||
if(!citiesReachedToMediums.containsKey(reachedCity)){
|
||||
newCitiesToCheck.add(reachedCity)
|
||||
|
|
|
@ -75,7 +75,7 @@ class TileMap {
|
|||
fun placeUnitNearTile(position: Vector2, unitName: String, civInfo: CivilizationInfo): MapUnit? {
|
||||
val unit = GameBasics.Units[unitName]!!.getMapUnit()
|
||||
val tilesInDistance = getTilesInDistance(position, 2)
|
||||
unit.assignOwner(civInfo) // both the civ name and actual civ need to be in here in order to calculate the canMoveTo...Darn
|
||||
unit.assignOwner(civInfo,false) // both the civ name and actual civ need to be in here in order to calculate the canMoveTo...Darn
|
||||
var unitToPlaceTile = tilesInDistance.firstOrNull { unit.canMoveTo(it) && (unit.type.isWaterUnit() || it.isLand) }
|
||||
if (unitToPlaceTile==null)
|
||||
unitToPlaceTile = tilesInDistance.firstOrNull { unit.canMoveTo(it) }
|
||||
|
@ -88,6 +88,10 @@ class TileMap {
|
|||
// Only once we add the unit to the civ we can activate addPromotion, because it will try to update civ viewable tiles
|
||||
for(promotion in unit.baseUnit.promotions)
|
||||
unit.promotions.addPromotion(promotion,true)
|
||||
|
||||
// And update civ stats, since the new unit changes both unit upkeep and resource consumption
|
||||
civInfo.updateStatsForNextTurn()
|
||||
civInfo.updateDetailedCivResources()
|
||||
}
|
||||
else {
|
||||
civInfo.removeUnit(unit) // since we added it to the civ units in the previous assignOwner
|
||||
|
|
Loading…
Reference in a new issue