diff --git a/core/src/com/unciv/UncivGame.kt b/core/src/com/unciv/UncivGame.kt index e609077db3..68499eeef1 100644 --- a/core/src/com/unciv/UncivGame.kt +++ b/core/src/com/unciv/UncivGame.kt @@ -8,7 +8,7 @@ import com.badlogic.gdx.audio.Music import com.unciv.logic.GameInfo import com.unciv.logic.GameSaver import com.unciv.logic.GameStarter -import com.unciv.models.gamebasics.GameBasics +import com.unciv.models.gamebasics.RuleSet import com.unciv.models.metadata.GameParameters import com.unciv.models.metadata.GameSettings import com.unciv.ui.LanguagePickerScreen @@ -36,11 +36,11 @@ class UncivGame(val version: String) : Game() { val musicLocation = "music/thatched-villagers.mp3" var isInitialized=false - lateinit var gameBasics:GameBasics + lateinit var ruleSet:RuleSet override fun create() { Current = this - gameBasics = GameBasics() + ruleSet = RuleSet() if(Gdx.app.type!= Application.ApplicationType.Desktop) viewEntireMapForDebug=false diff --git a/core/src/com/unciv/logic/GameInfo.kt b/core/src/com/unciv/logic/GameInfo.kt index 7b287b6564..945e2a810d 100644 --- a/core/src/com/unciv/logic/GameInfo.kt +++ b/core/src/com/unciv/logic/GameInfo.kt @@ -20,7 +20,7 @@ class GameInfo { /** This is used in multiplayer games, where I may have a saved game state on my phone * that is inconsistent with the saved game on the cloud */ @Transient var isUpToDate=false - @Transient var gameBasics = UncivGame.Current.gameBasics + @Transient var gameBasics = UncivGame.Current.ruleSet var civilizations = mutableListOf() var difficulty="Chieftain" // difficulty is game-wide, think what would happen if 2 human players could play on different difficulties? diff --git a/core/src/com/unciv/logic/GameStarter.kt b/core/src/com/unciv/logic/GameStarter.kt index b008091e09..b8c9ed3bda 100644 --- a/core/src/com/unciv/logic/GameStarter.kt +++ b/core/src/com/unciv/logic/GameStarter.kt @@ -5,7 +5,7 @@ import com.unciv.Constants import com.unciv.UncivGame import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.map.* -import com.unciv.models.gamebasics.GameBasics +import com.unciv.models.gamebasics.RuleSet import com.unciv.models.metadata.GameParameters import java.util.* import kotlin.collections.ArrayList @@ -17,7 +17,7 @@ class GameStarter{ val gameInfo = GameInfo() gameInfo.gameParameters = newGameParameters - val gameBasics = UncivGame.Current.gameBasics + val gameBasics = UncivGame.Current.ruleSet if(newGameParameters.mapType==MapType.file) gameInfo.tileMap = MapSaver().loadMap(newGameParameters.mapFileName!!) @@ -54,9 +54,9 @@ class GameStarter{ return gameInfo } - private fun addCivilizations(newGameParameters: GameParameters, gameInfo: GameInfo, gameBasics: GameBasics) { + private fun addCivilizations(newGameParameters: GameParameters, gameInfo: GameInfo, ruleSet: RuleSet) { val availableCivNames = Stack() - availableCivNames.addAll(gameBasics.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") @@ -82,7 +82,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(gameBasics.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)) { diff --git a/core/src/com/unciv/logic/map/MapGenerator.kt b/core/src/com/unciv/logic/map/MapGenerator.kt index befda32ec0..5fdf53b9d9 100644 --- a/core/src/com/unciv/logic/map/MapGenerator.kt +++ b/core/src/com/unciv/logic/map/MapGenerator.kt @@ -4,7 +4,7 @@ import com.badlogic.gdx.math.Vector2 import com.unciv.Constants import com.unciv.logic.HexMath import com.unciv.models.Counter -import com.unciv.models.gamebasics.GameBasics +import com.unciv.models.gamebasics.RuleSet import com.unciv.models.gamebasics.tile.ResourceType import com.unciv.models.gamebasics.tile.TerrainType import com.unciv.models.metadata.GameParameters @@ -27,26 +27,26 @@ class MapType { class MapGenerator { - fun generateMap(gameParameters: GameParameters, gameBasics: GameBasics): TileMap { + fun generateMap(gameParameters: GameParameters, ruleSet: RuleSet): TileMap { val mapRadius = gameParameters.mapRadius val mapType = gameParameters.mapType - val map = TileMap(mapRadius, gameBasics) + val map = TileMap(mapRadius, ruleSet) // Step one - separate land and water, in form of Grasslands and Oceans if (mapType == MapType.perlin) MapLandmassGenerator().generateLandPerlin(map) else MapLandmassGenerator().generateLandCellularAutomata(map, mapRadius, mapType) - divideIntoBiomes(map, 6, 0.05f, mapRadius, gameBasics) + divideIntoBiomes(map, 6, 0.05f, mapRadius, ruleSet) for (tile in map.values) tile.setTransients() setWaterTiles(map) - for (tile in map.values) randomizeTile(tile, gameParameters, gameBasics) + for (tile in map.values) randomizeTile(tile, gameParameters, ruleSet) - randomizeResources(map, mapRadius, gameBasics) + randomizeResources(map, mapRadius, ruleSet) return map } @@ -93,12 +93,12 @@ class MapGenerator { } } - fun randomizeTile(tileInfo: TileInfo, gameParameters: GameParameters, gameBasics: GameBasics) { + fun randomizeTile(tileInfo: TileInfo, gameParameters: GameParameters, ruleSet: RuleSet) { if (tileInfo.getBaseTerrain().type == TerrainType.Land && Math.random() < 0.05f) { tileInfo.baseTerrain = Constants.mountain tileInfo.setTransients() } - addRandomTerrainFeature(tileInfo, gameBasics) + addRandomTerrainFeature(tileInfo, ruleSet) maybeAddAncientRuins(tileInfo, gameParameters) } @@ -106,10 +106,10 @@ class MapGenerator { return (sin(3.1416 / 3) * vector.y).toFloat() } - fun divideIntoBiomes(map: TileMap, averageTilesPerArea: Int, waterPercent: Float, distance: Int, gameBasics: GameBasics) { + fun divideIntoBiomes(map: TileMap, averageTilesPerArea: Int, waterPercent: Float, distance: Int, ruleSet: RuleSet) { val areas = ArrayList() - val terrains = gameBasics.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 @@ -184,9 +184,9 @@ class MapGenerator { } - fun addRandomTerrainFeature(tileInfo: TileInfo, gameBasics: GameBasics) { + fun addRandomTerrainFeature(tileInfo: TileInfo, ruleSet: RuleSet) { if (tileInfo.getBaseTerrain().canHaveOverlay && Math.random() > 0.7f) { - val secondaryTerrains = gameBasics.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 } @@ -200,19 +200,19 @@ class MapGenerator { } - fun randomizeResources(mapToReturn: TileMap, distance: Int, gameBasics: GameBasics) { + fun randomizeResources(mapToReturn: TileMap, distance: Int, ruleSet: RuleSet) { for (tile in mapToReturn.values) if (tile.resource != null) tile.resource = null - randomizeStrategicResources(mapToReturn, distance, gameBasics) - randomizeResource(mapToReturn, distance, ResourceType.Luxury, gameBasics) - randomizeResource(mapToReturn, distance, ResourceType.Bonus, gameBasics) + randomizeStrategicResources(mapToReturn, distance, ruleSet) + randomizeResource(mapToReturn, distance, ResourceType.Luxury, ruleSet) + randomizeResource(mapToReturn, distance, ResourceType.Bonus, ruleSet) } // Here, we need each specific resource to be spread over the map - it matters less if specific resources are near each other - private fun randomizeStrategicResources(mapToReturn: TileMap, distance: Int, gameBasics: GameBasics) { - val resourcesOfType = gameBasics.TileResources.values.filter { it.resourceType == ResourceType.Strategic } + private fun randomizeStrategicResources(mapToReturn: TileMap, distance: Int, ruleSet: RuleSet) { + 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) } @@ -227,8 +227,8 @@ class MapGenerator { } // Here, we need there to be some luxury/bonus resource - it matters less what - private fun randomizeResource(mapToReturn: TileMap, distance: Int, resourceType: ResourceType, gameBasics: GameBasics) { - val resourcesOfType = gameBasics.TileResources.values.filter { it.resourceType == resourceType } + private fun randomizeResource(mapToReturn: TileMap, distance: Int, resourceType: ResourceType, ruleSet: RuleSet) { + 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 926c33cc88..864df50aa9 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -8,7 +8,7 @@ import com.unciv.logic.automation.WorkerAutomation import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.map.action.MapUnitAction import com.unciv.logic.map.action.StringAction -import com.unciv.models.gamebasics.GameBasics +import com.unciv.models.gamebasics.RuleSet import com.unciv.models.gamebasics.tech.TechEra import com.unciv.models.gamebasics.tile.TerrainType import com.unciv.models.gamebasics.unit.BaseUnit @@ -265,10 +265,10 @@ class MapUnit { //endregion //region state-changing functions - fun setTransients(gameBasics: GameBasics) { + fun setTransients(ruleSet: RuleSet) { promotions.unit=this mapUnitAction?.unit = this - baseUnit=gameBasics.Units[name]!! + baseUnit=ruleSet.Units[name]!! updateUniques() } diff --git a/core/src/com/unciv/logic/map/RoadStatus.kt b/core/src/com/unciv/logic/map/RoadStatus.kt index 67211fdf7e..f9d2ba19d9 100644 --- a/core/src/com/unciv/logic/map/RoadStatus.kt +++ b/core/src/com/unciv/logic/map/RoadStatus.kt @@ -2,7 +2,7 @@ package com.unciv.logic.map import com.unciv.logic.map.RoadStatus.Railroad import com.unciv.logic.map.RoadStatus.Road -import com.unciv.models.gamebasics.GameBasics +import com.unciv.models.gamebasics.RuleSet /** * You can use RoadStatus.name to identify [Road] and [Railroad] @@ -15,6 +15,6 @@ enum class RoadStatus { Railroad; /** returns null for [None] */ - fun improvement(gameBasics: GameBasics) = gameBasics.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 8b881838c2..5c8d14e550 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -5,7 +5,7 @@ import com.unciv.Constants import com.unciv.UncivGame import com.unciv.logic.city.CityInfo import com.unciv.logic.civilization.CivilizationInfo -import com.unciv.models.gamebasics.GameBasics +import com.unciv.models.gamebasics.RuleSet import com.unciv.models.gamebasics.tile.* import com.unciv.models.gamebasics.tr import com.unciv.models.stats.Stats @@ -13,7 +13,7 @@ import kotlin.math.abs open class TileInfo { @Transient lateinit var tileMap: TileMap - @Transient lateinit var gameBasics: GameBasics // a tile can be a tile with a ruleset, even without a map. + @Transient lateinit var ruleSet: RuleSet // a tile can be a tile with a ruleset, even without a map. @Transient var owningCity:CityInfo?=null @Transient private lateinit var baseTerrainObject:Terrain @@ -85,11 +85,11 @@ open class TileInfo { fun getTileResource(): TileResource = if (resource == null) throw Exception("No resource exists for this tile!") - else gameBasics.TileResources[resource!!]!! + else ruleSet.TileResources[resource!!]!! fun isCityCenter(): Boolean = getCity()?.location == position - fun getTileImprovement(): TileImprovement? = if (improvement == null) null else gameBasics.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, @@ -118,7 +118,7 @@ open class TileInfo { } fun getTerrainFeature(): Terrain? { - return if (terrainFeature == null) null else gameBasics.Terrains[terrainFeature!!] + return if (terrainFeature == null) null else ruleSet.Terrains[terrainFeature!!] } fun isWorked(): Boolean { @@ -310,7 +310,7 @@ open class TileInfo { //region state-changing functions fun setTransients(){ - baseTerrainObject = gameBasics.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 @@ -318,7 +318,7 @@ open class TileInfo { for (unit in getUnits()) { unit.currentTile = this unit.assignOwner(tileMap.gameInfo.getCivilization(unit.owner),false) - unit.setTransients(gameBasics) + unit.setTransients(ruleSet) } } diff --git a/core/src/com/unciv/logic/map/TileMap.kt b/core/src/com/unciv/logic/map/TileMap.kt index 3d9d0be348..88bc388a3a 100644 --- a/core/src/com/unciv/logic/map/TileMap.kt +++ b/core/src/com/unciv/logic/map/TileMap.kt @@ -5,7 +5,7 @@ import com.unciv.Constants import com.unciv.logic.GameInfo import com.unciv.logic.HexMath import com.unciv.logic.civilization.CivilizationInfo -import com.unciv.models.gamebasics.GameBasics +import com.unciv.models.gamebasics.RuleSet class TileMap { @@ -32,10 +32,10 @@ class TileMap { - constructor(radius:Int, gameBasics: GameBasics){ + constructor(radius:Int, ruleSet: RuleSet){ for(vector in HexMath().getVectorsInDistance(Vector2.Zero, radius)) tileList.add(TileInfo().apply { position = vector; baseTerrain= Constants.grassland }) - setTransients(gameBasics) + setTransients(ruleSet) } @@ -146,7 +146,7 @@ class TileMap { return viewableTiles } - fun setTransients(gameBasics: GameBasics) { + fun setTransients(ruleSet: RuleSet) { if(tiles.any()) tileList.addAll(tiles.values) @@ -164,7 +164,7 @@ class TileMap { for (tileInfo in values){ tileMatrix[tileInfo.position.x.toInt()-leftX][tileInfo.position.y.toInt()-bottomY] = tileInfo tileInfo.tileMap = this - tileInfo.gameBasics = gameBasics + tileInfo.ruleSet = ruleSet tileInfo.setTransients() } } diff --git a/core/src/com/unciv/models/gamebasics/Building.kt b/core/src/com/unciv/models/gamebasics/Building.kt index 06986af9e4..fd8db8c1b1 100644 --- a/core/src/com/unciv/models/gamebasics/Building.kt +++ b/core/src/com/unciv/models/gamebasics/Building.kt @@ -45,14 +45,14 @@ class Building : NamedStats(), IConstruction{ var resourceBonusStats: Stats? = null - fun getShortDescription(gameBasics: GameBasics): String { // should fit in one line + fun getShortDescription(ruleSet: RuleSet): String { // should fit in one line val infoList= mutableListOf() val str = getStats(null).toString() if(str.isNotEmpty()) infoList += str for(stat in getStatPercentageBonuses(null).toHashMap()) if(stat.value!=0f) infoList+="+${stat.value.toInt()}% ${stat.key.toString().tr()}" - val improvedResources = gameBasics.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() @@ -66,7 +66,7 @@ class Building : NamedStats(), IConstruction{ return infoList.joinToString() } - fun getDescription(forBuildingPickerScreen: Boolean, civInfo: CivilizationInfo?, gameBasics: GameBasics): String { + fun getDescription(forBuildingPickerScreen: Boolean, civInfo: CivilizationInfo?, ruleSet: RuleSet): String { val stats = getStats(civInfo) val stringBuilder = StringBuilder() if(uniqueTo!=null) stringBuilder.appendln("Unique to [$uniqueTo], replaces [$replaces]".tr()) @@ -102,7 +102,7 @@ class Building : NamedStats(), IConstruction{ if (gpp.culture != 0f) stringBuilder.appendln("+" + gpp.culture.toInt() + " "+"[Great Artist] points".tr()) } if (resourceBonusStats != null) { - val resources = gameBasics.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()) } @@ -367,8 +367,8 @@ class Building : NamedStats(), IConstruction{ return false } - fun getBaseBuilding(gameBasics: GameBasics): Building { + fun getBaseBuilding(ruleSet: RuleSet): Building { if(replaces==null) return this - else return gameBasics.Buildings[replaces!!]!! + else return ruleSet.Buildings[replaces!!]!! } } diff --git a/core/src/com/unciv/models/gamebasics/GameBasics.kt b/core/src/com/unciv/models/gamebasics/RuleSet.kt similarity index 99% rename from core/src/com/unciv/models/gamebasics/GameBasics.kt rename to core/src/com/unciv/models/gamebasics/RuleSet.kt index 7a742e3199..96ceb69b5a 100644 --- a/core/src/com/unciv/models/gamebasics/GameBasics.kt +++ b/core/src/com/unciv/models/gamebasics/RuleSet.kt @@ -12,7 +12,7 @@ import com.unciv.models.gamebasics.unit.Promotion import com.unciv.models.stats.INamed import kotlin.collections.set -class GameBasics { +class RuleSet { val Buildings = LinkedHashMap() val Terrains = LinkedHashMap() val TileResources = LinkedHashMap() diff --git a/core/src/com/unciv/models/gamebasics/Translations.kt b/core/src/com/unciv/models/gamebasics/Translations.kt index 0244530f75..6a31fdd0fe 100644 --- a/core/src/com/unciv/models/gamebasics/Translations.kt +++ b/core/src/com/unciv/models/gamebasics/Translations.kt @@ -90,7 +90,7 @@ fun String.tr(): String { val translationStringWithSquareBracketsOnly = replace(squareBraceRegex,"[]") - val translationEntry = UncivGame.Current.gameBasics.Translations.values + val translationEntry = UncivGame.Current.ruleSet.Translations.values .firstOrNull { translationStringWithSquareBracketsOnly == it.entryWithShortenedSquareBrackets } if(translationEntry==null || @@ -115,6 +115,6 @@ fun String.tr(): String { return Regex("\\{(.*?)\\}").replace(this) { it.groups[1]!!.value.tr() } } - val translation = UncivGame.Current.gameBasics.Translations.get(this, UncivGame.Current.settings.language) // single word + val translation = UncivGame.Current.ruleSet.Translations.get(this, UncivGame.Current.settings.language) // single word return translation } diff --git a/core/src/com/unciv/models/gamebasics/tech/Technology.kt b/core/src/com/unciv/models/gamebasics/tech/Technology.kt index ef9dc51831..f05769feb1 100644 --- a/core/src/com/unciv/models/gamebasics/tech/Technology.kt +++ b/core/src/com/unciv/models/gamebasics/tech/Technology.kt @@ -3,7 +3,7 @@ package com.unciv.models.gamebasics.tech import com.unciv.UncivGame import com.unciv.logic.civilization.CivilizationInfo import com.unciv.models.gamebasics.Building -import com.unciv.models.gamebasics.GameBasics +import com.unciv.models.gamebasics.RuleSet import com.unciv.models.gamebasics.tr import com.unciv.models.gamebasics.unit.BaseUnit import java.util.* @@ -20,11 +20,11 @@ class Technology { var row: Int = 0 var quote="" - fun getDescription(gameBasics: GameBasics): String { + fun getDescription(ruleSet: RuleSet): String { val lineList = ArrayList() // more readable than StringBuilder, with same performance for our use-case for (unique in uniques) lineList += unique.tr() - val improvedImprovements = gameBasics.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() } + @@ -46,20 +46,20 @@ class Technology { if (regularBuildings.isNotEmpty()) { lineList += "{Buildings enabled}: " for (building in regularBuildings) - lineList += "* " + building.name.tr() + " (" + building.getShortDescription(gameBasics) + ")" + lineList += "* " + building.name.tr() + " (" + building.getShortDescription(ruleSet) + ")" } val wonders = enabledBuildings.filter { it.isWonder || it.isNationalWonder } if (wonders.isNotEmpty()) { lineList += "{Wonders enabled}: " for (wonder in wonders) - lineList += " * " + wonder.name.tr() + " (" + wonder.getShortDescription(gameBasics) + ")" + lineList += " * " + wonder.name.tr() + " (" + wonder.getShortDescription(ruleSet) + ")" } - val revealedResource = gameBasics.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 = gameBasics.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() } diff --git a/core/src/com/unciv/models/gamebasics/tile/Terrain.kt b/core/src/com/unciv/models/gamebasics/tile/Terrain.kt index 955a09a7bc..45e3195277 100644 --- a/core/src/com/unciv/models/gamebasics/tile/Terrain.kt +++ b/core/src/com/unciv/models/gamebasics/tile/Terrain.kt @@ -1,19 +1,19 @@ package com.unciv.models.gamebasics.tile import com.badlogic.gdx.graphics.Color -import com.unciv.models.gamebasics.GameBasics +import com.unciv.models.gamebasics.RuleSet import com.unciv.models.gamebasics.tr import com.unciv.models.stats.NamedStats import com.unciv.ui.utils.colorFromRGB class Terrain : NamedStats() { - fun getDescription(gameBasics: GameBasics): String { + fun getDescription(ruleSet: RuleSet): String { val sb = StringBuilder() sb.appendln(this.clone().toString()) if (occursOn != null) { sb.appendln("Occurs on [${occursOn.joinToString(", ")}]".tr()) } - val resourcesFound = gameBasics.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/gamebasics/tile/TileImprovement.kt b/core/src/com/unciv/models/gamebasics/tile/TileImprovement.kt index 58dd772fa6..427adf377a 100644 --- a/core/src/com/unciv/models/gamebasics/tile/TileImprovement.kt +++ b/core/src/com/unciv/models/gamebasics/tile/TileImprovement.kt @@ -1,7 +1,7 @@ package com.unciv.models.gamebasics.tile import com.unciv.logic.civilization.CivilizationInfo -import com.unciv.models.gamebasics.GameBasics +import com.unciv.models.gamebasics.RuleSet import com.unciv.models.gamebasics.tr import com.unciv.models.stats.NamedStats import com.unciv.models.stats.Stats @@ -30,7 +30,7 @@ class TileImprovement : NamedStats() { return realTurnsToBuild.roundToInt() } - fun getDescription(gameBasics: GameBasics): String { + fun getDescription(ruleSet: RuleSet): String { val stringBuilder = StringBuilder() if (this.clone().toString().isNotEmpty()) stringBuilder.appendln(this.clone().toString()) if (!terrainsCanBeBuiltOn.isEmpty()) { @@ -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 gameBasics.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/gamebasics/tile/TileResource.kt b/core/src/com/unciv/models/gamebasics/tile/TileResource.kt index 85fa24bea6..540c1364b8 100644 --- a/core/src/com/unciv/models/gamebasics/tile/TileResource.kt +++ b/core/src/com/unciv/models/gamebasics/tile/TileResource.kt @@ -1,7 +1,5 @@ package com.unciv.models.gamebasics.tile -import com.unciv.models.gamebasics.Building -import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.tr import com.unciv.models.stats.NamedStats import com.unciv.models.stats.Stats diff --git a/core/src/com/unciv/models/gamebasics/unit/BaseUnit.kt b/core/src/com/unciv/models/gamebasics/unit/BaseUnit.kt index 860dfbcbeb..0be1fdd226 100644 --- a/core/src/com/unciv/models/gamebasics/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/gamebasics/unit/BaseUnit.kt @@ -6,7 +6,7 @@ import com.unciv.logic.city.CityConstructions import com.unciv.logic.city.IConstruction import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.map.MapUnit -import com.unciv.models.gamebasics.GameBasics +import com.unciv.models.gamebasics.RuleSet import com.unciv.models.gamebasics.Translations import com.unciv.models.gamebasics.tr import com.unciv.models.stats.INamed @@ -78,11 +78,11 @@ class BaseUnit : INamed, IConstruction { return sb.toString() } - fun getMapUnit(gameBasics: GameBasics): MapUnit { + fun getMapUnit(ruleSet: RuleSet): MapUnit { val unit = MapUnit() unit.name = name - unit.setTransients(gameBasics) // must be after setting name because it sets the baseUnit according to the name + unit.setTransients(ruleSet) // must be after setting name because it sets the baseUnit according to the name return unit } diff --git a/core/src/com/unciv/ui/CivilopediaScreen.kt b/core/src/com/unciv/ui/CivilopediaScreen.kt index e16db4863c..dcf9f5bc8c 100644 --- a/core/src/com/unciv/ui/CivilopediaScreen.kt +++ b/core/src/com/unciv/ui/CivilopediaScreen.kt @@ -70,7 +70,7 @@ class CivilopediaScreen : CameraStageBaseScreen() { val basicHelpFileName = if(Gdx.files.internal("jsons/BasicHelp/BasicHelp_$language.json").exists())"BasicHelp/BasicHelp_$language" else "BasicHelp/BasicHelp" - val gameBasics = game.gameBasics + val gameBasics = game.ruleSet categoryToEntries["Basics"] = gameBasics.getFromJson(Array::class.java, basicHelpFileName).toList() categoryToEntries["Buildings"] = gameBasics.Buildings.values .map { CivilopediaEntry(it.name,it.getDescription(false, null,gameBasics), diff --git a/core/src/com/unciv/ui/LanguagePickerScreen.kt b/core/src/com/unciv/ui/LanguagePickerScreen.kt index 7f82045def..454bebb2fd 100644 --- a/core/src/com/unciv/ui/LanguagePickerScreen.kt +++ b/core/src/com/unciv/ui/LanguagePickerScreen.kt @@ -23,7 +23,7 @@ class LanguageTable(val language:String,skin: Skin):Table(skin){ defaults().pad(10f) if(ImageGetter.imageExists("FlagIcons/$language")) add(ImageGetter.getImage("FlagIcons/$language")).size(40f) - val translations = UncivGame.Current.gameBasics.Translations + val translations = UncivGame.Current.ruleSet.Translations val availableTranslations = translations.filter { it.value.containsKey(language) } if(language=="English") percentComplete = 100 @@ -60,7 +60,7 @@ class LanguagePickerScreen: PickerScreen(){ "If you want to help translating the game into your language, \n"+ " instructions are in the Github readme! (Menu > Community > Github)",skin)).pad(10f).row() - languageTables.addAll(UncivGame.Current.gameBasics.Translations.getLanguages().map { LanguageTable(it,skin) } + languageTables.addAll(UncivGame.Current.ruleSet.Translations.getLanguages().map { LanguageTable(it,skin) } .sortedByDescending { it.percentComplete } ) languageTables.forEach { diff --git a/core/src/com/unciv/ui/mapeditor/MapEditorScreen.kt b/core/src/com/unciv/ui/mapeditor/MapEditorScreen.kt index d530f354cd..1cd1dae7f6 100644 --- a/core/src/com/unciv/ui/mapeditor/MapEditorScreen.kt +++ b/core/src/com/unciv/ui/mapeditor/MapEditorScreen.kt @@ -40,7 +40,7 @@ class MapEditorScreen(): CameraStageBaseScreen(){ } fun initialize() { - tileMap.setTransients(game.gameBasics) + tileMap.setTransients(game.ruleSet) val mapHolder = getMapHolder(tileMap) stage.addActor(mapHolder) diff --git a/core/src/com/unciv/ui/mapeditor/TileEditorOptionsTable.kt b/core/src/com/unciv/ui/mapeditor/TileEditorOptionsTable.kt index eba4759fa5..772e3c8d4d 100644 --- a/core/src/com/unciv/ui/mapeditor/TileEditorOptionsTable.kt +++ b/core/src/com/unciv/ui/mapeditor/TileEditorOptionsTable.kt @@ -39,7 +39,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera private var currentHex: Actor = Group() - val gameBasics = UncivGame.Current.gameBasics + val gameBasics = UncivGame.Current.ruleSet init{ height=mapEditorScreen.stage.height diff --git a/core/src/com/unciv/ui/newgamescreen/NationTable.kt b/core/src/com/unciv/ui/newgamescreen/NationTable.kt index 41ed63da32..805f06c899 100644 --- a/core/src/com/unciv/ui/newgamescreen/NationTable.kt +++ b/core/src/com/unciv/ui/newgamescreen/NationTable.kt @@ -3,7 +3,7 @@ package com.unciv.ui.newgamescreen import com.badlogic.gdx.scenes.scene2d.Touchable import com.badlogic.gdx.scenes.scene2d.ui.Label import com.badlogic.gdx.scenes.scene2d.ui.Table -import com.unciv.models.gamebasics.GameBasics +import com.unciv.models.gamebasics.RuleSet import com.unciv.models.gamebasics.Nation import com.unciv.models.gamebasics.Translations import com.unciv.models.gamebasics.tr @@ -11,7 +11,7 @@ import com.unciv.ui.utils.CameraStageBaseScreen import com.unciv.ui.utils.ImageGetter import com.unciv.ui.utils.toLabel -class NationTable(val nation: Nation, width:Float, gameBasics: GameBasics) +class NationTable(val nation: Nation, width:Float, ruleSet: RuleSet) : Table(CameraStageBaseScreen.skin) { private val innerTable = Table() @@ -25,12 +25,12 @@ class NationTable(val nation: Nation, width:Float, gameBasics: GameBasics) titleTable.add(nation.getLeaderDisplayName().toLabel(nation.getInnerColor(),24)) innerTable.add(titleTable).row() - innerTable.add(getUniqueLabel(nation,gameBasics).apply { setWrap(true) }).width(width) + innerTable.add(getUniqueLabel(nation,ruleSet).apply { setWrap(true) }).width(width) touchable = Touchable.enabled add(innerTable) } - private fun getUniqueLabel(nation: Nation, gameBasics: GameBasics): Label { + private fun getUniqueLabel(nation: Nation, ruleSet: RuleSet): Label { val textList = ArrayList() if (nation.unique != null) { @@ -38,17 +38,17 @@ class NationTable(val nation: Nation, width:Float, gameBasics: GameBasics) textList += "" } - addUniqueBuildingsText(nation, textList,gameBasics) - addUniqueUnitsText(nation, textList,gameBasics) - addUniqueImprovementsText(nation, textList,gameBasics) + addUniqueBuildingsText(nation, textList,ruleSet) + addUniqueUnitsText(nation, textList,ruleSet) + addUniqueImprovementsText(nation, textList,ruleSet) return textList.joinToString("\n").tr().trim().toLabel(nation.getInnerColor()) } - private fun addUniqueBuildingsText(nation: Nation, textList: ArrayList, gameBasics: GameBasics) { - for (building in gameBasics.Buildings.values + private fun addUniqueBuildingsText(nation: Nation, textList: ArrayList, ruleSet: RuleSet) { + for (building in ruleSet.Buildings.values .filter { it.uniqueTo == nation.name }) { - val originalBuilding = gameBasics.Buildings[building.replaces!!]!! + val originalBuilding = ruleSet.Buildings[building.replaces!!]!! textList += building.name.tr() + " - {replaces} " + originalBuilding.name.tr() val originalBuildingStatMap = originalBuilding.toHashMap() @@ -70,10 +70,10 @@ class NationTable(val nation: Nation, width:Float, gameBasics: GameBasics) } } - private fun addUniqueUnitsText(nation: Nation, textList: ArrayList, gameBasics: GameBasics) { - for (unit in gameBasics.Units.values + private fun addUniqueUnitsText(nation: Nation, textList: ArrayList, ruleSet: RuleSet) { + for (unit in ruleSet.Units.values .filter { it.uniqueTo == nation.name }) { - val originalUnit = gameBasics.Units[unit.replaces!!]!! + val originalUnit = ruleSet.Units[unit.replaces!!]!! textList += unit.name.tr() + " - {replaces} " + originalUnit.name.tr() if (unit.cost != originalUnit.cost) @@ -93,14 +93,14 @@ class NationTable(val nation: Nation, width:Float, gameBasics: GameBasics) 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(gameBasics.UnitPromotions[promotion]!!.effect) + ")" + textList += " " + promotion.tr() + " (" + Translations.translateBonusOrPenalty(ruleSet.UnitPromotions[promotion]!!.effect) + ")" textList += "" } } - private fun addUniqueImprovementsText(nation: Nation, textList: ArrayList, gameBasics: GameBasics) { - for (improvement in gameBasics.TileImprovements.values + private fun addUniqueImprovementsText(nation: Nation, textList: ArrayList, ruleSet: RuleSet) { + for (improvement in ruleSet.TileImprovements.values .filter { it.uniqueTo == nation.name }) { textList += improvement.name.tr() diff --git a/core/src/com/unciv/ui/newgamescreen/NewGameScreenOptionsTable.kt b/core/src/com/unciv/ui/newgamescreen/NewGameScreenOptionsTable.kt index d00fd36eb4..ee31438fb4 100644 --- a/core/src/com/unciv/ui/newgamescreen/NewGameScreenOptionsTable.kt +++ b/core/src/com/unciv/ui/newgamescreen/NewGameScreenOptionsTable.kt @@ -128,7 +128,7 @@ class NewGameScreenOptionsTable(val newGameParameters: GameParameters, val onMul val cityStatesSelectBox = SelectBox(CameraStageBaseScreen.skin) val cityStatesArray = Array() - (0..UncivGame.Current.gameBasics.Nations.filter { it.value.isCityState() }.size).forEach { cityStatesArray.add(it) } + (0..UncivGame.Current.ruleSet.Nations.filter { it.value.isCityState() }.size).forEach { cityStatesArray.add(it) } cityStatesSelectBox.items = cityStatesArray cityStatesSelectBox.selected = newGameParameters.numberOfCityStates add(cityStatesSelectBox).pad(10f).row() @@ -141,7 +141,7 @@ class NewGameScreenOptionsTable(val newGameParameters: GameParameters, val onMul private fun addDifficultySelectBox() { add("{Difficulty}:".tr()) - val difficultySelectBox = TranslatedSelectBox(UncivGame.Current.gameBasics.Difficulties.keys, newGameParameters.difficulty, CameraStageBaseScreen.skin) + val difficultySelectBox = TranslatedSelectBox(UncivGame.Current.ruleSet.Difficulties.keys, newGameParameters.difficulty, CameraStageBaseScreen.skin) difficultySelectBox.addListener(object : ChangeListener() { override fun changed(event: ChangeEvent?, actor: Actor?) { newGameParameters.difficulty = difficultySelectBox.selected.value diff --git a/core/src/com/unciv/ui/newgamescreen/PlayerPickerTable.kt b/core/src/com/unciv/ui/newgamescreen/PlayerPickerTable.kt index 69e5015b7a..1f94859366 100644 --- a/core/src/com/unciv/ui/newgamescreen/PlayerPickerTable.kt +++ b/core/src/com/unciv/ui/newgamescreen/PlayerPickerTable.kt @@ -10,7 +10,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextField import com.badlogic.gdx.utils.Align import com.unciv.UncivGame import com.unciv.logic.civilization.PlayerType -import com.unciv.models.gamebasics.GameBasics +import com.unciv.models.gamebasics.RuleSet import com.unciv.models.gamebasics.tr import com.unciv.models.metadata.GameParameters import com.unciv.models.metadata.Player @@ -30,7 +30,7 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters: fun update() { playerListTable.clear() - val gameBasics = UncivGame.Current.gameBasics // when we add mods, this will need to change + val gameBasics = UncivGame.Current.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() }) { @@ -39,12 +39,12 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters: } } - fun getPlayerTable(player: Player, gameBasics: GameBasics): Table { + fun getPlayerTable(player: Player, ruleSet: RuleSet): Table { val playerTable = Table() playerTable.pad(20f) playerTable.background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.8f)) - val nationTable = getNationTable(player,gameBasics) + val nationTable = getNationTable(player,ruleSet) playerTable.add(nationTable) val playerTypeTextbutton = TextButton(player.playerType.name, CameraStageBaseScreen.skin) @@ -102,22 +102,22 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters: return playerTable } - private fun getNationTable(player: Player, gameBasics: GameBasics): Table { + private fun getNationTable(player: Player, ruleSet: RuleSet): Table { val nationTable = Table() val nationImage = if (player.chosenCiv == "Random") "?".toLabel(Color.BLACK,30) .apply { this.setAlignment(Align.center) } .surroundWithCircle(50f) - else ImageGetter.getNationIndicator(gameBasics.Nations[player.chosenCiv]!!, 50f) + else ImageGetter.getNationIndicator(ruleSet.Nations[player.chosenCiv]!!, 50f) nationTable.add(nationImage) nationTable.add(player.chosenCiv.toLabel()).pad(20f) nationTable.touchable = Touchable.enabled nationTable.onClick { - popupNationPicker(player,gameBasics) + popupNationPicker(player,ruleSet) } return nationTable } - private fun popupNationPicker(player: Player, gameBasics: GameBasics) { + private fun popupNationPicker(player: Player, ruleSet: RuleSet) { val nationsPopup = PopupTable(newGameScreen) val nationListTable = Table() @@ -137,11 +137,11 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters: nationListTable.add(randomPlayerTable).pad(10f).width(halfWidth).row() - for (nation in gameBasics.Nations.values.filter { !it.isCityState() && it.name != "Barbarians" }) { + for (nation in ruleSet.Nations.values.filter { !it.isCityState() && it.name != "Barbarians" }) { if (player.chosenCiv != nation.name && newGameParameters.players.any { it.chosenCiv == nation.name }) continue - nationListTable.add(NationTable(nation, halfWidth,gameBasics).onClick { + nationListTable.add(NationTable(nation, halfWidth,ruleSet).onClick { player.chosenCiv = nation.name nationsPopup.close() update() diff --git a/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt index ab941746f1..989e24488a 100644 --- a/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt @@ -15,7 +15,7 @@ class GreatPersonPickerScreen : PickerScreen() { init { closeButton.isVisible=false rightSideButton.setText("Choose a free great person".tr()) - for (unit in game.gameBasics.Units.values + for (unit in game.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 295a99ac39..fecf24e64b 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 game.gameBasics.TileImprovements.values) { + for (improvement in game.ruleSet.TileImprovements.values) { if (!tileInfo.canBuildImprovement(improvement, currentPlayerCiv)) continue if(improvement.name == tileInfo.improvement) continue if(improvement.name==tileInfo.improvementInProgress) continue @@ -62,7 +62,7 @@ class ImprovementPickerScreen(tileInfo: TileInfo, onAccept: ()->Unit) : PickerSc group.onClick { selectedImprovement = improvement pick(improvement.name.tr()) - descriptionLabel.setText(improvement.getDescription(game.gameBasics)) + descriptionLabel.setText(improvement.getDescription(game.ruleSet)) } val pickNow = "Pick now!".toLabel() diff --git a/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt index d11fc0fb95..c70d396cdd 100644 --- a/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/PromotionPickerScreen.kt @@ -8,7 +8,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup import com.badlogic.gdx.utils.Align import com.unciv.UncivGame import com.unciv.logic.map.MapUnit -import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.Translations import com.unciv.models.gamebasics.tr import com.unciv.models.gamebasics.unit.Promotion diff --git a/core/src/com/unciv/ui/utils/Fonts.kt b/core/src/com/unciv/ui/utils/Fonts.kt index 7ac526ed1b..b97245b913 100644 --- a/core/src/com/unciv/ui/utils/Fonts.kt +++ b/core/src/com/unciv/ui/utils/Fonts.kt @@ -36,7 +36,7 @@ class Fonts { if (Gdx.files.internal("jsons/Tutorials/Tutorials_$language.json").exists()) charSet.addAll(Gdx.files.internal("jsons/Tutorials/Tutorials_$language.json").readString().asIterable()) - for (entry in UncivGame.Current.gameBasics.Translations.entries) { + for (entry in UncivGame.Current.ruleSet.Translations.entries) { for (lang in entry.value) { if (lang.key == language) charSet.addAll(lang.value.asIterable()) } diff --git a/core/src/com/unciv/ui/utils/ImageGetter.kt b/core/src/com/unciv/ui/utils/ImageGetter.kt index 4d6403b37f..ffebee8816 100644 --- a/core/src/com/unciv/ui/utils/ImageGetter.kt +++ b/core/src/com/unciv/ui/utils/ImageGetter.kt @@ -33,7 +33,7 @@ object ImageGetter { setTextureRegionDrawables() } - fun getGameBasics() = UncivGame.Current.gameBasics + fun getGameBasics() = UncivGame.Current.ruleSet fun setTextureRegionDrawables(){ textureRegionDrawables.clear() diff --git a/core/src/com/unciv/ui/utils/Tutorials.kt b/core/src/com/unciv/ui/utils/Tutorials.kt index f6e0fafc36..70fcb6b9d3 100644 --- a/core/src/com/unciv/ui/utils/Tutorials.kt +++ b/core/src/com/unciv/ui/utils/Tutorials.kt @@ -41,7 +41,7 @@ class Tutorials{ // ...Yes. Disgusting. I wish I didn't have to do this. val x = LinkedHashMap>>() val tutorials: LinkedHashMap>> = - UncivGame.Current.gameBasics.getFromJson(x.javaClass, "Tutorials/Tutorials_$language") + UncivGame.Current.ruleSet.getFromJson(x.javaClass, "Tutorials/Tutorials_$language") val tutorialMap = HashMap>() for (tutorial in tutorials){ val list = ArrayList() diff --git a/core/src/com/unciv/ui/worldscreen/AlertPopup.kt b/core/src/com/unciv/ui/worldscreen/AlertPopup.kt index 4a71ebcd32..91a20f0c81 100644 --- a/core/src/com/unciv/ui/worldscreen/AlertPopup.kt +++ b/core/src/com/unciv/ui/worldscreen/AlertPopup.kt @@ -5,7 +5,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton import com.unciv.logic.civilization.AlertType import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.PopupAlert -import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.tr import com.unciv.ui.utils.* import com.unciv.ui.worldscreen.optionstable.PopupTable diff --git a/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenOptionsTable.kt b/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenOptionsTable.kt index b0a5b00085..30a92535c2 100644 --- a/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenOptionsTable.kt +++ b/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenOptionsTable.kt @@ -15,9 +15,9 @@ import kotlin.concurrent.thread class Language(val language:String){ val percentComplete:Int init{ - val availableTranslations = UncivGame.Current.gameBasics.Translations.count { it.value.containsKey(language) } + val availableTranslations = UncivGame.Current.ruleSet.Translations.count { it.value.containsKey(language) } if(language=="English") percentComplete = 100 - else percentComplete = (availableTranslations*100 / UncivGame.Current.gameBasics.Translations.size) + else percentComplete = (availableTranslations*100 / UncivGame.Current.ruleSet.Translations.size) } override fun toString(): String { val spaceSplitLang = language.replace("_"," ") @@ -263,7 +263,7 @@ class WorldScreenOptionsTable(val worldScreen:WorldScreen) : PopupTable(worldScr innerTable.add("Language".toLabel()) val languageSelectBox = SelectBox(skin) val languageArray = Array() - UncivGame.Current.gameBasics.Translations.getLanguages().map { Language(it) } + UncivGame.Current.ruleSet.Translations.getLanguages().map { Language(it) } .sortedByDescending { it.percentComplete } .forEach { languageArray.add(it) } languageSelectBox.items = languageArray @@ -286,7 +286,7 @@ class WorldScreenOptionsTable(val worldScreen:WorldScreen) : PopupTable(worldScr val missingTextSelectBox = SelectBox(skin) val missingTextArray = Array() val currentLanguage = UncivGame.Current.settings.language - UncivGame.Current.gameBasics.Translations.filter { !it.value.containsKey(currentLanguage) } + UncivGame.Current.ruleSet.Translations.filter { !it.value.containsKey(currentLanguage) } .forEach { missingTextArray.add(it.key) } missingTextSelectBox.items = missingTextArray missingTextSelectBox.selected = "Untranslated texts" diff --git a/tests/src/de/tomgrill/gdxtesting/examples/BasicTests.java b/tests/src/de/tomgrill/gdxtesting/examples/BasicTests.java index ee13654a15..b312b6b3b6 100644 --- a/tests/src/de/tomgrill/gdxtesting/examples/BasicTests.java +++ b/tests/src/de/tomgrill/gdxtesting/examples/BasicTests.java @@ -3,7 +3,7 @@ package de.tomgrill.gdxtesting.examples; import com.badlogic.gdx.Gdx; -import com.unciv.models.gamebasics.GameBasics; +import com.unciv.models.gamebasics.RuleSet; import org.junit.Test; import org.junit.runner.RunWith; @@ -26,7 +26,7 @@ public class BasicTests { @Test public void gameBasicsLoad() { assertTrue("This test will only pass when the jsons can be loaded", - GameBasics.INSTANCE.getBuildings().size() > 0); + RuleSet.INSTANCE.getBuildings().size() > 0); } diff --git a/tests/src/de/tomgrill/gdxtesting/examples/TranslationTests.java b/tests/src/de/tomgrill/gdxtesting/examples/TranslationTests.java index 53999af975..6893a362d3 100644 --- a/tests/src/de/tomgrill/gdxtesting/examples/TranslationTests.java +++ b/tests/src/de/tomgrill/gdxtesting/examples/TranslationTests.java @@ -2,7 +2,7 @@ package de.tomgrill.gdxtesting.examples; -import com.unciv.models.gamebasics.GameBasics; +import com.unciv.models.gamebasics.RuleSet; import org.junit.Test; import org.junit.runner.RunWith; @@ -21,26 +21,26 @@ public class TranslationTests { @Test public void translationsLoad() { assertTrue("This test will only pass there are translations", - GameBasics.INSTANCE.getTranslations().size() > 0); + RuleSet.INSTANCE.getTranslations().size() > 0); } @Test public void allUnitsHaveTranslation() { - Boolean allUnitsHaveTranslation = allStringAreTranslated(GameBasics.INSTANCE.getUnits().keySet()); + Boolean allUnitsHaveTranslation = allStringAreTranslated(RuleSet.INSTANCE.getUnits().keySet()); assertTrue("This test will only pass when there is a translation for all units", allUnitsHaveTranslation); } @Test public void allBuildingsHaveTranslation() { - Boolean allBuildingsHaveTranslation = allStringAreTranslated(GameBasics.INSTANCE.getBuildings().keySet()); + Boolean allBuildingsHaveTranslation = allStringAreTranslated(RuleSet.INSTANCE.getBuildings().keySet()); assertTrue("This test will only pass when there is a translation for all buildings", allBuildingsHaveTranslation); } @Test public void allTerrainsHaveTranslation() { - Set strings = GameBasics.INSTANCE.getTerrains().keySet(); + Set strings = RuleSet.INSTANCE.getTerrains().keySet(); Boolean allStringsHaveTranslation = allStringAreTranslated(strings); assertTrue("This test will only pass when there is a translation for all buildings", allStringsHaveTranslation); @@ -48,7 +48,7 @@ public class TranslationTests { @Test public void allImprovementsHaveTranslation() { - Set strings = GameBasics.INSTANCE.getTileImprovements().keySet(); + Set strings = RuleSet.INSTANCE.getTileImprovements().keySet(); Boolean allStringsHaveTranslation = allStringAreTranslated(strings); assertTrue("This test will only pass when there is a translation for all improvements", allStringsHaveTranslation); @@ -56,7 +56,7 @@ public class TranslationTests { @Test public void allTechnologiesHaveTranslation() { - Set strings = GameBasics.INSTANCE.getTechnologies().keySet(); + Set strings = RuleSet.INSTANCE.getTechnologies().keySet(); Boolean allStringsHaveTranslation = allStringAreTranslated(strings); assertTrue("This test will only pass when there is a translation for all technologies", allStringsHaveTranslation); @@ -64,7 +64,7 @@ public class TranslationTests { @Test public void allPromotionsHaveTranslation() { - Set strings = GameBasics.INSTANCE.getUnitPromotions().keySet(); + Set strings = RuleSet.INSTANCE.getUnitPromotions().keySet(); Boolean allStringsHaveTranslation = allStringAreTranslated(strings); assertTrue("This test will only pass when there is a translation for all promotions", allStringsHaveTranslation); @@ -73,7 +73,7 @@ public class TranslationTests { private Boolean allStringAreTranslated(Set strings) { boolean allBuildingsHaveTranslation = true; for (String unitName : strings) { - if (!GameBasics.INSTANCE.getTranslations().containsKey(unitName)) { + if (!RuleSet.INSTANCE.getTranslations().containsKey(unitName)) { allBuildingsHaveTranslation = false; System.out.println(unitName); }