mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-14 09:48:12 +07:00
Treat compilation warnings (#11741)
* Treat compilation warnings * Finish treating compiler warnings for now
This commit is contained in:
@ -277,6 +277,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions) {
|
||||
}
|
||||
|
||||
|
||||
@Suppress("UNUSED_PARAMETER") // stub for future use
|
||||
private fun applyOnetimeUniqueBonuses(building: Building): Float {
|
||||
var value = 0f
|
||||
// TODO: Add specific Uniques here
|
||||
|
@ -31,6 +31,7 @@ class RoadToAutomation(val civInfo: Civilization) {
|
||||
*/
|
||||
// TODO: Caching
|
||||
// TODO: Hide the automate road button if road is not unlocked
|
||||
@Suppress("UNUSED_PARAMETER") // tilesWhereWeWillBeCaptured may be useful in the future
|
||||
fun automateConnectRoad(unit: MapUnit, tilesWhereWeWillBeCaptured: Set<Tile>){
|
||||
if (actualBestRoadAvailable == RoadStatus.None) return
|
||||
|
||||
|
@ -506,7 +506,7 @@ object UnitAutomation {
|
||||
|
||||
fun hasPreparationFlag(targetCiv: Civilization): Boolean {
|
||||
val diploManager = civInfo.getDiplomacyManager(targetCiv)!!
|
||||
if (diploManager.hasFlag(DiplomacyFlags.Denunciation)
|
||||
if (diploManager.hasFlag(DiplomacyFlags.Denunciation)
|
||||
|| diploManager.otherCivDiplomacy().hasFlag(DiplomacyFlags.Denunciation)) return true
|
||||
if (diploManager.hasFlag(DiplomacyFlags.WaryOf) && diploManager.getFlag(DiplomacyFlags.WaryOf) < 0) return true
|
||||
return false
|
||||
@ -517,7 +517,7 @@ object UnitAutomation {
|
||||
.sortedBy { unit.getTile().aerialDistanceTo(it.city1.getCenterTile()) }
|
||||
|
||||
// Move to the closest city with a tile we can enter nearby
|
||||
for ((city, enemyCity) in citiesToDefend) {
|
||||
for ((city, _) in citiesToDefend) {
|
||||
if (unit.getTile().aerialDistanceTo(city.getCenterTile()) <= 2) return true
|
||||
val tileToMoveTo = city.getCenterTile().getTilesInDistance(2).firstOrNull { unit.movement.canMoveTo(it) && unit.movement.canReach(it) } ?: continue
|
||||
unit.movement.headTowards(tileToMoveTo)
|
||||
|
@ -14,6 +14,7 @@ object MapPathing {
|
||||
* to upgrade it to a railroad, we consider it to be a railroad for pathing since it will be upgraded.
|
||||
* Otherwise, we set every tile to have equal value since building a road on any of them makes the original movement cost irrelevant.
|
||||
*/
|
||||
@Suppress("UNUSED_PARAMETER") // While `from` is unused, this function should stay close to the signatures expected by the AStar and getPath `heuristic` parameter.
|
||||
private fun roadPreferredMovementCost(unit: MapUnit, from: Tile, to: Tile): Float{
|
||||
// hasRoadConnection accounts for civs that treat jungle/forest as roads
|
||||
// Ignore road over river penalties.
|
||||
@ -30,8 +31,8 @@ object MapPathing {
|
||||
&& !tile.isImpassible()
|
||||
&& unit.civ.hasExplored(tile)
|
||||
&& tile.canCivPassThrough(unit.civ)
|
||||
&& (tile.hasRoadConnection(unit.civ, false)
|
||||
|| tile.hasRailroadConnection(false)
|
||||
&& (tile.hasRoadConnection(unit.civ, false)
|
||||
|| tile.hasRailroadConnection(false)
|
||||
|| tile.improvementFunctions.canBuildImprovement(roadImprovement, unit.civ))
|
||||
|| tile.improvementFunctions.canBuildImprovement(railRoadImprovement, unit.civ)
|
||||
}
|
||||
@ -51,9 +52,8 @@ object MapPathing {
|
||||
startTile,
|
||||
endTile,
|
||||
::isValidRoadPathTile,
|
||||
::roadPreferredMovementCost,
|
||||
{_, _, _ -> 0f}
|
||||
)
|
||||
::roadPreferredMovementCost
|
||||
) { _, _, _ -> 0f }
|
||||
}
|
||||
|
||||
/**
|
||||
@ -102,16 +102,16 @@ object MapPathing {
|
||||
* Gets the connection to the end tile. This does not take into account tile movement costs.
|
||||
* Takes in a civilization instead of a specific unit.
|
||||
*/
|
||||
fun getConnection(civ: Civilization,
|
||||
fun getConnection(civ: Civilization,
|
||||
startTile: Tile,
|
||||
endTile: Tile,
|
||||
predicate: (Civilization, Tile) -> Boolean
|
||||
): List<Tile>? {
|
||||
val astar = AStar(
|
||||
startTile,
|
||||
{ tile -> predicate(civ, tile) },
|
||||
{ from, to -> 1f },
|
||||
{ from, to -> from.aerialDistanceTo(to).toFloat() }
|
||||
predicate = { tile -> predicate(civ, tile) },
|
||||
cost = { _, _ -> 1f },
|
||||
heuristic = { from, to -> from.aerialDistanceTo(to).toFloat() }
|
||||
)
|
||||
while (true) {
|
||||
if (astar.hasEnded()) {
|
||||
|
@ -199,7 +199,7 @@ class Nation : RulesetObject() {
|
||||
if (building.replaces != null && ruleset.buildings.containsKey(building.replaces!!)) {
|
||||
val originalBuilding = ruleset.buildings[building.replaces!!]!!
|
||||
yield(FormattedLine("Replaces [${originalBuilding.name}]", link = originalBuilding.makeLink(), indent = 1))
|
||||
yieldAll(BuildingDescriptions.getDifferences(ruleset, originalBuilding, building))
|
||||
yieldAll(BuildingDescriptions.getDifferences(originalBuilding, building))
|
||||
yield(FormattedLine())
|
||||
} else if (building.replaces != null) {
|
||||
yield(FormattedLine("Replaces [${building.replaces}], which is not found in the ruleset!", indent = 1))
|
||||
|
@ -118,7 +118,7 @@ object BuildingDescriptions {
|
||||
* @param replacementBuilding The "uniqueTo" Building
|
||||
*/
|
||||
fun getDifferences(
|
||||
ruleset: Ruleset, originalBuilding: Building, replacementBuilding: Building
|
||||
originalBuilding: Building, replacementBuilding: Building
|
||||
): Sequence<FormattedLine> = sequence {
|
||||
for ((key, value) in replacementBuilding)
|
||||
if (value != originalBuilding[key])
|
||||
|
@ -104,10 +104,11 @@ class ConstructionInfoTable(val cityScreen: CityScreen) : Table() {
|
||||
cityScreen.canChangeState &&
|
||||
(!cityScreen.city.hasSoldBuildingThisTurn || cityScreen.city.civ.gameInfo.gameParameters.godMode)
|
||||
sellBuildingButton.isEnabled = enableSell
|
||||
if (sellBuildingButton.isEnabled) sellBuildingButton.onClick(UncivSound.Coin) {
|
||||
sellBuildingButton.disable()
|
||||
sellBuildingClicked(construction, sellText)
|
||||
}
|
||||
if (enableSell)
|
||||
sellBuildingButton.onClick(UncivSound.Coin) {
|
||||
sellBuildingButton.disable()
|
||||
sellBuildingClicked(construction, sellText)
|
||||
}
|
||||
|
||||
if (cityScreen.city.hasSoldBuildingThisTurn && !cityScreen.city.civ.gameInfo.gameParameters.godMode
|
||||
|| cityScreen.city.isPuppet
|
||||
|
Reference in New Issue
Block a user