mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 14:24:43 -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 {
|
private fun prepareIntent(report: CrashReport) = Intent(Intent.ACTION_SEND).apply {
|
||||||
type = "message/rfc822"
|
type = "message/rfc822"
|
||||||
putExtra(Intent.EXTRA_EMAIL, arrayOf(EMAIL_TO))
|
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))
|
putExtra(Intent.EXTRA_TEXT, buildEmailBody(report))
|
||||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ class CityExpansionManager {
|
|||||||
fun relinquishOwnership(tileInfo: TileInfo) {
|
fun relinquishOwnership(tileInfo: TileInfo) {
|
||||||
cityInfo.tiles = cityInfo.tiles.withoutItem(tileInfo.position)
|
cityInfo.tiles = cityInfo.tiles.withoutItem(tileInfo.position)
|
||||||
for (city in cityInfo.civInfo.cities) {
|
for (city in cityInfo.civInfo.cities) {
|
||||||
if (city.workedTiles.contains(tileInfo.position)) {
|
if (city.isWorked(tileInfo)) {
|
||||||
city.workedTiles = city.workedTiles.withoutItem(tileInfo.position)
|
city.workedTiles = city.workedTiles.withoutItem(tileInfo.position)
|
||||||
city.population.autoAssignPopulation()
|
city.population.autoAssignPopulation()
|
||||||
}
|
}
|
||||||
|
@ -158,6 +158,7 @@ class CityInfo {
|
|||||||
fun getCenterTile(): TileInfo = centerTileInfo
|
fun getCenterTile(): TileInfo = centerTileInfo
|
||||||
fun getTiles(): Sequence<TileInfo> = tiles.asSequence().map { tileMap[it] }
|
fun getTiles(): Sequence<TileInfo> = tiles.asSequence().map { tileMap[it] }
|
||||||
fun getWorkableTiles() = tilesInRange.asSequence().filter { it.getOwner() == civInfo }
|
fun getWorkableTiles() = tilesInRange.asSequence().filter { it.getOwner() == civInfo }
|
||||||
|
fun isWorked(tileInfo: TileInfo) = workedTiles.contains(tileInfo.position)
|
||||||
|
|
||||||
fun isCapital(): Boolean = cityConstructions.builtBuildings.contains(capitalCityIndicator())
|
fun isCapital(): Boolean = cityConstructions.builtBuildings.contains(capitalCityIndicator())
|
||||||
fun capitalCityIndicator(): String = getRuleset().buildings.values.first { it.uniques.contains("Indicates the capital city") }.name
|
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 {
|
private fun getStatsFromTiles(): Stats {
|
||||||
val stats = Stats()
|
val stats = Stats()
|
||||||
for (cell in cityInfo.tilesInRange
|
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))
|
stats.add(cell.getTileStats(cityInfo, cityInfo.civInfo))
|
||||||
return stats
|
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.")
|
@Deprecated("As of 3.10.14, changed to Counter<String> to accommodate dynamic specialist types. Use specialistAllocations instead.")
|
||||||
val specialists = Stats()
|
val specialists = Stats()
|
||||||
|
|
||||||
// In favor of this bad boy
|
// In favor of this bad boy
|
||||||
val specialistAllocations = Counter<String>()
|
val specialistAllocations = Counter<String>()
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ class PopulationManager {
|
|||||||
fun nextTurn(food: Int) {
|
fun nextTurn(food: Int) {
|
||||||
foodStored += food
|
foodStored += food
|
||||||
if (food < 0)
|
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 (foodStored < 0) { // starvation!
|
||||||
if (population > 1) population--
|
if (population > 1) population--
|
||||||
foodStored = 0
|
foodStored = 0
|
||||||
@ -67,11 +68,11 @@ class PopulationManager {
|
|||||||
foodStored += (getFoodToNextPopulation() * percentOfFoodCarriedOver / 100f).toInt()
|
foodStored += (getFoodToNextPopulation() * percentOfFoodCarriedOver / 100f).toInt()
|
||||||
population++
|
population++
|
||||||
autoAssignPopulation()
|
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!
|
// todo - change tile choice according to city!
|
||||||
@ -109,9 +110,8 @@ class PopulationManager {
|
|||||||
|
|
||||||
fun unassignExtraPopulation() {
|
fun unassignExtraPopulation() {
|
||||||
for (tile in cityInfo.workedTiles.map { cityInfo.tileMap[it] }) {
|
for (tile in cityInfo.workedTiles.map { cityInfo.tileMap[it] }) {
|
||||||
if (tile.getOwner() != cityInfo.civInfo || tile.getWorkingCity() != cityInfo)
|
if (tile.getOwner() != cityInfo.civInfo || tile.getWorkingCity() != cityInfo
|
||||||
cityInfo.workedTiles = cityInfo.workedTiles.withoutItem(tile.position)
|
|| tile.aerialDistanceTo(cityInfo.getCenterTile()) > 3)
|
||||||
if (tile.aerialDistanceTo(cityInfo.getCenterTile()) > 3)
|
|
||||||
cityInfo.workedTiles = cityInfo.workedTiles.withoutItem(tile.position)
|
cityInfo.workedTiles = cityInfo.workedTiles.withoutItem(tile.position)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +146,6 @@ class PopulationManager {
|
|||||||
valueWorstSpecialist = Automation.rankSpecialist(getStatsOfSpecialist(worstJob), cityInfo)
|
valueWorstSpecialist = Automation.rankSpecialist(getStatsOfSpecialist(worstJob), cityInfo)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//un-assign population
|
//un-assign population
|
||||||
if ((worstWorkedTile != null && valueWorstTile < valueWorstSpecialist)
|
if ((worstWorkedTile != null && valueWorstTile < valueWorstSpecialist)
|
||||||
|| worstJob == null) {
|
|| worstJob == null) {
|
||||||
@ -162,5 +161,4 @@ class PopulationManager {
|
|||||||
counter.add(building.newSpecialists())
|
counter.add(building.newSpecialists())
|
||||||
return counter
|
return counter
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -164,7 +164,7 @@ open class TileInfo {
|
|||||||
fun getWorkingCity(): CityInfo? {
|
fun getWorkingCity(): CityInfo? {
|
||||||
val civInfo = getOwner()
|
val civInfo = getOwner()
|
||||||
if (civInfo == null) return null
|
if (civInfo == null) return null
|
||||||
return civInfo.cities.firstOrNull { it.workedTiles.contains(position) }
|
return civInfo.cities.firstOrNull { it.isWorked(this) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isWorked(): Boolean {
|
fun isWorked(): Boolean {
|
||||||
|
@ -54,11 +54,11 @@ class CityScreenTileTable(private val cityScreen: CityScreen): Table(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(city.civInfo.cities.filterNot { it==city }
|
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()
|
innerTable.add("Worked by [${selectedTile.getWorkingCity()!!.name}]".toLabel()).row()
|
||||||
}
|
}
|
||||||
|
|
||||||
if(city.workedTiles.contains(selectedTile.position)){
|
if(city.isWorked(selectedTile)){
|
||||||
if(selectedTile.isLocked()) {
|
if(selectedTile.isLocked()) {
|
||||||
val unlockButton = "Unlock".toTextButton()
|
val unlockButton = "Unlock".toTextButton()
|
||||||
unlockButton.onClick {
|
unlockButton.onClick {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user