mirror of
https://github.com/yairm210/Unciv.git
synced 2024-12-22 17:14:24 +07:00
Fixed cities built on pillages roads colored red
Some checks failed
Docker / build (push) Failing after 1m50s
Build and test / Check code and run unit tests (push) Failing after 5m39s
Conflict marking / main (push) Failing after 5s
Detekt / detekt (ubuntu-latest) (push) Failing after 45s
Generate mkdocs from docs folder / deploy (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 20s
Some checks failed
Docker / build (push) Failing after 1m50s
Build and test / Check code and run unit tests (push) Failing after 5m39s
Conflict marking / main (push) Failing after 5s
Detekt / detekt (ubuntu-latest) (push) Failing after 45s
Generate mkdocs from docs folder / deploy (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 20s
This commit is contained in:
parent
f791b70997
commit
8519453d19
@ -5,7 +5,6 @@ import com.unciv.logic.city.CityConstructions
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomacyFlags
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomacyManager
|
||||
import com.unciv.logic.civilization.managers.TechManager
|
||||
import com.unciv.logic.map.tile.RoadStatus
|
||||
import com.unciv.models.ruleset.ModOptions
|
||||
import com.unciv.models.ruleset.PerpetualConstruction
|
||||
import com.unciv.models.ruleset.Ruleset
|
||||
@ -61,8 +60,7 @@ object BackwardCompatibility {
|
||||
if (!ruleset.tileImprovements.containsKey(Constants.repair))
|
||||
for (tile in tileMap.values) {
|
||||
if (tile.roadIsPillaged) {
|
||||
tile.roadStatus = RoadStatus.None
|
||||
tile.roadIsPillaged = false
|
||||
tile.removeRoad()
|
||||
}
|
||||
if (tile.improvementIsPillaged) {
|
||||
tile.improvement = null
|
||||
|
@ -91,7 +91,7 @@ class City : IsPartOfGameInfoSerialization, INamed {
|
||||
civ.gameInfo.getCities().filter { it != this && it.getCenterTile().isExplored(civ) && it.getCenterTile().aerialDistanceTo(getCenterTile()) <= 12 }.toList()
|
||||
}
|
||||
|
||||
var cityAIFocus: String = CityFocus.NoFocus.name
|
||||
private var cityAIFocus: String = CityFocus.NoFocus.name
|
||||
fun getCityFocus() = CityFocus.entries.firstOrNull { it.name == cityAIFocus } ?: CityFocus.NoFocus
|
||||
fun setCityFocus(cityFocus: CityFocus){ cityAIFocus = cityFocus.name }
|
||||
|
||||
@ -385,15 +385,12 @@ class City : IsPartOfGameInfoSerialization, INamed {
|
||||
CityConquestFunctions(this).moveToCiv(newCivInfo)
|
||||
|
||||
internal fun tryUpdateRoadStatus() {
|
||||
if (getCenterTile().roadStatus == RoadStatus.None) {
|
||||
val roadImprovement = getRuleset().roadImprovement
|
||||
if (roadImprovement != null && roadImprovement.techRequired in civ.tech.techsResearched)
|
||||
getCenterTile().roadStatus = RoadStatus.Road
|
||||
} else if (getCenterTile().roadStatus != RoadStatus.Railroad) {
|
||||
val railroadImprovement = getRuleset().railroadImprovement
|
||||
if (railroadImprovement != null && railroadImprovement.techRequired in civ.tech.techsResearched)
|
||||
getCenterTile().roadStatus = RoadStatus.Railroad
|
||||
val requiredRoad = when{
|
||||
getRuleset().railroadImprovement?.let { it.techRequired == null || it.techRequired in civ.tech.techsResearched } == true -> RoadStatus.Railroad
|
||||
getRuleset().roadImprovement?.let { it.techRequired == null || it.techRequired in civ.tech.techsResearched } == true -> RoadStatus.Road
|
||||
else -> RoadStatus.None
|
||||
}
|
||||
getCenterTile().setRoadStatus(requiredRoad, civ)
|
||||
}
|
||||
|
||||
fun getGoldForSellingBuilding(buildingName: String) =
|
||||
|
@ -80,6 +80,7 @@ class Tile : IsPartOfGameInfoSerialization, Json.Serializable {
|
||||
private val improvementQueue = ArrayList<ImprovementQueueEntry>(1)
|
||||
|
||||
var roadStatus = RoadStatus.None
|
||||
|
||||
var roadIsPillaged = false
|
||||
private var roadOwner: String = "" // either who last built the road or last owner of tile
|
||||
|
||||
@ -885,11 +886,16 @@ class Tile : IsPartOfGameInfoSerialization, Json.Serializable {
|
||||
fun setImprovement(improvementStr: String, civToHandleCompletion: Civilization? = null, unit: MapUnit? = null) =
|
||||
improvementFunctions.setImprovement(improvementStr, civToHandleCompletion, unit)
|
||||
|
||||
// function handling when adding a road to the tile
|
||||
fun addRoad(roadType: RoadStatus, creatingCivInfo: Civilization?) {
|
||||
roadStatus = roadType
|
||||
// function handling when removing a road from the tile
|
||||
fun removeRoad() = setRoadStatus(RoadStatus.None, null)
|
||||
|
||||
fun setRoadStatus(newRoadStatus: RoadStatus, creatingCivInfo: Civilization?) {
|
||||
roadStatus = newRoadStatus
|
||||
roadIsPillaged = false
|
||||
if (getOwner() != null) {
|
||||
|
||||
if (newRoadStatus == RoadStatus.None && owningCity == null)
|
||||
getRoadOwner()?.neutralRoads?.remove(this.position)
|
||||
else if (getOwner() != null) {
|
||||
roadOwner = getOwner()!!.civName
|
||||
} else if (creatingCivInfo != null) {
|
||||
roadOwner = creatingCivInfo.civName // neutral tile, use building unit
|
||||
@ -897,15 +903,6 @@ class Tile : IsPartOfGameInfoSerialization, Json.Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
// function handling when removing a road from the tile
|
||||
fun removeRoad() {
|
||||
roadIsPillaged = false
|
||||
if (roadStatus == RoadStatus.None) return
|
||||
roadStatus = RoadStatus.None
|
||||
if (owningCity == null)
|
||||
getRoadOwner()?.neutralRoads?.remove(this.position)
|
||||
}
|
||||
|
||||
fun startWorkingOnImprovement(improvement: TileImprovement, civInfo: Civilization, unit: MapUnit) {
|
||||
improvementQueue.clear()
|
||||
queueImprovement(improvement, civInfo, unit)
|
||||
|
@ -203,8 +203,8 @@ class TileImprovementFunctions(val tile: Tile) {
|
||||
improvementName?.startsWith(Constants.remove) == true -> {
|
||||
activateRemovalImprovement(improvementName, civToActivateBroaderEffects)
|
||||
}
|
||||
improvementName == RoadStatus.Road.name -> tile.addRoad(RoadStatus.Road, civToActivateBroaderEffects)
|
||||
improvementName == RoadStatus.Railroad.name -> tile.addRoad(RoadStatus.Railroad, civToActivateBroaderEffects)
|
||||
improvementName == RoadStatus.Road.name -> tile.setRoadStatus(RoadStatus.Road, civToActivateBroaderEffects)
|
||||
improvementName == RoadStatus.Railroad.name -> tile.setRoadStatus(RoadStatus.Railroad, civToActivateBroaderEffects)
|
||||
improvementName == Constants.repair -> tile.setRepaired()
|
||||
else -> {
|
||||
tile.improvementIsPillaged = false
|
||||
|
@ -8,7 +8,6 @@ import com.unciv.logic.civilization.NotificationCategory
|
||||
import com.unciv.logic.civilization.NotificationIcon
|
||||
import com.unciv.logic.map.mapgenerator.RiverGenerator
|
||||
import com.unciv.logic.map.mapgenerator.RiverGenerator.RiverDirections
|
||||
import com.unciv.logic.map.tile.RoadStatus
|
||||
import com.unciv.logic.map.tile.Tile
|
||||
import com.unciv.models.ruleset.tile.Terrain
|
||||
import com.unciv.models.ruleset.tile.TerrainType
|
||||
@ -42,7 +41,7 @@ internal class ConsoleTileCommands: ConsoleCommandNode {
|
||||
|
||||
"removeroad" to ConsoleAction("tile removeroad") { console, _ ->
|
||||
val selectedTile = console.getSelectedTile()
|
||||
selectedTile.roadStatus = RoadStatus.None
|
||||
selectedTile.removeRoad()
|
||||
//todo this covers many cases but not all - do we really need to loop over all civs?
|
||||
selectedTile.getOwner()?.cache?.updateCitiesConnectedToCapital()
|
||||
DevConsoleResponse.OK
|
||||
|
@ -224,7 +224,7 @@ class MapEditorEditImprovementsTab(
|
||||
val road = RoadStatus.entries.firstOrNull { r -> r.name == it }
|
||||
if (road != null)
|
||||
editTab.setBrush(it, "Improvement/$it", handlerType = BrushHandlerType.Road) { tile ->
|
||||
tile.roadStatus = if (tile.roadStatus == road) RoadStatus.None else road
|
||||
tile.setRoadStatus(if (tile.roadStatus == road) RoadStatus.None else road, null)
|
||||
}
|
||||
else
|
||||
editTab.setBrush(it, "Improvement/$it") { tile ->
|
||||
|
Loading…
Reference in New Issue
Block a user