mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 06:16:37 -04:00
Game can now handle improvements with no special stats from resources
This commit is contained in:
parent
b26d2fc6e7
commit
231963f050
@ -382,7 +382,9 @@ open class TileInfo {
|
||||
|
||||
fun getImprovementStats(improvement: TileImprovement, observingCiv: CivilizationInfo, city: CityInfo?): Stats {
|
||||
val stats = improvement.cloneStats()
|
||||
if (hasViewableResource(observingCiv) && tileResource.improvement == improvement.name)
|
||||
if (hasViewableResource(observingCiv) && tileResource.improvement == improvement.name
|
||||
&& tileResource.improvementStats != null
|
||||
)
|
||||
stats.add(tileResource.improvementStats!!.clone()) // resource-specific improvement
|
||||
|
||||
val conditionalState = StateForConditionals(civInfo = observingCiv, cityInfo = city)
|
||||
@ -401,8 +403,9 @@ open class TileInfo {
|
||||
// Freshwater and non-freshwater cannot be moved to matchesUniqueFilter since that creates an endless feedback.
|
||||
// If you're attempting that, check that it works!
|
||||
|| unique.params[1] == "Fresh water" && isAdjacentToFreshwater
|
||||
|| unique.params[1] == "non-fresh water" && !isAdjacentToFreshwater)
|
||||
stats.add(unique.stats)
|
||||
|| unique.params[1] == "non-fresh water" && !isAdjacentToFreshwater
|
||||
)
|
||||
stats.add(unique.stats)
|
||||
}
|
||||
|
||||
for (unique in city.getMatchingUniques(UniqueType.StatsFromObject)) {
|
||||
@ -416,13 +419,13 @@ open class TileInfo {
|
||||
val adjacent = unique.params[1]
|
||||
val numberOfBonuses = neighbors.count {
|
||||
it.matchesFilter(adjacent, observingCiv)
|
||||
|| it.roadStatus.name == adjacent
|
||||
|| it.roadStatus.name == adjacent
|
||||
}
|
||||
stats.add(unique.stats.times(numberOfBonuses.toFloat()))
|
||||
}
|
||||
|
||||
for (unique in observingCiv.getMatchingUniques(UniqueType.AllStatsPercentFromObject) +
|
||||
observingCiv.getMatchingUniques(UniqueType.AllStatsSignedPercentFromObject)
|
||||
observingCiv.getMatchingUniques(UniqueType.AllStatsSignedPercentFromObject)
|
||||
)
|
||||
if (improvement.matchesFilter(unique.params[1]))
|
||||
stats.timesInPlace(unique.params[0].toPercent())
|
||||
|
@ -150,18 +150,18 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
|
||||
val updatedTiles = ArrayList<TileInfo>()
|
||||
for (tileToCheck in tilesToCheck)
|
||||
for (neighbor in tileToCheck.neighbors) {
|
||||
var totalDistanceToTile: Float = if (unit.civInfo.exploredTiles.contains(neighbor.position)) {
|
||||
if (!canPassThrough(neighbor))
|
||||
unitMovement // Can't go here.
|
||||
var totalDistanceToTile: Float = when {
|
||||
!unit.civInfo.exploredTiles.contains(neighbor.position) ->
|
||||
distanceToTiles[tileToCheck]!!.totalDistance + 1f // If we don't know then we just guess it to be 1.
|
||||
!canPassThrough(neighbor) -> unitMovement // Can't go here.
|
||||
// The reason that we don't just "return" is so that when calculating how to reach an enemy,
|
||||
// You need to assume his tile is reachable, otherwise all movement algorithms on reaching enemy
|
||||
// cities and units goes kaput.
|
||||
|
||||
else {
|
||||
else -> {
|
||||
val distanceBetweenTiles = getMovementCostBetweenAdjacentTiles(tileToCheck, neighbor, unit.civInfo, considerZoneOfControl)
|
||||
distanceToTiles[tileToCheck]!!.totalDistance + distanceBetweenTiles
|
||||
}
|
||||
} else distanceToTiles[tileToCheck]!!.totalDistance + 1f // If we don't know then we just guess it to be 1.
|
||||
}
|
||||
|
||||
if (!distanceToTiles.containsKey(neighbor) || distanceToTiles[neighbor]!!.totalDistance > totalDistanceToTile) { // this is the new best path
|
||||
if (totalDistanceToTile < unitMovement) // We can still keep moving from here!
|
||||
@ -592,7 +592,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
|
||||
if (tile.isImpassible()) {
|
||||
// special exception - ice tiles are technically impassible, but some units can move through them anyway
|
||||
// helicopters can pass through impassable tiles like mountains
|
||||
if (!(tile.terrainFeatures.contains(Constants.ice) && unit.canEnterIceTiles) && !unit.canPassThroughImpassableTiles
|
||||
if (!unit.canPassThroughImpassableTiles && !(unit.canEnterIceTiles && tile.terrainFeatures.contains(Constants.ice))
|
||||
// carthage-like uniques sometimes allow passage through impassible tiles
|
||||
&& !(unit.civInfo.passThroughImpassableUnlocked && unit.civInfo.passableImpassables.contains(tile.getLastTerrain().name)))
|
||||
return false
|
||||
|
Loading…
x
Reference in New Issue
Block a user