Skip to content

Commit

Permalink
chore: Delete dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
yairm210 committed Oct 6, 2024
1 parent 034c081 commit 7fbd8a1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 47 deletions.
1 change: 0 additions & 1 deletion core/src/com/unciv/logic/city/managers/CityFounder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class CityFounder {
city.expansion.reset()

city.tryUpdateRoadStatus()
// civInfo.cache.updateCitiesConnectedToCapital() // Carthage cities can connect immediately

val tile = city.getCenterTile()
for (terrainFeature in tile.terrainFeatures.filter {
Expand Down
46 changes: 0 additions & 46 deletions core/src/com/unciv/logic/map/tile/TileImprovementFunctions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.unciv.logic.civilization.Civilization
import com.unciv.logic.civilization.LocationAction
import com.unciv.logic.civilization.NotificationCategory
import com.unciv.logic.civilization.NotificationIcon
import com.unciv.logic.civilization.diplomacy.DiplomaticModifiers
import com.unciv.logic.map.mapunit.MapUnit
import com.unciv.models.ruleset.tile.TileImprovement
import com.unciv.models.ruleset.unique.StateForConditionals
Expand Down Expand Up @@ -317,51 +316,6 @@ class TileImprovementFunctions(val tile: Tile) {
}
}

private fun takeOverTilesAround(civ: Civilization, tile: Tile) {
// This method should only be called for a citadel - therefore one of the neighbour tile
// must belong to unit's civ, so minByOrNull in the nearestCity formula should be never `null`.
// That is, unless a mod does not specify the proper unique - then fallbackNearestCity will take over.

fun priority(tile: Tile): Int { // helper calculates priority (lower is better): distance plus razing malus
val city = tile.getCity()!! // !! assertion is guaranteed by the outer filter selector.
return city.getCenterTile().aerialDistanceTo(tile) +
(if (city.isBeingRazed) 5 else 0)
}
fun fallbackNearestCity(civ: Civilization, tile: Tile) =
civ.cities.minByOrNull {
it.getCenterTile().aerialDistanceTo(tile) +
(if (it.isBeingRazed) 5 else 0)
}!!

// In the rare case more than one city owns tiles neighboring the citadel
// this will prioritize the nearest one not being razed
val nearestCity = tile.neighbors
.filter { it.getOwner() == civ }
.minByOrNull { priority(it) }?.getCity()
?: fallbackNearestCity(civ, tile)

// capture all tiles which do not belong to unit's civ and are not enemy cities
// we use getTilesInDistance here, not neighbours to include the current tile as well
val tilesToTakeOver = tile.getTilesInDistance(1)
.filter { !it.isCityCenter() && it.getOwner() != civ }

val civsToNotify = mutableSetOf<Civilization>()
for (tileToTakeOver in tilesToTakeOver) {
val otherCiv = tileToTakeOver.getOwner()
if (otherCiv != null) {
// decrease relations for -10 pt/tile
otherCiv.getDiplomacyManagerOrMeet(civ).addModifier(DiplomaticModifiers.StealingTerritory, -10f)
civsToNotify.add(otherCiv)
}
nearestCity.expansion.takeOwnership(tileToTakeOver)
}

for (otherCiv in civsToNotify)
otherCiv.addNotification("Your territory has been stolen by [$civ]!",
tile.position, NotificationCategory.Cities, civ.civName, NotificationIcon.War)
}



/** Marks tile as target tile for a building with a [UniqueType.CreatesOneImprovement] unique */
fun markForCreatesOneImprovement(improvement: String) {
Expand Down

0 comments on commit 7fbd8a1

Please sign in to comment.