mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 06:16:37 -04:00
Remove unnecessary/harmful open
on classes without subclasses (#11217)
* Remove open modifier from classes never actually subclassed * Correct resulting compilation errors with readabilty improvement
This commit is contained in:
parent
6a61a71c36
commit
8946ee8bfa
@ -144,11 +144,17 @@ object SpecificUnitAutomation {
|
||||
|
||||
if (bestCityLocation == null) {
|
||||
// Find the best tile that is within
|
||||
bestCityLocation = bestTilesInfo.tileRankMap.filter { bestTilesInfo.bestTile == null || it.value >= bestTilesInfo.tileRankMap[bestTilesInfo.bestTile]!! - 5 }.asSequence().sortedByDescending { it.value }.firstOrNull {
|
||||
if (it.key in dangerousTiles && it != unit.getTile()) return@firstOrNull false
|
||||
fun isTileRankOK(it: Map.Entry<Tile, Float>): Boolean {
|
||||
if (it.key in dangerousTiles && it.key != unit.getTile()) return false
|
||||
val pathSize = unit.movement.getShortestPath(it.key).size
|
||||
return@firstOrNull pathSize in 1..3
|
||||
}?.key
|
||||
return pathSize in 1..3
|
||||
}
|
||||
|
||||
bestCityLocation = bestTilesInfo.tileRankMap.entries.asSequence()
|
||||
.filter { bestTilesInfo.bestTile == null || it.value >= bestTilesInfo.tileRankMap[bestTilesInfo.bestTile]!! - 5 }
|
||||
.sortedByDescending { it.value }
|
||||
.firstOrNull(::isTileRankOK)
|
||||
?.key
|
||||
}
|
||||
|
||||
// We still haven't found a best city tile within 3 turns so lets just head to the best tile
|
||||
|
@ -169,7 +169,7 @@ class WorkerAutomation(
|
||||
*/
|
||||
private fun findTileToWork(unit: MapUnit, tilesToAvoid: Set<Tile>): Tile {
|
||||
val currentTile = unit.getTile()
|
||||
if (currentTile != tilesToAvoid && getBasePriority(currentTile, unit) >= 5
|
||||
if (currentTile !in tilesToAvoid && getBasePriority(currentTile, unit) >= 5
|
||||
&& (tileHasWorkToDo(currentTile, unit) || currentTile.isPillaged() || currentTile.hasFalloutEquivalent())) {
|
||||
return currentTile
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import com.unciv.logic.IsPartOfGameInfoSerialization
|
||||
import com.unciv.ui.screens.victoryscreen.RankingType
|
||||
|
||||
/** Records for each turn (key of outer map) what the score (value of inner map) was for each RankingType. */
|
||||
open class CivRankingHistory : HashMap<Int, Map<RankingType, Int>>(),
|
||||
class CivRankingHistory : HashMap<Int, Map<RankingType, Int>>(),
|
||||
IsPartOfGameInfoSerialization {
|
||||
|
||||
/**
|
||||
|
@ -108,7 +108,7 @@ class UnitMovement(val unit: MapUnit) {
|
||||
return cachedPath
|
||||
|
||||
val currentTile = unit.getTile()
|
||||
if (currentTile.position == destination) {
|
||||
if (currentTile.position == destination.position) {
|
||||
// edge case that's needed, so that workers will know that they can reach their own tile. *sigh*
|
||||
pathfindingCache.setShortestPathCache(destination, listOf(currentTile))
|
||||
return listOf(currentTile)
|
||||
|
@ -33,7 +33,7 @@ import kotlin.math.abs
|
||||
import kotlin.math.min
|
||||
import kotlin.random.Random
|
||||
|
||||
open class Tile : IsPartOfGameInfoSerialization {
|
||||
class Tile : IsPartOfGameInfoSerialization {
|
||||
@Transient
|
||||
lateinit var tileMap: TileMap
|
||||
|
||||
|
@ -13,7 +13,7 @@ import java.util.TreeMap
|
||||
*
|
||||
* @see com.unciv.ui.screens.victoryscreen.ReplayMap
|
||||
*/
|
||||
open class TileHistory : IsPartOfGameInfoSerialization {
|
||||
class TileHistory : IsPartOfGameInfoSerialization {
|
||||
|
||||
class TileHistoryState(
|
||||
/** The name of the civilization owning this tile or `null` if there is no owner. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user