Skip to content

Commit

Permalink
rename: changeImprovement -> setImprovement
Browse files Browse the repository at this point in the history
  • Loading branch information
yairm210 committed Jun 13, 2024
1 parent db85cee commit 4f436e9
Show file tree
Hide file tree
Showing 17 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class BarbarianManager : IsPartOfGameInfoSerialization {
} else
tile = viableTiles.random()

tile.changeImprovement(Constants.barbarianEncampment)
tile.setImprovement(Constants.barbarianEncampment)
val newCamp = Encampment(tile.position)
newCamp.gameInfo = gameInfo
encampments.add(newCamp)
Expand Down
2 changes: 1 addition & 1 deletion core/src/com/unciv/logic/city/City.kt
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ class City : IsPartOfGameInfoSerialization, INamed {
if (isCapital()) civ.moveCapitalToNextLargest(null)

civ.cities = civ.cities.toMutableList().apply { remove(this@City) }
getCenterTile().changeImprovement("City ruins")
getCenterTile().setImprovement("City ruins")

// Edge case! What if a water unit is in a city, and you raze the city?
// Well, the water unit has to return to the water!
Expand Down
2 changes: 1 addition & 1 deletion core/src/com/unciv/logic/city/CityConstructions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ class CityConstructions : IsPartOfGameInfoSerialization {
val tileForImprovement = getTileForImprovement(improvement.name) ?: return
tileForImprovement.stopWorkingOnImprovement() // clears mark
if (removeOnly) return
tileForImprovement.changeImprovement(improvement.name, city.civ)
tileForImprovement.setImprovement(improvement.name, city.civ)
// If bought the worldscreen will not have been marked to update, and the new improvement won't show until later...
GUI.setUpdateWorldOnNextRender()
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/com/unciv/logic/city/managers/CityFounder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CityFounder {
tile.removeTerrainFeature(terrainFeature)

if (civInfo.gameInfo.ruleset.tileImprovements.containsKey(Constants.cityCenter))
tile.changeImprovement(Constants.cityCenter, civInfo)
tile.setImprovement(Constants.cityCenter, civInfo)
tile.stopWorkingOnImprovement()

val ruleset = civInfo.gameInfo.ruleset
Expand Down
2 changes: 1 addition & 1 deletion core/src/com/unciv/logic/map/mapunit/UnitTurnManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class UnitTurnManager(val unit: MapUnit) {
UncivGame.Current.settings.addCompletedTutorialTask("Construct an improvement")

val improvementInProgress = tile.improvementInProgress ?: return
tile.changeImprovement(improvementInProgress, unit.civ, unit)
tile.setImprovement(improvementInProgress, unit.civ, unit)

tile.improvementInProgress = null
tile.getCity()?.updateCitizens = true
Expand Down
2 changes: 1 addition & 1 deletion core/src/com/unciv/logic/map/tile/Tile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ class Tile : IsPartOfGameInfoSerialization {
fun removeImprovement() =
improvementFunctions.changeImprovement(null)

fun changeImprovement(improvementStr: String, civToHandleCompletion: Civilization? = null, unit: MapUnit? = null) =
fun setImprovement(improvementStr: String, civToHandleCompletion: Civilization? = null, unit: MapUnit? = null) =
improvementFunctions.changeImprovement(improvementStr, civToHandleCompletion, unit)

// function handling when adding a road to the tile
Expand Down
2 changes: 1 addition & 1 deletion core/src/com/unciv/logic/map/tile/TileStatFunctions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class TileStatFunctions(val tile: Tile) {
val tileClone = tile.clone()
tileClone.setTerrainTransients()

tileClone.changeImprovement(improvement.name)
tileClone.setImprovement(improvement.name)
val futureStats = tileClone.stats.getTileStats(city, observingCiv, cityUniqueCache)

return futureStats.minus(currentStats)
Expand Down
2 changes: 1 addition & 1 deletion core/src/com/unciv/ui/popups/options/DebugTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ fun debugTab(
tile.resourceAmount = 999
// Debug option, so if it crashes on this that's relatively fine
// If this becomes a problem, check if such an improvement exists and otherwise plop down a great improvement or so
tile.changeImprovement(resource.getImprovements().first())
tile.setImprovement(resource.getImprovements().first())
}
curGameInfo.getCurrentPlayerCivilization().cache.updateSightAndResources()
GUI.setUpdateWorldOnNextRender()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ class CityStateDiplomacyTable(private val diplomacyScreen: DiplomacyScreen) {
improveTileButton.onClick {
viewingCiv.addGold(-200)
improvableTile.stopWorkingOnImprovement()
improvableTile.changeImprovement(tileImprovement.name)
improvableTile.setImprovement(tileImprovement.name)
otherCiv.cache.updateCivResources()
diplomacyScreen.rightSideTable.clear()
diplomacyScreen.rightSideTable.add(ScrollPane(getCityStateDiplomacyTable(otherCiv)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class MapEditorEditImprovementsTab(
}
else
editTab.setBrush(it, "Improvement/$it") { tile ->
tile.changeImprovement(it)
tile.setImprovement(it)
}
}).padTop(0f).row()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ object UnitActionsFromUniques {

return UnitAction(UnitActionType.CreateImprovement, 82f, "Create [$improvementName]",
action = {
tile.changeImprovement(improvementName, unit.civ, unit)
tile.setImprovement(improvementName, unit.civ, unit)
unit.destroy() // Modders may wish for a nondestructive way, but that should be another Unique
}.takeIf { unit.currentMovement > 0 })
}
Expand Down Expand Up @@ -287,7 +287,7 @@ object UnitActionsFromUniques {
),
action = {
val unitTile = unit.getTile()
unitTile.changeImprovement(improvement.name, unit.civ, unit)
unitTile.setImprovement(improvement.name, unit.civ, unit)

unit.civ.cache.updateViewableTiles() // to update 'last seen improvement'

Expand Down
2 changes: 1 addition & 1 deletion tests/src/com/unciv/logic/GameSerializationTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class GameSerializationTests {
val tile = unit.getTile()
unit.civ.addCity(tile.position)
if (tile.ruleset.tileImprovements.containsKey(Constants.cityCenter))
tile.changeImprovement(Constants.cityCenter)
tile.setImprovement(Constants.cityCenter)
unit.destroy()

// Ensure some diplomacy objects are instantiated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ internal class WorkerAutomationTest {

val currentTile = testGame.tileMap[1,1] // owned by city
currentTile.resource = "Iron" // This tile also has a resource needs to be enabled by a building a Mine
currentTile.changeImprovement("Mine")
currentTile.setImprovement("Mine")
currentTile.setPillaged()

val mapUnit = testGame.addUnit("Worker", civInfo, currentTile)
Expand Down
2 changes: 1 addition & 1 deletion tests/src/com/unciv/logic/civilization/CityMovingTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class CityMovingTests {
val resourceTile = testGame.tileMap[0,1]
resourceTile.resource = "Iron"
resourceTile.resourceAmount = 3
resourceTile.changeImprovement("Mine")
resourceTile.setImprovement("Mine")
theirCapital.expansion.takeOwnership(resourceTile)

theirCapital.moveToCiv(civInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ class TileImprovementConstructionTests {
tile.addTerrainFeature("Forest")
Assert.assertEquals(tile.terrainFeatures, listOf("Hill", "Forest"))

tile.changeImprovement("Landmark")
tile.setImprovement("Landmark")
Assert.assertEquals(tile.terrainFeatures, listOf("Hill"))
}

@Test
fun citadelTakesOverAdjacentTiles() {
val tile = tileMap[1,1]
Assert.assertFalse(tile.neighbors.all { it.owningCity == city })
tile.changeImprovement("Citadel", civInfo)
tile.setImprovement("Citadel", civInfo)
Assert.assertTrue(tile.neighbors.all { it.owningCity == city })
}

Expand Down Expand Up @@ -228,7 +228,7 @@ class TileImprovementConstructionTests {
allowedImprovement.terrainsCanBeBuiltOn += "Forest"
Assert.assertTrue("Forest should allow building when allowed",
tile.improvementFunctions.canBuildImprovement(allowedImprovement, civInfo))
tile.changeImprovement(allowedImprovement.name)
tile.setImprovement(allowedImprovement.name)
Assert.assertTrue(tile.improvement == allowedImprovement.name)
Assert.assertTrue("Forest should not be removed with this improvement", tile.terrainFeatures.contains("Forest"))
}
Expand All @@ -241,7 +241,7 @@ class TileImprovementConstructionTests {

val improvement = testGame.createTileImprovement("Does not need removal of [Forest]")
Assert.assertTrue(tile.improvementFunctions.canBuildImprovement(improvement, civInfo))
tile.changeImprovement(improvement.name)
tile.setImprovement(improvement.name)
Assert.assertTrue(tile.improvement == improvement.name)
Assert.assertTrue("Forest should not be removed with this improvement", tile.terrainFeatures.contains("Forest"))
}
Expand Down
4 changes: 2 additions & 2 deletions tests/src/com/unciv/uniques/GlobalUniquesTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class GlobalUniquesTests {
city.cityConstructions.addBuilding(faithBuilding)

val tile2 = game.setTileTerrain(Vector2(0f,1f), Constants.grassland)
tile2.changeImprovement("Farm")
tile2.setImprovement("Farm")
Assert.assertTrue(tile2.stats.getTileStats(city, civInfo).faith == 9f)

city.cityConstructions.addBuilding(emptyBuilding)
Expand All @@ -334,7 +334,7 @@ class GlobalUniquesTests {
city.cityConstructions.addBuilding(faithBuilding)

val tile2 = game.setTileTerrain(Vector2(0f,1f), Constants.grassland)
tile2.changeImprovement("Farm")
tile2.setImprovement("Farm")
Assert.assertTrue(tile2.stats.getTileStats(city, civInfo).faith == 9f)

city.cityConstructions.addBuilding(emptyBuilding)
Expand Down
2 changes: 1 addition & 1 deletion tests/src/com/unciv/uniques/TileUniquesTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TileUniquesTests {
civInfo.addGold(-civInfo.gold) // reset gold just to be sure

val testImprovement = game.createTileImprovement("Pillaging this improvement yields [+20 Gold, +11 Food]")
tile.changeImprovement(testImprovement.name)
tile.setImprovement(testImprovement.name)
val unit = game.addUnit("Warrior", civInfo, tile)
unit.currentMovement = 2f

Expand Down

0 comments on commit 4f436e9

Please sign in to comment.