Avoid Civilopedia stumbling over missing Grassland (#10953)

* Avoid Civilopedia stumbling over missing Grassland

* A few wiki comments on Terrain

* Minor linting of my own crud

* Pedia linking PromotionPickerScreen

* Change actionTypeToFunctions signature to use Sequence
This commit is contained in:
SomeTroglodyte 2024-01-19 10:59:58 +01:00 committed by GitHub
parent bfaf049b6a
commit e5e86aa0d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 11 deletions

View File

@ -3,7 +3,6 @@ package com.unciv.ui.screens.civilopediascreen
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.ui.Container
import com.unciv.Constants
import com.unciv.logic.map.tile.Tile
import com.unciv.models.ruleset.Ruleset
import com.unciv.models.ruleset.tile.Terrain
@ -26,17 +25,17 @@ internal object CivilopediaImageGetters {
private fun terrainImage(terrain: Terrain, ruleset: Ruleset, imageSize: Float): Actor {
val tile = Tile()
tile.ruleset = ruleset
val baseTerrainFromOccursOn =
terrain.occursOn.mapNotNull { ruleset.terrains[it] }.lastOrNull { it.type.isBaseTerrain }?.name
?: ruleset.terrains.values.firstOrNull { it.type == TerrainType.Land }?.name
?: ruleset.terrains.keys.first()
when (terrain.type) {
TerrainType.NaturalWonder -> {
tile.naturalWonder = terrain.name
tile.baseTerrain = terrain.turnsInto ?: terrain.occursOn.firstOrNull() ?: Constants.grassland
tile.baseTerrain = terrain.turnsInto ?: baseTerrainFromOccursOn
}
TerrainType.TerrainFeature -> {
tile.baseTerrain =
if (terrain.occursOn.isEmpty() || terrain.occursOn.contains(Constants.grassland))
Constants.grassland
else
terrain.occursOn.lastOrNull()!!
tile.baseTerrain = baseTerrainFromOccursOn
tile.setTerrainTransients()
tile.addTerrainFeature(terrain.name)
}

View File

@ -229,9 +229,9 @@ class PolicyPickerScreen(
}
scrollPane.updateVisualScroll()
when(select) {
when (select) {
in branches -> branchToGroup[select]?.toggle()
in policyNameToButton -> policyNameToButton[select]!!.also { pickPolicy(it) }
in policyNameToButton -> pickPolicy(policyNameToButton[select]!!)
}
}

View File

@ -16,11 +16,15 @@ import com.unciv.models.translations.tr
import com.unciv.ui.audio.SoundPlayer
import com.unciv.ui.components.extensions.isEnabled
import com.unciv.ui.components.extensions.toTextButton
import com.unciv.ui.components.input.KeyboardBinding
import com.unciv.ui.components.input.keyShortcuts
import com.unciv.ui.components.input.onActivation
import com.unciv.ui.components.input.onClick
import com.unciv.ui.components.input.onDoubleClick
import com.unciv.ui.images.ImageGetter
import com.unciv.ui.screens.basescreen.BaseScreen
import com.unciv.ui.screens.basescreen.RecreateOnResize
import com.unciv.ui.screens.civilopediascreen.CivilopediaScreen
import kotlin.math.abs
class PromotionPickerScreen(
@ -324,6 +328,11 @@ class PromotionPickerScreen(
}
val promotionText = node.promotion.getDescription(tree.possiblePromotions)
descriptionLabel.setText("$topLine\n$promotionText")
descriptionLabel.clearListeners()
descriptionLabel.onActivation {
game.pushScreen(CivilopediaScreen(unit.baseUnit.ruleset, link = node.promotion.makeLink()))
}
descriptionLabel.keyShortcuts.add(KeyboardBinding.Civilopedia)
}
override fun recreate() = recreate(closeOnPick)

View File

@ -10,8 +10,8 @@ Each terrain entry has the following structure:
| Attribute | Type | Default | Notes |
| --------- | ---- | ------- | ----- |
| name | String | Required | |
| type | Enum | Required | Land, Water, TerrainFeature, NaturalWonder |
| name | String | Required | [^A] |
| type | Enum | Required | Land, Water, TerrainFeature, NaturalWonder [^B] |
| occursOn | List of Strings | none | Only for terrain features and Natural Wonders: The baseTerrain it can be placed on |
| turnsInto | String | none | Only for NaturalWonder: the base terrain is changed to this after placing the Natural Wonder |
| weight | Integer | 10 | Only for NaturalWonder: _relative_ weight of being picked by the map generator |
@ -25,6 +25,11 @@ Each terrain entry has the following structure:
| uniques | List of Strings | empty | List of [unique abilities](../uniques) this terrain has |
| civilopediaText | List | empty | See [civilopediaText chapter](5-Miscellaneous-JSON-files.md#civilopedia-text) |
[^A]: Some names have special meanings. `Grassland` is used as fallback in some cases - e.g. Civilopedia prefers to displays a TerrainFeature on top of it, unless `occursOn` is not empty and does not contain it.
`River` is hardcoded to be used to look up a [Stats](../uniques.md#global-uniques) unique to determine the bonuses an actual River provides (remember, rivers live on the edges not as terrain).
River should always be a TerrainFeature and have the same uniques the one in the vanilla rulesets has - if you change that, expect surprises.
[^B]: A base ruleset mod is always expected to provide at least one Land and at least one Water terrain. We do not support Land-only or Water-only mods, even if they might be possible to pull off.
## TileImprovements.json
[Link to original](https://github.com/yairm210/Unciv/blob/master/android/assets/jsons/Civ%20V%20-%20Vanilla/TileImprovements.json)