mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-10 07:16:54 +07:00
Add TechManager.isResearched(construction) (#10646)
* Update TechManager.kt * Update CityStateFunctions.kt * Update QuestManager.kt * Update UnitUpgradeManager.kt * Update Victory.kt * Update TechManager.kt * Update TechManager.kt
This commit is contained in:
parent
75a4f06d03
commit
55a068d0a0
@ -93,7 +93,7 @@ class CityStateFunctions(val civInfo: Civilization) {
|
||||
fun giftableUniqueUnit(): BaseUnit? {
|
||||
val uniqueUnit = civInfo.gameInfo.ruleset.units[civInfo.cityStateUniqueUnit]
|
||||
?: return null
|
||||
if (uniqueUnit.requiredTech != null && !receivingCiv.tech.isResearched(uniqueUnit.requiredTech!!))
|
||||
if (!receivingCiv.tech.isResearched(uniqueUnit))
|
||||
return null
|
||||
if (uniqueUnit.obsoleteTech != null && receivingCiv.tech.isResearched(uniqueUnit.obsoleteTech!!))
|
||||
return null
|
||||
|
@ -720,7 +720,7 @@ class QuestManager : IsPartOfGameInfoSerialization {
|
||||
.filter { building ->
|
||||
// Buildable wonder
|
||||
building.isWonder
|
||||
&& (building.requiredTech == null || challenger.tech.isResearched(building.requiredTech!!))
|
||||
&& challenger.tech.isResearched(building)
|
||||
&& civInfo.gameInfo.getCities().none { it.cityConstructions.isBuilt(building.name) }
|
||||
// Can't be disabled
|
||||
&& building.name !in startingEra.startingObsoleteWonders
|
||||
|
@ -14,6 +14,7 @@ import com.unciv.logic.civilization.PopupAlert
|
||||
import com.unciv.logic.civilization.TechAction
|
||||
import com.unciv.logic.map.MapSize
|
||||
import com.unciv.logic.map.tile.RoadStatus
|
||||
import com.unciv.models.ruleset.INonPerpetualConstruction
|
||||
import com.unciv.models.ruleset.tech.Era
|
||||
import com.unciv.models.ruleset.tech.Technology
|
||||
import com.unciv.models.ruleset.unique.UniqueMap
|
||||
@ -153,6 +154,8 @@ class TechManager : IsPartOfGameInfoSerialization {
|
||||
|
||||
fun isResearched(techName: String): Boolean = techsResearched.contains(techName)
|
||||
|
||||
fun isResearched(construction: INonPerpetualConstruction): Boolean = construction.requiredTechs().all{ requiredTech -> isResearched(requiredTech) }
|
||||
|
||||
fun canBeResearched(techName: String): Boolean {
|
||||
val tech = getRuleset().technologies[techName]!!
|
||||
if (tech.uniqueObjects.any { it.type == UniqueType.OnlyAvailableWhen && !it.conditionalsApply(civInfo) })
|
||||
|
@ -33,7 +33,7 @@ class UnitUpgradeManager(val unit:MapUnit) {
|
||||
val upgradePath = getUpgradePath()
|
||||
|
||||
fun isInvalidUpgradeDestination(baseUnit: BaseUnit): Boolean{
|
||||
if (baseUnit.requiredTech != null && !unit.civ.tech.isResearched(baseUnit.requiredTech!!))
|
||||
if (!unit.civ.tech.isResearched(baseUnit))
|
||||
return true
|
||||
if (baseUnit.getMatchingUniques(UniqueType.OnlyAvailableWhen, StateForConditionals.IgnoreConditionals).any {
|
||||
!it.conditionalsApply(StateForConditionals(unit.civ, unit = unit ))
|
||||
|
@ -270,13 +270,13 @@ class Milestone(val uniqueDescription: String, private val parentVictory: Victor
|
||||
return when (type!!) {
|
||||
MilestoneType.BuiltBuilding -> {
|
||||
val building = ruleset.buildings[params[0]]!!
|
||||
if (building.requiredTech != null && !civInfo.tech.isResearched(building.requiredTech!!)) Victory.Focus.Science
|
||||
if (!civInfo.tech.isResearched(building)) Victory.Focus.Science
|
||||
// if (building.hasUnique(UniqueType.Unbuildable)) Stat.Gold // Temporary, should be replaced with whatever is required to buy
|
||||
Victory.Focus.Production
|
||||
}
|
||||
MilestoneType.BuildingBuiltGlobally -> {
|
||||
val building = ruleset.buildings[params[0]]!!
|
||||
if (building.requiredTech != null && !civInfo.tech.isResearched(building.requiredTech!!)) Victory.Focus.Science
|
||||
if (!civInfo.tech.isResearched(building)) Victory.Focus.Science
|
||||
// if (building.hasUnique(UniqueType.Unbuildable)) Victory.Focus.Gold
|
||||
Victory.Focus.Production
|
||||
}
|
||||
@ -287,7 +287,7 @@ class Milestone(val uniqueDescription: String, private val parentVictory: Victor
|
||||
ruleset.buildings[it]!!
|
||||
else ruleset.units[it]!!
|
||||
}
|
||||
if (constructions.any { it.requiredTech != null && !civInfo.tech.isResearched(it.requiredTech!!) } ) Victory.Focus.Science
|
||||
if (constructions.any { !civInfo.tech.isResearched(it) } ) Victory.Focus.Science
|
||||
// if (constructions.any { it.hasUnique(UniqueType.Unbuildable) } ) Stat.Gold
|
||||
Victory.Focus.Production
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user