Resolved #3289 - can place unbuildable improvements that can exist on tiles

This commit is contained in:
Yair Morgenstern 2020-12-09 22:46:15 +02:00
parent f57955c8d5
commit c1a717e4f8
3 changed files with 74 additions and 71 deletions

View File

@ -299,7 +299,7 @@ open class TileInfo {
}
}
/** Without regards to what civinfo it is, a lot of the checks are ust for the improvement on the tile.
/** Without regards to what civinfo it is, a lot of the checks are just for the improvement on the tile.
* Doubles as a check for the map editor.
*/
fun canImprovementBeBuiltHere(improvement: TileImprovement, resourceIsVisible:Boolean = resource!=null): Boolean {

View File

@ -250,8 +250,12 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
it.airUnits.add(unit)
if (!it.isCityCenter()) unit.isTransported = true // if not city - air unit enters carrier
}
unit.type.isCivilian() -> { it.civilianUnit = unit }
else -> { it.militaryUnit = unit }
unit.type.isCivilian() -> {
it.civilianUnit = unit
}
else -> {
it.militaryUnit = unit
}
}
unit.currentTile = it // needed for unit icon - unit needs to know if it's embarked or not...
}
@ -274,7 +278,8 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
nationImage.onClick {
currentNation = nation;
currentPlayer = getPlayerIndexString(player)
setUnitTileAction() }
setUnitTileAction()
}
}
// barbarians icon
@ -518,7 +523,10 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
}
val improvement = tileInfo.getTileImprovement()!!
tileInfo.improvement = null // Unset, and check if it can be reset. If so, do it, if not, invalid.
if (tileInfo.canImprovementBeBuiltHere(improvement))
if (tileInfo.canImprovementBeBuiltHere(improvement)
// Allow building 'other' improvements like city ruins, barb encampments, Great Improvements etc
|| (improvement.terrainsCanBeBuiltOn.isEmpty() && ruleset.tileResources.values.none { it.improvement==improvement.name }
&& !tileInfo.isImpassible() && tileInfo.isLand))
tileInfo.improvement = improvement.name
}

View File

@ -85,9 +85,4 @@ class BasicTests {
Assert.assertTrue(modCheck == "")
}
// @Test // This should NOT run as part of the test suite!
// fun tryGetGithubTopicInfo(){
// println(Github.tryGetGithubReposWithTopic())
// }
}