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