mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 15:27:50 +07:00
Minor improvements
This commit is contained in:
@ -714,7 +714,7 @@ class CityInfo {
|
||||
}
|
||||
|
||||
|
||||
fun getNeighbouringCivs(): List<String> {
|
||||
fun getNeighbouringCivs(): Set<String> {
|
||||
val tilesList: HashSet<TileInfo> = getTiles().toHashSet()
|
||||
val cityPositionList: ArrayList<TileInfo> = arrayListOf()
|
||||
|
||||
@ -726,12 +726,8 @@ class CityInfo {
|
||||
return cityPositionList
|
||||
.asSequence()
|
||||
.mapNotNull { it.getOwner()?.civName }
|
||||
.distinct()
|
||||
.toList()
|
||||
.toSet()
|
||||
}
|
||||
|
||||
fun getImprovableTiles(): Sequence<TileInfo> = getTiles()
|
||||
.filter { it.hasViewableResource(civInfo) && it.improvement == null }
|
||||
|
||||
//endregion
|
||||
}
|
@ -163,15 +163,14 @@ class TradeEvaluation {
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun surroundedByOurCities(city: CityInfo, civInfo: CivilizationInfo): Int{
|
||||
val borderingCivs: List<String> = city.getNeighbouringCivs()
|
||||
if (borderingCivs.size == 1 && borderingCivs.contains(civInfo.civName)){
|
||||
return 10*civInfo.getEraNumber() // if the city is surrounded only by trading civ
|
||||
private fun surroundedByOurCities(city: CityInfo, civInfo: CivilizationInfo): Int {
|
||||
val borderingCivs: Set<String> = city.getNeighbouringCivs()
|
||||
if (borderingCivs.size == 1 && borderingCivs.contains(civInfo.civName)) {
|
||||
return 10 * civInfo.getEraNumber() // if the city is surrounded only by trading civ
|
||||
}
|
||||
if (borderingCivs.contains(civInfo.civName))
|
||||
return 2*civInfo.getEraNumber() // if the city has a border with trading civ
|
||||
return 2 * civInfo.getEraNumber() // if the city has a border with trading civ
|
||||
return 0
|
||||
|
||||
}
|
||||
|
||||
private fun evaluateSellCost(offer: TradeOffer, civInfo: CivilizationInfo, tradePartner: CivilizationInfo): Int {
|
||||
|
@ -328,13 +328,12 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
|
||||
otherCivDiplomacyManager: DiplomacyManager
|
||||
): TextButton? {
|
||||
if (otherCiv.cities.isEmpty()) return null
|
||||
val improvableTiles = otherCiv.getCapital().getImprovableTiles()
|
||||
.filterNot { it.getTileResource().resourceType == ResourceType.Bonus }.toList()
|
||||
val improvableResourceTiles = getImprovableResourceTiles(otherCiv)
|
||||
val improvements =
|
||||
otherCiv.gameInfo.ruleSet.tileImprovements.filter { it.value.turnsToBuild != 0 }
|
||||
var needsImprovements = false
|
||||
|
||||
for (improvableTile in improvableTiles)
|
||||
for (improvableTile in improvableResourceTiles)
|
||||
for (tileImprovement in improvements.values)
|
||||
if (improvableTile.canBuildImprovement(
|
||||
tileImprovement,
|
||||
@ -401,16 +400,19 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
|
||||
return diplomacyTable
|
||||
}
|
||||
|
||||
fun getImprovableResourceTiles(otherCiv:CivilizationInfo) = otherCiv.getCapital().getTiles()
|
||||
.filter { it.hasViewableResource(otherCiv) && it.improvement == null
|
||||
&& it.getTileResource().resourceType!=ResourceType.Bonus }
|
||||
|
||||
private fun getImprovementGiftTable(otherCiv: CivilizationInfo): Table {
|
||||
val improvementGiftTable = getCityStateDiplomacyTableHeader(otherCiv)
|
||||
improvementGiftTable.addSeparator()
|
||||
|
||||
val improvableTiles = otherCiv.getCapital().getImprovableTiles()
|
||||
.filterNot { it.getTileResource().resourceType == ResourceType.Bonus }.toList()
|
||||
val improvableResourceTiles = getImprovableResourceTiles(otherCiv)
|
||||
val tileImprovements =
|
||||
otherCiv.gameInfo.ruleSet.tileImprovements.filter { it.value.turnsToBuild != 0 }
|
||||
|
||||
for (improvableTile in improvableTiles) {
|
||||
for (improvableTile in improvableResourceTiles) {
|
||||
for (tileImprovement in tileImprovements.values) {
|
||||
if (improvableTile.canBuildImprovement(tileImprovement, otherCiv) &&
|
||||
improvableTile.getTileResource().improvement == tileImprovement.name
|
||||
|
Reference in New Issue
Block a user