From 87830bf8b2c9c6b8daaef59fe84fbaa91f22f95b Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 26 Dec 2019 22:00:49 +0200 Subject: [PATCH] Code cleanup - ruleset maps are now lowercased --- core/src/com/unciv/logic/GameInfo.kt | 6 +- core/src/com/unciv/logic/GameStarter.kt | 8 +-- .../logic/automation/NextTurnAutomation.kt | 4 +- .../unciv/logic/automation/UnitAutomation.kt | 2 +- .../logic/automation/WorkerAutomation.kt | 2 +- .../com/unciv/logic/battle/CityCombatant.kt | 2 +- .../com/unciv/logic/city/CityConstructions.kt | 18 ++--- core/src/com/unciv/logic/city/CityInfo.kt | 10 +-- core/src/com/unciv/logic/city/CityStats.kt | 2 +- .../civilization/CivInfoTransientUpdater.kt | 2 +- .../logic/civilization/CivilizationInfo.kt | 14 ++-- .../unciv/logic/civilization/Notification.kt | 2 +- .../unciv/logic/civilization/PolicyManager.kt | 4 +- .../unciv/logic/civilization/TechManager.kt | 20 +++--- .../diplomacy/DiplomacyManager.kt | 4 +- core/src/com/unciv/logic/map/MapGenerator.kt | 30 ++++---- core/src/com/unciv/logic/map/MapUnit.kt | 6 +- core/src/com/unciv/logic/map/RoadStatus.kt | 2 +- core/src/com/unciv/logic/map/TileInfo.kt | 12 ++-- core/src/com/unciv/logic/map/TileMap.kt | 2 +- .../src/com/unciv/logic/map/UnitPromotions.kt | 2 +- .../com/unciv/logic/trade/TradeEvaluation.kt | 6 +- core/src/com/unciv/models/ruleset/Building.kt | 12 ++-- core/src/com/unciv/models/ruleset/Nation.kt | 12 ++-- core/src/com/unciv/models/ruleset/Ruleset.kt | 71 ++++++++++--------- .../unciv/models/ruleset/tech/Technology.kt | 10 +-- .../com/unciv/models/ruleset/tile/Terrain.kt | 2 +- .../models/ruleset/tile/TileImprovement.kt | 2 +- .../com/unciv/models/ruleset/unit/BaseUnit.kt | 2 +- core/src/com/unciv/ui/CivilopediaScreen.kt | 18 ++--- core/src/com/unciv/ui/VictoryScreen.kt | 2 +- .../unciv/ui/cityscreen/ConstructionsTable.kt | 4 +- .../ui/mapeditor/TileEditorOptionsTable.kt | 10 +-- .../NewGameScreenOptionsTable.kt | 9 ++- .../ui/newgamescreen/PlayerPickerTable.kt | 6 +- .../pickerscreens/GreatPersonPickerScreen.kt | 2 +- .../pickerscreens/ImprovementPickerScreen.kt | 2 +- .../ui/pickerscreens/PolicyPickerScreen.kt | 2 +- .../ui/pickerscreens/PromotionPickerScreen.kt | 2 +- .../com/unciv/ui/pickerscreens/TechButton.kt | 6 +- .../ui/pickerscreens/TechPickerScreen.kt | 10 +-- core/src/com/unciv/ui/utils/ImageGetter.kt | 12 ++-- .../com/unciv/ui/worldscreen/AlertPopup.kt | 4 +- .../com/unciv/ui/worldscreen/WorldScreen.kt | 2 +- .../unciv/ui/worldscreen/WorldScreenTopBar.kt | 4 +- .../unciv/ui/worldscreen/unit/UnitActions.kt | 4 +- tests/src/com/unciv/testing/BasicTests.kt | 4 +- .../src/com/unciv/testing/TranslationTests.kt | 22 +++--- 48 files changed, 198 insertions(+), 198 deletions(-) diff --git a/core/src/com/unciv/logic/GameInfo.kt b/core/src/com/unciv/logic/GameInfo.kt index b6305d27..a846b2be 100644 --- a/core/src/com/unciv/logic/GameInfo.kt +++ b/core/src/com/unciv/logic/GameInfo.kt @@ -168,13 +168,13 @@ class GameInfo { fun placeBarbarianUnit(tileToPlace: TileInfo) { // 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 = ruleSet.Technologies.keys.toMutableList() + val allResearchedTechs = ruleSet.technologies.keys.toMutableList() for (civ in civilizations.filter { !it.isBarbarian() && !it.isDefeated() }) { allResearchedTechs.retainAll(civ.tech.techsResearched) } val barbarianCiv = getBarbarianCivilization() barbarianCiv.tech.techsResearched = allResearchedTechs.toHashSet() - val unitList = ruleSet.Units.values + val unitList = ruleSet.units.values .filter { !it.unitType.isCivilian()} .filter { it.isBuildable(barbarianCiv) } @@ -230,7 +230,7 @@ class GameInfo { getCurrentPlayerCivilization().playerType=PlayerType.Human if(getCurrentPlayerCivilization().difficulty!="Chieftain") difficulty= getCurrentPlayerCivilization().difficulty - difficultyObject = ruleSet.Difficulties[difficulty]!! + difficultyObject = ruleSet.difficulties[difficulty]!! // We have to remove all deprecated buildings from all cities BEFORE we update a single one, or run setTransients on the civs, // because updating leads to getting the building uniques from the civ info, diff --git a/core/src/com/unciv/logic/GameStarter.kt b/core/src/com/unciv/logic/GameStarter.kt index e036ae8a..092f6730 100644 --- a/core/src/com/unciv/logic/GameStarter.kt +++ b/core/src/com/unciv/logic/GameStarter.kt @@ -41,7 +41,7 @@ class GameStarter{ for (tech in gameInfo.getDifficulty().aiFreeTechs) civInfo.tech.addTechnology(tech) - for (tech in gameBasics.Technologies.values + for (tech in gameBasics.technologies.values .filter { it.era() < newGameParameters.startingEra }) if (!civInfo.tech.isResearched(tech.name)) civInfo.tech.addTechnology(tech.name) @@ -57,7 +57,7 @@ class GameStarter{ private fun addCivilizations(newGameParameters: GameParameters, gameInfo: GameInfo, ruleset: Ruleset) { val availableCivNames = Stack() - availableCivNames.addAll(ruleset.Nations.filter { !it.value.isCityState() }.keys.shuffled()) + availableCivNames.addAll(ruleset.nations.filter { !it.value.isCityState() }.keys.shuffled()) availableCivNames.removeAll(newGameParameters.players.map { it.chosenCiv }) availableCivNames.remove("Barbarians") @@ -83,7 +83,7 @@ class GameStarter{ val availableCityStatesNames = Stack() // since we shuffle and then order by, we end up with all the city states with starting tiles first in a random order, // and then all the other city states in a random order! Because the sortedBy function is stable! - availableCityStatesNames.addAll(ruleset.Nations.filter { it.value.isCityState() }.keys + availableCityStatesNames.addAll(ruleset.nations.filter { it.value.isCityState() }.keys .shuffled().sortedByDescending { it in cityStatesWithStartingLocations }) for (cityStateName in availableCityStatesNames.take(newGameParameters.numberOfCityStates)) { @@ -100,7 +100,7 @@ class GameStarter{ // For later starting eras, or for civs like Polynesia with a different Warrior, we need different starting units fun getWarriorEquivalent(civ: CivilizationInfo): String { - val availableMilitaryUnits = gameInfo.ruleSet.Units.values.filter { + val availableMilitaryUnits = gameInfo.ruleSet.units.values.filter { it.isBuildable(civ) && it.unitType.isLandUnit() && !it.unitType.isCivilian() diff --git a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt index 836bce0b..8bffb97f 100644 --- a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt +++ b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt @@ -170,7 +170,7 @@ class NextTurnAutomation{ private fun chooseTechToResearch(civInfo: CivilizationInfo) { if (civInfo.tech.techsToResearch.isEmpty()) { - val researchableTechs = civInfo.gameInfo.ruleSet.Technologies.values + val researchableTechs = civInfo.gameInfo.ruleSet.technologies.values .filter { !civInfo.tech.isResearched(it.name) && civInfo.tech.canBeResearched(it.name) } val techsGroups = researchableTechs.groupBy { it.cost } val costs = techsGroups.keys.sorted() @@ -198,7 +198,7 @@ class NextTurnAutomation{ private fun adoptPolicy(civInfo: CivilizationInfo) { while (civInfo.policies.canAdoptPolicy()) { - val adoptablePolicies = civInfo.gameInfo.ruleSet.PolicyBranches.values + val adoptablePolicies = civInfo.gameInfo.ruleSet.policyBranches.values .flatMap { it.policies.union(listOf(it)) } .filter { civInfo.policies.isAdoptable(it) } diff --git a/core/src/com/unciv/logic/automation/UnitAutomation.kt b/core/src/com/unciv/logic/automation/UnitAutomation.kt index 01605b4a..a12cdf35 100644 --- a/core/src/com/unciv/logic/automation/UnitAutomation.kt +++ b/core/src/com/unciv/logic/automation/UnitAutomation.kt @@ -291,7 +291,7 @@ class UnitAutomation{ private fun tryUpgradeUnit(unit: MapUnit, unitActions: List): Boolean { if (unit.baseUnit().upgradesTo != null) { - val upgradedUnit = unit.civInfo.gameInfo.ruleSet.Units[unit.baseUnit().upgradesTo!!]!! + val upgradedUnit = unit.civInfo.gameInfo.ruleSet.units[unit.baseUnit().upgradesTo!!]!! if (upgradedUnit.isBuildable(unit.civInfo)) { val upgradeAction = unitActions.firstOrNull { it.name.startsWith("Upgrade to") } if (upgradeAction != null && upgradeAction.canAct) { diff --git a/core/src/com/unciv/logic/automation/WorkerAutomation.kt b/core/src/com/unciv/logic/automation/WorkerAutomation.kt index 8b8dc869..7fe584da 100644 --- a/core/src/com/unciv/logic/automation/WorkerAutomation.kt +++ b/core/src/com/unciv/logic/automation/WorkerAutomation.kt @@ -202,7 +202,7 @@ class WorkerAutomation(val unit: MapUnit) { else -> throw Exception("No improvement found for "+tile.baseTerrain) } if (improvementString == null) return null - return unit.civInfo.gameInfo.ruleSet.TileImprovements[improvementString]!! + return unit.civInfo.gameInfo.ruleSet.tileImprovements[improvementString]!! } } \ No newline at end of file diff --git a/core/src/com/unciv/logic/battle/CityCombatant.kt b/core/src/com/unciv/logic/battle/CityCombatant.kt index f36a1f83..605602bc 100644 --- a/core/src/com/unciv/logic/battle/CityCombatant.kt +++ b/core/src/com/unciv/logic/battle/CityCombatant.kt @@ -41,7 +41,7 @@ class CityCombatant(val city: CityInfo) : ICombatant { if(cityTile.baseTerrain== Constants.hill) strength+=5 // as tech progresses so does city strength val techsPercentKnown: Float = city.civInfo.tech.techsResearched.count().toFloat() / - getCivInfo().gameInfo.ruleSet.Technologies.count() + getCivInfo().gameInfo.ruleSet.technologies.count() strength += (techsPercentKnown * 5.5).pow(2.8).toFloat() // The way all of this adds up... diff --git a/core/src/com/unciv/logic/city/CityConstructions.kt b/core/src/com/unciv/logic/city/CityConstructions.kt index d11d3448..c44a1bf1 100644 --- a/core/src/com/unciv/logic/city/CityConstructions.kt +++ b/core/src/com/unciv/logic/city/CityConstructions.kt @@ -33,10 +33,10 @@ class CityConstructions { return toReturn } - internal fun getBuildableBuildings(): List = cityInfo.getRuleset().Buildings.values + internal fun getBuildableBuildings(): List = cityInfo.getRuleset().buildings.values .filter { it.isBuildable(this) } - fun getConstructableUnits() = cityInfo.getRuleset().Units.values + fun getConstructableUnits() = cityInfo.getRuleset().units.values .filter { it.isBuildable(this) } fun getStats(): Stats { @@ -95,10 +95,10 @@ class CityConstructions { internal fun getConstruction(constructionName: String): IConstruction { val gameBasics = cityInfo.getRuleset() - if (gameBasics.Buildings.containsKey(constructionName)) - return gameBasics.Buildings[constructionName]!! - else if (gameBasics.Units.containsKey(constructionName)) - return gameBasics.Units[constructionName]!! + if (gameBasics.buildings.containsKey(constructionName)) + return gameBasics.buildings[constructionName]!! + else if (gameBasics.units.containsKey(constructionName)) + return gameBasics.units[constructionName]!! else{ if(constructionName=="") return getConstruction("Nothing") val special = SpecialConstruction.getSpecialConstructions().firstOrNull{it.name==constructionName} @@ -155,7 +155,7 @@ class CityConstructions { //region state changing functions fun setTransients(){ - builtBuildingObjects = ArrayList(builtBuildings.map { cityInfo.getRuleset().Buildings[it]!! }) + builtBuildingObjects = ArrayList(builtBuildings.map { cityInfo.getRuleset().buildings[it]!! }) } fun addProductionPoints(productionToAdd: Int) { @@ -217,13 +217,13 @@ class CityConstructions { } fun addBuilding(buildingName:String){ - val buildingObject = cityInfo.getRuleset().Buildings[buildingName]!! + val buildingObject = cityInfo.getRuleset().buildings[buildingName]!! builtBuildingObjects = builtBuildingObjects.withItem(buildingObject) builtBuildings.add(buildingName) } fun removeBuilding(buildingName:String){ - val buildingObject = cityInfo.getRuleset().Buildings[buildingName]!! + val buildingObject = cityInfo.getRuleset().buildings[buildingName]!! builtBuildingObjects = builtBuildingObjects.withoutItem(buildingObject) builtBuildings.remove(buildingName) } diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index 498b7d34..06885f41 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -139,7 +139,7 @@ class CityInfo { } for (building in cityConstructions.getBuiltBuildings().filter { it.requiredResource != null }) { - val resource = getRuleset().TileResources[building.requiredResource]!! + val resource = getRuleset().tileResources[building.requiredResource]!! cityResources.add(resource, -1, "Buildings") } @@ -166,7 +166,7 @@ class CityInfo { // Even if the improvement exists (we conquered an enemy city or somesuch) or we have a city on it, we won't get the resource until the correct tech is researched if (resource.improvement!=null){ - val improvement = getRuleset().TileImprovements[resource.improvement!!]!! + val improvement = getRuleset().tileImprovements[resource.improvement!!]!! if(improvement.techRequired!=null && !civInfo.tech.isResearched(improvement.techRequired!!)) return 0 } @@ -483,15 +483,15 @@ class CityInfo { private fun tryUpdateRoadStatus(){ if(getCenterTile().roadStatus==RoadStatus.None - && getRuleset().TileImprovements["Road"]!!.techRequired in civInfo.tech.techsResearched) + && getRuleset().tileImprovements["Road"]!!.techRequired in civInfo.tech.techsResearched) getCenterTile().roadStatus=RoadStatus.Road else if(getCenterTile().roadStatus!=RoadStatus.Railroad - && getRuleset().TileImprovements["Railroad"]!!.techRequired in civInfo.tech.techsResearched) + && getRuleset().tileImprovements["Railroad"]!!.techRequired in civInfo.tech.techsResearched) getCenterTile().roadStatus=RoadStatus.Railroad } - fun getGoldForSellingBuilding(buildingName:String) = getRuleset().Buildings[buildingName]!!.cost / 10 + fun getGoldForSellingBuilding(buildingName:String) = getRuleset().buildings[buildingName]!!.cost / 10 fun sellBuilding(buildingName:String){ cityConstructions.builtBuildings.remove(buildingName) diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index 05104aae..ae953c0f 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -74,7 +74,7 @@ class CityStats { private fun getStatPercentBonusesFromRailroad(): Stats { val stats = Stats() - val techEnablingRailroad = cityInfo.getRuleset().TileImprovements["Railroad"]!!.techRequired!! + val techEnablingRailroad = cityInfo.getRuleset().tileImprovements["Railroad"]!!.techRequired!! // If we conquered enemy cities connected by railroad, but we don't yet have that tech, // we shouldn't get bonuses, it's as if the tracks aare layed out but we can't operate them. if (cityInfo.civInfo.tech.isResearched(techEnablingRailroad) diff --git a/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt b/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt index d92b7801..041725d4 100644 --- a/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt +++ b/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt @@ -210,7 +210,7 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo){ for (dip in civInfo.diplomacy.values) newDetailedCivResources.add(dip.resourcesFromTrade()) for(resource in civInfo.getCivUnits().mapNotNull { it.baseUnit.requiredResource } - .map { civInfo.gameInfo.ruleSet.TileResources[it]!! }) + .map { civInfo.gameInfo.ruleSet.tileResources[it]!! }) newDetailedCivResources.add(resource,-1,"Units") civInfo.detailedCivResources = newDetailedCivResources } diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index e9d74158..555e733d 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -110,7 +110,7 @@ class CivilizationInfo { //region pure functions fun getDifficulty():Difficulty { if (isPlayerCivilization()) return gameInfo.getDifficulty() - return gameInfo.ruleSet.Difficulties["Chieftain"]!! + return gameInfo.ruleSet.difficulties["Chieftain"]!! } fun getTranslatedNation(): Nation { @@ -174,7 +174,7 @@ class CivilizationInfo { */ fun getCivResourcesByName():HashMap{ val hashMap = HashMap() - for(resource in gameInfo.ruleSet.TileResources.keys) hashMap[resource]=0 + for(resource in gameInfo.ruleSet.tileResources.keys) hashMap[resource]=0 for(entry in getCivResources()) hashMap[entry.resource.name] = entry.amount return hashMap @@ -232,19 +232,19 @@ class CivilizationInfo { fun getEquivalentBuilding(buildingName:String): Building { - val baseBuilding = gameInfo.ruleSet.Buildings[buildingName]!!.getBaseBuilding(gameInfo.ruleSet) + val baseBuilding = gameInfo.ruleSet.buildings[buildingName]!!.getBaseBuilding(gameInfo.ruleSet) - for(building in gameInfo.ruleSet.Buildings.values) + for(building in gameInfo.ruleSet.buildings.values) if(building.replaces==baseBuilding.name && building.uniqueTo==civName) return building return baseBuilding } fun getEquivalentUnit(baseUnitName:String):BaseUnit { - for (unit in gameInfo.ruleSet.Units.values) + for (unit in gameInfo.ruleSet.units.values) if (unit.replaces == baseUnitName && unit.uniqueTo == civName) return unit - return gameInfo.ruleSet.Units[baseUnitName]!! + return gameInfo.ruleSet.units[baseUnitName]!! } fun meetCivilization(otherCiv: CivilizationInfo) { @@ -306,7 +306,7 @@ class CivilizationInfo { * And if they civs on'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]!! } fun setTransients() { diff --git a/core/src/com/unciv/logic/civilization/Notification.kt b/core/src/com/unciv/logic/civilization/Notification.kt index cc56d155..a332f4ba 100644 --- a/core/src/com/unciv/logic/civilization/Notification.kt +++ b/core/src/com/unciv/logic/civilization/Notification.kt @@ -40,7 +40,7 @@ data class LocationAction(var locations: ArrayList = ArrayList()) : Not /** show tech screen */ class TechAction(val techName: String = "") : NotificationAction { override fun execute(worldScreen: WorldScreen) { - val tech = worldScreen.gameInfo.ruleSet.Technologies[techName] + val tech = worldScreen.gameInfo.ruleSet.technologies[techName] worldScreen.game.setScreen(TechPickerScreen(worldScreen.viewingCiv, tech)) } } diff --git a/core/src/com/unciv/logic/civilization/PolicyManager.kt b/core/src/com/unciv/logic/civilization/PolicyManager.kt index 8cdd31c3..3f90f191 100644 --- a/core/src/com/unciv/logic/civilization/PolicyManager.kt +++ b/core/src/com/unciv/logic/civilization/PolicyManager.kt @@ -53,7 +53,7 @@ class PolicyManager { if (freePolicies == 0 && storedCulture < getCultureNeededForNextPolicy()) return false - val hasAdoptablePolicies = civInfo.gameInfo.ruleSet.PolicyBranches.values + val hasAdoptablePolicies = civInfo.gameInfo.ruleSet.policyBranches.values .flatMap { it.policies.union(listOf(it)) } .any { civInfo.policies.isAdoptable(it) } return hasAdoptablePolicies @@ -100,7 +100,7 @@ class PolicyManager { VictoryType.Cultural -> "Great Artist" VictoryType.Scientific -> "Great Scientist" VictoryType.Domination,VictoryType.Neutral -> - civInfo.gameInfo.ruleSet.Units.keys.filter { it.startsWith("Great") }.random() + civInfo.gameInfo.ruleSet.units.keys.filter { it.startsWith("Great") }.random() } civInfo.addGreatPerson(greatPerson) } diff --git a/core/src/com/unciv/logic/civilization/TechManager.kt b/core/src/com/unciv/logic/civilization/TechManager.kt index a0ec644c..2b672d7b 100644 --- a/core/src/com/unciv/logic/civilization/TechManager.kt +++ b/core/src/com/unciv/logic/civilization/TechManager.kt @@ -51,7 +51,7 @@ class TechManager { fun getRuleset() = civInfo.gameInfo.ruleSet fun costOfTech(techName: String): Int { - var techCost = getRuleset().Technologies[techName]!!.cost.toFloat() + var techCost = getRuleset().technologies[techName]!!.cost.toFloat() if (civInfo.isPlayerCivilization()) techCost *= civInfo.getDifficulty().researchCostModifier techCost *= civInfo.gameInfo.gameParameters.gameSpeed.getModifier() @@ -74,7 +74,7 @@ class TechManager { fun currentTechnology(): Technology? { val currentTechnologyName = currentTechnologyName() if (currentTechnologyName == null) return null - return getRuleset().Technologies[currentTechnologyName] + return getRuleset().technologies[currentTechnologyName] } fun currentTechnologyName(): String? { @@ -94,7 +94,7 @@ class TechManager { fun isResearched(TechName: String): Boolean = techsResearched.contains(TechName) fun canBeResearched(TechName: String): Boolean { - return getRuleset().Technologies[TechName]!!.prerequisites.all { isResearched(it) } + return getRuleset().technologies[TechName]!!.prerequisites.all { isResearched(it) } } fun getTechUniques() = researchedTechUniques @@ -115,7 +115,7 @@ class TechManager { (isResearched(techToCheck.name) || prerequisites.contains(techToCheck)) ) continue //no need to add or check prerequisites for (prerequisite in techToCheck.prerequisites) - checkPrerequisites.add(getRuleset().Technologies[prerequisite]!!) + checkPrerequisites.add(getRuleset().technologies[prerequisite]!!) prerequisites.add(techToCheck) } @@ -157,7 +157,7 @@ class TechManager { // Apparently yes, we care about the absolute tech cost, not the actual calculated-for-this-player tech cost, // so don't change to costOfTech() return min(overflowscience, max(civInfo.statsForNextTurn.science.toInt() * 5, - getRuleset().Technologies[currentTechnologyName()]!!.cost)) + getRuleset().technologies[currentTechnologyName()]!!.cost)) } fun nextTurn(scienceForNewTurn: Int) { @@ -194,7 +194,7 @@ class TechManager { techsResearched.add(techName) // this is to avoid concurrent modification problems - val newTech = getRuleset().Technologies[techName]!! + val newTech = getRuleset().technologies[techName]!! researchedTechnologies = researchedTechnologies.withItem(newTech) for(unique in newTech.uniques) researchedTechUniques = researchedTechUniques.withItem(unique) @@ -206,11 +206,11 @@ class TechManager { val currentEra = civInfo.getEra() if (previousEra < currentEra) { civInfo.addNotification("You have entered the [$currentEra era]!", null, Color.GOLD) - getRuleset().PolicyBranches.values.filter { it.era == currentEra } + getRuleset().policyBranches.values.filter { it.era == currentEra } .forEach { civInfo.addNotification("[" + it.name + "] policy branch unlocked!", null, Color.PURPLE) } } - for(revealedResource in getRuleset().TileResources.values.filter{ techName == it.revealedBy }){ + for(revealedResource in getRuleset().tileResources.values.filter{ techName == it.revealedBy }){ for (tileInfo in civInfo.gameInfo.tileMap.values .filter { it.resource == revealedResource.name && civInfo == it.getOwner() }) { @@ -224,7 +224,7 @@ class TechManager { } } - val obsoleteUnits = getRuleset().Units.values.filter { it.obsoleteTech == techName } + val obsoleteUnits = getRuleset().units.values.filter { it.obsoleteTech == techName } for (city in civInfo.cities) if (city.cityConstructions.getCurrentConstruction() in obsoleteUnits) { val currentConstructionUnit = city.cityConstructions.getCurrentConstruction() as BaseUnit @@ -260,7 +260,7 @@ class TechManager { techsToResearch = newTechToReseach } - researchedTechnologies.addAll(techsResearched.map { getRuleset().Technologies[it]!! }) + researchedTechnologies.addAll(techsResearched.map { getRuleset().technologies[it]!! }) researchedTechUniques.addAll(researchedTechnologies.flatMap { it.uniques }) updateTransientBooleans() } diff --git a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt index 1d5e01e6..c7f0708d 100644 --- a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt +++ b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt @@ -191,10 +191,10 @@ class DiplomacyManager() { for(trade in trades){ for(offer in trade.ourOffers) if(offer.type== TradeType.Strategic_Resource || offer.type== TradeType.Luxury_Resource) - counter.add(civInfo.gameInfo.ruleSet.TileResources[offer.name]!!,-offer.amount,"Trade") + counter.add(civInfo.gameInfo.ruleSet.tileResources[offer.name]!!,-offer.amount,"Trade") for(offer in trade.theirOffers) if(offer.type== TradeType.Strategic_Resource || offer.type== TradeType.Luxury_Resource) - counter.add(civInfo.gameInfo.ruleSet.TileResources[offer.name]!!,offer.amount,"Trade") + counter.add(civInfo.gameInfo.ruleSet.tileResources[offer.name]!!,offer.amount,"Trade") } return counter } diff --git a/core/src/com/unciv/logic/map/MapGenerator.kt b/core/src/com/unciv/logic/map/MapGenerator.kt index c8700f50..f7ae694e 100644 --- a/core/src/com/unciv/logic/map/MapGenerator.kt +++ b/core/src/com/unciv/logic/map/MapGenerator.kt @@ -117,7 +117,7 @@ class MapGenerator { fun divideIntoBiomes(map: TileMap, averageTilesPerArea: Int, waterPercent: Float, distance: Int, ruleset: Ruleset) { val areas = ArrayList() - val terrains = ruleset.Terrains.values + val terrains = ruleset.terrains.values .filter { it.type === TerrainType.Land && it.name != Constants.lakes && it.name != Constants.mountain } for (tile in map.values.filter { it.baseTerrain == Constants.grassland }) tile.baseTerrain = "" // So we know it's not chosen @@ -194,7 +194,7 @@ class MapGenerator { fun addRandomTerrainFeature(tileInfo: TileInfo, ruleset: Ruleset) { if (tileInfo.getBaseTerrain().canHaveOverlay && Math.random() > 0.7f) { - val secondaryTerrains = ruleset.Terrains.values + val secondaryTerrains = ruleset.terrains.values .filter { it.type === TerrainType.TerrainFeature && it.occursOn != null && it.occursOn.contains(tileInfo.baseTerrain) } if (secondaryTerrains.any()) tileInfo.terrainFeature = secondaryTerrains.random().name } @@ -229,7 +229,7 @@ class MapGenerator { val numberToSpawn = round(mapRadius * 0.13133208f - 0.56128831f).toInt() val toBeSpawned = ArrayList() - val allNaturalWonders = ruleset.Terrains.values + val allNaturalWonders = ruleset.terrains.values .filter { it.type == TerrainType.NaturalWonder }.toMutableList() while (allNaturalWonders.isNotEmpty() && toBeSpawned.size < numberToSpawn) { @@ -269,7 +269,7 @@ class MapGenerator { of 2 mountains and a maximum of 4 hills and mountains; avoids oceans; becomes mountain */ private fun spawnBarringerCrater(mapToReturn: TileMap, ruleset: Ruleset) { - val wonder = ruleset.Terrains[Constants.barringerCrater]!! + val wonder = ruleset.terrains[Constants.barringerCrater]!! val suitableLocations = mapToReturn.values.filter { it.resource == null && it.improvement == null && wonder.occursOn!!.contains(it.getLastTerrain().name) && it.neighbors.none { neighbor -> neighbor.getBaseTerrain().name == Constants.grassland } @@ -293,7 +293,7 @@ class MapGenerator { can be adjacent to a maximum of 2 hills; becomes mountain */ private fun spawnMountFuji(mapToReturn: TileMap, ruleset: Ruleset) { - val wonder = ruleset.Terrains[Constants.mountFuji]!! + val wonder = ruleset.terrains[Constants.mountFuji]!! val suitableLocations = mapToReturn.values.filter { it.resource == null && it.improvement == null && wonder.occursOn!!.contains(it.getLastTerrain().name) && it.neighbors.none { neighbor -> neighbor.getBaseTerrain().name == Constants.tundra } @@ -319,7 +319,7 @@ class MapGenerator { cannot be adjacent to grass; can be adjacent to a maximum of 2 mountains; avoids oceans; becomes mountain */ private fun spawnGrandMesa(mapToReturn: TileMap, ruleset: Ruleset) { - val wonder = ruleset.Terrains[Constants.grandMesa]!! + val wonder = ruleset.terrains[Constants.grandMesa]!! val suitableLocations = mapToReturn.values.filter { it.resource == null && it.improvement == null && wonder.occursOn!!.contains(it.getLastTerrain().name) && it.neighbors.count{ neighbor -> neighbor.getBaseTerrain().name == Constants.hill } >= 2 @@ -344,7 +344,7 @@ class MapGenerator { TODO: investigate Great Barrier Reef placement requirements */ private fun spawnGreatBarrierReef(mapToReturn: TileMap, ruleset: Ruleset) { - val wonder = ruleset.Terrains[Constants.greatBarrierReef]!! + val wonder = ruleset.terrains[Constants.greatBarrierReef]!! val suitableLocations = mapToReturn.values.filter { it.resource == null && it.improvement == null && wonder.occursOn!!.contains(it.getLastTerrain().name) && it.neighbors.none{ neighbor -> neighbor.getBaseTerrain().name == Constants.tundra } @@ -379,7 +379,7 @@ class MapGenerator { TODO: cannot be adjacent to ice */ private fun spawnKrakatoa(mapToReturn: TileMap, ruleset: Ruleset) { - val wonder = ruleset.Terrains[Constants.krakatoa]!! + val wonder = ruleset.terrains[Constants.krakatoa]!! val suitableLocations = mapToReturn.values.filter { it.resource == null && it.improvement == null && wonder.occursOn!!.contains(it.getLastTerrain().name) && it.neighbors.any { neighbor -> neighbor.getBaseTerrain().name == Constants.coast } @@ -411,7 +411,7 @@ class MapGenerator { TODO: investigate Rock of Gibraltar placement requirements */ private fun spawnRockOfGibraltar(mapToReturn: TileMap, ruleset: Ruleset) { - val wonder = ruleset.Terrains[Constants.rockOfGibraltar]!! + val wonder = ruleset.terrains[Constants.rockOfGibraltar]!! val suitableLocations = mapToReturn.values.filter { it.resource == null && it.improvement == null && wonder.occursOn!!.contains(it.getLastTerrain().name) && it.neighbors.any { neighbor -> neighbor.getBaseTerrain().name == Constants.coast } @@ -445,7 +445,7 @@ class MapGenerator { avoids oceans; becomes mountain */ private fun spawnOldFaithful(mapToReturn: TileMap, ruleset: Ruleset) { - val wonder = ruleset.Terrains[Constants.oldFaithful]!! + val wonder = ruleset.terrains[Constants.oldFaithful]!! val suitableLocations = mapToReturn.values.filter { it.resource == null && it.improvement == null && wonder.occursOn!!.contains(it.getLastTerrain().name) && it.neighbors.count { neighbor -> neighbor.getBaseTerrain().name == Constants.mountain } <= 4 @@ -470,7 +470,7 @@ class MapGenerator { Cerro de Potosi: Must be adjacent to at least 1 hill; avoids oceans; becomes mountain */ private fun spawnCerroDePotosi(mapToReturn: TileMap, ruleset: Ruleset) { - val wonder = ruleset.Terrains[Constants.cerroDePotosi]!! + val wonder = ruleset.terrains[Constants.cerroDePotosi]!! val suitableLocations = mapToReturn.values.filter { it.resource == null && it.improvement == null && wonder.occursOn!!.contains(it.getLastTerrain().name) && it.neighbors.any { neighbor -> neighbor.getBaseTerrain().name == Constants.hill } @@ -491,7 +491,7 @@ class MapGenerator { El Dorado: Must be next to at least 1 jungle tile; avoids oceans; becomes flatland plains */ private fun spawnElDorado(mapToReturn: TileMap, ruleset: Ruleset) { - val wonder = ruleset.Terrains[Constants.elDorado]!! + val wonder = ruleset.terrains[Constants.elDorado]!! val suitableLocations = mapToReturn.values.filter { it.resource == null && it.improvement == null && wonder.occursOn!!.contains(it.getLastTerrain().name) && it.neighbors.any { neighbor -> neighbor.getLastTerrain().name == Constants.jungle } @@ -512,7 +512,7 @@ class MapGenerator { Fountain of Youth: Avoids oceans; becomes flatland plains */ private fun spawnFountainOfYouth(mapToReturn: TileMap, ruleset: Ruleset) { - val wonder = ruleset.Terrains[Constants.fountainOfYouth]!! + val wonder = ruleset.terrains[Constants.fountainOfYouth]!! val suitableLocations = mapToReturn.values.filter { it.resource == null && it.improvement == null && wonder.occursOn!!.contains(it.getLastTerrain().name) } @@ -529,7 +529,7 @@ class MapGenerator { // Here, we need each specific resource to be spread over the map - it matters less if specific resources are near each other private fun spreadStrategicResources(mapToReturn: TileMap, distance: Int, ruleset: Ruleset) { - val resourcesOfType = ruleset.TileResources.values.filter { it.resourceType == ResourceType.Strategic } + val resourcesOfType = ruleset.tileResources.values.filter { it.resourceType == ResourceType.Strategic } for (resource in resourcesOfType) { val suitableTiles = mapToReturn.values .filter { it.resource == null && resource.terrainsCanBeFoundOn.contains(it.getLastTerrain().name) } @@ -545,7 +545,7 @@ class MapGenerator { // Here, we need there to be some luxury/bonus resource - it matters less what private fun spreadResource(mapToReturn: TileMap, distance: Int, resourceType: ResourceType, ruleset: Ruleset) { - val resourcesOfType = ruleset.TileResources.values.filter { it.resourceType == resourceType } + val resourcesOfType = ruleset.tileResources.values.filter { it.resourceType == resourceType } val suitableTiles = mapToReturn.values .filter { it.resource == null && resourcesOfType.any { r -> r.terrainsCanBeFoundOn.contains(it.getLastTerrain().name) } } diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index 2fbdaa50..dfc153a8 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -114,7 +114,7 @@ class MapUnit { val uniques = ArrayList() val baseUnit = baseUnit() uniques.addAll(baseUnit.uniques) - uniques.addAll(promotions.promotions.map { currentTile.tileMap.gameInfo.ruleSet.UnitPromotions[it]!!.effect }) + uniques.addAll(promotions.promotions.map { currentTile.tileMap.gameInfo.ruleSet.unitPromotions[it]!!.effect }) tempUniques = uniques if("Ignores terrain cost" in uniques) ignoresTerrainCost=true @@ -269,7 +269,7 @@ class MapUnit { fun setTransients(ruleset: Ruleset) { promotions.unit=this mapUnitAction?.unit = this - baseUnit=ruleset.Units[name]!! + baseUnit=ruleset.units[name]!! updateUniques() } @@ -469,7 +469,7 @@ class MapUnit { city.population.autoAssignPopulation() civInfo.addNotification("We have found survivors in the ruins - population added to ["+city.name+"]",tile.position, Color.GREEN) } - val researchableAncientEraTechs = tile.tileMap.gameInfo.ruleSet.Technologies.values + val researchableAncientEraTechs = tile.tileMap.gameInfo.ruleSet.technologies.values .filter { !civInfo.tech.isResearched(it.name) && civInfo.tech.canBeResearched(it.name) diff --git a/core/src/com/unciv/logic/map/RoadStatus.kt b/core/src/com/unciv/logic/map/RoadStatus.kt index 4d9c7a51..37520a56 100644 --- a/core/src/com/unciv/logic/map/RoadStatus.kt +++ b/core/src/com/unciv/logic/map/RoadStatus.kt @@ -15,6 +15,6 @@ enum class RoadStatus { Railroad; /** returns null for [None] */ - fun improvement(ruleset: Ruleset) = ruleset.TileImprovements[this.name] + fun improvement(ruleset: Ruleset) = ruleset.tileImprovements[this.name] } diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index c95eb18e..7c2c36d6 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -87,16 +87,16 @@ open class TileInfo { fun getTileResource(): TileResource = if (resource == null) throw Exception("No resource exists for this tile!") - else ruleset.TileResources[resource!!]!! + else ruleset.tileResources[resource!!]!! fun getNaturalWonder() : Terrain = if (naturalWonder == null) throw Exception("No natural wonder exists for this tile!") - else ruleset.Terrains[naturalWonder!!]!! + else ruleset.terrains[naturalWonder!!]!! fun isCityCenter(): Boolean = getCity()?.location == position fun isNaturalWonder() : Boolean = naturalWonder != null - fun getTileImprovement(): TileImprovement? = if (improvement == null) null else ruleset.TileImprovements[improvement!!] + fun getTileImprovement(): TileImprovement? = if (improvement == null) null else ruleset.tileImprovements[improvement!!] // This is for performance - since we access the neighbors of a tile ALL THE TIME, @@ -125,7 +125,7 @@ open class TileInfo { } fun getTerrainFeature(): Terrain? { - return if (terrainFeature == null) null else ruleset.Terrains[terrainFeature!!] + return if (terrainFeature == null) null else ruleset.terrains[terrainFeature!!] } fun isWorked(): Boolean { @@ -176,7 +176,7 @@ open class TileInfo { val resource = getTileResource() stats.add(getTileResource()) // resource base if (resource.building != null && city != null && city.cityConstructions.isBuilt(resource.building!!)) { - val resourceBuilding = tileMap.gameInfo.ruleSet.Buildings[resource.building!!]!! + val resourceBuilding = tileMap.gameInfo.ruleSet.buildings[resource.building!!]!! stats.add(resourceBuilding.resourceBonusStats!!) // resource-specific building (eg forge, stable) bonus } if(resource.resourceType==ResourceType.Strategic @@ -328,7 +328,7 @@ open class TileInfo { //region state-changing functions fun setTransients(){ - baseTerrainObject = ruleset.Terrains[baseTerrain]!! // This is a HACK. + baseTerrainObject = ruleset.terrains[baseTerrain]!! // This is a HACK. isWater = getBaseTerrain().type==TerrainType.Water isLand = getBaseTerrain().type==TerrainType.Land isOcean = baseTerrain == Constants.ocean diff --git a/core/src/com/unciv/logic/map/TileMap.kt b/core/src/com/unciv/logic/map/TileMap.kt index 3a804e4e..ba74d853 100644 --- a/core/src/com/unciv/logic/map/TileMap.kt +++ b/core/src/com/unciv/logic/map/TileMap.kt @@ -65,7 +65,7 @@ class TileMap { } fun placeUnitNearTile(position: Vector2, unitName: String, civInfo: CivilizationInfo): MapUnit? { - val unit = gameInfo.ruleSet.Units[unitName]!!.getMapUnit(gameInfo.ruleSet) + val unit = gameInfo.ruleSet.units[unitName]!!.getMapUnit(gameInfo.ruleSet) fun isTileMovePotential(tileInfo:TileInfo): Boolean { if(unit.type.isWaterUnit()) return tileInfo.isWater || tileInfo.isCityCenter() diff --git a/core/src/com/unciv/logic/map/UnitPromotions.kt b/core/src/com/unciv/logic/map/UnitPromotions.kt index e24e2942..859b8364 100644 --- a/core/src/com/unciv/logic/map/UnitPromotions.kt +++ b/core/src/com/unciv/logic/map/UnitPromotions.kt @@ -36,7 +36,7 @@ class UnitPromotions{ } fun getAvailablePromotions(): List { - return unit.civInfo.gameInfo.ruleSet.UnitPromotions.values + return unit.civInfo.gameInfo.ruleSet.unitPromotions.values .filter { unit.type.toString() in it.unitTypes && it.name !in promotions } .filter { it.prerequisites.isEmpty() || it.prerequisites.any { p->p in promotions } } } diff --git a/core/src/com/unciv/logic/trade/TradeEvaluation.kt b/core/src/com/unciv/logic/trade/TradeEvaluation.kt index cb3a4f64..5aea4331 100644 --- a/core/src/com/unciv/logic/trade/TradeEvaluation.kt +++ b/core/src/com/unciv/logic/trade/TradeEvaluation.kt @@ -117,7 +117,7 @@ class TradeEvaluation{ } TradeType.Technology -> - return (sqrt(civInfo.gameInfo.ruleSet.Technologies[offer.name]!!.cost.toDouble()) + return (sqrt(civInfo.gameInfo.ruleSet.technologies[offer.name]!!.cost.toDouble()) * civInfo.gameInfo.gameParameters.gameSpeed.getModifier()).toInt()*20 TradeType.Introduction -> return 250 TradeType.WarDeclaration -> { @@ -167,7 +167,7 @@ class TradeEvaluation{ TradeType.Strategic_Resource -> { if(!civInfo.isAtWar()) return 50*offer.amount - val canUseForUnits = civInfo.gameInfo.ruleSet.Units.values + val canUseForUnits = civInfo.gameInfo.ruleSet.units.values .any { it.requiredResource==offer.name && it.isBuildable(civInfo) } if(!canUseForUnits) return 50*offer.amount @@ -188,7 +188,7 @@ class TradeEvaluation{ } return totalCost } - TradeType.Technology -> return sqrt(civInfo.gameInfo.ruleSet.Technologies[offer.name]!!.cost.toDouble()).toInt()*20 + TradeType.Technology -> return sqrt(civInfo.gameInfo.ruleSet.technologies[offer.name]!!.cost.toDouble()).toInt()*20 TradeType.Introduction -> return 250 TradeType.WarDeclaration -> { val civToDeclareWarOn = civInfo.gameInfo.getCivilization(offer.name) diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index b73ec625..528fc34b 100644 --- a/core/src/com/unciv/models/ruleset/Building.kt +++ b/core/src/com/unciv/models/ruleset/Building.kt @@ -53,7 +53,7 @@ class Building : NamedStats(), IConstruction{ for(stat in getStatPercentageBonuses(null).toHashMap()) if(stat.value!=0f) infoList+="+${stat.value.toInt()}% ${stat.key.toString().tr()}" - val improvedResources = ruleset.TileResources.values.filter { it.building==name }.map { it.name.tr() } + val improvedResources = ruleset.tileResources.values.filter { it.building==name }.map { it.name.tr() } if(improvedResources.isNotEmpty()){ // buildings that improve resources infoList += improvedResources.joinToString()+ " {provide} ".tr()+ resourceBonusStats.toString() @@ -103,7 +103,7 @@ class Building : NamedStats(), IConstruction{ if (gpp.culture != 0f) stringBuilder.appendln("+" + gpp.culture.toInt() + " "+"[Great Artist] points".tr()) } if (resourceBonusStats != null) { - val resources = ruleset.TileResources.values.filter { name == it.building }.joinToString { it.name.tr() } + val resources = ruleset.tileResources.values.filter { name == it.building }.joinToString { it.name.tr() } stringBuilder.appendln("$resources {provide} $resourceBonusStats".tr()) } @@ -251,7 +251,7 @@ class Building : NamedStats(), IConstruction{ val civInfo = construction.cityInfo.civInfo if (uniqueTo!=null && uniqueTo!=civInfo.civName) return "Unique to $uniqueTo" - if (civInfo.gameInfo.ruleSet.Buildings.values.any { it.uniqueTo==civInfo.civName && it.replaces==name }) return "Our unique building replaces this" + if (civInfo.gameInfo.ruleSet.buildings.values.any { it.uniqueTo==civInfo.civName && it.replaces==name }) return "Our unique building replaces this" if (requiredTech != null && !civInfo.tech.isResearched(requiredTech!!)) return "$requiredTech not researched" // Regular wonders @@ -329,7 +329,7 @@ class Building : NamedStats(), IConstruction{ if (providesFreeBuilding != null && !construction.containsBuildingOrEquivalent(providesFreeBuilding!!)) { var buildingToAdd = providesFreeBuilding!! - for(building in civInfo.gameInfo.ruleSet.Buildings.values) + for(building in civInfo.gameInfo.ruleSet.buildings.values) if(building.replaces == buildingToAdd && building.uniqueTo==civInfo.civName) buildingToAdd = building.name @@ -351,7 +351,7 @@ class Building : NamedStats(), IConstruction{ if ("Free Social Policy" in uniques) civInfo.policies.freePolicies++ if ("Free Great Person" in uniques) { if (civInfo.isPlayerCivilization()) civInfo.greatPeople.freeGreatPeople++ - else civInfo.addGreatPerson(civInfo.gameInfo.ruleSet.Units.keys.filter { it.startsWith("Great") }.random()) + else civInfo.addGreatPerson(civInfo.gameInfo.ruleSet.units.keys.filter { it.startsWith("Great") }.random()) } if ("+1 population in each city" in uniques) { for(city in civInfo.cities){ @@ -375,6 +375,6 @@ class Building : NamedStats(), IConstruction{ fun getBaseBuilding(ruleset: Ruleset): Building { if(replaces==null) return this - else return ruleset.Buildings[replaces!!]!! + else return ruleset.buildings[replaces!!]!! } } diff --git a/core/src/com/unciv/models/ruleset/Nation.kt b/core/src/com/unciv/models/ruleset/Nation.kt index 0859f89f..14f5ebac 100644 --- a/core/src/com/unciv/models/ruleset/Nation.kt +++ b/core/src/com/unciv/models/ruleset/Nation.kt @@ -97,9 +97,9 @@ class Nation : INamed { } private fun addUniqueBuildingsText(textList: ArrayList, ruleset: Ruleset) { - for (building in ruleset.Buildings.values + for (building in ruleset.buildings.values .filter { it.uniqueTo == name }) { - val originalBuilding = ruleset.Buildings[building.replaces!!]!! + val originalBuilding = ruleset.buildings[building.replaces!!]!! textList += building.name.tr() + " - {replaces} " + originalBuilding.name.tr() val originalBuildingStatMap = originalBuilding.toHashMap() @@ -122,9 +122,9 @@ class Nation : INamed { } private fun addUniqueUnitsText(textList: ArrayList, ruleset: Ruleset) { - for (unit in ruleset.Units.values + for (unit in ruleset.units.values .filter { it.uniqueTo == name }) { - val originalUnit = ruleset.Units[unit.replaces!!]!! + val originalUnit = ruleset.units[unit.replaces!!]!! textList += unit.name.tr() + " - {replaces} " + originalUnit.name.tr() if (unit.cost != originalUnit.cost) @@ -144,14 +144,14 @@ class Nation : INamed { for (unique in originalUnit.uniques.filterNot { it in unit.uniques }) textList += " " + "Lost ability".tr() + "(vs " + originalUnit.name.tr() + "): " + Translations.translateBonusOrPenalty(unique) for (promotion in unit.promotions.filter { it !in originalUnit.promotions }) - textList += " " + promotion.tr() + " (" + Translations.translateBonusOrPenalty(ruleset.UnitPromotions[promotion]!!.effect) + ")" + textList += " " + promotion.tr() + " (" + Translations.translateBonusOrPenalty(ruleset.unitPromotions[promotion]!!.effect) + ")" textList += "" } } private fun addUniqueImprovementsText(textList: ArrayList, ruleset: Ruleset) { - for (improvement in ruleset.TileImprovements.values + for (improvement in ruleset.tileImprovements.values .filter { it.uniqueTo == name }) { textList += improvement.name.tr() diff --git a/core/src/com/unciv/models/ruleset/Ruleset.kt b/core/src/com/unciv/models/ruleset/Ruleset.kt index c425b0d5..e98ccc52 100644 --- a/core/src/com/unciv/models/ruleset/Ruleset.kt +++ b/core/src/com/unciv/models/ruleset/Ruleset.kt @@ -13,16 +13,17 @@ import com.unciv.models.stats.INamed import kotlin.collections.set class Ruleset { - val Buildings = LinkedHashMap() - val Terrains = LinkedHashMap() - val TileResources = LinkedHashMap() - val TileImprovements = LinkedHashMap() - val Technologies = LinkedHashMap() - val Units = LinkedHashMap() - val UnitPromotions = LinkedHashMap() - val Nations = LinkedHashMap() - val PolicyBranches = LinkedHashMap() - val Difficulties = LinkedHashMap() + val mods = ArrayList() + val buildings = LinkedHashMap() + val terrains = LinkedHashMap() + val tileResources = LinkedHashMap() + val tileImprovements = LinkedHashMap() + val technologies = LinkedHashMap() + val units = LinkedHashMap() + val unitPromotions = LinkedHashMap() + val nations = LinkedHashMap() + val policyBranches = LinkedHashMap() + val difficulties = LinkedHashMap() fun getFromJson(tClass: Class, filePath:String): T { val jsonText = Gdx.files.internal(filePath).readString(Charsets.UTF_8.name()) @@ -38,17 +39,17 @@ class Ruleset { fun clone(): Ruleset{ val newRuleset = Ruleset(false) - newRuleset.Buildings.putAll(Buildings) - newRuleset.Difficulties.putAll(Difficulties) - newRuleset.Nations .putAll(Nations) - newRuleset.PolicyBranches.putAll(PolicyBranches) - newRuleset.Technologies.putAll(Technologies) - newRuleset.Buildings.putAll(Buildings) - newRuleset.Terrains.putAll(Terrains) - newRuleset.TileImprovements.putAll(TileImprovements) - newRuleset.TileResources.putAll(TileResources) - newRuleset.UnitPromotions.putAll(UnitPromotions) - newRuleset.Units.putAll(Units) + newRuleset.buildings.putAll(buildings) + newRuleset.difficulties.putAll(difficulties) + newRuleset.nations .putAll(nations) + newRuleset.policyBranches.putAll(policyBranches) + newRuleset.technologies.putAll(technologies) + newRuleset.buildings.putAll(buildings) + newRuleset.terrains.putAll(terrains) + newRuleset.tileImprovements.putAll(tileImprovements) + newRuleset.tileResources.putAll(tileResources) + newRuleset.unitPromotions.putAll(unitPromotions) + newRuleset.units.putAll(units) return newRuleset } @@ -64,26 +65,26 @@ class Ruleset { for (tech in techColumn.techs) { if (tech.cost==0) tech.cost = techColumn.techCost tech.column = techColumn - Technologies[tech.name] = tech + technologies[tech.name] = tech } } - Buildings += createHashmap(getFromJson(Array::class.java, "$folderPath/Buildings.json")) - for (building in Buildings.values) { + buildings += createHashmap(getFromJson(Array::class.java, "$folderPath/Buildings.json")) + for (building in buildings.values) { if (building.requiredTech == null) continue - val column = Technologies[building.requiredTech!!]!!.column + val column = technologies[building.requiredTech!!]!!.column if (building.cost == 0) building.cost = if (building.isWonder || building.isNationalWonder) column!!.wonderCost else column!!.buildingCost } - Terrains += createHashmap(getFromJson(Array::class.java, "$folderPath/Terrains.json")) - TileResources += createHashmap(getFromJson(Array::class.java, "$folderPath/TileResources.json")) - TileImprovements += createHashmap(getFromJson(Array::class.java, "$folderPath/TileImprovements.json")) - Units += createHashmap(getFromJson(Array::class.java, "$folderPath/Units.json")) - UnitPromotions += createHashmap(getFromJson(Array::class.java, "$folderPath/UnitPromotions.json")) + terrains += createHashmap(getFromJson(Array::class.java, "$folderPath/Terrains.json")) + tileResources += createHashmap(getFromJson(Array::class.java, "$folderPath/TileResources.json")) + tileImprovements += createHashmap(getFromJson(Array::class.java, "$folderPath/TileImprovements.json")) + units += createHashmap(getFromJson(Array::class.java, "$folderPath/Units.json")) + unitPromotions += createHashmap(getFromJson(Array::class.java, "$folderPath/UnitPromotions.json")) - PolicyBranches += createHashmap(getFromJson(Array::class.java, "$folderPath/Policies.json")) - for (branch in PolicyBranches.values) { + policyBranches += createHashmap(getFromJson(Array::class.java, "$folderPath/Policies.json")) + for (branch in policyBranches.values) { branch.requires = ArrayList() branch.branch = branch for (policy in branch.policies) { @@ -93,10 +94,10 @@ class Ruleset { branch.policies.last().name = branch.name + " Complete" } - Nations += createHashmap(getFromJson(Array::class.java, "$folderPath/Nations/Nations.json")) - for(nation in Nations.values) nation.setTransients() + nations += createHashmap(getFromJson(Array::class.java, "$folderPath/Nations/Nations.json")) + for(nation in nations.values) nation.setTransients() - Difficulties += createHashmap(getFromJson(Array::class.java, "$folderPath/Difficulties.json")) + difficulties += createHashmap(getFromJson(Array::class.java, "$folderPath/Difficulties.json")) val gameBasicsLoadTime = System.currentTimeMillis() - gameBasicsStartTime println("Loading game basics - "+gameBasicsLoadTime+"ms") diff --git a/core/src/com/unciv/models/ruleset/tech/Technology.kt b/core/src/com/unciv/models/ruleset/tech/Technology.kt index f2a04ded..1afe2c89 100644 --- a/core/src/com/unciv/models/ruleset/tech/Technology.kt +++ b/core/src/com/unciv/models/ruleset/tech/Technology.kt @@ -24,7 +24,7 @@ class Technology { val lineList = ArrayList() // more readable than StringBuilder, with same performance for our use-case for (unique in uniques) lineList += unique.tr() - val improvedImprovements = ruleset.TileImprovements.values + val improvedImprovements = ruleset.tileImprovements.values .filter { it.improvingTech == name }.groupBy { it.improvingTechStats.toString() } for (improvement in improvedImprovements) { val impimpString = improvement.value.joinToString { it.name.tr() } + @@ -56,10 +56,10 @@ class Technology { lineList += " * " + wonder.name.tr() + " (" + wonder.getShortDescription(ruleset) + ")" } - val revealedResource = ruleset.TileResources.values.filter { it.revealedBy == name }.map { it.name }.firstOrNull() // can only be one + val revealedResource = ruleset.tileResources.values.filter { it.revealedBy == name }.map { it.name }.firstOrNull() // can only be one if (revealedResource != null) lineList += "Reveals [$revealedResource] on the map".tr() - val tileImprovements = ruleset.TileImprovements.values.filter { it.techRequired == name } + val tileImprovements = ruleset.tileImprovements.values.filter { it.techRequired == name } if (tileImprovements.isNotEmpty()) lineList += "{Tile improvements enabled}: " + tileImprovements.joinToString { it.name.tr() } @@ -67,7 +67,7 @@ class Technology { } fun getEnabledBuildings(civInfo: CivilizationInfo): List { - var enabledBuildings = civInfo.gameInfo.ruleSet.Buildings.values.filter { + var enabledBuildings = civInfo.gameInfo.ruleSet.buildings.values.filter { it.requiredTech == name && (it.uniqueTo == null || it.uniqueTo == civInfo.civName) } @@ -81,7 +81,7 @@ class Technology { } fun getEnabledUnits(civInfo:CivilizationInfo): List { - var enabledUnits = civInfo.gameInfo.ruleSet.Units.values.filter { + var enabledUnits = civInfo.gameInfo.ruleSet.units.values.filter { it.requiredTech == name && (it.uniqueTo == null || it.uniqueTo == civInfo.civName) } diff --git a/core/src/com/unciv/models/ruleset/tile/Terrain.kt b/core/src/com/unciv/models/ruleset/tile/Terrain.kt index 283f7cc1..f5cb672e 100644 --- a/core/src/com/unciv/models/ruleset/tile/Terrain.kt +++ b/core/src/com/unciv/models/ruleset/tile/Terrain.kt @@ -13,7 +13,7 @@ class Terrain : NamedStats() { if (occursOn != null) { sb.appendln("Occurs on [${occursOn.joinToString(", ")}]".tr()) } - val resourcesFound = ruleset.TileResources.values.filter { it.terrainsCanBeFoundOn.contains(name) } + val resourcesFound = ruleset.tileResources.values.filter { it.terrainsCanBeFoundOn.contains(name) } if (resourcesFound.isNotEmpty()) { sb.appendln("May contain [${resourcesFound.joinToString(", ") { it.name.tr() }}]".tr()) } diff --git a/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt b/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt index bc8e2d34..5afe9bcf 100644 --- a/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt +++ b/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt @@ -41,7 +41,7 @@ class TileImprovement : NamedStats() { stringBuilder.appendln("Can be built on ".tr() + terrainsCanBeBuiltOnString.joinToString(", "))//language can be changed when setting changes. } val statsToResourceNames = HashMap>() - for (tr: TileResource in ruleset.TileResources.values.filter { it.improvement == name }) { + for (tr: TileResource in ruleset.tileResources.values.filter { it.improvement == name }) { val statsString = tr.improvementStats.toString() if (!statsToResourceNames.containsKey(statsString)) statsToResourceNames[statsString] = ArrayList() diff --git a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt index b1f9500e..c6482427 100644 --- a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt @@ -131,7 +131,7 @@ class BaseUnit : INamed, IConstruction { if (requiredTech!=null && !civInfo.tech.isResearched(requiredTech!!)) return "$requiredTech not researched" if (obsoleteTech!=null && civInfo.tech.isResearched(obsoleteTech!!)) return "Obsolete by $obsoleteTech" if (uniqueTo!=null && uniqueTo!=civInfo.civName) return "Unique to $uniqueTo" - if (civInfo.gameInfo.ruleSet.Units.values.any { it.uniqueTo==civInfo.civName && it.replaces==name }) return "Our unique unit replaces this" + if (civInfo.gameInfo.ruleSet.units.values.any { it.uniqueTo==civInfo.civName && it.replaces==name }) return "Our unique unit replaces this" if (!UncivGame.Current.settings.nuclearWeaponEnabled && (name == "Manhattan Project" || uniques.contains("Requires Manhattan Project"))) return "Disabled by setting" if (uniques.contains("Requires Manhattan Project") && !civInfo.containsBuildingUnique("Enables nuclear weapon")) diff --git a/core/src/com/unciv/ui/CivilopediaScreen.kt b/core/src/com/unciv/ui/CivilopediaScreen.kt index b66d2b12..98e9cacc 100644 --- a/core/src/com/unciv/ui/CivilopediaScreen.kt +++ b/core/src/com/unciv/ui/CivilopediaScreen.kt @@ -61,29 +61,29 @@ class CivilopediaScreen(ruleset: Ruleset) : CameraStageBaseScreen() { description.setWrap(true) - categoryToEntries["Buildings"] = ruleset.Buildings.values + categoryToEntries["Buildings"] = ruleset.buildings.values .map { CivilopediaEntry(it.name,it.getDescription(false, null,ruleset), ImageGetter.getConstructionImage(it.name)) } - categoryToEntries["Resources"] = ruleset.TileResources.values + categoryToEntries["Resources"] = ruleset.tileResources.values .map { CivilopediaEntry(it.name,it.getDescription(), ImageGetter.getResourceImage(it.name,50f)) } - categoryToEntries["Terrains"] = ruleset.Terrains.values + categoryToEntries["Terrains"] = ruleset.terrains.values .map { CivilopediaEntry(it.name,it.getDescription(ruleset)) } - categoryToEntries["Tile Improvements"] = ruleset.TileImprovements.values + categoryToEntries["Tile Improvements"] = ruleset.tileImprovements.values .map { CivilopediaEntry(it.name,it.getDescription(ruleset), ImageGetter.getImprovementIcon(it.name,50f)) } - categoryToEntries["Units"] = ruleset.Units.values + categoryToEntries["Units"] = ruleset.units.values .map { CivilopediaEntry(it.name,it.getDescription(false), ImageGetter.getConstructionImage(it.name)) } - categoryToEntries["Nations"] = ruleset.Nations.values + categoryToEntries["Nations"] = ruleset.nations.values .filter { it.isMajorCiv() } .map { CivilopediaEntry(it.name,it.getUniqueString(ruleset), ImageGetter.getNationIndicator(it,50f)) } - categoryToEntries["Technologies"] = ruleset.Technologies.values + categoryToEntries["Technologies"] = ruleset.technologies.values .map { CivilopediaEntry(it.name,it.getDescription(ruleset), ImageGetter.getTechIconGroup(it.name,50f)) } - categoryToEntries["Promotions"] = ruleset.UnitPromotions.values - .map { CivilopediaEntry(it.name,it.getDescription(ruleset.UnitPromotions.values, true), + categoryToEntries["Promotions"] = ruleset.unitPromotions.values + .map { CivilopediaEntry(it.name,it.getDescription(ruleset.unitPromotions.values, true), Table().apply { add(ImageGetter.getPromotionIcon(it.name)) }) } categoryToEntries["Tutorials"] = tutorialMiner.getCivilopediaTutorials(UncivGame.Current.settings.language) diff --git a/core/src/com/unciv/ui/VictoryScreen.kt b/core/src/com/unciv/ui/VictoryScreen.kt index dc5f1ef7..7eb33bbf 100644 --- a/core/src/com/unciv/ui/VictoryScreen.kt +++ b/core/src/com/unciv/ui/VictoryScreen.kt @@ -133,7 +133,7 @@ class VictoryScreen : PickerScreen() { fun culturalVictoryColumn():Table{ val t=Table() t.defaults().pad(5f) - for(branch in playerCivInfo.gameInfo.ruleSet.PolicyBranches.values) { + for(branch in playerCivInfo.gameInfo.ruleSet.policyBranches.values) { val finisher = branch.policies.last().name t.add(getMilestone(finisher, playerCivInfo.policies.isAdopted(finisher))).row() } diff --git a/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt b/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt index 0f2e36fd..3106a68b 100644 --- a/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt +++ b/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt @@ -94,7 +94,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre constructionPickerTable.background = ImageGetter.getBackground(Color.BLACK) val units = ArrayList() - for (unit in city.getRuleset().Units.values.filter { it.shouldBeDisplayed(cityConstructions) }) { + for (unit in city.getRuleset().units.values.filter { it.shouldBeDisplayed(cityConstructions) }) { val turnsToUnit = cityConstructions.turnsToConstruction(unit.name) units += getProductionButton(unit.name, unit.name.tr() + "\r\n" + turnsToUnit + (if(turnsToUnit>1) " {turns}".tr() else " {turn}".tr()), @@ -107,7 +107,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre val buildableNationalWonders = ArrayList
() val buildableBuildings = ArrayList
() - for (building in city.getRuleset().Buildings.values) { + for (building in city.getRuleset().buildings.values) { if (!building.shouldBeDisplayed(cityConstructions) && building.name != cityConstructions.currentConstruction) continue val turnsToBuilding = cityConstructions.turnsToConstruction(building.name) val productionTextButton = getProductionButton(building.name, diff --git a/core/src/com/unciv/ui/mapeditor/TileEditorOptionsTable.kt b/core/src/com/unciv/ui/mapeditor/TileEditorOptionsTable.kt index 0e0015e9..5c85bfb1 100644 --- a/core/src/com/unciv/ui/mapeditor/TileEditorOptionsTable.kt +++ b/core/src/com/unciv/ui/mapeditor/TileEditorOptionsTable.kt @@ -74,7 +74,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera } }).row() - for(improvement in ruleSet.TileImprovements.values){ + for(improvement in ruleSet.tileImprovements.values){ if(improvement.name.startsWith("Remove")) continue val improvementImage = getHex(Color.WHITE,ImageGetter.getImprovementIcon(improvement.name,40f)) improvementImage.onClick { @@ -88,7 +88,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera editorPickTable.add(ScrollPane(improvementsTable)).height(mapEditorScreen.stage.height*0.7f) val nationsTable = Table() - for(nation in ruleSet.Nations.values){ + for(nation in ruleSet.nations.values){ val nationImage = getHex(Color.WHITE,ImageGetter.getNationIndicator(nation,40f)) nationImage.onClick { clearSelection() @@ -151,7 +151,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera } }) - for (resource in ruleSet.TileResources.values) { + for (resource in ruleSet.tileResources.values) { val resourceHex = getHex(Color.WHITE, ImageGetter.getResourceImage(resource.name, 40f)) resourceHex.onClick { clearSelection() @@ -160,7 +160,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera tileInfo.ruleset = mapEditorScreen.ruleSet val terrain = resource.terrainsCanBeFoundOn.first() - val terrainObject = ruleSet.Terrains[terrain]!! + val terrainObject = ruleSet.terrains[terrain]!! if (terrainObject.type == TerrainType.TerrainFeature) { tileInfo.baseTerrain = when { terrainObject.occursOn == null -> terrainObject.occursOn!!.first() @@ -179,7 +179,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera } private fun addTerrainOptions(terrainFeaturesTable: Table, baseTerrainTable: Table) { - for (terrain in ruleSet.Terrains.values) { + for (terrain in ruleSet.terrains.values) { val tileInfo = TileInfo() tileInfo.ruleset = mapEditorScreen.ruleSet if (terrain.type == TerrainType.TerrainFeature) { diff --git a/core/src/com/unciv/ui/newgamescreen/NewGameScreenOptionsTable.kt b/core/src/com/unciv/ui/newgamescreen/NewGameScreenOptionsTable.kt index 4493238d..6341b1ab 100644 --- a/core/src/com/unciv/ui/newgamescreen/NewGameScreenOptionsTable.kt +++ b/core/src/com/unciv/ui/newgamescreen/NewGameScreenOptionsTable.kt @@ -8,11 +8,11 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener import com.badlogic.gdx.utils.Array import com.unciv.logic.MapSaver +import com.unciv.models.metadata.GameSpeed import com.unciv.models.ruleset.Ruleset import com.unciv.models.ruleset.VictoryType import com.unciv.models.ruleset.tech.TechEra import com.unciv.models.translations.tr -import com.unciv.models.metadata.GameSpeed import com.unciv.ui.utils.CameraStageBaseScreen import com.unciv.ui.utils.toLabel @@ -144,7 +144,7 @@ class NewGameScreenOptionsTable(val newGameScreen: NewGameScreen, val onMultipla val cityStatesSelectBox = SelectBox(CameraStageBaseScreen.skin) val cityStatesArray = Array() - (0..ruleset.Nations.filter { it.value.isCityState() }.size).forEach { cityStatesArray.add(it) } + (0..ruleset.nations.filter { it.value.isCityState() }.size).forEach { cityStatesArray.add(it) } cityStatesSelectBox.items = cityStatesArray cityStatesSelectBox.selected = newGameParameters.numberOfCityStates add(cityStatesSelectBox).pad(10f).row() @@ -157,7 +157,7 @@ class NewGameScreenOptionsTable(val newGameScreen: NewGameScreen, val onMultipla private fun addDifficultySelectBox() { add("{Difficulty}:".tr()) - val difficultySelectBox = TranslatedSelectBox(ruleset.Difficulties.keys, newGameParameters.difficulty, CameraStageBaseScreen.skin) + val difficultySelectBox = TranslatedSelectBox(ruleset.difficulties.keys, newGameParameters.difficulty, CameraStageBaseScreen.skin) difficultySelectBox.addListener(object : ChangeListener() { override fun changed(event: ChangeEvent?, actor: Actor?) { newGameParameters.difficulty = difficultySelectBox.selected.value @@ -221,9 +221,8 @@ class NewGameScreenOptionsTable(val newGameScreen: NewGameScreen, val onMultipla fun addModCheckboxes() { - add("{Victory conditions}:".tr()).colspan(2).row() + add("{Mods}:".tr()).colspan(2).row() - // Create a checkbox for each VictoryType existing val modCheckboxTable = Table().apply { defaults().pad(10f) } val mods = Gdx.files.local("mods") diff --git a/core/src/com/unciv/ui/newgamescreen/PlayerPickerTable.kt b/core/src/com/unciv/ui/newgamescreen/PlayerPickerTable.kt index e8ae9832..f2016573 100644 --- a/core/src/com/unciv/ui/newgamescreen/PlayerPickerTable.kt +++ b/core/src/com/unciv/ui/newgamescreen/PlayerPickerTable.kt @@ -33,7 +33,7 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters: val gameBasics = newGameScreen.ruleSet // when we add mods, this will need to change for (player in newGameParameters.players) playerListTable.add(getPlayerTable(player,gameBasics)).pad(10f).row() - if(newGameParameters.players.count() < gameBasics.Nations.values.count { it.isMajorCiv() }) { + if(newGameParameters.players.count() < gameBasics.nations.values.count { it.isMajorCiv() }) { playerListTable.add("+".toLabel(Color.BLACK,30).apply { this.setAlignment(Align.center) } .surroundWithCircle(50f).onClick { newGameParameters.players.add(Player()); update() }) } @@ -107,7 +107,7 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters: val nationImage = if (player.chosenCiv == "Random") "?".toLabel(Color.BLACK,30) .apply { this.setAlignment(Align.center) } .surroundWithCircle(50f) - else ImageGetter.getNationIndicator(newGameScreen.ruleSet.Nations[player.chosenCiv]!!, 50f) + else ImageGetter.getNationIndicator(newGameScreen.ruleSet.nations[player.chosenCiv]!!, 50f) nationTable.add(nationImage) nationTable.add(player.chosenCiv.toLabel()).pad(20f) nationTable.touchable = Touchable.enabled @@ -137,7 +137,7 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters: nationListTable.add(randomPlayerTable).pad(10f).width(nationsPopupWidth).row() - for (nation in newGameScreen.ruleSet.Nations.values.filter { !it.isCityState() && it.name != "Barbarians" }) { + for (nation in newGameScreen.ruleSet.nations.values.filter { !it.isCityState() && it.name != "Barbarians" }) { if (player.chosenCiv != nation.name && newGameParameters.players.any { it.chosenCiv == nation.name }) continue diff --git a/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt index 43e08911..f119520c 100644 --- a/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt @@ -16,7 +16,7 @@ class GreatPersonPickerScreen(val civInfo:CivilizationInfo) : PickerScreen() { init { closeButton.isVisible=false rightSideButton.setText("Choose a free great person".tr()) - for (unit in civInfo.gameInfo.ruleSet.Units.values + for (unit in civInfo.gameInfo.ruleSet.units.values .filter { it.name in GreatPersonManager().statToGreatPersonMapping.values || it.name == "Great General"}) { val button = Button(skin) diff --git a/core/src/com/unciv/ui/pickerscreens/ImprovementPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/ImprovementPickerScreen.kt index 0236c8c5..bfd68bb1 100644 --- a/core/src/com/unciv/ui/pickerscreens/ImprovementPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/ImprovementPickerScreen.kt @@ -38,7 +38,7 @@ class ImprovementPickerScreen(tileInfo: TileInfo, onAccept: ()->Unit) : PickerSc val regularImprovements = VerticalGroup() regularImprovements.space(10f) - for (improvement in tileInfo.tileMap.gameInfo.ruleSet.TileImprovements.values) { + for (improvement in tileInfo.tileMap.gameInfo.ruleSet.tileImprovements.values) { if (!tileInfo.canBuildImprovement(improvement, currentPlayerCiv)) continue if(improvement.name == tileInfo.improvement) continue if(improvement.name==tileInfo.improvementInProgress) continue diff --git a/core/src/com/unciv/ui/pickerscreens/PolicyPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/PolicyPickerScreen.kt index 51b71ffb..cecdd24c 100644 --- a/core/src/com/unciv/ui/pickerscreens/PolicyPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/PolicyPickerScreen.kt @@ -53,7 +53,7 @@ class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: CivilizationInfo topTable.row().pad(30f) - for (branch in viewingCiv.gameInfo.ruleSet.PolicyBranches.values) { + for (branch in viewingCiv.gameInfo.ruleSet.policyBranches.values) { if (branch.name == "Commerce") topTable.addSeparator() val branchGroup = Table() branchGroup.row().pad(20f) diff --git a/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt index a5793586..8648c0b2 100644 --- a/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt @@ -41,7 +41,7 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() { availablePromotionsGroup.space(10f) val unitType = unit.type - val promotionsForUnitType = unit.civInfo.gameInfo.ruleSet.UnitPromotions.values.filter { + val promotionsForUnitType = unit.civInfo.gameInfo.ruleSet.unitPromotions.values.filter { it.unitTypes.contains(unitType.toString()) || unit.promotions.promotions.contains(it.name) } val unitAvailablePromotions = unit.promotions.getAvailablePromotions() diff --git a/core/src/com/unciv/ui/pickerscreens/TechButton.kt b/core/src/com/unciv/ui/pickerscreens/TechButton.kt index 48728310..96e1028e 100644 --- a/core/src/com/unciv/ui/pickerscreens/TechButton.kt +++ b/core/src/com/unciv/ui/pickerscreens/TechButton.kt @@ -44,7 +44,7 @@ class TechButton(techName:String, val techManager: TechManager, isWorldScreen: B val civName = techManager.civInfo.civName val gameBasics = techManager.civInfo.gameInfo.ruleSet - val tech = gameBasics.Technologies[techName]!! + val tech = gameBasics.technologies[techName]!! for (unit in tech.getEnabledUnits(techManager.civInfo)) techEnabledIcons.add(ImageGetter.getConstructionImage(unit.name).surroundWithCircle(30f)) @@ -52,7 +52,7 @@ class TechButton(techName:String, val techManager: TechManager, isWorldScreen: B for (building in tech.getEnabledBuildings(techManager.civInfo)) techEnabledIcons.add(ImageGetter.getConstructionImage(building.name).surroundWithCircle(30f)) - for (improvement in gameBasics.TileImprovements.values + for (improvement in gameBasics.tileImprovements.values .filter { it.techRequired == techName || it.improvingTech == techName } .filter { it.uniqueTo==null || it.uniqueTo==civName }) { if (improvement.name.startsWith("Remove")) @@ -60,7 +60,7 @@ class TechButton(techName:String, val techManager: TechManager, isWorldScreen: B else techEnabledIcons.add(ImageGetter.getImprovementIcon(improvement.name, 30f)) } - for (resource in gameBasics.TileResources.values.filter { it.revealedBy == techName }) + for (resource in gameBasics.tileResources.values.filter { it.revealedBy == techName }) techEnabledIcons.add(ImageGetter.getResourceImage(resource.name, 30f)) for (unique in tech.uniques) diff --git a/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt index 8edc003d..3904b999 100644 --- a/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt @@ -24,7 +24,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec private var lines=ArrayList() // 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(7,46,43) @@ -33,7 +33,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec private val queuedTechColor = colorFromRGB(39,114,154) - 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)}) constructor(freeTechPick: Boolean, civInfo: CivilizationInfo) : this(civInfo) { isFreeTechPick = freeTechPick @@ -75,10 +75,10 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec } private fun createTechTable() { - val columns = civInfo.gameInfo.ruleSet.Technologies.values.map { it.column!!.columnNumber}.max()!! +1 + val columns = civInfo.gameInfo.ruleSet.technologies.values.map { it.column!!.columnNumber}.max()!! +1 val techMatrix = Array>(columns) { arrayOfNulls(10) } // Divided into columns, then rows - for (technology in civInfo.gameInfo.ruleSet.Technologies.values) { + for (technology in civInfo.gameInfo.ruleSet.technologies.values) { techMatrix[technology.column!!.columnNumber][technology.row - 1] = technology } @@ -145,7 +145,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec for (line in lines) line.remove() lines.clear() - for (tech in civInfo.gameInfo.ruleSet.Technologies.values) { + for (tech in civInfo.gameInfo.ruleSet.technologies.values) { val techButton = techNameToButton[tech.name]!! for (prerequisite in tech.prerequisites) { val prerequisiteButton = techNameToButton[prerequisite]!! diff --git a/core/src/com/unciv/ui/utils/ImageGetter.kt b/core/src/com/unciv/ui/utils/ImageGetter.kt index 740a27f3..7f2dcc56 100644 --- a/core/src/com/unciv/ui/utils/ImageGetter.kt +++ b/core/src/com/unciv/ui/utils/ImageGetter.kt @@ -112,13 +112,13 @@ object ImageGetter { return getImage("OtherIcons/Stop") if(improvementName.startsWith("StartingLocation ")){ val nationName = improvementName.removePrefix("StartingLocation ") - val nation = getRuleSet().Nations[nationName]!! + val nation = getRuleSet().nations[nationName]!! return getNationIndicator(nation,size) } val iconGroup = getImage("ImprovementIcons/$improvementName").surroundWithCircle(size) - val improvement = getRuleSet().TileImprovements[improvementName]!! + val improvement = getRuleSet().tileImprovements[improvementName]!! when { improvement.food>0 -> iconGroup.circle.color= foodCircleColor improvement.production>0 -> iconGroup.circle.color= productionCircleColor @@ -131,8 +131,8 @@ object ImageGetter { } fun getConstructionImage(construction: String): Image { - if(getRuleSet().Buildings.containsKey(construction)) return getImage("BuildingIcons/$construction") - if(getRuleSet().Units.containsKey(construction)) return getUnitIcon(construction) + if(getRuleSet().buildings.containsKey(construction)) return getImage("BuildingIcons/$construction") + if(getRuleSet().units.containsKey(construction)) return getUnitIcon(construction) if(construction=="Nothing") return getImage("OtherIcons/Stop") return getStatIcon(construction) } @@ -180,7 +180,7 @@ object ImageGetter { fun getResourceImage(resourceName: String, size:Float): Actor { val iconGroup = getImage("ResourceIcons/$resourceName").surroundWithCircle(size) - val resource = getRuleSet().TileResources[resourceName]!! + val resource = getRuleSet().tileResources[resourceName]!! when { resource.food>0 -> iconGroup.circle.color= foodCircleColor resource.production>0 -> iconGroup.circle.color= productionCircleColor @@ -204,7 +204,7 @@ object ImageGetter { fun getTechIconGroup(techName: String, circleSize: Float): Group { var techIconColor = Color.WHITE - when (getRuleSet().Technologies[techName]!!.era().name) { + when (getRuleSet().technologies[techName]!!.era().name) { "Ancient" -> techIconColor = colorFromRGB(255, 87, 35) "Classical" -> techIconColor = colorFromRGB(233, 31, 99) "Medieval" -> techIconColor = colorFromRGB(157, 39, 176) diff --git a/core/src/com/unciv/ui/worldscreen/AlertPopup.kt b/core/src/com/unciv/ui/worldscreen/AlertPopup.kt index 63b1001c..b3628f78 100644 --- a/core/src/com/unciv/ui/worldscreen/AlertPopup.kt +++ b/core/src/com/unciv/ui/worldscreen/AlertPopup.kt @@ -149,7 +149,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() val centerTable = Table() @@ -162,7 +162,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu } AlertType.TechResearched -> { val gameBasics = worldScreen.gameInfo.ruleSet - val tech = gameBasics.Technologies[popupAlert.value]!! + val tech = gameBasics.technologies[popupAlert.value]!! addGoodSizedLabel(tech.name) addSeparator() val centerTable = Table() diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index 14119847..f1626c43 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -296,7 +296,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() { techButtonHolder.isVisible = viewingCiv.cities.isNotEmpty() techButtonHolder.clearChildren() - val researchableTechs = viewingCiv.gameInfo.ruleSet.Technologies.values.filter { !viewingCiv.tech.isResearched(it.name) && viewingCiv.tech.canBeResearched(it.name) } + val researchableTechs = viewingCiv.gameInfo.ruleSet.technologies.values.filter { !viewingCiv.tech.isResearched(it.name) && viewingCiv.tech.canBeResearched(it.name) } if (viewingCiv.tech.currentTechnology() == null && researchableTechs.isEmpty()) viewingCiv.tech.techsToResearch.add(Constants.futureTech) diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt b/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt index d5bf6c35..7568b90d 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreenTopBar.kt @@ -57,7 +57,7 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() { private fun getResourceTable(): Table { val resourceTable = Table() resourceTable.defaults().pad(5f) - val revealedStrategicResources = worldScreen.gameInfo.ruleSet.TileResources.values + val revealedStrategicResources = worldScreen.gameInfo.ruleSet.tileResources.values .filter { it.resourceType == ResourceType.Strategic } // && currentPlayerCivInfo.tech.isResearched(it.revealedBy!!) } for (resource in revealedStrategicResources) { val resourceImage = ImageGetter.getResourceImage(resource.name,20f) @@ -105,7 +105,7 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() { internal fun update(civInfo: CivilizationInfo) { - val revealedStrategicResources = civInfo.gameInfo.ruleSet.TileResources.values + val revealedStrategicResources = civInfo.gameInfo.ruleSet.tileResources.values .filter { it.resourceType == ResourceType.Strategic } val civResources = civInfo.getCivResources() for (resource in revealedStrategicResources) { diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index 2ba8b77b..12b45cbe 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -142,7 +142,7 @@ class UnitActions { actionList += UnitAction("Construct improvement", unit.currentMovement > 0 && !tile.isCityCenter() - && unit.civInfo.gameInfo.ruleSet.TileImprovements.values.any { tile.canBuildImprovement(it, unit.civInfo) }, + && unit.civInfo.gameInfo.ruleSet.tileImprovements.values.any { tile.canBuildImprovement(it, unit.civInfo) }, currentAction = unit.currentTile.hasImprovementInProgress() ) { worldScreen.game.setScreen(ImprovementPickerScreen(tile) { unitTable.selectedUnit = null }) } @@ -172,7 +172,7 @@ class UnitActions { && tile.isWater // because fishing boats can enter cities, and if there's oil in the city... ;) && tile.improvement==null && tile.getTileResource().improvement == improvement - && unit.civInfo.tech.isResearched(unit.civInfo.gameInfo.ruleSet.TileImprovements[improvement]!!.techRequired!!) + && unit.civInfo.tech.isResearched(unit.civInfo.gameInfo.ruleSet.tileImprovements[improvement]!!.techRequired!!) ) actionList += UnitAction("Create [$improvement]", unit.currentMovement >0) { tile.improvement = improvement diff --git a/tests/src/com/unciv/testing/BasicTests.kt b/tests/src/com/unciv/testing/BasicTests.kt index 2391a683..e67595aa 100644 --- a/tests/src/com/unciv/testing/BasicTests.kt +++ b/tests/src/com/unciv/testing/BasicTests.kt @@ -20,7 +20,7 @@ class BasicTests { @Test fun loadRuleset() { Assert.assertTrue("This test will only pass when the jsons can be loaded", - Ruleset(true).Buildings.size > 0) + Ruleset(true).buildings.size > 0) } @Test @@ -34,7 +34,7 @@ class BasicTests { // and we try to work on its upgrade, we'll get an exception - see techManager @Test fun allObsoletingUnitsHaveUpgrades() { - val units: Collection = Ruleset(true).Units.values + val units: Collection = Ruleset(true).units.values var allObsoletingUnitsHaveUpgrades = true for (unit in units) { if (unit.obsoleteTech != null && unit.upgradesTo == null) { diff --git a/tests/src/com/unciv/testing/TranslationTests.kt b/tests/src/com/unciv/testing/TranslationTests.kt index 65090bde..7fd8c783 100644 --- a/tests/src/com/unciv/testing/TranslationTests.kt +++ b/tests/src/com/unciv/testing/TranslationTests.kt @@ -30,7 +30,7 @@ class TranslationTests { @Test fun allUnitsHaveTranslation() { - val allUnitsHaveTranslation = allStringAreTranslated(ruleSet.Units.keys) + val allUnitsHaveTranslation = allStringAreTranslated(ruleSet.units.keys) Assert.assertTrue("This test will only pass when there is a translation for all units", allUnitsHaveTranslation) } @@ -38,7 +38,7 @@ class TranslationTests { @Test fun allUnitUniquesHaveTranslation() { val strings: MutableSet = HashSet() - for (unit in ruleSet.Units.values) for (unique in unit.uniques) if (!unique.startsWith("Bonus") + for (unit in ruleSet.units.values) for (unique in unit.uniques) if (!unique.startsWith("Bonus") && !unique.startsWith("Penalty") && !unique.contains("[")) // templates strings.add(unique) @@ -48,7 +48,7 @@ class TranslationTests { @Test fun allBuildingsHaveTranslation() { - val allBuildingsHaveTranslation = allStringAreTranslated(ruleSet.Buildings.keys) + val allBuildingsHaveTranslation = allStringAreTranslated(ruleSet.buildings.keys) Assert.assertTrue("This test will only pass when there is a translation for all buildings", allBuildingsHaveTranslation) } @@ -56,7 +56,7 @@ class TranslationTests { @Test fun allBuildingUniquesHaveTranslation() { val strings: MutableSet = HashSet() - for (building in ruleSet.Buildings.values) { + for (building in ruleSet.buildings.values) { strings.addAll(building.uniques) } val allStringsHaveTranslation = allStringAreTranslated(strings) @@ -66,7 +66,7 @@ class TranslationTests { @Test fun allBuildingQuotesHaveTranslation() { val strings: MutableSet = HashSet() - for (building in ruleSet.Buildings.values) { + for (building in ruleSet.buildings.values) { if (building.quote == "") continue strings.add(building.quote) } @@ -76,7 +76,7 @@ class TranslationTests { @Test fun allTerrainsHaveTranslation() { - val strings: Set = ruleSet.Terrains.keys + val strings: Set = ruleSet.terrains.keys val allStringsHaveTranslation = allStringAreTranslated(strings) Assert.assertTrue("This test will only pass when there is a translation for all buildings", allStringsHaveTranslation) @@ -84,7 +84,7 @@ class TranslationTests { @Test fun allImprovementsHaveTranslation() { - val strings: Set = ruleSet.TileImprovements.keys + val strings: Set = ruleSet.tileImprovements.keys val allStringsHaveTranslation = allStringAreTranslated(strings) Assert.assertTrue("This test will only pass when there is a translation for all improvements", allStringsHaveTranslation) @@ -93,7 +93,7 @@ class TranslationTests { @Test fun allImprovementUniquesHaveTranslation() { val strings: MutableSet = HashSet() - for (improvement in ruleSet.TileImprovements.values) { + for (improvement in ruleSet.tileImprovements.values) { strings.addAll(improvement.uniques) } val allStringsHaveTranslation = allStringAreTranslated(strings) @@ -102,7 +102,7 @@ class TranslationTests { @Test fun allTechnologiesHaveTranslation() { - val strings: Set = ruleSet.Technologies.keys + val strings: Set = ruleSet.technologies.keys val allStringsHaveTranslation = allStringAreTranslated(strings) Assert.assertTrue("This test will only pass when there is a translation for all technologies", allStringsHaveTranslation) @@ -111,7 +111,7 @@ class TranslationTests { @Test fun allTechnologiesQuotesHaveTranslation() { val strings: MutableSet = HashSet() - for (tech in ruleSet.Technologies.values) { + for (tech in ruleSet.technologies.values) { strings.add(tech.quote) } val allStringsHaveTranslation = allStringAreTranslated(strings) @@ -121,7 +121,7 @@ class TranslationTests { @Test fun allPromotionsHaveTranslation() { - val strings: Set = ruleSet.UnitPromotions.keys + val strings: Set = ruleSet.unitPromotions.keys val allStringsHaveTranslation = allStringAreTranslated(strings) Assert.assertTrue("This test will only pass when there is a translation for all promotions", allStringsHaveTranslation)