Resolved #2588 - instead of tile ownershp being transferrable between cities, cities can now work tiles belonging to other cities.

This commit is contained in:
Yair Morgenstern 2020-05-06 23:37:02 +03:00
parent e0406ac708
commit 0eb79fff82
5 changed files with 22 additions and 36 deletions

View file

@ -1 +0,0 @@
{checkForDueUnits:false,tutorialsShown:[Injured_Units,Roads_and_Railroads,Happiness,Enemy_City,Golden_Age,_OtherCivEncountered,Strategic_Resource,Siege_Units,City_Expansion,Apollo_Program,Embarking,Tile_Clicked,Culture_and_Policies,_EnemyCityNeedsConqueringWithMeleeUnit,Introduction,Workers,Luxury_Resource,_BarbarianEncountered,_Slow_Start,Cities,Slow_Start,Unhappiness,Contact_Me],tutorialTasksCompleted:[See your stats breakdown,Found city,Enter city screen,Open the options table,Create a trade route,Conquer a city,Pick construction,Move an air unit,Pick technology,Move unit,Meet another civilization,Reassign worked tiles,Pass a turn,Construct an improvement],soundEffectsVolume:0,musicVolume:0,showTutorials:false,showPixelUnits:true,userId:b4565c3f-c349-446e-a013-909b6e73fb89,windowState:{width:1920,height:986}}

View file

@ -528,18 +528,6 @@ class CityInfo {
tryUpdateRoadStatus()
}
// Acquiring in this context means transferring ownership to another city of the same civ
fun canAcquireTile(newTileInfo: TileInfo): Boolean {
val owningCity = newTileInfo.getCity()
if (owningCity!=null && owningCity!=this
&& newTileInfo.getOwner()!!.isCurrentPlayer()
&& newTileInfo.aerialDistanceTo(getCenterTile()) <= 3
&& newTileInfo.neighbors.any{it.getCity()==this}) {
return true
}
return false
}
private fun tryUpdateRoadStatus(){
if(getCenterTile().roadStatus==RoadStatus.None){
val roadImprovement = getRuleset().tileImprovements["Road"]

View file

@ -2,12 +2,10 @@ package com.unciv.ui.cityscreen
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
import com.unciv.UncivGame
import com.unciv.logic.map.TileInfo
import com.unciv.models.UncivSound
import com.unciv.models.stats.Stats
import com.unciv.models.translations.tr
import com.unciv.ui.utils.*
import kotlin.math.roundToInt
@ -52,13 +50,10 @@ class CityScreenTileTable(val cityScreen: CityScreen): Table(){
innerTable.add(buyTileButton).row()
innerTable.add("You have [${city.civInfo.gold}] gold".toLabel(Color.YELLOW, 16)).padTop(2f)
}
if(city.canAcquireTile(selectedTile)) {
val acquireTileButton = "Acquire".toTextButton()
acquireTileButton.onClick {
city.expansion.takeOwnership(selectedTile)
UncivGame.Current.setScreen(CityScreen(city))
}
innerTable.add(acquireTileButton).row()
if(city.civInfo.cities.filterNot { it==city }
.any { it.workedTiles.contains(selectedTile.position) }) {
innerTable.add("Worked by [${selectedTile.getCity()!!.name}]".toLabel()).row()
}
if(city.workedTiles.contains(selectedTile.position)){

View file

@ -30,11 +30,9 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo, tileSetStrin
// this needs to happen on update, because we can buy tiles, which changes the definition of the bought tiles...
when {
tileInfo.getCity()!=city -> { // outside of city
tileInfo.getOwner()!=city.civInfo -> { // outside of civ boundary
baseLayerGroup.color.a = 0.3f
yieldGroup.isVisible = false
if (city.canAcquireTile(tileInfo))
icons.addPopulationIcon(ImageGetter.getStatIcon("Acquire"))
}
tileInfo !in city.tilesInRange -> { // within city but not close enough to be workable
@ -42,6 +40,12 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo, tileSetStrin
baseLayerGroup.color.a = 0.5f
}
city.civInfo.cities.filterNot { it==city } // worked by another city
.any { it.workedTiles.contains(tileInfo.position) } -> {
// Don't fade out, but don't add a population icon either.
}
tileInfo.isLocked() -> {
icons.addPopulationIcon(ImageGetter.getImage("OtherIcons/Lock"))
}
@ -70,7 +74,7 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo, tileSetStrin
yieldGroup.centerX(this)
yieldGroup.y= height * 0.25f - yieldGroup.height / 2
if (tileInfo.isWorked() || city.canAcquireTile(tileInfo)) {
if (tileInfo.isWorked()) {
yieldGroup.color = Color.WHITE
}
else if(!tileInfo.isCityCenter()){
@ -85,7 +89,7 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo, tileSetStrin
populationIcon.setPosition(width / 2 - populationIcon.width / 2,
height * 0.85f - populationIcon.height / 2)
if (tileInfo.isWorked() || city.canAcquireTile(tileInfo)) {
if (tileInfo.isWorked()) {
populationIcon.color = Color.WHITE
}
else if(!tileInfo.isCityCenter()){

View file

@ -241,21 +241,21 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
val identifier = tileBaseImageLocations.joinToString(";")
if (identifier == tileImagesIdentifier) return
for(image in tileBaseImages) image.remove()
for (image in tileBaseImages) image.remove()
tileBaseImages.clear()
for(location in tileBaseImageLocations.reversed()) { // reversed because we send each one to back
for (location in tileBaseImageLocations.reversed()) { // reversed because we send each one to back
// Here we check what actual tiles exist, and pick one - not at random, but based on the tile location,
// so it stays consistent throughout the game
val existingImages = ArrayList<String>()
existingImages.add(location)
var i=2
while (true){
val tileVariant = location+i
if(ImageGetter.imageExists(location+i)) existingImages.add(tileVariant)
var i = 2
while (true) {
val tileVariant = location + i
if (ImageGetter.imageExists(tileVariant)) existingImages.add(tileVariant)
else break
i+=1
i += 1
}
val finalLocation = existingImages.random(Random(tileInfo.position.hashCode()+location.hashCode()))
val finalLocation = existingImages.random(Random(tileInfo.position.hashCode() + location.hashCode()))
val image = ImageGetter.getImage(finalLocation)
tileBaseImages.add(image)
@ -268,7 +268,7 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
fun showMilitaryUnit(viewingCiv: CivilizationInfo) = showEntireMap
|| viewingCiv.viewableInvisibleUnitsTiles.contains(tileInfo)
|| (!tileInfo.hasEnemySubmarine(viewingCiv))
|| !tileInfo.hasEnemySubmarine(viewingCiv)
fun isViewable(viewingCiv: CivilizationInfo) = showEntireMap
|| viewingCiv.viewableTiles.contains(tileInfo)