chore: Use new tech.isRevealed(resource) in other places

This commit is contained in:
yairm210 2024-10-25 13:11:24 +03:00
parent add48125c7
commit fa658e1bd0
5 changed files with 8 additions and 10 deletions

View File

@ -770,7 +770,7 @@ class QuestManager : IsPartOfGameInfoSerialization {
val resourcesOnMap = civ.gameInfo.tileMap.values.asSequence().mapNotNull { it.resource }.distinct()
val viewableResourcesForChallenger = resourcesOnMap.map { ruleset.tileResources[it]!! }
.filter { it.revealedBy == null || challenger.tech.isResearched(it.revealedBy!!) }
.filter { challenger.tech.isRevealed(it) }
val notOwnedResources = viewableResourcesForChallenger.filter {
it.resourceType != ResourceType.Bonus &&

View File

@ -531,13 +531,12 @@ class Tile : IsPartOfGameInfoSerialization, Json.Serializable {
fun isCoastalTile() = _isCoastalTile
fun hasViewableResource(civInfo: Civilization): Boolean =
resource != null && (tileResource.revealedBy == null || civInfo.tech.isResearched(
tileResource.revealedBy!!))
resource != null && civInfo.tech.isRevealed(tileResource)
fun getViewableTilesList(distance: Int): List<Tile> = tileMap.getViewableTiles(position, distance)
fun getTilesInDistance(distance: Int): Sequence<Tile> = tileMap.getTilesInDistance(position, distance)
fun getTilesInDistanceRange(range: IntRange): Sequence<Tile> = tileMap.getTilesInDistanceRange(position, range)
fun getTilesAtDistance(distance: Int): Sequence<Tile> =tileMap.getTilesAtDistance(position, distance)
fun getTilesAtDistance(distance: Int): Sequence<Tile> = tileMap.getTilesAtDistance(position, distance)
fun getDefensiveBonus(includeImprovementBonus: Boolean = true): Float {
var bonus = baseTerrainObject.defenceBonus

View File

@ -122,7 +122,7 @@ class ResourcesOverviewTab(
TradeOffer("Trade offer","Trade offer", "Resources we're offering in trades")
;
companion object {
fun safeValueOf(name: String) = values().firstOrNull { it.name == name }
fun safeValueOf(name: String) = entries.firstOrNull { it.name == name }
}
}
private val fixedContent = Table()
@ -284,7 +284,7 @@ class ResourcesOverviewTab(
/** Show unlocked **strategic** resources even if you have no access at all */
for (resource in viewingPlayer.gameInfo.ruleset.tileResources.values) {
if (resource.resourceType != ResourceType.Strategic) continue
if (resource.revealedBy == null || viewingPlayer.tech.isResearched(resource.revealedBy!!))
if (viewingPlayer.tech.isRevealed(resource))
newResourceSupplyList.add(resource, "No source", 0)
}

View File

@ -97,8 +97,7 @@ internal class WorldScreenTopBarResources(topbar: WorldScreenTopBar) : ScalingTa
val amount = civResources[resource.name] ?: 0
if (resource.revealedBy != null && !civInfo.tech.isResearched(resource.revealedBy!!)
&& amount == 0) // You can trade for resources you cannot process yourself yet
if (!civInfo.tech.isRevealed(resource) && amount == 0) // You cannot trade for resources you cannot process yourself yet
continue
resourcesWrapper.add(icon).padLeft(if (index == 0) 0f else extraPadBetweenResources)

View File

@ -91,9 +91,9 @@ internal object ImagePacker {
var innerException = ex
while (innerException.cause != null && innerException.cause !== innerException) innerException = innerException.cause!!
if (innerException === ex)
Log.error("Exception in ImagePacker: %s", ex.message)
Log.error("Exception in ImagePacker for mod ${mod.name}: ${ex.message}")
else
Log.error("Exception in ImagePacker: %s (%s)", ex.message, innerException.message)
Log.error("Exception in ImagePacker for mod ${mod.name}: ${ex.message} (${innerException.message})")
}
}
}