mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 13:55:54 -04:00
Crash reports contain the game version for easy filtering
Added helper function cityInfo.isWorked(tile)
This commit is contained in:
parent
6a73909c67
commit
22b3f563f3
@ -36,7 +36,7 @@ class CrashReportSenderAndroid(private val activity: Activity) : CrashReportSend
|
||||
private fun prepareIntent(report: CrashReport) = Intent(Intent.ACTION_SEND).apply {
|
||||
type = "message/rfc822"
|
||||
putExtra(Intent.EXTRA_EMAIL, arrayOf(EMAIL_TO))
|
||||
putExtra(Intent.EXTRA_SUBJECT, EMAIL_TITLE)
|
||||
putExtra(Intent.EXTRA_SUBJECT, "$EMAIL_TITLE - ${report.version}")
|
||||
putExtra(Intent.EXTRA_TEXT, buildEmailBody(report))
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ class CityExpansionManager {
|
||||
fun relinquishOwnership(tileInfo: TileInfo) {
|
||||
cityInfo.tiles = cityInfo.tiles.withoutItem(tileInfo.position)
|
||||
for (city in cityInfo.civInfo.cities) {
|
||||
if (city.workedTiles.contains(tileInfo.position)) {
|
||||
if (city.isWorked(tileInfo)) {
|
||||
city.workedTiles = city.workedTiles.withoutItem(tileInfo.position)
|
||||
city.population.autoAssignPopulation()
|
||||
}
|
||||
|
@ -158,6 +158,7 @@ class CityInfo {
|
||||
fun getCenterTile(): TileInfo = centerTileInfo
|
||||
fun getTiles(): Sequence<TileInfo> = tiles.asSequence().map { tileMap[it] }
|
||||
fun getWorkableTiles() = tilesInRange.asSequence().filter { it.getOwner() == civInfo }
|
||||
fun isWorked(tileInfo: TileInfo) = workedTiles.contains(tileInfo.position)
|
||||
|
||||
fun isCapital(): Boolean = cityConstructions.builtBuildings.contains(capitalCityIndicator())
|
||||
fun capitalCityIndicator(): String = getRuleset().buildings.values.first { it.uniques.contains("Indicates the capital city") }.name
|
||||
|
@ -39,7 +39,7 @@ class CityStats {
|
||||
private fun getStatsFromTiles(): Stats {
|
||||
val stats = Stats()
|
||||
for (cell in cityInfo.tilesInRange
|
||||
.filter { cityInfo.location == it.position || cityInfo.workedTiles.contains(it.position) })
|
||||
.filter { cityInfo.location == it.position || cityInfo.isWorked(it) })
|
||||
stats.add(cell.getTileStats(cityInfo, cityInfo.civInfo))
|
||||
return stats
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ class PopulationManager {
|
||||
|
||||
@Deprecated("As of 3.10.14, changed to Counter<String> to accommodate dynamic specialist types. Use specialistAllocations instead.")
|
||||
val specialists = Stats()
|
||||
|
||||
// In favor of this bad boy
|
||||
val specialistAllocations = Counter<String>()
|
||||
|
||||
@ -43,8 +44,8 @@ class PopulationManager {
|
||||
|
||||
fun getFoodToNextPopulation(): Int {
|
||||
// civ v math, civilization.wikia
|
||||
var foodRequired = 15 + 6 * (population - 1) + floor((population - 1).toDouble().pow(1.8))
|
||||
if(!cityInfo.civInfo.isPlayerCivilization())
|
||||
var foodRequired = 15 + 6 * (population - 1) + floor((population - 1).toDouble().pow(1.8))
|
||||
if (!cityInfo.civInfo.isPlayerCivilization())
|
||||
foodRequired *= cityInfo.civInfo.gameInfo.getDifficulty().aiCityGrowthModifier
|
||||
return foodRequired.toInt()
|
||||
}
|
||||
@ -54,7 +55,7 @@ class PopulationManager {
|
||||
fun nextTurn(food: Int) {
|
||||
foodStored += food
|
||||
if (food < 0)
|
||||
cityInfo.civInfo.addNotification("[" + cityInfo.name + "] is starving!", cityInfo.location, Color.RED)
|
||||
cityInfo.civInfo.addNotification("[${cityInfo.name}] is starving!", cityInfo.location, Color.RED)
|
||||
if (foodStored < 0) { // starvation!
|
||||
if (population > 1) population--
|
||||
foodStored = 0
|
||||
@ -67,11 +68,11 @@ class PopulationManager {
|
||||
foodStored += (getFoodToNextPopulation() * percentOfFoodCarriedOver / 100f).toInt()
|
||||
population++
|
||||
autoAssignPopulation()
|
||||
cityInfo.civInfo.addNotification("[" + cityInfo.name + "] has grown!", cityInfo.location, Color.GREEN)
|
||||
cityInfo.civInfo.addNotification("[${cityInfo.name}] has grown!", cityInfo.location, Color.GREEN)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun getStatsOfSpecialist(name:String) = cityInfo.cityStats.getStatsOfSpecialist(name)
|
||||
private fun getStatsOfSpecialist(name: String) = cityInfo.cityStats.getStatsOfSpecialist(name)
|
||||
|
||||
|
||||
// todo - change tile choice according to city!
|
||||
@ -89,7 +90,7 @@ class PopulationManager {
|
||||
else Automation.rankTileForCityWork(bestTile, cityInfo, foodWeight)
|
||||
|
||||
val bestJob: String? = getMaxSpecialists()
|
||||
.filter { specialistAllocations[it.key]!!<it.value }
|
||||
.filter { specialistAllocations[it.key]!! < it.value }
|
||||
.map { it.key }
|
||||
.maxBy { Automation.rankSpecialist(getStatsOfSpecialist(it), cityInfo) }
|
||||
|
||||
@ -109,9 +110,8 @@ class PopulationManager {
|
||||
|
||||
fun unassignExtraPopulation() {
|
||||
for (tile in cityInfo.workedTiles.map { cityInfo.tileMap[it] }) {
|
||||
if (tile.getOwner() != cityInfo.civInfo || tile.getWorkingCity() != cityInfo)
|
||||
cityInfo.workedTiles = cityInfo.workedTiles.withoutItem(tile.position)
|
||||
if (tile.aerialDistanceTo(cityInfo.getCenterTile()) > 3)
|
||||
if (tile.getOwner() != cityInfo.civInfo || tile.getWorkingCity() != cityInfo
|
||||
|| tile.aerialDistanceTo(cityInfo.getCenterTile()) > 3)
|
||||
cityInfo.workedTiles = cityInfo.workedTiles.withoutItem(tile.position)
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ class PopulationManager {
|
||||
val specialistsHashmap = specialistAllocations
|
||||
for ((specialistName, amount) in maxSpecialists)
|
||||
if (specialistsHashmap[specialistName]!! > amount)
|
||||
specialistAllocations[specialistName]=amount
|
||||
specialistAllocations[specialistName] = amount
|
||||
|
||||
|
||||
|
||||
@ -146,7 +146,6 @@ class PopulationManager {
|
||||
valueWorstSpecialist = Automation.rankSpecialist(getStatsOfSpecialist(worstJob), cityInfo)
|
||||
|
||||
|
||||
|
||||
//un-assign population
|
||||
if ((worstWorkedTile != null && valueWorstTile < valueWorstSpecialist)
|
||||
|| worstJob == null) {
|
||||
@ -162,5 +161,4 @@ class PopulationManager {
|
||||
counter.add(building.newSpecialists())
|
||||
return counter
|
||||
}
|
||||
|
||||
}
|
@ -164,7 +164,7 @@ open class TileInfo {
|
||||
fun getWorkingCity(): CityInfo? {
|
||||
val civInfo = getOwner()
|
||||
if (civInfo == null) return null
|
||||
return civInfo.cities.firstOrNull { it.workedTiles.contains(position) }
|
||||
return civInfo.cities.firstOrNull { it.isWorked(this) }
|
||||
}
|
||||
|
||||
fun isWorked(): Boolean {
|
||||
|
@ -54,11 +54,11 @@ class CityScreenTileTable(private val cityScreen: CityScreen): Table(){
|
||||
}
|
||||
|
||||
if(city.civInfo.cities.filterNot { it==city }
|
||||
.any { it.workedTiles.contains(selectedTile.position) }) {
|
||||
.any { it.isWorked(selectedTile) }) {
|
||||
innerTable.add("Worked by [${selectedTile.getWorkingCity()!!.name}]".toLabel()).row()
|
||||
}
|
||||
|
||||
if(city.workedTiles.contains(selectedTile.position)){
|
||||
if(city.isWorked(selectedTile)){
|
||||
if(selectedTile.isLocked()) {
|
||||
val unlockButton = "Unlock".toTextButton()
|
||||
unlockButton.onClick {
|
||||
|
Loading…
x
Reference in New Issue
Block a user