mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-23 03:23:17 -04:00
chore: renamed GameInfo.ruleSet -> ruleset
This commit is contained in:
parent
5329b9125b
commit
0548b3b472
@ -221,7 +221,7 @@ class MainMenuScreen: BaseScreen(), RecreateOnResize {
|
||||
val curWorldScreen = game.worldScreen
|
||||
if (curWorldScreen != null) {
|
||||
game.resetToWorldScreen()
|
||||
ImageGetter.ruleset = game.gameInfo!!.ruleSet
|
||||
ImageGetter.ruleset = game.gameInfo!!.ruleset
|
||||
curWorldScreen.popups.filterIsInstance(WorldScreenMenuPopup::class.java).forEach(Popup::close)
|
||||
} else {
|
||||
QuickSave.autoLoadGame(this)
|
||||
|
||||
@ -236,7 +236,7 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
|
||||
|| prevGameInfo.gameParameters.baseRuleset != newGameInfo.gameParameters.baseRuleset
|
||||
|| prevGameInfo.gameParameters.mods != newGameInfo.gameParameters.mods) {
|
||||
withGLContext {
|
||||
ImageGetter.setNewRuleset(newGameInfo.ruleSet)
|
||||
ImageGetter.setNewRuleset(newGameInfo.ruleset)
|
||||
}
|
||||
val fullModList = newGameInfo.gameParameters.getModsAndBaseRuleset()
|
||||
musicController.setModList(fullModList)
|
||||
@ -332,7 +332,7 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
|
||||
val worldScreen= screenStack.last() as WorldScreen
|
||||
|
||||
// Re-initialize translations, images etc. that may have been 'lost' when we were playing around in NewGameScreen
|
||||
val ruleset = worldScreen.gameInfo.ruleSet
|
||||
val ruleset = worldScreen.gameInfo.ruleset
|
||||
translations.translationActiveMods = ruleset.mods
|
||||
ImageGetter.setNewRuleset(ruleset)
|
||||
|
||||
|
||||
@ -27,31 +27,31 @@ object BackwardCompatibility {
|
||||
* This function removes them so the game doesn't crash when it tries to access them.
|
||||
*/
|
||||
fun GameInfo.removeMissingModReferences() {
|
||||
tileMap.removeMissingTerrainModReferences(ruleSet)
|
||||
tileMap.removeMissingTerrainModReferences(ruleset)
|
||||
|
||||
for (tile in tileMap.values) {
|
||||
for (unit in tile.getUnits()) {
|
||||
if (!ruleSet.units.containsKey(unit.name)) tile.removeUnit(unit)
|
||||
if (!ruleset.units.containsKey(unit.name)) tile.removeUnit(unit)
|
||||
|
||||
for (promotion in unit.promotions.promotions.toList())
|
||||
if (!ruleSet.unitPromotions.containsKey(promotion))
|
||||
if (!ruleset.unitPromotions.containsKey(promotion))
|
||||
unit.promotions.promotions.remove(promotion)
|
||||
}
|
||||
}
|
||||
|
||||
for (city in civilizations.asSequence().flatMap { it.cities.asSequence() }) {
|
||||
|
||||
changeBuildingNameIfNotInRuleset(ruleSet, city.cityConstructions, "Hanse", "Bank")
|
||||
changeBuildingNameIfNotInRuleset(ruleset, city.cityConstructions, "Hanse", "Bank")
|
||||
|
||||
for (building in city.cityConstructions.builtBuildings.toHashSet()) {
|
||||
|
||||
if (!ruleSet.buildings.containsKey(building))
|
||||
if (!ruleset.buildings.containsKey(building))
|
||||
city.cityConstructions.builtBuildings.remove(building)
|
||||
}
|
||||
|
||||
fun isInvalidConstruction(construction: String) =
|
||||
!ruleSet.buildings.containsKey(construction)
|
||||
&& !ruleSet.units.containsKey(construction)
|
||||
!ruleset.buildings.containsKey(construction)
|
||||
&& !ruleset.units.containsKey(construction)
|
||||
&& !PerpetualConstruction.perpetualConstructionsMap.containsKey(construction)
|
||||
|
||||
// Remove invalid buildings or units from the queue - don't just check buildings and units because it might be a special construction as well
|
||||
@ -67,10 +67,10 @@ object BackwardCompatibility {
|
||||
|
||||
for (civInfo in civilizations) {
|
||||
for (tech in civInfo.tech.techsResearched.toList())
|
||||
if (!ruleSet.technologies.containsKey(tech))
|
||||
if (!ruleset.technologies.containsKey(tech))
|
||||
civInfo.tech.techsResearched.remove(tech)
|
||||
for (policy in civInfo.policies.adoptedPolicies.toList())
|
||||
if (!ruleSet.policies.containsKey(policy))
|
||||
if (!ruleset.policies.containsKey(policy))
|
||||
civInfo.policies.adoptedPolicies.remove(policy)
|
||||
}
|
||||
}
|
||||
@ -202,7 +202,7 @@ object BackwardCompatibility {
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
fun GameInfo.convertOldGameSpeed() {
|
||||
if (gameParameters.gameSpeed != "" && gameParameters.gameSpeed in ruleSet.speeds.keys) {
|
||||
if (gameParameters.gameSpeed != "" && gameParameters.gameSpeed in ruleset.speeds.keys) {
|
||||
gameParameters.speed = gameParameters.gameSpeed
|
||||
gameParameters.gameSpeed = ""
|
||||
}
|
||||
|
||||
@ -126,7 +126,7 @@ class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion
|
||||
var isUpToDate = false
|
||||
|
||||
@Transient
|
||||
lateinit var ruleSet: Ruleset
|
||||
lateinit var ruleset: Ruleset
|
||||
|
||||
/** Simulate until any player wins,
|
||||
* or turns exceeds indicated number
|
||||
@ -218,8 +218,8 @@ class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion
|
||||
}
|
||||
|
||||
fun isReligionEnabled(): Boolean {
|
||||
val religionDisabledByRuleset = (ruleSet.eras[gameParameters.startingEra]!!.hasUnique(UniqueType.DisablesReligion)
|
||||
|| ruleSet.modOptions.uniques.contains(ModOptionsConstants.disableReligion))
|
||||
val religionDisabledByRuleset = (ruleset.eras[gameParameters.startingEra]!!.hasUnique(UniqueType.DisablesReligion)
|
||||
|| ruleset.modOptions.uniques.contains(ModOptionsConstants.disableReligion))
|
||||
return !religionDisabledByRuleset
|
||||
}
|
||||
|
||||
@ -229,7 +229,7 @@ class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion
|
||||
|
||||
private fun getEquivalentTurn(): Int {
|
||||
val totalTurns = speed.numTotalTurns()
|
||||
val startPercent = ruleSet.eras[gameParameters.startingEra]!!.startPercent
|
||||
val startPercent = ruleset.eras[gameParameters.startingEra]!!.startPercent
|
||||
return turns + (totalTurns * startPercent / 100)
|
||||
}
|
||||
|
||||
@ -368,7 +368,7 @@ class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion
|
||||
)
|
||||
}
|
||||
|
||||
fun getEnabledVictories() = ruleSet.victories.filter { !it.value.hiddenInVictoryScreen && gameParameters.victoryTypes.contains(it.key) }
|
||||
fun getEnabledVictories() = ruleset.victories.filter { !it.value.hiddenInVictoryScreen && gameParameters.victoryTypes.contains(it.key) }
|
||||
|
||||
fun processDiplomaticVictory() {
|
||||
if (diplomaticVictoryVotesProcessed) return
|
||||
@ -418,7 +418,7 @@ class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion
|
||||
data class CityTileAndDistance(val city: City, val tile: Tile, val distance: Int)
|
||||
|
||||
val exploredRevealTiles: Sequence<Tile> =
|
||||
if (ruleSet.tileResources[resourceName]!!.hasUnique(UniqueType.CityStateOnlyResource)) {
|
||||
if (ruleset.tileResources[resourceName]!!.hasUnique(UniqueType.CityStateOnlyResource)) {
|
||||
// Look for matching mercantile CS centers
|
||||
getAliveCityStates()
|
||||
.asSequence()
|
||||
@ -480,13 +480,13 @@ class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion
|
||||
}
|
||||
barbarians.migrateBarbarianCamps()
|
||||
|
||||
ruleSet = RulesetCache.getComplexRuleset(gameParameters)
|
||||
ruleset = RulesetCache.getComplexRuleset(gameParameters)
|
||||
|
||||
// any mod the saved game lists that is currently not installed causes null pointer
|
||||
// exceptions in this routine unless it contained no new objects or was very simple.
|
||||
// Player's fault, so better complain early:
|
||||
val missingMods = (gameParameters.mods + gameParameters.baseRuleset)
|
||||
.filterNot { it in ruleSet.mods }
|
||||
.filterNot { it in ruleset.mods }
|
||||
.joinToString(limit = 120) { it }
|
||||
if (missingMods.isNotEmpty()) {
|
||||
throw MissingModsException(missingMods)
|
||||
@ -496,8 +496,8 @@ class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion
|
||||
|
||||
convertOldGameSpeed()
|
||||
|
||||
for (baseUnit in ruleSet.units.values)
|
||||
baseUnit.ruleset = ruleSet
|
||||
for (baseUnit in ruleset.units.values)
|
||||
baseUnit.ruleset = ruleset
|
||||
|
||||
// This needs to go before tileMap.setTransients, as units need to access
|
||||
// the nation of their civilization when setting transients
|
||||
@ -511,14 +511,14 @@ class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion
|
||||
}
|
||||
}
|
||||
|
||||
tileMap.setTransients(ruleSet)
|
||||
tileMap.setTransients(ruleset)
|
||||
|
||||
if (currentPlayer == "") currentPlayer = civilizations.first { it.isHuman() }.civName
|
||||
currentPlayerCiv = getCivilization(currentPlayer)
|
||||
|
||||
difficultyObject = ruleSet.difficulties[difficulty]!!
|
||||
difficultyObject = ruleset.difficulties[difficulty]!!
|
||||
|
||||
speed = ruleSet.speeds[gameParameters.speed]!!
|
||||
speed = ruleset.speeds[gameParameters.speed]!!
|
||||
|
||||
for (religion in religions.values) religion.setTransients(this)
|
||||
|
||||
@ -565,7 +565,7 @@ class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion
|
||||
cityInfo.cityConstructions.chooseNextConstruction()
|
||||
|
||||
// We also remove resources that the city may be demanding but are no longer in the ruleset
|
||||
if (!ruleSet.tileResources.containsKey(cityInfo.demandedResource))
|
||||
if (!ruleset.tileResources.containsKey(cityInfo.demandedResource))
|
||||
cityInfo.demandedResource = ""
|
||||
|
||||
cityInfo.cityStats.update()
|
||||
@ -577,9 +577,9 @@ class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion
|
||||
}
|
||||
|
||||
spaceResources.clear()
|
||||
spaceResources.addAll(ruleSet.buildings.values.filter { it.hasUnique(UniqueType.SpaceshipPart) }
|
||||
spaceResources.addAll(ruleset.buildings.values.filter { it.hasUnique(UniqueType.SpaceshipPart) }
|
||||
.flatMap { it.getResourceRequirements().keys })
|
||||
spaceResources.addAll(ruleSet.victories.values.flatMap { it.requiredSpaceshipParts })
|
||||
spaceResources.addAll(ruleset.victories.values.flatMap { it.requiredSpaceshipParts })
|
||||
|
||||
barbarians.setTransients(this)
|
||||
|
||||
|
||||
@ -210,7 +210,7 @@ object GameStarter {
|
||||
}
|
||||
|
||||
private fun addCivStats(gameInfo: GameInfo) {
|
||||
val ruleSet = gameInfo.ruleSet
|
||||
val ruleSet = gameInfo.ruleset
|
||||
val startingEra = gameInfo.gameParameters.startingEra
|
||||
val era = ruleSet.eras[startingEra]!!
|
||||
for (civInfo in gameInfo.civilizations.filter { !it.isBarbarian() }) {
|
||||
@ -321,7 +321,7 @@ object GameStarter {
|
||||
|
||||
private fun addCivStartingUnits(gameInfo: GameInfo) {
|
||||
|
||||
val ruleSet = gameInfo.ruleSet
|
||||
val ruleSet = gameInfo.ruleset
|
||||
val tileMap = gameInfo.tileMap
|
||||
val startingEra = gameInfo.gameParameters.startingEra
|
||||
var startingUnits: MutableList<String>
|
||||
|
||||
@ -109,7 +109,7 @@ object Automation {
|
||||
if (city.isPuppet) return
|
||||
if ((city.cityConstructions.getCurrentConstruction() as? BaseUnit)?.isMilitary() == true)
|
||||
return // already training a military unit
|
||||
val chosenUnitName = chooseMilitaryUnit(city, city.civ.gameInfo.ruleSet.units.values.asSequence())
|
||||
val chosenUnitName = chooseMilitaryUnit(city, city.civ.gameInfo.ruleset.units.values.asSequence())
|
||||
if (chosenUnitName != null)
|
||||
city.cityConstructions.currentConstructionFromQueue = chosenUnitName
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
||||
private val militaryUnits = civUnits.count { it.baseUnit.isMilitary() }
|
||||
private val workers = civUnits.count { it.cache.hasUniqueToBuildImprovements && it.isCivilian() }.toFloat()
|
||||
private val cities = civInfo.cities.size
|
||||
private val allTechsAreResearched = civInfo.gameInfo.ruleSet.technologies.values
|
||||
private val allTechsAreResearched = civInfo.gameInfo.ruleset.technologies.values
|
||||
.all { civInfo.tech.isResearched(it.name) || !civInfo.tech.canBeResearched(it.name)}
|
||||
|
||||
private val isAtWar = civInfo.isAtWar()
|
||||
|
||||
@ -251,13 +251,13 @@ class Encampment() : IsPartOfGameInfoSerialization {
|
||||
private fun chooseBarbarianUnit(naval: Boolean): String? {
|
||||
// if we don't make this into a separate list then the retain() will happen on the Tech keys,
|
||||
// which effectively removes those techs from the game and causes all sorts of problems
|
||||
val allResearchedTechs = gameInfo.ruleSet.technologies.keys.toMutableList()
|
||||
val allResearchedTechs = gameInfo.ruleset.technologies.keys.toMutableList()
|
||||
for (civ in gameInfo.civilizations.filter { !it.isBarbarian() && !it.isDefeated() }) {
|
||||
allResearchedTechs.retainAll(civ.tech.techsResearched)
|
||||
}
|
||||
val barbarianCiv = gameInfo.getBarbarianCivilization()
|
||||
barbarianCiv.tech.techsResearched = allResearchedTechs.toHashSet()
|
||||
val unitList = gameInfo.ruleSet.units.values
|
||||
val unitList = gameInfo.ruleset.units.values
|
||||
.filter { it.isMilitary() &&
|
||||
!(it.hasUnique(UniqueType.MustSetUp) ||
|
||||
it.hasUnique(UniqueType.CannotAttack) ||
|
||||
@ -284,7 +284,7 @@ class Encampment() : IsPartOfGameInfoSerialization {
|
||||
if (gameInfo.gameParameters.ragingBarbarians)
|
||||
countdown /= 2
|
||||
// Higher on low difficulties
|
||||
countdown += gameInfo.ruleSet.difficulties[gameInfo.gameParameters.difficulty]!!.barbarianSpawnDelay
|
||||
countdown += gameInfo.ruleset.difficulties[gameInfo.gameParameters.difficulty]!!.barbarianSpawnDelay
|
||||
// Quicker if this camp has already spawned units
|
||||
countdown -= min(3, spawnedUnits)
|
||||
|
||||
|
||||
@ -57,7 +57,7 @@ object NextTurnAutomation {
|
||||
respondToTradeRequests(civInfo)
|
||||
|
||||
if (civInfo.isMajorCiv()) {
|
||||
if (!civInfo.gameInfo.ruleSet.modOptions.hasUnique(ModOptionsConstants.diplomaticRelationshipsCannotChange)) {
|
||||
if (!civInfo.gameInfo.ruleset.modOptions.hasUnique(ModOptionsConstants.diplomaticRelationshipsCannotChange)) {
|
||||
declareWar(civInfo)
|
||||
offerPeaceTreaty(civInfo)
|
||||
// offerDeclarationOfFriendship(civInfo)
|
||||
@ -407,7 +407,7 @@ object NextTurnAutomation {
|
||||
|
||||
private fun chooseTechToResearch(civInfo: Civilization) {
|
||||
if (civInfo.tech.techsToResearch.isEmpty()) {
|
||||
val researchableTechs = civInfo.gameInfo.ruleSet.technologies.values
|
||||
val researchableTechs = civInfo.gameInfo.ruleset.technologies.values
|
||||
.filter { civInfo.tech.canBeResearched(it.name) }
|
||||
val techsGroups = researchableTechs.groupBy { it.cost }
|
||||
val costs = techsGroups.keys.sorted()
|
||||
@ -503,7 +503,7 @@ object NextTurnAutomation {
|
||||
* a unit and selling a building to make room. Can happen due to trades etc */
|
||||
private fun freeUpSpaceResources(civInfo: Civilization) {
|
||||
// No need to build spaceship parts just yet
|
||||
if (civInfo.gameInfo.ruleSet.victories.none { civInfo.victoryManager.getNextMilestone(it.key)?.type == MilestoneType.AddedSSPartsInCapital } )
|
||||
if (civInfo.gameInfo.ruleset.victories.none { civInfo.victoryManager.getNextMilestone(it.key)?.type == MilestoneType.AddedSSPartsInCapital } )
|
||||
return
|
||||
|
||||
for (resource in civInfo.gameInfo.spaceResources) {
|
||||
@ -520,7 +520,7 @@ object NextTurnAutomation {
|
||||
for (city in civInfo.cities) {
|
||||
if (city.hasSoldBuildingThisTurn)
|
||||
continue
|
||||
val buildingToSell = civInfo.gameInfo.ruleSet.buildings.values.filter {
|
||||
val buildingToSell = civInfo.gameInfo.ruleset.buildings.values.filter {
|
||||
it.name in city.cityConstructions.builtBuildings
|
||||
&& it.requiresResource(resource)
|
||||
&& it.isSellable()
|
||||
@ -559,7 +559,7 @@ object NextTurnAutomation {
|
||||
|
||||
private fun foundReligion(civInfo: Civilization) {
|
||||
if (civInfo.religionManager.religionState != ReligionState.FoundingReligion) return
|
||||
val availableReligionIcons = civInfo.gameInfo.ruleSet.religions
|
||||
val availableReligionIcons = civInfo.gameInfo.ruleset.religions
|
||||
.filterNot { civInfo.gameInfo.religions.values.map { religion -> religion.name }.contains(it) }
|
||||
val religionIcon =
|
||||
if (civInfo.nation.favoredReligion in availableReligionIcons) civInfo.nation.favoredReligion
|
||||
@ -601,7 +601,7 @@ object NextTurnAutomation {
|
||||
}
|
||||
|
||||
private fun chooseBeliefOfType(civInfo: Civilization, beliefType: BeliefType, additionalBeliefsToExclude: HashSet<Belief> = hashSetOf()): Belief? {
|
||||
return civInfo.gameInfo.ruleSet.beliefs
|
||||
return civInfo.gameInfo.ruleset.beliefs
|
||||
.filter {
|
||||
(it.value.type == beliefType || beliefType == BeliefType.Any)
|
||||
&& !additionalBeliefsToExclude.contains(it.value)
|
||||
@ -917,7 +917,7 @@ object NextTurnAutomation {
|
||||
if (civInfo.wantsToFocusOn(Victory.Focus.Culture) && civInfo.cities.size > 3) return
|
||||
if (civInfo.cities.none() || civInfo.getHappiness() <= civInfo.cities.size + 5) return
|
||||
|
||||
val settlerUnits = civInfo.gameInfo.ruleSet.units.values
|
||||
val settlerUnits = civInfo.gameInfo.ruleset.units.values
|
||||
.filter { it.hasUnique(UniqueType.FoundCity) && it.isBuildable(civInfo) }
|
||||
if (settlerUnits.isEmpty()) return
|
||||
if (civInfo.units.getCivUnits().none { it.hasUnique(UniqueType.FoundCity) }
|
||||
|
||||
@ -103,7 +103,7 @@ object ReligionAutomation {
|
||||
|
||||
private fun buyMissionaryInAnyCity(civInfo: Civilization) {
|
||||
if (civInfo.religionManager.religionState < ReligionState.Religion) return
|
||||
var missionaries = civInfo.gameInfo.ruleSet.units.values.filter { unit ->
|
||||
var missionaries = civInfo.gameInfo.ruleset.units.values.filter { unit ->
|
||||
unit.getMatchingUniques(UniqueType.CanActionSeveralTimes).filter { it.params[0] == Constants.spreadReligion }.any()
|
||||
}
|
||||
missionaries = missionaries.map { civInfo.getEquivalentUnit(it) }
|
||||
@ -117,7 +117,7 @@ object ReligionAutomation {
|
||||
?: return
|
||||
|
||||
|
||||
val hasUniqueToTakeCivReligion = civInfo.gameInfo.ruleSet.units[missionaryConstruction.name]!!.hasUnique(UniqueType.TakeReligionOverBirthCity)
|
||||
val hasUniqueToTakeCivReligion = civInfo.gameInfo.ruleset.units[missionaryConstruction.name]!!.hasUnique(UniqueType.TakeReligionOverBirthCity)
|
||||
|
||||
val validCitiesToBuy = civInfo.cities.filter {
|
||||
(hasUniqueToTakeCivReligion || it.religion.getMajorityReligion() == civInfo.religionManager.religion)
|
||||
@ -159,7 +159,7 @@ object ReligionAutomation {
|
||||
|
||||
private fun buyInquisitorNear(civInfo: Civilization, city: City) {
|
||||
if (civInfo.religionManager.religionState < ReligionState.Religion) return
|
||||
var inquisitors = civInfo.gameInfo.ruleSet.units.values.filter {
|
||||
var inquisitors = civInfo.gameInfo.ruleset.units.values.filter {
|
||||
it.getMapUnit(civInfo).canDoReligiousAction(Constants.removeHeresy)
|
||||
|| it.hasUnique(UniqueType.PreventSpreadingReligion)
|
||||
}
|
||||
@ -175,7 +175,7 @@ object ReligionAutomation {
|
||||
?: return
|
||||
|
||||
|
||||
val hasUniqueToTakeCivReligion = civInfo.gameInfo.ruleSet.units[inquisitorConstruction.name]!!.hasUnique(UniqueType.TakeReligionOverBirthCity)
|
||||
val hasUniqueToTakeCivReligion = civInfo.gameInfo.ruleset.units[inquisitorConstruction.name]!!.hasUnique(UniqueType.TakeReligionOverBirthCity)
|
||||
|
||||
val validCitiesToBuy = civInfo.cities.filter {
|
||||
(hasUniqueToTakeCivReligion || it.religion.getMajorityReligion() == civInfo.religionManager.religion)
|
||||
@ -245,7 +245,7 @@ object ReligionAutomation {
|
||||
|
||||
private fun beliefBonusForCity(civInfo: Civilization, belief: Belief, city: City): Float {
|
||||
var score = 0f
|
||||
val ruleSet = civInfo.gameInfo.ruleSet
|
||||
val ruleSet = civInfo.gameInfo.ruleset
|
||||
for (unique in belief.uniqueObjects) {
|
||||
val modifier = 0.5f.pow(unique.conditionals.size)
|
||||
// Multiply by 3/10 if has an obsoleted era
|
||||
|
||||
@ -150,7 +150,7 @@ object SpecificUnitAutomation {
|
||||
}
|
||||
|
||||
fun automateSettlerActions(unit: MapUnit) {
|
||||
val modConstants = unit.civ.gameInfo.ruleSet.modOptions.constants
|
||||
val modConstants = unit.civ.gameInfo.ruleset.modOptions.constants
|
||||
if (unit.getTile().militaryUnit == null // Don't move until you're accompanied by a military unit
|
||||
&& !unit.civ.isCityState() // ..unless you're a city state that was unable to settle its city on turn 1
|
||||
&& unit.getDamageFromTerrain() < unit.health) return // Also make sure we won't die waiting
|
||||
@ -224,7 +224,7 @@ object SpecificUnitAutomation {
|
||||
|
||||
/** @return the number of tiles 4 (un-modded) out from this city that could hold a city, ie how lonely this city is */
|
||||
fun getFrontierScore(city: City) = city.getCenterTile()
|
||||
.getTilesAtDistance(city.civ.gameInfo.ruleSet.modOptions.constants.minimalCityDistance + 1)
|
||||
.getTilesAtDistance(city.civ.gameInfo.ruleset.modOptions.constants.minimalCityDistance + 1)
|
||||
.count { it.canBeSettled() && (it.getOwner() == null || it.getOwner() == city.civ ) }
|
||||
|
||||
val frontierCity = unit.civ.cities.maxByOrNull { getFrontierScore(it) }
|
||||
@ -251,7 +251,7 @@ object SpecificUnitAutomation {
|
||||
val improvementBuildingUniques = unit.getMatchingUniques(UniqueType.ConstructImprovementConsumingUnit)
|
||||
|
||||
val improvementName = improvementBuildingUniques.first().params[0]
|
||||
val improvement = unit.civ.gameInfo.ruleSet.tileImprovements[improvementName]
|
||||
val improvement = unit.civ.gameInfo.ruleset.tileImprovements[improvementName]
|
||||
?: return
|
||||
val relatedStat = improvement.maxByOrNull { it.value }?.key ?: Stat.Culture
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ class WorkerAutomation(
|
||||
) {
|
||||
///////////////////////////////////////// Cached data /////////////////////////////////////////
|
||||
|
||||
private val ruleSet = civInfo.gameInfo.ruleSet
|
||||
private val ruleSet = civInfo.gameInfo.ruleset
|
||||
|
||||
/** Caches road to build for connecting cities unless option is off or ruleset removed all roads */
|
||||
private val bestRoadAvailable: RoadStatus =
|
||||
|
||||
@ -483,7 +483,7 @@ object Battle {
|
||||
private fun addXp(thisCombatant: ICombatant, amount: Int, otherCombatant: ICombatant) {
|
||||
var baseXP = amount
|
||||
if (thisCombatant !is MapUnitCombatant) return
|
||||
val modConstants = thisCombatant.unit.civ.gameInfo.ruleSet.modOptions.constants
|
||||
val modConstants = thisCombatant.unit.civ.gameInfo.ruleset.modOptions.constants
|
||||
if (thisCombatant.unit.promotions.totalXpProduced() >= modConstants.maxXPfromBarbarians
|
||||
&& otherCombatant.getCivInfo().isBarbarian())
|
||||
return
|
||||
@ -507,7 +507,7 @@ object Battle {
|
||||
for (unique in thisCombatant.getMatchingUniques(UniqueType.GreatPersonEarnedFaster, stateForConditionals, true)) {
|
||||
val unitName = unique.params[0]
|
||||
// From the unique we know this unit exists
|
||||
val unit = thisCombatant.getCivInfo().gameInfo.ruleSet.units[unitName]!!
|
||||
val unit = thisCombatant.getCivInfo().gameInfo.ruleset.units[unitName]!!
|
||||
if (unit.uniques.contains("Great Person - [War]"))
|
||||
greatGeneralPointsModifier += unique.params[1].toFloat() / 100
|
||||
}
|
||||
|
||||
@ -40,14 +40,14 @@ class CityCombatant(val city: City) : ICombatant {
|
||||
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
fun getCityStrength(combatAction: CombatAction = CombatAction.Defend): Int { // Civ fanatics forum, from a modder who went through the original code
|
||||
val modConstants = getCivInfo().gameInfo.ruleSet.modOptions.constants
|
||||
val modConstants = getCivInfo().gameInfo.ruleset.modOptions.constants
|
||||
var strength = modConstants.cityStrengthBase
|
||||
strength += (city.population.population * modConstants.cityStrengthPerPop) // Each 5 pop gives 2 defence
|
||||
val cityTile = city.getCenterTile()
|
||||
for (unique in cityTile.allTerrains.flatMap { it.getMatchingUniques(UniqueType.GrantsCityStrength) })
|
||||
strength += unique.params[0].toInt()
|
||||
// as tech progresses so does city strength
|
||||
val techCount = getCivInfo().gameInfo.ruleSet.technologies.size
|
||||
val techCount = getCivInfo().gameInfo.ruleset.technologies.size
|
||||
val techsPercentKnown: Float = if (techCount > 0) city.civ.tech.techsResearched.size.toFloat() / techCount else 0.5f // for mods with no tech
|
||||
strength += (techsPercentKnown * modConstants.cityStrengthFromTechsMultiplier).pow(modConstants.cityStrengthFromTechsExponent) * modConstants.cityStrengthFromTechsFullMultiplier
|
||||
|
||||
|
||||
@ -160,7 +160,7 @@ class City : IsPartOfGameInfoSerialization {
|
||||
fun isInResistance() = hasFlag(CityFlags.Resistance)
|
||||
|
||||
|
||||
fun getRuleset() = civ.gameInfo.ruleSet
|
||||
fun getRuleset() = civ.gameInfo.ruleset
|
||||
|
||||
fun getCityResources(): ResourceSupplyList {
|
||||
val cityResources = ResourceSupplyList()
|
||||
@ -341,8 +341,8 @@ class City : IsPartOfGameInfoSerialization {
|
||||
fun canBeDestroyed(justCaptured: Boolean = false): Boolean {
|
||||
if (civ.gameInfo.gameParameters.noCityRazing) return false
|
||||
|
||||
val allowRazeCapital = civ.gameInfo.ruleSet.modOptions.uniques.contains(ModOptionsConstants.allowRazeCapital)
|
||||
val allowRazeHolyCity = civ.gameInfo.ruleSet.modOptions.uniques.contains(ModOptionsConstants.allowRazeHolyCity)
|
||||
val allowRazeCapital = civ.gameInfo.ruleset.modOptions.uniques.contains(ModOptionsConstants.allowRazeCapital)
|
||||
val allowRazeHolyCity = civ.gameInfo.ruleset.modOptions.uniques.contains(ModOptionsConstants.allowRazeHolyCity)
|
||||
|
||||
if (isOriginalCapital && !allowRazeCapital) return false
|
||||
if (isHolyCity() && !allowRazeHolyCity) return false
|
||||
|
||||
@ -55,7 +55,7 @@ class CityFounder {
|
||||
tile.changeImprovement(null)
|
||||
tile.improvementInProgress = null
|
||||
|
||||
val ruleset = civInfo.gameInfo.ruleSet
|
||||
val ruleset = civInfo.gameInfo.ruleset
|
||||
city.workedTiles = hashSetOf() //reassign 1st working tile
|
||||
|
||||
city.population.setPopulation(ruleset.eras[startingEra]!!.settlerPopulation)
|
||||
@ -179,7 +179,7 @@ class CityFounder {
|
||||
// As per fandom wiki, once the names from the other nations in the game are exhausted,
|
||||
// names are taken from the rest of the major nations in the rule set
|
||||
val absentMajorNations: Sequence<Nation> =
|
||||
foundingCiv.gameInfo.ruleSet.nations.values.asSequence().filter { nation ->
|
||||
foundingCiv.gameInfo.ruleset.nations.values.asSequence().filter { nation ->
|
||||
nation.isMajorCiv() && nation !in aliveMajorNations
|
||||
}
|
||||
newCityNames =
|
||||
@ -195,7 +195,7 @@ class CityFounder {
|
||||
|
||||
|
||||
private fun addStartingBuildings(city: City, civInfo: Civilization, startingEra: String) {
|
||||
val ruleset = civInfo.gameInfo.ruleSet
|
||||
val ruleset = civInfo.gameInfo.ruleset
|
||||
if (civInfo.cities.size == 1) city.cityConstructions.addBuilding(city.capitalCityIndicator())
|
||||
|
||||
// Add buildings and pop we get from starting in this era
|
||||
|
||||
@ -303,9 +303,9 @@ class Civilization : IsPartOfGameInfoSerialization {
|
||||
fun getDifficulty(): Difficulty {
|
||||
if (isHuman()) return gameInfo.getDifficulty()
|
||||
// TODO We should be able to mark a difficulty as 'default AI difficulty' somehow
|
||||
val chieftainDifficulty = gameInfo.ruleSet.difficulties["Chieftain"]
|
||||
val chieftainDifficulty = gameInfo.ruleset.difficulties["Chieftain"]
|
||||
if (chieftainDifficulty != null) return chieftainDifficulty
|
||||
return gameInfo.ruleSet.difficulties.values.first()
|
||||
return gameInfo.ruleset.difficulties.values.first()
|
||||
}
|
||||
|
||||
fun getDiplomacyManager(civInfo: Civilization) = getDiplomacyManager(civInfo.civName)
|
||||
@ -334,7 +334,7 @@ class Civilization : IsPartOfGameInfoSerialization {
|
||||
fun isAlive(): Boolean = !isDefeated()
|
||||
|
||||
@delegate:Transient
|
||||
val cityStateType: CityStateType by lazy { gameInfo.ruleSet.cityStateTypes[nation.cityStateType!!]!! }
|
||||
val cityStateType: CityStateType by lazy { gameInfo.ruleset.cityStateTypes[nation.cityStateType!!]!! }
|
||||
var cityStatePersonality: CityStatePersonality = CityStatePersonality.Neutral
|
||||
var cityStateResource: String? = null
|
||||
var cityStateUniqueUnit: String? = null // Unique unit for militaristic city state. Might still be null if there are no appropriate units
|
||||
@ -351,7 +351,7 @@ class Civilization : IsPartOfGameInfoSerialization {
|
||||
if (victoryTypes.size == 1)
|
||||
return victoryTypes.first() // That is the most relevant one
|
||||
val victoryType = nation.preferredVictoryType
|
||||
return if (victoryType in gameInfo.ruleSet.victories) victoryType
|
||||
return if (victoryType in gameInfo.ruleset.victories) victoryType
|
||||
else Constants.neutralVictoryType
|
||||
}
|
||||
|
||||
@ -359,7 +359,7 @@ class Civilization : IsPartOfGameInfoSerialization {
|
||||
fun getPreferredVictoryTypeObject(): Victory? {
|
||||
val preferredVictoryType = getPreferredVictoryType()
|
||||
return if (preferredVictoryType == Constants.neutralVictoryType) null
|
||||
else gameInfo.ruleSet.victories[getPreferredVictoryType()]!!
|
||||
else gameInfo.ruleset.victories[getPreferredVictoryType()]!!
|
||||
}
|
||||
|
||||
fun wantsToFocusOn(focus: Victory.Focus): Boolean {
|
||||
@ -403,8 +403,8 @@ class Civilization : IsPartOfGameInfoSerialization {
|
||||
* Returns a dictionary of ALL resource names, and the amount that the civ has of each
|
||||
*/
|
||||
fun getCivResourcesByName(): HashMap<String, Int> {
|
||||
val hashMap = HashMap<String, Int>(gameInfo.ruleSet.tileResources.size)
|
||||
for (resource in gameInfo.ruleSet.tileResources.keys) hashMap[resource] = 0
|
||||
val hashMap = HashMap<String, Int>(gameInfo.ruleset.tileResources.size)
|
||||
for (resource in gameInfo.ruleset.tileResources.keys) hashMap[resource] = 0
|
||||
for (entry in getCivResources())
|
||||
hashMap[entry.resource.name] = entry.amount
|
||||
return hashMap
|
||||
@ -450,7 +450,7 @@ class Civilization : IsPartOfGameInfoSerialization {
|
||||
.flatMap { it.resource.getMatchingUniques(uniqueType, stateForConditionals) }
|
||||
)
|
||||
|
||||
yieldAll(gameInfo.ruleSet.globalUniques.getMatchingUniques(uniqueType, stateForConditionals))
|
||||
yieldAll(gameInfo.ruleset.globalUniques.getMatchingUniques(uniqueType, stateForConditionals))
|
||||
}
|
||||
|
||||
fun getTriggeredUniques(trigger: UniqueType, stateForConditionals: StateForConditionals = StateForConditionals(this)) : Sequence<Unique> = sequence{
|
||||
@ -461,7 +461,7 @@ class Civilization : IsPartOfGameInfoSerialization {
|
||||
yieldAll(policies.policyUniques.getTriggeredUniques(trigger, stateForConditionals))
|
||||
yieldAll(tech.techUniques.getTriggeredUniques(trigger, stateForConditionals))
|
||||
yieldAll(getEra().uniqueMap.getTriggeredUniques (trigger, stateForConditionals))
|
||||
yieldAll(gameInfo.ruleSet.globalUniques.uniqueMap.getTriggeredUniques(trigger, stateForConditionals))
|
||||
yieldAll(gameInfo.ruleset.globalUniques.uniqueMap.getTriggeredUniques(trigger, stateForConditionals))
|
||||
}
|
||||
|
||||
|
||||
@ -471,7 +471,7 @@ class Civilization : IsPartOfGameInfoSerialization {
|
||||
return tech.currentTechnology() == null && cities.isNotEmpty()
|
||||
}
|
||||
|
||||
fun getEquivalentBuilding(buildingName: String) = getEquivalentBuilding(gameInfo.ruleSet.buildings[buildingName]!!)
|
||||
fun getEquivalentBuilding(buildingName: String) = getEquivalentBuilding(gameInfo.ruleset.buildings[buildingName]!!)
|
||||
fun getEquivalentBuilding(baseBuilding: Building): Building {
|
||||
if (baseBuilding.replaces != null)
|
||||
return getEquivalentBuilding(baseBuilding.replaces!!)
|
||||
@ -483,7 +483,7 @@ class Civilization : IsPartOfGameInfoSerialization {
|
||||
}
|
||||
|
||||
fun getEquivalentUnit(baseUnitName: String): BaseUnit {
|
||||
val baseUnit = gameInfo.ruleSet.units[baseUnitName]
|
||||
val baseUnit = gameInfo.ruleset.units[baseUnitName]
|
||||
?: throw UncivShowableException("Unit $baseUnitName doesn't seem to exist!")
|
||||
return getEquivalentUnit(baseUnit)
|
||||
}
|
||||
@ -597,7 +597,7 @@ class Civilization : IsPartOfGameInfoSerialization {
|
||||
scoreBreakdown["Tiles"] = cities.sumOf { city -> city.getTiles().filter { !it.isWater}.count() } * 1 * mapSizeModifier
|
||||
scoreBreakdown["Wonders"] = 40 * cities
|
||||
.sumOf { city -> city.cityConstructions.builtBuildings
|
||||
.filter { gameInfo.ruleSet.buildings[it]!!.isWonder }.size
|
||||
.filter { gameInfo.ruleset.buildings[it]!!.isWonder }.size
|
||||
}.toDouble()
|
||||
scoreBreakdown["Technologies"] = tech.getNumberOfTechsResearched() * 4.toDouble()
|
||||
scoreBreakdown["Future Tech"] = tech.repeatingTechsResearched * 10.toDouble()
|
||||
@ -616,7 +616,7 @@ class Civilization : IsPartOfGameInfoSerialization {
|
||||
* And if the civs don't yet know who they are then they don't know if they're barbarians =\
|
||||
* */
|
||||
fun setNationTransient() {
|
||||
nation = gameInfo.ruleSet.nations[civName]
|
||||
nation = gameInfo.ruleset.nations[civName]
|
||||
?: throw UncivShowableException("Nation $civName is not found!")
|
||||
}
|
||||
|
||||
@ -650,7 +650,7 @@ class Civilization : IsPartOfGameInfoSerialization {
|
||||
passThroughImpassableUnlocked = passableImpassables.isNotEmpty()
|
||||
// Cache whether this civ gets nonstandard terrain damage for performance reasons.
|
||||
nonStandardTerrainDamage = getMatchingUniques(UniqueType.DamagesContainingUnits)
|
||||
.any { gameInfo.ruleSet.terrains[it.params[0]]!!.damagePerTurn != it.params[1].toInt() }
|
||||
.any { gameInfo.ruleset.terrains[it.params[0]]!!.damagePerTurn != it.params[1].toInt() }
|
||||
|
||||
hasLongCountDisplayUnique = hasUnique(UniqueType.MayanCalendarDisplay)
|
||||
|
||||
|
||||
@ -114,7 +114,7 @@ data class LocationAction(var locations: ArrayList<Vector2> = ArrayList()) : Not
|
||||
/** show tech screen */
|
||||
class TechAction(val techName: String = "") : NotificationAction, IsPartOfGameInfoSerialization {
|
||||
override fun execute(worldScreen: WorldScreen) {
|
||||
val tech = worldScreen.gameInfo.ruleSet.technologies[techName]
|
||||
val tech = worldScreen.gameInfo.ruleset.technologies[techName]
|
||||
worldScreen.game.pushScreen(TechPickerScreen(worldScreen.viewingCiv, tech))
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ class CityStateFunctions(val civInfo: Civilization) {
|
||||
fun giveGreatPersonToPatron(receivingCiv: Civilization) {
|
||||
|
||||
// Great Prophets can't be gotten from CS
|
||||
val giftableUnits = civInfo.gameInfo.ruleSet.units.values.filter { it.isGreatPerson()
|
||||
val giftableUnits = civInfo.gameInfo.ruleset.units.values.filter { it.isGreatPerson()
|
||||
&& !it.hasUnique(UniqueType.MayFoundReligion) }
|
||||
if (giftableUnits.isEmpty()) // For badly defined mods that don't have great people but do have the policy that makes city states grant them
|
||||
return
|
||||
@ -92,7 +92,7 @@ class CityStateFunctions(val civInfo: Civilization) {
|
||||
val city = cities.city1
|
||||
|
||||
fun giftableUniqueUnit(): BaseUnit? {
|
||||
val uniqueUnit = civInfo.gameInfo.ruleSet.units[civInfo.cityStateUniqueUnit]
|
||||
val uniqueUnit = civInfo.gameInfo.ruleset.units[civInfo.cityStateUniqueUnit]
|
||||
?: return null
|
||||
if (uniqueUnit.requiredTech != null && !receivingCiv.tech.isResearched(uniqueUnit.requiredTech!!))
|
||||
return null
|
||||
@ -431,7 +431,7 @@ class CityStateFunctions(val civInfo: Civilization) {
|
||||
fun tributeWorker(demandingCiv: Civilization) {
|
||||
if (!civInfo.isCityState()) throw Exception("You can only demand workers from City-States!")
|
||||
|
||||
val buildableWorkerLikeUnits = civInfo.gameInfo.ruleSet.units.filter {
|
||||
val buildableWorkerLikeUnits = civInfo.gameInfo.ruleset.units.filter {
|
||||
it.value.hasUnique(UniqueType.BuildImprovements) &&
|
||||
it.value.isCivilian() && it.value.isBuildable(civInfo)
|
||||
}
|
||||
@ -476,7 +476,7 @@ class CityStateFunctions(val civInfo: Civilization) {
|
||||
|
||||
fun getFreeTechForCityState() {
|
||||
// City-States automatically get all techs that at least half of the major civs know
|
||||
val researchableTechs = civInfo.gameInfo.ruleSet.technologies.keys
|
||||
val researchableTechs = civInfo.gameInfo.ruleset.technologies.keys
|
||||
.filter { civInfo.tech.canBeResearched(it) }
|
||||
for (tech in researchableTechs) {
|
||||
val aliveMajorCivs = civInfo.gameInfo.getAliveMajorCivs()
|
||||
|
||||
@ -101,7 +101,7 @@ class DiplomacyFunctions(val civInfo:Civilization){
|
||||
fun canSignResearchAgreement(): Boolean {
|
||||
if (!civInfo.isMajorCiv()) return false
|
||||
if (!civInfo.hasUnique(UniqueType.EnablesResearchAgreements)) return false
|
||||
if (civInfo.gameInfo.ruleSet.technologies.values
|
||||
if (civInfo.gameInfo.ruleset.technologies.values
|
||||
.none { civInfo.tech.canBeResearched(it.name) && !civInfo.tech.isResearched(it.name) }) return false
|
||||
return true
|
||||
}
|
||||
|
||||
@ -331,7 +331,7 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
|
||||
|
||||
fun resourcesFromTrade(): ResourceSupplyList {
|
||||
val newResourceSupplyList = ResourceSupplyList()
|
||||
val resourcesMap = civInfo.gameInfo.ruleSet.tileResources
|
||||
val resourcesMap = civInfo.gameInfo.ruleset.tileResources
|
||||
val isResourceFilter: (TradeOffer) -> Boolean = {
|
||||
(it.type == TradeType.Strategic_Resource || it.type == TradeType.Luxury_Resource)
|
||||
&& resourcesMap.containsKey(it.name)
|
||||
@ -377,7 +377,7 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
|
||||
|
||||
for (offer in trade.ourOffers) {
|
||||
if (offer.type in listOf(TradeType.Luxury_Resource, TradeType.Strategic_Resource)
|
||||
&& (offer.name in negativeCivResources || !civInfo.gameInfo.ruleSet.tileResources.containsKey(offer.name))
|
||||
&& (offer.name in negativeCivResources || !civInfo.gameInfo.ruleset.tileResources.containsKey(offer.name))
|
||||
) {
|
||||
|
||||
trades.remove(trade)
|
||||
|
||||
@ -65,7 +65,7 @@ class GreatPersonManager : IsPartOfGameInfoSerialization {
|
||||
|
||||
|
||||
fun getGreatPeople(): HashSet<BaseUnit> {
|
||||
val greatPeople = civInfo.gameInfo.ruleSet.units.values.asSequence()
|
||||
val greatPeople = civInfo.gameInfo.ruleset.units.values.asSequence()
|
||||
.filter { it.isGreatPerson() }
|
||||
.map { civInfo.getEquivalentUnit(it.name) }
|
||||
return if (!civInfo.gameInfo.isReligionEnabled())
|
||||
|
||||
@ -80,7 +80,7 @@ class PolicyManager : IsPartOfGameInfoSerialization {
|
||||
|
||||
/** A [Set] of all [PolicyBranch]es. */
|
||||
val branches: Set<PolicyBranch>
|
||||
get() = civInfo.gameInfo.ruleSet.policyBranches.values.toSet()
|
||||
get() = civInfo.gameInfo.ruleset.policyBranches.values.toSet()
|
||||
|
||||
fun clone(): PolicyManager {
|
||||
val toReturn = PolicyManager()
|
||||
@ -92,7 +92,7 @@ class PolicyManager : IsPartOfGameInfoSerialization {
|
||||
return toReturn
|
||||
}
|
||||
|
||||
private fun getRulesetPolicies() = civInfo.gameInfo.ruleSet.policies
|
||||
private fun getRulesetPolicies() = civInfo.gameInfo.ruleset.policies
|
||||
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
fun getPolicyByName(name: String): Policy = getRulesetPolicies()[name]!!
|
||||
@ -159,7 +159,7 @@ class PolicyManager : IsPartOfGameInfoSerialization {
|
||||
if (isAdopted(policy.name)) return false
|
||||
if (policy.policyBranchType == PolicyBranchType.BranchComplete) return false
|
||||
if (!getAdoptedPolicies().containsAll(policy.requires!!)) return false
|
||||
if (checkEra && civInfo.gameInfo.ruleSet.eras[policy.branch.era]!!.eraNumber > civInfo.getEraNumber()) return false
|
||||
if (checkEra && civInfo.gameInfo.ruleset.eras[policy.branch.era]!!.eraNumber > civInfo.getEraNumber()) return false
|
||||
if (policy.uniqueObjects.filter { it.type == UniqueType.OnlyAvailableWhen }
|
||||
.any { !it.conditionalsApply(civInfo) }) return false
|
||||
return true
|
||||
|
||||
@ -185,7 +185,7 @@ class QuestManager : IsPartOfGameInfoSerialization {
|
||||
if (assignedQuests.count { it.isGlobal() } >= GLOBAL_QUEST_MAX_ACTIVE)
|
||||
return
|
||||
|
||||
val globalQuests = civInfo.gameInfo.ruleSet.quests.values.filter { it.isGlobal() }
|
||||
val globalQuests = civInfo.gameInfo.ruleset.quests.values.filter { it.isGlobal() }
|
||||
val majorCivs = civInfo.getKnownCivs().filter { it.isMajorCiv() && !it.isAtWarWith(civInfo) }
|
||||
|
||||
val assignableQuests = ArrayList<Quest>()
|
||||
@ -215,7 +215,7 @@ class QuestManager : IsPartOfGameInfoSerialization {
|
||||
if (assignedQuests.count { it.assignee == challenger.civName && it.isIndividual() } >= INDIVIDUAL_QUEST_MAX_ACTIVE)
|
||||
return
|
||||
|
||||
val assignableQuests = civInfo.gameInfo.ruleSet.quests.values.filter { it.isIndividual() && isQuestValid(it, challenger) }
|
||||
val assignableQuests = civInfo.gameInfo.ruleset.quests.values.filter { it.isIndividual() && isQuestValid(it, challenger) }
|
||||
val weights = assignableQuests.map { getQuestWeight(it.name) }
|
||||
|
||||
if (assignableQuests.isNotEmpty()) {
|
||||
@ -406,9 +406,9 @@ class QuestManager : IsPartOfGameInfoSerialization {
|
||||
val assignee = civInfo.gameInfo.getCivilization(assignedQuest.assignee)
|
||||
return when (assignedQuest.questName) {
|
||||
QuestName.Route.value -> assignee.isCapitalConnectedToCity(civInfo.getCapital()!!)
|
||||
QuestName.ConnectResource.value -> assignee.detailedCivResources.map { it.resource }.contains(civInfo.gameInfo.ruleSet.tileResources[assignedQuest.data1])
|
||||
QuestName.ConnectResource.value -> assignee.detailedCivResources.map { it.resource }.contains(civInfo.gameInfo.ruleset.tileResources[assignedQuest.data1])
|
||||
QuestName.ConstructWonder.value -> assignee.cities.any { it.cityConstructions.isBuilt(assignedQuest.data1) }
|
||||
QuestName.GreatPerson.value -> assignee.units.getCivGreatPeople().any { it.baseUnit.getReplacedUnit(civInfo.gameInfo.ruleSet).name == assignedQuest.data1 }
|
||||
QuestName.GreatPerson.value -> assignee.units.getCivGreatPeople().any { it.baseUnit.getReplacedUnit(civInfo.gameInfo.ruleset).name == assignedQuest.data1 }
|
||||
QuestName.FindPlayer.value -> assignee.hasMetCivTerritory(civInfo.gameInfo.getCivilization(assignedQuest.data1))
|
||||
QuestName.FindNaturalWonder.value -> assignee.naturalWonders.contains(assignedQuest.data1)
|
||||
QuestName.PledgeToProtect.value -> assignee in civInfo.cityStateFunctions.getProtectorCivs()
|
||||
@ -434,7 +434,7 @@ class QuestManager : IsPartOfGameInfoSerialization {
|
||||
|
||||
/** Increments [assignedQuest.assignee][AssignedQuest.assignee] influence on [civInfo] and adds a [Notification] */
|
||||
private fun giveReward(assignedQuest: AssignedQuest) {
|
||||
val rewardInfluence = civInfo.gameInfo.ruleSet.quests[assignedQuest.questName]!!.influence
|
||||
val rewardInfluence = civInfo.gameInfo.ruleset.quests[assignedQuest.questName]!!.influence
|
||||
val assignee = civInfo.gameInfo.getCivilization(assignedQuest.assignee)
|
||||
|
||||
civInfo.getDiplomacyManager(assignedQuest.assignee).addInfluence(rewardInfluence)
|
||||
@ -660,7 +660,7 @@ class QuestManager : IsPartOfGameInfoSerialization {
|
||||
*/
|
||||
private fun getQuestWeight(questName: String): Float {
|
||||
var weight = 1f
|
||||
val quest = civInfo.gameInfo.ruleSet.quests[questName] ?: return 0f
|
||||
val quest = civInfo.gameInfo.ruleset.quests[questName] ?: return 0f
|
||||
|
||||
val personalityWeight = quest.weightForCityStateType[civInfo.cityStatePersonality.name]
|
||||
if (personalityWeight != null) weight *= personalityWeight
|
||||
@ -696,7 +696,7 @@ class QuestManager : IsPartOfGameInfoSerialization {
|
||||
val ownedByMajorResources = challenger.detailedCivResources.map { it.resource }
|
||||
|
||||
val resourcesOnMap = civInfo.gameInfo.tileMap.values.asSequence().mapNotNull { it.resource }.distinct()
|
||||
val viewableResourcesForChallenger = resourcesOnMap.map { civInfo.gameInfo.ruleSet.tileResources[it]!! }
|
||||
val viewableResourcesForChallenger = resourcesOnMap.map { civInfo.gameInfo.ruleset.tileResources[it]!! }
|
||||
.filter { it.revealedBy == null || challenger.tech.isResearched(it.revealedBy!!) }
|
||||
|
||||
val notOwnedResources = viewableResourcesForChallenger.filter {
|
||||
@ -712,8 +712,8 @@ class QuestManager : IsPartOfGameInfoSerialization {
|
||||
}
|
||||
|
||||
private fun getWonderToBuildForQuest(challenger: Civilization): Building? {
|
||||
val startingEra = civInfo.gameInfo.ruleSet.eras[civInfo.gameInfo.gameParameters.startingEra]!!
|
||||
val wonders = civInfo.gameInfo.ruleSet.buildings.values
|
||||
val startingEra = civInfo.gameInfo.ruleset.eras[civInfo.gameInfo.gameParameters.startingEra]!!
|
||||
val wonders = civInfo.gameInfo.ruleset.buildings.values
|
||||
.filter { building ->
|
||||
// Buildable wonder
|
||||
building.isWonder
|
||||
@ -751,7 +751,7 @@ class QuestManager : IsPartOfGameInfoSerialization {
|
||||
* Returns a Great Person [BaseUnit] that is not owned by both the [challenger] and the [civInfo]
|
||||
*/
|
||||
private fun getGreatPersonForQuest(challenger: Civilization): BaseUnit? {
|
||||
val ruleSet = civInfo.gameInfo.ruleSet
|
||||
val ruleSet = civInfo.gameInfo.ruleset
|
||||
|
||||
val challengerGreatPeople = challenger.units.getCivGreatPeople().map { it.baseUnit.getReplacedUnit(ruleSet) }
|
||||
val cityStateGreatPeople = civInfo.units.getCivGreatPeople().map { it.baseUnit.getReplacedUnit(ruleSet) }
|
||||
@ -821,16 +821,16 @@ class AssignedQuest(val questName: String = "",
|
||||
lateinit var gameInfo: GameInfo
|
||||
|
||||
fun isIndividual(): Boolean = !isGlobal()
|
||||
fun isGlobal(): Boolean = gameInfo.ruleSet.quests[questName]!!.isGlobal()
|
||||
fun isGlobal(): Boolean = gameInfo.ruleset.quests[questName]!!.isGlobal()
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
fun doesExpire(): Boolean = gameInfo.ruleSet.quests[questName]!!.duration > 0
|
||||
fun doesExpire(): Boolean = gameInfo.ruleset.quests[questName]!!.duration > 0
|
||||
fun isExpired(): Boolean = doesExpire() && getRemainingTurns() == 0
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
fun getDuration(): Int = (gameInfo.speed.modifier * gameInfo.ruleSet.quests[questName]!!.duration).toInt()
|
||||
fun getDuration(): Int = (gameInfo.speed.modifier * gameInfo.ruleset.quests[questName]!!.duration).toInt()
|
||||
fun getRemainingTurns(): Int = max(0, (assignedOnTurn + getDuration()) - gameInfo.turns)
|
||||
|
||||
fun getDescription(): String {
|
||||
val quest = gameInfo.ruleSet.quests[questName]!!
|
||||
val quest = gameInfo.ruleset.quests[questName]!!
|
||||
return quest.description.fillPlaceholders(data1)
|
||||
}
|
||||
|
||||
|
||||
@ -167,7 +167,7 @@ class ReligionManager : IsPartOfGameInfoSerialization {
|
||||
}
|
||||
|
||||
fun getGreatProphetEquivalent(): String? {
|
||||
return civInfo.gameInfo.ruleSet.units.values.firstOrNull { it.hasUnique(UniqueType.MayFoundReligion) }?.name
|
||||
return civInfo.gameInfo.ruleset.units.values.firstOrNull { it.hasUnique(UniqueType.MayFoundReligion) }?.name
|
||||
}
|
||||
|
||||
private fun generateProphet() {
|
||||
@ -187,7 +187,7 @@ class ReligionManager : IsPartOfGameInfoSerialization {
|
||||
}
|
||||
|
||||
private fun maxNumberOfReligions() = min(
|
||||
civInfo.gameInfo.ruleSet.religions.size,
|
||||
civInfo.gameInfo.ruleset.religions.size,
|
||||
civInfo.gameInfo.civilizations.count { it.isMajorCiv() } / 2 + 1
|
||||
)
|
||||
|
||||
@ -211,8 +211,8 @@ class ReligionManager : IsPartOfGameInfoSerialization {
|
||||
|
||||
fun numberOfBeliefsAvailable(type: BeliefType): Int {
|
||||
val gameInfo = civInfo.gameInfo
|
||||
val numberOfBeliefs = if (type == BeliefType.Any) gameInfo.ruleSet.beliefs.values.count()
|
||||
else gameInfo.ruleSet.beliefs.values.count { it.type == type }
|
||||
val numberOfBeliefs = if (type == BeliefType.Any) gameInfo.ruleset.beliefs.values.count()
|
||||
else gameInfo.ruleset.beliefs.values.count { it.type == type }
|
||||
return numberOfBeliefs - gameInfo.religions.flatMap { it.value.getBeliefs(type) }.distinct().count()
|
||||
// We need to do the distinct above, as pantheons and religions founded out of those pantheons might share beliefs
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ class RuinsManager : IsPartOfGameInfoSerialization {
|
||||
|
||||
fun setTransients(civInfo: Civilization) {
|
||||
this.civInfo = civInfo
|
||||
validRewards = civInfo.gameInfo.ruleSet.ruinRewards.values.toList()
|
||||
validRewards = civInfo.gameInfo.ruleset.ruinRewards.values.toList()
|
||||
}
|
||||
|
||||
fun selectNextRuinsReward(triggeringUnit: MapUnit) {
|
||||
|
||||
@ -91,7 +91,7 @@ class TechManager : IsPartOfGameInfoSerialization {
|
||||
|
||||
fun getNumberOfTechsResearched(): Int = techsResearched.size
|
||||
|
||||
private fun getRuleset() = civInfo.gameInfo.ruleSet
|
||||
private fun getRuleset() = civInfo.gameInfo.ruleset
|
||||
|
||||
fun costOfTech(techName: String): Int {
|
||||
var techCost = getRuleset().technologies[techName]!!.cost.toFloat()
|
||||
@ -427,7 +427,7 @@ class TechManager : IsPartOfGameInfoSerialization {
|
||||
}
|
||||
|
||||
private fun updateEra() {
|
||||
val ruleset = civInfo.gameInfo.ruleSet
|
||||
val ruleset = civInfo.gameInfo.ruleset
|
||||
if (ruleset.technologies.isEmpty() || researchedTechnologies.isEmpty())
|
||||
return
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ class TurnManager(val civInfo: Civilization) {
|
||||
civInfo.updateStatsForNextTurn() // for things that change when turn passes e.g. golden age, city state influence
|
||||
|
||||
// Do this after updateStatsForNextTurn but before cities.startTurn
|
||||
if (civInfo.playerType == PlayerType.AI && civInfo.gameInfo.ruleSet.modOptions.uniques.contains(
|
||||
if (civInfo.playerType == PlayerType.AI && civInfo.gameInfo.ruleset.modOptions.uniques.contains(
|
||||
ModOptionsConstants.convertGoldToScience))
|
||||
NextTurnAutomation.automateGoldToSciencePercentage(civInfo)
|
||||
|
||||
@ -39,7 +39,7 @@ class TurnManager(val civInfo: Civilization) {
|
||||
// so they won't be generated out in the open and vulnerable to enemy attacks before you can control them
|
||||
if (civInfo.cities.isNotEmpty()) { //if no city available, addGreatPerson will throw exception
|
||||
val greatPerson = civInfo.greatPeople.getNewGreatPerson()
|
||||
if (greatPerson != null && civInfo.gameInfo.ruleSet.units.containsKey(greatPerson))
|
||||
if (greatPerson != null && civInfo.gameInfo.ruleset.units.containsKey(greatPerson))
|
||||
civInfo.units.addUnit(greatPerson)
|
||||
civInfo.religionManager.startTurn()
|
||||
if (civInfo.isLongCountActive())
|
||||
@ -162,7 +162,7 @@ class TurnManager(val civInfo: Civilization) {
|
||||
val rebelCount = 1 + random.nextInt(100 + 20 * (civInfo.cities.size - 1)) / 100
|
||||
val spawnCity = civInfo.cities.maxByOrNull { random.nextInt(it.population.population + 10) } ?: return
|
||||
val spawnTile = spawnCity.getTiles().maxByOrNull { rateTileForRevoltSpawn(it) } ?: return
|
||||
val unitToSpawn = civInfo.gameInfo.ruleSet.units.values.asSequence().filter {
|
||||
val unitToSpawn = civInfo.gameInfo.ruleset.units.values.asSequence().filter {
|
||||
it.uniqueTo == null && it.isMelee() && it.isLandUnit()
|
||||
&& !it.hasUnique(UniqueType.CannotAttack) && it.isBuildable(civInfo)
|
||||
}.maxByOrNull {
|
||||
@ -243,7 +243,7 @@ class TurnManager(val civInfo: Civilization) {
|
||||
|
||||
civInfo.addGold( nextTurnStats.gold.toInt() )
|
||||
|
||||
if (civInfo.cities.isNotEmpty() && civInfo.gameInfo.ruleSet.technologies.isNotEmpty())
|
||||
if (civInfo.cities.isNotEmpty() && civInfo.gameInfo.ruleset.technologies.isNotEmpty())
|
||||
civInfo.tech.endTurn(nextTurnStats.science.toInt())
|
||||
|
||||
civInfo.religionManager.endTurn(nextTurnStats.faith.toInt())
|
||||
|
||||
@ -28,7 +28,7 @@ class UnitManager(val civInfo:Civilization) {
|
||||
|
||||
fun addUnit(unitName: String, city: City? = null): MapUnit? {
|
||||
if (civInfo.cities.isEmpty()) return null
|
||||
if (!civInfo.gameInfo.ruleSet.units.containsKey(unitName)) return null
|
||||
if (!civInfo.gameInfo.ruleset.units.containsKey(unitName)) return null
|
||||
|
||||
val cityToAddTo = city ?: civInfo.cities.random()
|
||||
val unit = civInfo.getEquivalentUnit(unitName)
|
||||
|
||||
@ -58,7 +58,7 @@ class VictoryManager : IsPartOfGameInfoSerialization {
|
||||
fun getVictoryTypeAchieved(): String? {
|
||||
if (!civInfo.isMajorCiv()) return null
|
||||
for (victoryName in civInfo.gameInfo.gameParameters.victoryTypes
|
||||
.filter { it != Constants.neutralVictoryType && it in civInfo.gameInfo.ruleSet.victories}) {
|
||||
.filter { it != Constants.neutralVictoryType && it in civInfo.gameInfo.ruleset.victories}) {
|
||||
if (getNextMilestone(victoryName) == null)
|
||||
return victoryName
|
||||
}
|
||||
@ -68,7 +68,7 @@ class VictoryManager : IsPartOfGameInfoSerialization {
|
||||
}
|
||||
|
||||
fun getNextMilestone(victory: String): Milestone? {
|
||||
for (milestone in civInfo.gameInfo.ruleSet.victories[victory]!!.milestoneObjects) {
|
||||
for (milestone in civInfo.gameInfo.ruleset.victories[victory]!!.milestoneObjects) {
|
||||
if (!milestone.hasBeenCompletedBy(civInfo))
|
||||
return milestone
|
||||
}
|
||||
@ -77,7 +77,7 @@ class VictoryManager : IsPartOfGameInfoSerialization {
|
||||
|
||||
fun amountMilestonesCompleted(victory: String): Int {
|
||||
var completed = 0
|
||||
for (milestone in civInfo.gameInfo.ruleSet.victories[victory]!!.milestoneObjects) {
|
||||
for (milestone in civInfo.gameInfo.ruleset.victories[victory]!!.milestoneObjects) {
|
||||
if (milestone.hasBeenCompletedBy(civInfo))
|
||||
++completed
|
||||
else
|
||||
|
||||
@ -22,7 +22,7 @@ class CapitalConnectionsFinder(private val civInfo: Civilization) {
|
||||
private val harborFromRoad = "$harbor-$road"
|
||||
private val harborFromRailroad = "$harbor-$railroad"
|
||||
|
||||
private val ruleset = civInfo.gameInfo.ruleSet
|
||||
private val ruleset = civInfo.gameInfo.ruleset
|
||||
private val roadIsResearched = ruleset.tileImprovements[road].let {
|
||||
it != null && (it.techRequired==null || civInfo.tech.isResearched(it.techRequired!!)) }
|
||||
|
||||
|
||||
@ -150,7 +150,7 @@ class CivInfoStatsForNextTurn(val civInfo: Civilization) {
|
||||
(civInfo.getDifficulty().unitSupplyPerCity + civInfo.getMatchingUniques(UniqueType.UnitSupplyPerCity).sumOf { it.params[0].toInt() })
|
||||
}
|
||||
fun getUnitSupplyFromPop(): Int {
|
||||
var totalSupply = civInfo.cities.sumOf { it.population.population } * civInfo.gameInfo.ruleSet.modOptions.constants.unitSupplyPerPopulation
|
||||
var totalSupply = civInfo.cities.sumOf { it.population.population } * civInfo.gameInfo.ruleset.modOptions.constants.unitSupplyPerPopulation
|
||||
|
||||
for (unique in civInfo.getMatchingUniques(UniqueType.UnitSupplyPerPop)) {
|
||||
val applicablePopulation = civInfo.cities
|
||||
|
||||
@ -35,7 +35,7 @@ class CivInfoTransientCache(val civInfo: Civilization) {
|
||||
val uniqueBuildings = hashSetOf<Building>()
|
||||
|
||||
fun setTransients(){
|
||||
val ruleset = civInfo.gameInfo.ruleSet
|
||||
val ruleset = civInfo.gameInfo.ruleset
|
||||
for (resource in ruleset.tileResources.values.asSequence().filter { it.resourceType == ResourceType.Strategic }.map { it.name }) {
|
||||
val applicableBuildings = ruleset.buildings.values.filter { it.requiresResource(resource) && civInfo.getEquivalentBuilding(it) == it }
|
||||
val applicableUnits = ruleset.units.values.filter { it.requiresResource(resource) && civInfo.getEquivalentUnit(it) == it }
|
||||
@ -274,7 +274,7 @@ class CivInfoTransientCache(val civInfo: Civilization) {
|
||||
for (unique in civInfo.getMatchingUniques(UniqueType.ProvidesResources)) {
|
||||
if (unique.sourceObjectType == UniqueTarget.Building || unique.sourceObjectType == UniqueTarget.Wonder) continue // already calculated in city
|
||||
newDetailedCivResources.add(
|
||||
civInfo.gameInfo.ruleSet.tileResources[unique.params[1]]!!,
|
||||
civInfo.gameInfo.ruleset.tileResources[unique.params[1]]!!,
|
||||
unique.sourceObjectType?.name ?: "",
|
||||
unique.params[0].toInt()
|
||||
)
|
||||
@ -285,7 +285,7 @@ class CivInfoTransientCache(val civInfo: Civilization) {
|
||||
|
||||
for (unit in civInfo.units.getCivUnits())
|
||||
newDetailedCivResources.subtractResourceRequirements(
|
||||
unit.baseUnit.getResourceRequirements(), civInfo.gameInfo.ruleSet, "Units")
|
||||
unit.baseUnit.getResourceRequirements(), civInfo.gameInfo.ruleset, "Units")
|
||||
|
||||
// Check if anything has actually changed so we don't update stats for no reason - this uses List equality which means it checks the elements
|
||||
if (civInfo.detailedCivResources == newDetailedCivResources) return
|
||||
|
||||
@ -494,7 +494,7 @@ class TileMap : IsPartOfGameInfoSerialization {
|
||||
unitName: String,
|
||||
civInfo: Civilization
|
||||
): MapUnit? {
|
||||
val unit = gameInfo.ruleSet.units[unitName]!!.getMapUnit(civInfo)
|
||||
val unit = gameInfo.ruleset.units[unitName]!!.getMapUnit(civInfo)
|
||||
|
||||
fun getPassableNeighbours(tile: Tile): Set<Tile> =
|
||||
tile.neighbors.filter { unit.movement.canPassThrough(it) }.toSet()
|
||||
|
||||
@ -88,7 +88,7 @@ class MapUnitCache(val mapUnit: MapUnit) {
|
||||
doubleMovementInTerrain.clear()
|
||||
for (unique in mapUnit.getMatchingUniques(UniqueType.DoubleMovementOnTerrain)) {
|
||||
val param = unique.params[0]
|
||||
val terrain = mapUnit.civ.gameInfo.ruleSet.terrains[param]
|
||||
val terrain = mapUnit.civ.gameInfo.ruleset.terrains[param]
|
||||
doubleMovementInTerrain[param] = when {
|
||||
terrain == null -> DoubleMovementTerrainTarget.Filter
|
||||
terrain.name == Constants.hill -> DoubleMovementTerrainTarget.Hill
|
||||
@ -122,7 +122,7 @@ class MapUnitCache(val mapUnit: MapUnit) {
|
||||
|
||||
hasStrengthBonusInRadiusUnique = mapUnit.hasUnique(UniqueType.StrengthBonusInRadius)
|
||||
hasCitadelPlacementUnique = mapUnit.getMatchingUniques(UniqueType.ConstructImprovementConsumingUnit)
|
||||
.mapNotNull { mapUnit.civ.gameInfo.ruleSet.tileImprovements[it.params[0]] }
|
||||
.mapNotNull { mapUnit.civ.gameInfo.ruleset.tileImprovements[it.params[0]] }
|
||||
.any { it.hasUnique(UniqueType.TakesOverAdjacentTiles) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ class UnitPromotions : IsPartOfGameInfoSerialization {
|
||||
*/
|
||||
fun getPromotions(sorted: Boolean = false): Sequence<Promotion> = sequence {
|
||||
if (promotions.isEmpty()) return@sequence
|
||||
val unitPromotions = unit.civ.gameInfo.ruleSet.unitPromotions
|
||||
val unitPromotions = unit.civ.gameInfo.ruleset.unitPromotions
|
||||
if (sorted && promotions.size > 1) {
|
||||
for (promotion in unitPromotions.values)
|
||||
if (promotion.name in promotions) yield(promotion)
|
||||
@ -65,7 +65,7 @@ class UnitPromotions : IsPartOfGameInfoSerialization {
|
||||
numberOfPromotions++
|
||||
}
|
||||
|
||||
val ruleset = unit.civ.gameInfo.ruleSet
|
||||
val ruleset = unit.civ.gameInfo.ruleset
|
||||
val promotion = ruleset.unitPromotions[promotionName]!!
|
||||
|
||||
if (!promotion.hasUnique(UniqueType.SkipPromotion))
|
||||
@ -93,7 +93,7 @@ class UnitPromotions : IsPartOfGameInfoSerialization {
|
||||
* Checks unit type, already acquired promotions, prerequisites and incompatibility uniques.
|
||||
*/
|
||||
fun getAvailablePromotions(): Sequence<Promotion> {
|
||||
return unit.civ.gameInfo.ruleSet.unitPromotions.values
|
||||
return unit.civ.gameInfo.ruleset.unitPromotions.values
|
||||
.asSequence()
|
||||
.filter { unit.type.name in it.unitTypes && it.name !in promotions }
|
||||
.filter { it.prerequisites.isEmpty() || it.prerequisites.any { p->p in promotions } }
|
||||
|
||||
@ -206,7 +206,7 @@ class UnitTurnManager(val unit: MapUnit) {
|
||||
tile.improvementInProgress == RoadStatus.Railroad.name -> tile.addRoad(RoadStatus.Railroad, unit.civ)
|
||||
tile.improvementInProgress == Constants.repair -> tile.setRepaired()
|
||||
else -> {
|
||||
val improvement = unit.civ.gameInfo.ruleSet.tileImprovements[tile.improvementInProgress]!!
|
||||
val improvement = unit.civ.gameInfo.ruleset.tileImprovements[tile.improvementInProgress]!!
|
||||
improvement.handleImprovementCompletion(unit)
|
||||
tile.changeImprovement(tile.improvementInProgress)
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ class UnitUpgradeManager(val unit:MapUnit) {
|
||||
|
||||
var goldCostOfUpgrade = 0
|
||||
|
||||
val ruleset = unit.civ.gameInfo.ruleSet
|
||||
val ruleset = unit.civ.gameInfo.ruleset
|
||||
val constants = ruleset.modOptions.constants.unitUpgradeCost
|
||||
// apply modifiers: Wonders (Pentagon), Policies (Professional Army). Cached outside loop despite
|
||||
// the UniqueType being allowed on a BaseUnit - we don't have a MapUnit in the loop.
|
||||
|
||||
@ -566,7 +566,7 @@ open class Tile : IsPartOfGameInfoSerialization {
|
||||
}
|
||||
|
||||
fun canBeSettled(): Boolean {
|
||||
val modConstants = tileMap.gameInfo.ruleSet.modOptions.constants
|
||||
val modConstants = tileMap.gameInfo.ruleset.modOptions.constants
|
||||
if (isWater || isImpassible())
|
||||
return false
|
||||
if (getTilesInDistance(modConstants.minimalCityDistanceOnDifferentContinents)
|
||||
|
||||
@ -118,9 +118,9 @@ class TradeEvaluation {
|
||||
}
|
||||
|
||||
TradeType.Technology -> // Currently unused
|
||||
return (sqrt(civInfo.gameInfo.ruleSet.technologies[offer.name]!!.cost.toDouble())
|
||||
return (sqrt(civInfo.gameInfo.ruleset.technologies[offer.name]!!.cost.toDouble())
|
||||
* civInfo.gameInfo.speed.scienceCostModifier).toInt() * 20
|
||||
TradeType.Introduction -> return introductionValue(civInfo.gameInfo.ruleSet)
|
||||
TradeType.Introduction -> return introductionValue(civInfo.gameInfo.ruleset)
|
||||
TradeType.WarDeclaration -> {
|
||||
val civToDeclareWarOn = civInfo.gameInfo.getCivilization(offer.name)
|
||||
val threatToThem = Automation.threatAssessment(civInfo, civToDeclareWarOn)
|
||||
@ -207,7 +207,7 @@ class TradeEvaluation {
|
||||
|
||||
if (!civInfo.isAtWar()) return 50 * offer.amount
|
||||
|
||||
val canUseForUnits = civInfo.gameInfo.ruleSet.units.values
|
||||
val canUseForUnits = civInfo.gameInfo.ruleset.units.values
|
||||
.any { it.getResourceRequirements().containsKey(offer.name)
|
||||
&& it.isBuildable(civInfo) }
|
||||
if (!canUseForUnits) return 50 * offer.amount
|
||||
@ -230,8 +230,8 @@ class TradeEvaluation {
|
||||
}
|
||||
return totalCost
|
||||
}
|
||||
TradeType.Technology -> return sqrt(civInfo.gameInfo.ruleSet.technologies[offer.name]!!.cost.toDouble()).toInt() * 20
|
||||
TradeType.Introduction -> return introductionValue(civInfo.gameInfo.ruleSet)
|
||||
TradeType.Technology -> return sqrt(civInfo.gameInfo.ruleset.technologies[offer.name]!!.cost.toDouble()).toInt() * 20
|
||||
TradeType.Introduction -> return introductionValue(civInfo.gameInfo.ruleset)
|
||||
TradeType.WarDeclaration -> {
|
||||
val civToDeclareWarOn = civInfo.gameInfo.getCivilization(offer.name)
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ class TradeLogic(val ourCivilization:Civilization, val otherCivilization: Civili
|
||||
val otherCivsWeKnow = civInfo.getKnownCivs()
|
||||
.filter { it.civName != otherCivilization.civName && it.isMajorCiv() && !it.isDefeated() }
|
||||
|
||||
if (civInfo.gameInfo.ruleSet.modOptions.hasUnique(ModOptionsConstants.tradeCivIntroductions)) {
|
||||
if (civInfo.gameInfo.ruleset.modOptions.hasUnique(ModOptionsConstants.tradeCivIntroductions)) {
|
||||
val civsWeKnowAndTheyDont = otherCivsWeKnow
|
||||
.filter { !otherCivilization.diplomacy.containsKey(it.civName) && !it.isDefeated() }
|
||||
for (thirdCiv in civsWeKnowAndTheyDont) {
|
||||
@ -59,7 +59,7 @@ class TradeLogic(val ourCivilization:Civilization, val otherCivilization: Civili
|
||||
}
|
||||
|
||||
if (!civInfo.isCityState() && !otherCivilization.isCityState()
|
||||
&& !civInfo.gameInfo.ruleSet.modOptions.hasUnique(ModOptionsConstants.diplomaticRelationshipsCannotChange)) {
|
||||
&& !civInfo.gameInfo.ruleset.modOptions.hasUnique(ModOptionsConstants.diplomaticRelationshipsCannotChange)) {
|
||||
val civsWeBothKnow = otherCivsWeKnow
|
||||
.filter { otherCivilization.diplomacy.containsKey(it.civName) }
|
||||
val civsWeArentAtWarWith = civsWeBothKnow
|
||||
|
||||
@ -53,7 +53,7 @@ class Religion() : INamed, IsPartOfGameInfoSerialization {
|
||||
else name
|
||||
|
||||
private fun mapToExistingBeliefs(beliefs: HashSet<String>): List<Belief> {
|
||||
val rulesetBeliefs = gameInfo.ruleSet.beliefs
|
||||
val rulesetBeliefs = gameInfo.ruleset.beliefs
|
||||
return beliefs.mapNotNull {
|
||||
if (it !in rulesetBeliefs) null
|
||||
else rulesetBeliefs[it]!!
|
||||
|
||||
@ -464,7 +464,7 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
||||
override fun getRejectionReasons(cityConstructions: CityConstructions): Sequence<RejectionReason> = sequence {
|
||||
val cityCenter = cityConstructions.city.getCenterTile()
|
||||
val civ = cityConstructions.city.civ
|
||||
val ruleSet = civ.gameInfo.ruleSet
|
||||
val ruleSet = civ.gameInfo.ruleset
|
||||
|
||||
if (cityConstructions.isBuilt(name))
|
||||
yield(RejectionReasonType.AlreadyBuilt.toInstance())
|
||||
@ -546,7 +546,7 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
||||
|
||||
UniqueType.RequiresBuildingInAllCities -> {
|
||||
val filter = unique.params[0]
|
||||
if (civ.gameInfo.ruleSet.buildings.containsKey(filter)
|
||||
if (civ.gameInfo.ruleset.buildings.containsKey(filter)
|
||||
&& civ.cities.any {
|
||||
!it.isPuppet && !it.cityConstructions.containsBuildingOrEquivalent(unique.params[0])
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ class Milestone(val uniqueDescription: String, private val parentVictory: Victor
|
||||
}
|
||||
|
||||
MilestoneType.CompletePolicyBranches -> {
|
||||
for (branch in civInfo.gameInfo.ruleSet.policyBranches.values) {
|
||||
for (branch in civInfo.gameInfo.ruleset.policyBranches.values) {
|
||||
val finisher = branch.policies.last().name
|
||||
buttons.add(getMilestoneButton(finisher, civInfo.policies.isAdopted(finisher)))
|
||||
}
|
||||
@ -248,7 +248,7 @@ class Milestone(val uniqueDescription: String, private val parentVictory: Victor
|
||||
}
|
||||
|
||||
fun getFocus(civInfo: Civilization): Victory.Focus {
|
||||
val ruleset = civInfo.gameInfo.ruleSet
|
||||
val ruleset = civInfo.gameInfo.ruleset
|
||||
return when (type!!) {
|
||||
MilestoneType.BuiltBuilding -> {
|
||||
val building = ruleset.buildings[params[0]]!!
|
||||
|
||||
@ -131,7 +131,7 @@ class TileResource : RulesetStatsObject() {
|
||||
|
||||
fun getImprovingImprovement(tile: Tile, civInfo: Civilization): String? {
|
||||
return getImprovements().firstOrNull {
|
||||
tile.improvementFunctions.canBuildImprovement(civInfo.gameInfo.ruleSet.tileImprovements[it]!!, civInfo)
|
||||
tile.improvementFunctions.canBuildImprovement(civInfo.gameInfo.ruleset.tileImprovements[it]!!, civInfo)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -128,7 +128,7 @@ class Unique(val text: String, val sourceObjectType: UniqueTarget? = null, val s
|
||||
if (condition.type!!.targetTypes.contains(UniqueTarget.TriggerCondition))
|
||||
return true // not a filtering condition
|
||||
|
||||
fun ruleset() = state.civInfo!!.gameInfo.ruleSet
|
||||
fun ruleset() = state.civInfo!!.gameInfo.ruleset
|
||||
|
||||
val relevantUnit by lazy {
|
||||
if (state.ourCombatant != null && state.ourCombatant is MapUnitCombatant) state.ourCombatant.unit
|
||||
|
||||
@ -47,7 +47,7 @@ object UniqueTriggerActivation {
|
||||
val tileBasedRandom =
|
||||
if (tile != null) Random(tile.position.toString().hashCode())
|
||||
else Random(-550) // Very random indeed
|
||||
val ruleSet = civInfo.gameInfo.ruleSet
|
||||
val ruleSet = civInfo.gameInfo.ruleset
|
||||
|
||||
when (unique.type) {
|
||||
UniqueType.OneTimeFreeUnit -> {
|
||||
@ -616,7 +616,7 @@ object UniqueTriggerActivation {
|
||||
return true
|
||||
}
|
||||
UniqueType.OneTimeUnitGainPromotion -> {
|
||||
val promotion = unit.civ.gameInfo.ruleSet.unitPromotions.keys
|
||||
val promotion = unit.civ.gameInfo.ruleset.unitPromotions.keys
|
||||
.firstOrNull { it == unique.params[0] }
|
||||
?: return false
|
||||
unit.promotions.addPromotion(promotion, true)
|
||||
|
||||
@ -75,7 +75,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
|
||||
// must be after setting name & civInfo because it sets the baseUnit according to the name
|
||||
// and the civInfo is required for using `hasUnique` when determining its movement options
|
||||
unit.setTransients(civInfo.gameInfo.ruleSet)
|
||||
unit.setTransients(civInfo.gameInfo.ruleset)
|
||||
|
||||
return unit
|
||||
}
|
||||
@ -238,7 +238,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
if (unit.matchesFilter(filter)
|
||||
|| (
|
||||
filter == "relevant"
|
||||
&& civInfo.gameInfo.ruleSet.unitPromotions.values
|
||||
&& civInfo.gameInfo.ruleset.unitPromotions.values
|
||||
.any {
|
||||
it.name == promotion
|
||||
&& unit.type.name in it.unitTypes
|
||||
|
||||
@ -39,7 +39,7 @@ class Simulation(
|
||||
for (civ in civilizations) {
|
||||
this.winRate[civ] = MutableInt(0)
|
||||
winRateByVictory[civ] = mutableMapOf()
|
||||
for (victory in UncivGame.Current.gameInfo!!.ruleSet.victories.keys)
|
||||
for (victory in UncivGame.Current.gameInfo!!.ruleset.victories.keys)
|
||||
winRateByVictory[civ]!![victory] = MutableInt(0)
|
||||
}
|
||||
}
|
||||
@ -122,7 +122,7 @@ class Simulation(
|
||||
outString += "\n$civ:\n"
|
||||
val wins = winRate[civ]!!.value * 100 / max(steps.size, 1)
|
||||
outString += "$wins% total win rate \n"
|
||||
for (victory in UncivGame.Current.gameInfo!!.ruleSet.victories.keys) {
|
||||
for (victory in UncivGame.Current.gameInfo!!.ruleset.victories.keys) {
|
||||
val winsVictory = winRateByVictory[civ]!![victory]!!.value * 100 / max(winRate[civ]!!.value, 1)
|
||||
outString += "$victory: $winsVictory% "
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ object SoundPlayer {
|
||||
|
||||
// Get a hash covering all mods - quickly, so don't map, cast or copy the Set types
|
||||
val gameInfo = game.gameInfo
|
||||
val hash1 = if (gameInfo != null) gameInfo.ruleSet.mods.hashCode() else 0
|
||||
val hash1 = if (gameInfo != null) gameInfo.ruleset.mods.hashCode() else 0
|
||||
val newHash = hash1.xor(game.settings.visualMods.hashCode())
|
||||
|
||||
// If hash the same, leave the cache as is
|
||||
@ -94,7 +94,7 @@ object SoundPlayer {
|
||||
val modList: MutableSet<String> = mutableSetOf()
|
||||
val gameInfo = game.gameInfo
|
||||
if (gameInfo != null) {
|
||||
modList.addAll(gameInfo.ruleSet.mods) // Sounds from game mods
|
||||
modList.addAll(gameInfo.ruleset.mods) // Sounds from game mods
|
||||
}
|
||||
modList.addAll(game.settings.visualMods)
|
||||
|
||||
|
||||
@ -86,7 +86,7 @@ class CityReligionInfoTable(
|
||||
val newScreen = if (religion == iconName) {
|
||||
EmpireOverviewScreen(civInfo, EmpireOverviewCategories.Religion.name, religion)
|
||||
} else {
|
||||
CivilopediaScreen(gameInfo.ruleSet, CivilopediaCategories.Belief, religion)
|
||||
CivilopediaScreen(gameInfo.ruleset, CivilopediaCategories.Belief, religion)
|
||||
}
|
||||
UncivGame.Current.pushScreen(newScreen)
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ class FormattedLine (
|
||||
private fun getCurrentRuleset() = when {
|
||||
!UncivGame.isCurrentInitialized() -> Ruleset()
|
||||
UncivGame.Current.gameInfo == null -> RulesetCache[BaseRuleset.Civ_V_Vanilla.fullName]!!
|
||||
else -> UncivGame.Current.gameInfo!!.ruleSet
|
||||
else -> UncivGame.Current.gameInfo!!.ruleset
|
||||
}
|
||||
private fun initNamesCategoryMap(ruleSet: Ruleset): HashMap<String, CivilopediaCategories> {
|
||||
//val startTime = System.nanoTime()
|
||||
|
||||
@ -60,7 +60,7 @@ class ImageAttempter<out T: Any>(val scope: T) {
|
||||
return tryImages(
|
||||
(civInfo.getEraNumber() downTo 0).asSequence().map {
|
||||
{
|
||||
val era = civInfo.gameInfo.ruleSet.eras.keys.elementAt(it)
|
||||
val era = civInfo.gameInfo.ruleset.eras.keys.elementAt(it)
|
||||
if (style != null)
|
||||
tileSetStrings.getString(locationToCheck, tileSetStrings.tag, style, tileSetStrings.tag, era)
|
||||
else
|
||||
|
||||
@ -52,14 +52,14 @@ class MapEditorViewTab(
|
||||
nation = Nation()
|
||||
nation.name = "Test"
|
||||
gameInfo = GameInfo()
|
||||
gameInfo.ruleSet = ruleset
|
||||
gameInfo.ruleset = ruleset
|
||||
// show yields of strategic resources too
|
||||
tech.techsResearched.addAll(ruleset.technologies.keys)
|
||||
}
|
||||
|
||||
private fun Civilization.updateMockCiv(ruleset: Ruleset) {
|
||||
if (gameInfo.ruleSet === ruleset) return
|
||||
gameInfo.ruleSet = ruleset
|
||||
if (gameInfo.ruleset === ruleset) return
|
||||
gameInfo.ruleset = ruleset
|
||||
tech.techsResearched.addAll(ruleset.technologies.keys)
|
||||
}
|
||||
|
||||
|
||||
@ -82,7 +82,7 @@ fun debugTab() = Table(BaseScreen.skin).apply {
|
||||
unlockTechsButton.onClick {
|
||||
if (curGameInfo == null)
|
||||
return@onClick
|
||||
for (tech in curGameInfo.ruleSet.technologies.keys) {
|
||||
for (tech in curGameInfo.ruleset.technologies.keys) {
|
||||
if (tech !in curGameInfo.getCurrentPlayerCivilization().tech.techsResearched) {
|
||||
curGameInfo.getCurrentPlayerCivilization().tech.addTechnology(tech)
|
||||
curGameInfo.getCurrentPlayerCivilization().popupAlerts.removeLastOrNull()
|
||||
@ -98,7 +98,7 @@ fun debugTab() = Table(BaseScreen.skin).apply {
|
||||
if (curGameInfo == null)
|
||||
return@onClick
|
||||
val ownedTiles = curGameInfo.tileMap.values.asSequence().filter { it.getOwner() == curGameInfo.getCurrentPlayerCivilization() }
|
||||
val resourceTypes = curGameInfo.ruleSet.tileResources.values.asSequence().filter { it.resourceType == ResourceType.Strategic }
|
||||
val resourceTypes = curGameInfo.ruleset.tileResources.values.asSequence().filter { it.resourceType == ResourceType.Strategic }
|
||||
for ((tile, resource) in ownedTiles zip resourceTypes) {
|
||||
tile.resource = resource.name
|
||||
tile.resourceAmount = 999
|
||||
|
||||
@ -99,7 +99,7 @@ class NotificationsOverviewTable(
|
||||
notification.action?.execute(worldScreen)
|
||||
}
|
||||
|
||||
notification.addNotificationIcons(worldScreen.gameInfo.ruleSet, iconSize, notificationTable)
|
||||
notification.addNotificationIcons(worldScreen.gameInfo.ruleset, iconSize, notificationTable)
|
||||
|
||||
turnTable.add(notificationTable).padTop(5f)
|
||||
turnTable.padTop(20f).row()
|
||||
|
||||
@ -176,7 +176,7 @@ class ReligionOverviewTab(
|
||||
MarkupRenderer.render(
|
||||
belief.getCivilopediaTextLines(withHeader = true)
|
||||
) {
|
||||
UncivGame.Current.pushScreen(CivilopediaScreen(gameInfo.ruleSet, link = it))
|
||||
UncivGame.Current.pushScreen(CivilopediaScreen(gameInfo.ruleset, link = it))
|
||||
}.apply {
|
||||
background = BaseScreen.skinStrings.getUiBackground(
|
||||
"OverviewScreen/ReligionOverviewTab/BeliefDescription",
|
||||
|
||||
@ -85,7 +85,7 @@ class ResourcesOverviewTab(
|
||||
}
|
||||
private fun TileResource.getLabel() = name.toLabel().apply {
|
||||
onClick {
|
||||
overviewScreen.game.pushScreen(CivilopediaScreen(gameInfo.ruleSet, CivilopediaCategories.Resource, this@getLabel.name))
|
||||
overviewScreen.game.pushScreen(CivilopediaScreen(gameInfo.ruleset, CivilopediaCategories.Resource, this@getLabel.name))
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ class ResourcesOverviewTab(
|
||||
val newResourceSupplyList = ResourceSupplyList()
|
||||
for (city in viewingPlayer.cities) {
|
||||
if (city.demandedResource.isEmpty()) continue
|
||||
val wltkResource = gameInfo.ruleSet.tileResources[city.demandedResource] ?: continue
|
||||
val wltkResource = gameInfo.ruleset.tileResources[city.demandedResource] ?: continue
|
||||
if (city.isWeLoveTheKingDayActive()) {
|
||||
newResourceSupplyList.add(wltkResource, ExtraInfoOrigin.CelebratingWLKT.name)
|
||||
} else {
|
||||
|
||||
@ -41,7 +41,7 @@ class StatsOverviewTab(
|
||||
scoreTable.defaults().pad(5f)
|
||||
|
||||
goldAndSliderTable.add(goldTable).row()
|
||||
if (gameInfo.ruleSet.modOptions.uniques.contains(ModOptionsConstants.convertGoldToScience))
|
||||
if (gameInfo.ruleset.modOptions.uniques.contains(ModOptionsConstants.convertGoldToScience))
|
||||
goldAndSliderTable.addGoldSlider()
|
||||
|
||||
update()
|
||||
|
||||
@ -22,7 +22,7 @@ class WonderOverviewTab(
|
||||
viewingPlayer: Civilization,
|
||||
overviewScreen: EmpireOverviewScreen
|
||||
) : EmpireOverviewTab(viewingPlayer, overviewScreen) {
|
||||
val ruleSet = gameInfo.ruleSet
|
||||
val ruleSet = gameInfo.ruleset
|
||||
|
||||
val wonderInfo = WonderInfo()
|
||||
private val wonders: Array<WonderInfo.WonderInfo> = wonderInfo.collectInfo(viewingPlayer)
|
||||
@ -92,7 +92,7 @@ class WonderOverviewTab(
|
||||
|
||||
class WonderInfo {
|
||||
val gameInfo = UncivGame.Current.gameInfo!!
|
||||
val ruleSet = gameInfo.ruleSet
|
||||
val ruleSet = gameInfo.ruleset
|
||||
private val hideReligionItems = !gameInfo.isReligionEnabled()
|
||||
private val startingObsolete = ruleSet.eras[gameInfo.gameParameters.startingEra]!!.startingObsoleteWonders
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ class ImprovementPickerScreen(
|
||||
|
||||
private var selectedImprovement: TileImprovement? = null
|
||||
private val gameInfo = tile.tileMap.gameInfo
|
||||
private val ruleSet = gameInfo.ruleSet
|
||||
private val ruleSet = gameInfo.ruleset
|
||||
private val currentPlayerCiv = gameInfo.getCurrentPlayerCivilization()
|
||||
// Support for UniqueType.CreatesOneImprovement
|
||||
private val tileMarkedForCreatesOneImprovement = tile.isMarkedForCreatesOneImprovement()
|
||||
|
||||
@ -202,7 +202,7 @@ class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: Civilization = w
|
||||
|
||||
topTable.row()
|
||||
|
||||
val branches = viewingCiv.gameInfo.ruleSet.policyBranches
|
||||
val branches = viewingCiv.gameInfo.ruleset.policyBranches
|
||||
val rowChangeCount: Int
|
||||
|
||||
// estimate how many branch boxes fit using average size (including pad)
|
||||
@ -304,7 +304,7 @@ class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: Civilization = w
|
||||
val onAdoption = branch.getDescription()
|
||||
val onCompletion = branch.policies.last().getDescription()
|
||||
var text = ""
|
||||
if (viewingCiv.gameInfo.ruleSet.eras[branch.era]!!.eraNumber > viewingCiv.getEraNumber())
|
||||
if (viewingCiv.gameInfo.ruleset.eras[branch.era]!!.eraNumber > viewingCiv.getEraNumber())
|
||||
text += "{Unlocked at} {${branch.era}}" + "\n\n"
|
||||
text += "{On adoption}:" + "\n\n" + onAdoption + "\n\n" +
|
||||
"{On completion}:" + "\n\n" + onCompletion
|
||||
@ -562,7 +562,7 @@ class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: Civilization = w
|
||||
table.add(expandIcon).minWidth(15f).expandX().left()
|
||||
table.add(branch.name.tr().uppercase().toLabel(fontSize = 14).apply { setAlignment(Align.center) }).center()
|
||||
table.add(icon).expandX().left().padLeft(5f)
|
||||
|
||||
|
||||
table.setTouchable(Touchable.enabled)
|
||||
|
||||
header.add(table).minWidth(150f).growX()
|
||||
@ -582,7 +582,7 @@ class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: Civilization = w
|
||||
if (viewingCiv.policies.isAdopted(branch.name)) {
|
||||
policy = branch.policies.last()
|
||||
text = "Completed"
|
||||
} else if (viewingCiv.gameInfo.ruleSet.eras[branch.era]!!.eraNumber > viewingCiv.getEraNumber()) {
|
||||
} else if (viewingCiv.gameInfo.ruleset.eras[branch.era]!!.eraNumber > viewingCiv.getEraNumber()) {
|
||||
policy = branch
|
||||
text = branch.era
|
||||
} else {
|
||||
|
||||
@ -170,7 +170,7 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen(), RecreateOnResiz
|
||||
availablePromotionsGroup.defaults().pad(5f)
|
||||
|
||||
val unitType = unit.type
|
||||
val promotionsForUnitType = unit.civ.gameInfo.ruleSet.unitPromotions.values.filter {
|
||||
val promotionsForUnitType = unit.civ.gameInfo.ruleset.unitPromotions.values.filter {
|
||||
it.unitTypes.contains(unitType.name) || unit.promotions.promotions.contains(it.name)
|
||||
}
|
||||
//Always allow the user to rename the unit as many times as they like.
|
||||
|
||||
@ -30,7 +30,7 @@ abstract class ReligionPickerScreenCommon(
|
||||
) : PickerScreen(disableScroll) {
|
||||
|
||||
protected val gameInfo = choosingCiv.gameInfo
|
||||
protected val ruleset = gameInfo.ruleSet
|
||||
protected val ruleset = gameInfo.ruleset
|
||||
|
||||
private val descriptionTable = Table(skin)
|
||||
private val descriptionScroll = descriptionLabel.parent as ScrollPane
|
||||
|
||||
@ -99,7 +99,7 @@ class TechButton(techName:String, private val techManager: TechManager, isWorldS
|
||||
val techIconSize = 30f
|
||||
|
||||
val civName = techManager.civInfo.civName
|
||||
val ruleset = techManager.civInfo.gameInfo.ruleSet
|
||||
val ruleset = techManager.civInfo.gameInfo.ruleset
|
||||
|
||||
val tech = ruleset.technologies[techName]!!
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ class TechPickerScreen(
|
||||
private val techTable = Table()
|
||||
|
||||
// All these are to counter performance problems when updating buttons for all techs.
|
||||
private var researchableTechs = civInfo.gameInfo.ruleSet.technologies.keys
|
||||
private var researchableTechs = civInfo.gameInfo.ruleset.technologies.keys
|
||||
.filter { civTech.canBeResearched(it) }.toHashSet()
|
||||
|
||||
private val currentTechColor = colorFromRGB(72, 147, 175)
|
||||
@ -61,7 +61,7 @@ class TechPickerScreen(
|
||||
private val queuedTechColor = colorFromRGB(7*2, 46*2, 43*2)
|
||||
|
||||
|
||||
private val turnsToTech = civInfo.gameInfo.ruleSet.technologies.values.associateBy({ it.name }, { civTech.turnsToTech(it.name) })
|
||||
private val turnsToTech = civInfo.gameInfo.ruleset.technologies.values.associateBy({ it.name }, { civTech.turnsToTech(it.name) })
|
||||
|
||||
init {
|
||||
setDefaultCloseAction()
|
||||
@ -69,7 +69,7 @@ class TechPickerScreen(
|
||||
|
||||
descriptionLabel.onClick {
|
||||
if (selectedTech != null)
|
||||
game.pushScreen(CivilopediaScreen(civInfo.gameInfo.ruleSet, CivilopediaCategories.Technology, selectedTech!!.name))
|
||||
game.pushScreen(CivilopediaScreen(civInfo.gameInfo.ruleset, CivilopediaCategories.Technology, selectedTech!!.name))
|
||||
}
|
||||
|
||||
tempTechsToResearch = ArrayList(civTech.techsToResearch)
|
||||
@ -95,7 +95,7 @@ class TechPickerScreen(
|
||||
} else {
|
||||
// center on any possible technology which is ready for the research right now
|
||||
val firstAvailable = researchableTechs.firstOrNull()
|
||||
val firstAvailableTech = civInfo.gameInfo.ruleSet.technologies[firstAvailable]
|
||||
val firstAvailableTech = civInfo.gameInfo.ruleset.technologies[firstAvailable]
|
||||
if (firstAvailableTech != null)
|
||||
centerOnTechnology(firstAvailableTech)
|
||||
}
|
||||
@ -120,7 +120,7 @@ class TechPickerScreen(
|
||||
for (label in eraLabels) label.remove()
|
||||
eraLabels.clear()
|
||||
|
||||
val allTechs = civInfo.gameInfo.ruleSet.technologies.values
|
||||
val allTechs = civInfo.gameInfo.ruleset.technologies.values
|
||||
if (allTechs.isEmpty()) return
|
||||
val columns = allTechs.maxOf { it.column!!.columnNumber } + 1
|
||||
val rows = allTechs.maxOf { it.row } + 1
|
||||
@ -141,7 +141,7 @@ class TechPickerScreen(
|
||||
val columnSpan = eraColumns.size
|
||||
val color = when {
|
||||
civTech.era.name == era -> queuedTechColor
|
||||
civInfo.gameInfo.ruleSet.eras[era]!!.eraNumber < civTech.era.eraNumber -> colorFromRGB(255, 175, 0)
|
||||
civInfo.gameInfo.ruleset.eras[era]!!.eraNumber < civTech.era.eraNumber -> colorFromRGB(255, 175, 0)
|
||||
else -> Color.BLACK.cpy()
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ class TechPickerScreen(
|
||||
|
||||
val label = era.toLabel().apply {
|
||||
setAlignment(Align.center)
|
||||
if (civInfo.gameInfo.ruleSet.eras[era]!!.eraNumber < civTech.era.eraNumber)
|
||||
if (civInfo.gameInfo.ruleset.eras[era]!!.eraNumber < civTech.era.eraNumber)
|
||||
this.color = colorFromRGB(120, 46, 16) }
|
||||
|
||||
eraLabels.add(label)
|
||||
@ -246,7 +246,7 @@ class TechPickerScreen(
|
||||
lines.add(line)
|
||||
}
|
||||
|
||||
for (tech in civInfo.gameInfo.ruleSet.technologies.values) {
|
||||
for (tech in civInfo.gameInfo.ruleset.technologies.values) {
|
||||
if (!techNameToButton.containsKey(tech.name)) {
|
||||
ToastPopup("Tech ${tech.name} appears to be missing - perhaps two techs have the same row & column", this)
|
||||
continue
|
||||
@ -373,7 +373,7 @@ class TechPickerScreen(
|
||||
|
||||
val previousSelectedTech = selectedTech
|
||||
selectedTech = tech
|
||||
descriptionLabel.setText(tech?.getDescription(civInfo.gameInfo.ruleSet))
|
||||
descriptionLabel.setText(tech?.getDescription(civInfo.gameInfo.ruleset))
|
||||
|
||||
if (!switchFromWorldScreen)
|
||||
return
|
||||
|
||||
@ -132,7 +132,7 @@ class DiplomacyScreen(
|
||||
civIndicator.addActor(relationshipIcon)
|
||||
|
||||
if (civ.isCityState()) {
|
||||
val innerColor = civ.gameInfo.ruleSet.nations[civ.civName]!!.getInnerColor()
|
||||
val innerColor = civ.gameInfo.ruleset.nations[civ.civName]!!.getInnerColor()
|
||||
val typeIcon = ImageGetter.getImage("CityStateIcons/"+civ.cityStateType.name)
|
||||
.surroundWithCircle(size = 35f, color = innerColor).apply {
|
||||
actor.color = Color.BLACK
|
||||
@ -206,7 +206,7 @@ class DiplomacyScreen(
|
||||
resourcesTable.add(wrapper).padRight(20f)
|
||||
wrapper.addTooltip(name, 18f)
|
||||
wrapper.onClick {
|
||||
UncivGame.Current.pushScreen(CivilopediaScreen(UncivGame.Current.gameInfo!!.ruleSet, link = "Resource/$name"))
|
||||
UncivGame.Current.pushScreen(CivilopediaScreen(UncivGame.Current.gameInfo!!.ruleset, link = "Resource/$name"))
|
||||
}
|
||||
}
|
||||
diplomacyTable.add(resourcesTable).row()
|
||||
@ -280,7 +280,7 @@ class DiplomacyScreen(
|
||||
|
||||
if (otherCiv.cityStateUniqueUnit != null) {
|
||||
val unitName = otherCiv.cityStateUniqueUnit
|
||||
val techName = viewingCiv.gameInfo.ruleSet.units[otherCiv.cityStateUniqueUnit]!!.requiredTech
|
||||
val techName = viewingCiv.gameInfo.ruleset.units[otherCiv.cityStateUniqueUnit]!!.requiredTech
|
||||
diplomacyTable.add("[${otherCiv.civName}] is able to provide [${unitName}] once [${techName}] is researched.".toLabel(fontSize = Constants.defaultFontSize)).row()
|
||||
}
|
||||
|
||||
@ -320,7 +320,7 @@ class DiplomacyScreen(
|
||||
if (isNotPlayersTurn() || viewingCiv.isAtWarWith(otherCiv)) demandTributeButton.disable()
|
||||
|
||||
val diplomacyManager = viewingCiv.getDiplomacyManager(otherCiv)
|
||||
if (!viewingCiv.gameInfo.ruleSet.modOptions.uniques.contains(ModOptionsConstants.diplomaticRelationshipsCannotChange)) {
|
||||
if (!viewingCiv.gameInfo.ruleset.modOptions.uniques.contains(ModOptionsConstants.diplomaticRelationshipsCannotChange)) {
|
||||
if (viewingCiv.isAtWarWith(otherCiv))
|
||||
diplomacyTable.add(getNegotiatePeaceCityStateButton(otherCiv, diplomacyManager)).row()
|
||||
else diplomacyTable.add(getDeclareWarButton(diplomacyManager, otherCiv)).row()
|
||||
@ -427,7 +427,7 @@ class DiplomacyScreen(
|
||||
if (otherCiv.cities.isEmpty()) return null
|
||||
val improvableResourceTiles = getImprovableResourceTiles(otherCiv)
|
||||
val improvements =
|
||||
otherCiv.gameInfo.ruleSet.tileImprovements.filter { it.value.turnsToBuild != 0 }
|
||||
otherCiv.gameInfo.ruleset.tileImprovements.filter { it.value.turnsToBuild != 0 }
|
||||
var needsImprovements = false
|
||||
|
||||
for (improvableTile in improvableResourceTiles)
|
||||
@ -507,7 +507,7 @@ class DiplomacyScreen(
|
||||
|
||||
val improvableResourceTiles = getImprovableResourceTiles(otherCiv)
|
||||
val tileImprovements =
|
||||
otherCiv.gameInfo.ruleSet.tileImprovements
|
||||
otherCiv.gameInfo.ruleset.tileImprovements
|
||||
|
||||
for (improvableTile in improvableResourceTiles) {
|
||||
for (tileImprovement in tileImprovements.values) {
|
||||
@ -589,7 +589,7 @@ class DiplomacyScreen(
|
||||
val questTable = Table()
|
||||
questTable.defaults().pad(10f)
|
||||
|
||||
val quest: Quest = viewingCiv.gameInfo.ruleSet.quests[assignedQuest.questName]!!
|
||||
val quest: Quest = viewingCiv.gameInfo.ruleset.quests[assignedQuest.questName]!!
|
||||
val remainingTurns: Int = assignedQuest.getRemainingTurns()
|
||||
val title = if (quest.influence > 0)
|
||||
"[${quest.name}] (+[${quest.influence.toInt()}] influence)"
|
||||
@ -647,7 +647,7 @@ class DiplomacyScreen(
|
||||
diplomacyTable.addSeparator()
|
||||
|
||||
val diplomaticRelationshipsCanChange =
|
||||
!viewingCiv.gameInfo.ruleSet.modOptions.uniques.contains(ModOptionsConstants.diplomaticRelationshipsCannotChange)
|
||||
!viewingCiv.gameInfo.ruleset.modOptions.uniques.contains(ModOptionsConstants.diplomaticRelationshipsCannotChange)
|
||||
|
||||
val diplomacyManager = viewingCiv.getDiplomacyManager(otherCiv)
|
||||
|
||||
|
||||
@ -92,7 +92,7 @@ class OffersListScroll(
|
||||
Luxury_Resource, Strategic_Resource ->
|
||||
ImageGetter.getResourcePortrait(offer.name, 30f)
|
||||
WarDeclaration ->
|
||||
ImageGetter.getNationPortrait(UncivGame.Current.gameInfo!!.ruleSet.nations[offer.name]!!, 30f)
|
||||
ImageGetter.getNationPortrait(UncivGame.Current.gameInfo!!.ruleset.nations[offer.name]!!, 30f)
|
||||
else -> null
|
||||
}
|
||||
val tradeButton = IconTextButton(tradeLabel, tradeIcon).apply {
|
||||
|
||||
@ -78,10 +78,10 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
||||
private fun wonOrLost(description: String, victoryType: String?, hasWon: Boolean) {
|
||||
val endGameMessage =
|
||||
when {
|
||||
hasWon && (victoryType == null || victoryType !in gameInfo.ruleSet.victories) -> "Your civilization stands above all others! The exploits of your people shall be remembered until the end of civilization itself!"
|
||||
victoryType == null || victoryType !in gameInfo.ruleSet.victories -> "You have been defeated. Your civilization has been overwhelmed by its many foes. But your people do not despair, for they know that one day you shall return - and lead them forward to victory!"
|
||||
hasWon -> playerCivInfo.gameInfo.ruleSet.victories[victoryType]!!.victoryString
|
||||
else -> playerCivInfo.gameInfo.ruleSet.victories[victoryType]!!.defeatString
|
||||
hasWon && (victoryType == null || victoryType !in gameInfo.ruleset.victories) -> "Your civilization stands above all others! The exploits of your people shall be remembered until the end of civilization itself!"
|
||||
victoryType == null || victoryType !in gameInfo.ruleset.victories -> "You have been defeated. Your civilization has been overwhelmed by its many foes. But your people do not despair, for they know that one day you shall return - and lead them forward to victory!"
|
||||
hasWon -> playerCivInfo.gameInfo.ruleset.victories[victoryType]!!.victoryString
|
||||
else -> playerCivInfo.gameInfo.ruleset.victories[victoryType]!!.defeatString
|
||||
}
|
||||
|
||||
descriptionLabel.setText(description.tr() + "\n" + endGameMessage.tr())
|
||||
@ -126,7 +126,7 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
||||
}
|
||||
|
||||
private fun getOurVictoryColumn(victory: String): Table {
|
||||
val victoryObject = gameInfo.ruleSet.victories[victory]!!
|
||||
val victoryObject = gameInfo.ruleset.victories[victory]!!
|
||||
val table = Table()
|
||||
table.defaults().pad(5f)
|
||||
var firstIncomplete = true
|
||||
@ -150,7 +150,7 @@ class VictoryScreen(val worldScreen: WorldScreen) : PickerScreen() {
|
||||
private fun setGlobalVictoryTable() {
|
||||
val majorCivs = gameInfo.civilizations.filter { it.isMajorCiv() }
|
||||
val globalVictoryTable = Table().apply { defaults().pad(10f) }
|
||||
val victoriesToShow = gameInfo.ruleSet.victories.filter { !it.value.hiddenInVictoryScreen && enabledVictoryTypes.contains(it.key) }
|
||||
val victoriesToShow = gameInfo.ruleset.victories.filter { !it.value.hiddenInVictoryScreen && enabledVictoryTypes.contains(it.key) }
|
||||
|
||||
for (victory in victoriesToShow) {
|
||||
globalVictoryTable.add(getGlobalVictoryColumn(majorCivs, victory.key))
|
||||
|
||||
@ -193,7 +193,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
||||
add(getCloseButton("Very well."))
|
||||
}
|
||||
AlertType.WonderBuilt -> {
|
||||
val wonder = worldScreen.gameInfo.ruleSet.buildings[popupAlert.value]!!
|
||||
val wonder = worldScreen.gameInfo.ruleset.buildings[popupAlert.value]!!
|
||||
addGoodSizedLabel(wonder.name)
|
||||
addSeparator()
|
||||
if(ImageGetter.wonderImageExists(wonder.name)) { // Wonder Graphic exists
|
||||
@ -222,7 +222,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
||||
UncivGame.Current.musicController.chooseTrack(wonder.name, MusicMood.Wonder, MusicTrackChooserFlags.setSpecific)
|
||||
}
|
||||
AlertType.TechResearched -> {
|
||||
val gameBasics = worldScreen.gameInfo.ruleSet
|
||||
val gameBasics = worldScreen.gameInfo.ruleset
|
||||
val tech = gameBasics.technologies[popupAlert.value]!!
|
||||
addGoodSizedLabel(tech.name)
|
||||
addSeparator()
|
||||
|
||||
@ -103,7 +103,7 @@ class NotificationsScroll(
|
||||
listItem.add(label).padRight(10f)
|
||||
}
|
||||
|
||||
notification.addNotificationIcons(worldScreen.gameInfo.ruleSet, iconSize, listItem)
|
||||
notification.addNotificationIcons(worldScreen.gameInfo.ruleset, iconSize, listItem)
|
||||
|
||||
// using a large click area with no gap in between each message item.
|
||||
// this avoids accidentally clicking in between the messages, resulting in a map click
|
||||
|
||||
@ -82,7 +82,7 @@ class TechPolicyDiplomacyButtons(val worldScreen: WorldScreen) : Table(BaseScree
|
||||
private fun updateTechButton() {
|
||||
techButtonHolder.touchable = Touchable.disabled
|
||||
techButtonHolder.actor = null
|
||||
if (worldScreen.gameInfo.ruleSet.technologies.isEmpty() || viewingCiv.cities.isEmpty()) return
|
||||
if (worldScreen.gameInfo.ruleset.technologies.isEmpty() || viewingCiv.cities.isEmpty()) return
|
||||
techButtonHolder.touchable = Touchable.enabled
|
||||
|
||||
if (viewingCiv.tech.currentTechnology() != null) {
|
||||
|
||||
@ -598,7 +598,7 @@ class WorldMapHolder(
|
||||
|
||||
// Fade out improvement icons (but not barb camps or ruins)
|
||||
if (shownImprovement != null && shownImprovement != Constants.barbarianEncampment
|
||||
&& !unit.civ.gameInfo.ruleSet.tileImprovements[shownImprovement]!!.isAncientRuinsEquivalent())
|
||||
&& !unit.civ.gameInfo.ruleset.tileImprovements[shownImprovement]!!.isAncientRuinsEquivalent())
|
||||
group.layerMisc.dimImprovement(true)
|
||||
}
|
||||
}
|
||||
|
||||
@ -221,7 +221,7 @@ class WorldScreen(
|
||||
|
||||
private fun addKeyboardPresses() {
|
||||
// Space and N are assigned in createNextTurnButton
|
||||
globalShortcuts.add(Input.Keys.F1) { game.pushScreen(CivilopediaScreen(gameInfo.ruleSet)) }
|
||||
globalShortcuts.add(Input.Keys.F1) { game.pushScreen(CivilopediaScreen(gameInfo.ruleset)) }
|
||||
globalShortcuts.add('E') { game.pushScreen(EmpireOverviewScreen(selectedCiv)) } // Empire overview last used page
|
||||
/*
|
||||
* These try to be faithful to default Civ5 key bindings as found in several places online
|
||||
|
||||
@ -148,7 +148,7 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
||||
worldScreen.game.pushScreen(EmpireOverviewScreen(worldScreen.selectedCiv, "Resources"))
|
||||
}
|
||||
|
||||
val strategicResources = worldScreen.gameInfo.ruleSet.tileResources.values
|
||||
val strategicResources = worldScreen.gameInfo.ruleset.tileResources.values
|
||||
.filter { it.resourceType == ResourceType.Strategic }
|
||||
for (resource in strategicResources) {
|
||||
val resourceImage = ImageGetter.getResourcePortrait(resource.name, 20f)
|
||||
@ -217,7 +217,7 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
||||
selectedCivLabel.setFontSize(25)
|
||||
selectedCivLabel.onClick {
|
||||
val civilopediaScreen = CivilopediaScreen(
|
||||
worldScreen.selectedCiv.gameInfo.ruleSet,
|
||||
worldScreen.selectedCiv.gameInfo.ruleset,
|
||||
CivilopediaCategories.Nation,
|
||||
worldScreen.selectedCiv.civName
|
||||
)
|
||||
@ -240,7 +240,7 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
||||
this.selectedCiv = newCiv
|
||||
|
||||
selectedCivLabel.setText(newCiv.tr())
|
||||
val nation = worldScreen.gameInfo.ruleSet.nations[worldScreen.selectedCiv.civName]!!
|
||||
val nation = worldScreen.gameInfo.ruleset.nations[worldScreen.selectedCiv.civName]!!
|
||||
val selectedCivIcon = ImageGetter.getNationPortrait(nation, 35f)
|
||||
selectedCivIconHolder.actor = selectedCivIcon
|
||||
invalidate()
|
||||
|
||||
@ -188,7 +188,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
||||
}
|
||||
|
||||
// from Battle.addXp(), check for can't gain more XP from Barbarians
|
||||
val maxXPFromBarbarians = attacker.getCivInfo().gameInfo.ruleSet.modOptions.constants.maxXPfromBarbarians
|
||||
val maxXPFromBarbarians = attacker.getCivInfo().gameInfo.ruleset.modOptions.constants.maxXPfromBarbarians
|
||||
if (attacker is MapUnitCombatant && attacker.unit.promotions.totalXpProduced() >= maxXPFromBarbarians
|
||||
&& defender.getCivInfo().isBarbarian()){
|
||||
add("Cannot gain more XP from Barbarians".toLabel(fontSize = 16).apply { wrap = true }).width(quarterScreen)
|
||||
|
||||
@ -30,7 +30,7 @@ class TileInfoTable(private val viewingCiv :Civilization) : Table(BaseScreen.ski
|
||||
if (tile != null && (UncivGame.Current.viewEntireMapForDebug || viewingCiv.hasExplored(tile)) ) {
|
||||
add(getStatsTable(tile))
|
||||
add(MarkupRenderer.render(TileDescription.toMarkup(tile, viewingCiv), padding = 0f, iconDisplay = IconDisplay.None) {
|
||||
UncivGame.Current.pushScreen(CivilopediaScreen(viewingCiv.gameInfo.ruleSet, link = it))
|
||||
UncivGame.Current.pushScreen(CivilopediaScreen(viewingCiv.gameInfo.ruleset, link = it))
|
||||
} ).pad(5f).row()
|
||||
if (UncivGame.Current.viewEntireMapForDebug)
|
||||
add(tile.position.run { "(${x.toInt()},${y.toInt()})" }.toLabel()).colspan(2).pad(5f)
|
||||
|
||||
@ -24,7 +24,7 @@ class WorldScreenMenuPopup(val worldScreen: WorldScreen) : Popup(worldScreen) {
|
||||
}.row()
|
||||
addButton("Civilopedia") {
|
||||
close()
|
||||
worldScreen.game.pushScreen(CivilopediaScreen(worldScreen.gameInfo.ruleSet))
|
||||
worldScreen.game.pushScreen(CivilopediaScreen(worldScreen.gameInfo.ruleset))
|
||||
}.row()
|
||||
addButton("Save game") {
|
||||
close()
|
||||
|
||||
@ -275,7 +275,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table() {
|
||||
}
|
||||
|
||||
unitIconHolder.onClick {
|
||||
worldScreen.game.pushScreen(CivilopediaScreen(worldScreen.gameInfo.ruleSet, CivilopediaCategories.Unit, selectedUnit!!.name))
|
||||
worldScreen.game.pushScreen(CivilopediaScreen(worldScreen.gameInfo.ruleset, CivilopediaCategories.Unit, selectedUnit!!.name))
|
||||
}
|
||||
} else { // multiple selected units
|
||||
for (unit in selectedUnits)
|
||||
|
||||
@ -367,7 +367,7 @@ object UnitActions {
|
||||
|
||||
val couldConstruct = unit.currentMovement > 0
|
||||
&& !tile.isCityCenter()
|
||||
&& unit.civ.gameInfo.ruleSet.tileImprovements.values.any {
|
||||
&& unit.civ.gameInfo.ruleset.tileImprovements.values.any {
|
||||
ImprovementPickerScreen.canReport(tile.improvementFunctions.getImprovementBuildingProblems(it, unit.civ).toSet())
|
||||
&& unit.canBuildImprovement(it)
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ class CapitalConnectionsFinderTests {
|
||||
every { mockGameInfo.getCivilization(capture(slot)) } answers { civilizations.getValue(slot.captured) }
|
||||
every { mockGameInfo.civilizations } answers { civilizations.values.toMutableList() }
|
||||
every { mockGameInfo.tileMap } returns tilesMap
|
||||
every { mockGameInfo.ruleSet } returns rules
|
||||
every { mockGameInfo.ruleset } returns rules
|
||||
every { mockGameInfo.getCities() } answers { civilizations.values.asSequence().flatMap { it.cities } }
|
||||
// Needs for founding cities
|
||||
every { mockGameInfo.turns } returns 1
|
||||
|
||||
@ -37,7 +37,7 @@ class UnitMovementAlgorithmsTests {
|
||||
civInfo.tech.embarkedUnitsCanEnterOcean = true
|
||||
civInfo.tech.unitsCanEmbark = true
|
||||
civInfo.gameInfo = GameInfo()
|
||||
civInfo.gameInfo.ruleSet = ruleSet
|
||||
civInfo.gameInfo.ruleset = ruleSet
|
||||
civInfo.gameInfo.difficultyObject = Difficulty()
|
||||
civInfo.gameInfo.speed = ruleSet.speeds[Speed.DEFAULTFORSIMULATION]!!
|
||||
civInfo.nation = Nation().apply { name = "My nation" }
|
||||
|
||||
@ -28,7 +28,7 @@ class VisibilityTests {
|
||||
RulesetCache.loadRulesets(noMods = true)
|
||||
ruleSet = RulesetCache.getVanillaRuleset()
|
||||
civInfo.gameInfo = GameInfo()
|
||||
civInfo.gameInfo.ruleSet = ruleSet
|
||||
civInfo.gameInfo.ruleset = ruleSet
|
||||
civInfo.nation = Nation().apply { name = "My nation" }
|
||||
civInfo.gameInfo.civilizations.add(civInfo)
|
||||
civInfo.gameInfo.civilizations.add(enemyCivInfo)
|
||||
|
||||
@ -48,7 +48,7 @@ class TestGame {
|
||||
// Create a new ruleset we can easily edit, and set the important variables of gameInfo
|
||||
RulesetCache.loadRulesets(noMods = true)
|
||||
ruleset = RulesetCache[BaseRuleset.Civ_V_GnK.fullName]!!
|
||||
gameInfo.ruleSet = ruleset
|
||||
gameInfo.ruleset = ruleset
|
||||
gameInfo.difficultyObject = ruleset.difficulties["Prince"]!!
|
||||
gameInfo.speed = ruleset.speeds[Speed.DEFAULTFORSIMULATION]!!
|
||||
gameInfo.currentPlayerCiv = Civilization()
|
||||
@ -188,7 +188,7 @@ class TestGame {
|
||||
fun createBaseUnit(unitType: String = createUnitType().name, vararg uniques: String) =
|
||||
createRulesetObject(ruleset.units, *uniques) {
|
||||
val baseUnit = BaseUnit()
|
||||
baseUnit.ruleset = gameInfo.ruleSet
|
||||
baseUnit.ruleset = gameInfo.ruleset
|
||||
baseUnit.unitType = unitType
|
||||
baseUnit
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user