Renamed gameInfo.gameBasics to ruleSet

This commit is contained in:
Yair Morgenstern 2019-12-05 20:22:34 +02:00
parent effaa558f6
commit 51a0d7727a
36 changed files with 75 additions and 73 deletions

View File

@ -51,11 +51,11 @@ class UncivGame(val version: String) : Game() {
settings.save()
}
if (GameSaver().getSave("Autosave").exists()) {
// try {
try {
loadGame("Autosave")
// } catch (ex: Exception) { // silent fail if we can't read the autosave
// startNewGame()
// }
} catch (ex: Exception) { // silent fail if we can't read the autosave
startNewGame()
}
}
else setScreen(LanguagePickerScreen())

View File

@ -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.ruleSet
@Transient var ruleSet = UncivGame.Current.ruleSet
var civilizations = mutableListOf<CivilizationInfo>()
var difficulty="Chieftain" // difficulty is game-wide, think what would happen if 2 human players could play on different difficulties?
@ -165,13 +165,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 = gameBasics.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 = gameBasics.Units.values
val unitList = ruleSet.Units.values
.filter { !it.unitType.isCivilian()}
.filter { it.isBuildable(barbarianCiv) }
@ -203,7 +203,7 @@ class GameInfo {
}
}
tileMap.setTransients(gameBasics)
tileMap.setTransients(ruleSet)
if(currentPlayer=="") currentPlayer=civilizations.first { it.isPlayerCivilization() }.civName
currentPlayerCiv=getCivilization(currentPlayer)
@ -217,7 +217,7 @@ class GameInfo {
getCurrentPlayerCivilization().playerType=PlayerType.Human
if(getCurrentPlayerCivilization().difficulty!="Chieftain")
difficulty= getCurrentPlayerCivilization().difficulty
difficultyObject = gameBasics.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,

View File

@ -99,7 +99,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.gameBasics.Units.values.filter {
val availableMilitaryUnits = gameInfo.ruleSet.Units.values.filter {
it.isBuildable(civ)
&& it.unitType.isLandUnit()
&& !it.unitType.isCivilian()

View File

@ -257,7 +257,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
private fun addFoodBuildingChoice() {
val foodBuilding = buildableNotWonders.filter { it.isStatRelated(Stat.Food)
|| it.getBaseBuilding(civInfo.gameInfo.gameBasics).name == "Aqueduct" || it.getBaseBuilding(civInfo.gameInfo.gameBasics).name == "Medical Lab"} // only stat related in unique
|| it.getBaseBuilding(civInfo.gameInfo.ruleSet).name == "Aqueduct" || it.getBaseBuilding(civInfo.gameInfo.ruleSet).name == "Medical Lab"} // only stat related in unique
.minBy { it.cost }
if (foodBuilding != null) {
var modifier = 1f

View File

@ -170,7 +170,7 @@ class NextTurnAutomation{
private fun chooseTechToResearch(civInfo: CivilizationInfo) {
if (civInfo.tech.techsToResearch.isEmpty()) {
val researchableTechs = civInfo.gameInfo.gameBasics.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.gameBasics.PolicyBranches.values
val adoptablePolicies = civInfo.gameInfo.ruleSet.PolicyBranches.values
.flatMap { it.policies.union(listOf(it)) }
.filter { civInfo.policies.isAdoptable(it) }

View File

@ -266,7 +266,7 @@ class UnitAutomation{
private fun tryUpgradeUnit(unit: MapUnit, unitActions: List<UnitAction>): Boolean {
if (unit.baseUnit().upgradesTo != null) {
val upgradedUnit = unit.civInfo.gameInfo.gameBasics.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) {

View File

@ -106,7 +106,7 @@ class WorkerAutomation(val unit: MapUnit) {
}
if(unit.currentMovement>0 && unit.currentTile==tileToConstructRoadOn
&& unit.currentTile.improvementInProgress!=targetRoad.name) {
val improvement = targetRoad.improvement(unit.civInfo.gameInfo.gameBasics)!!
val improvement = targetRoad.improvement(unit.civInfo.gameInfo.ruleSet)!!
tileToConstructRoadOn.startWorkingOnImprovement(improvement, unit.civInfo)
}
return true
@ -199,7 +199,7 @@ class WorkerAutomation(val unit: MapUnit) {
else -> throw Exception("No improvement found for "+tile.baseTerrain)
}
if (improvementString == null) return null
return unit.civInfo.gameInfo.gameBasics.TileImprovements[improvementString]!!
return unit.civInfo.gameInfo.ruleSet.TileImprovements[improvementString]!!
}
}

View File

@ -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.gameBasics.Technologies.count()
getCivInfo().gameInfo.ruleSet.Technologies.count()
strength += (techsPercentKnown * 5.5).pow(2.8).toFloat()
// The way all of this adds up...

View File

@ -119,7 +119,7 @@ class CityInfo {
fun getTiles(): List<TileInfo> = tiles.map { tileMap[it] }
fun getWorkableTiles() = getTiles().filter { it in tilesInRange }
fun getGameBasics() = civInfo.gameInfo.gameBasics
fun getGameBasics() = civInfo.gameInfo.ruleSet
fun getCityResources(): ResourceSupplyList {
val cityResources = ResourceSupplyList()

View File

@ -163,7 +163,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.gameBasics.TileResources[it]!! })
.map { civInfo.gameInfo.ruleSet.TileResources[it]!! })
newDetailedCivResources.add(resource,-1,"Units")
civInfo.detailedCivResources = newDetailedCivResources
}

View File

@ -107,13 +107,13 @@ class CivilizationInfo {
//region pure functions
fun getDifficulty():Difficulty {
if (isPlayerCivilization()) return gameInfo.getDifficulty()
return gameInfo.gameBasics.Difficulties["Chieftain"]!!
return gameInfo.ruleSet.Difficulties["Chieftain"]!!
}
fun getTranslatedNation(): Nation {
val language = UncivGame.Current.settings.language.replace(" ","_")
if(!Gdx.files.internal("jsons/Nations/Nations_$language.json").exists()) return nation
val translatedNation = gameInfo.gameBasics.getFromJson(Array<Nation>::class.java, "Nations/Nations_$language")
val translatedNation = gameInfo.ruleSet.getFromJson(Array<Nation>::class.java, "Nations/Nations_$language")
.firstOrNull { it.name==civName}
if(translatedNation==null) // this language's trnslation doesn't contain this nation yet,
return nation // default to english
@ -170,7 +170,7 @@ class CivilizationInfo {
*/
fun getCivResourcesByName():HashMap<String,Int>{
val hashMap = HashMap<String,Int>()
for(resource in gameInfo.gameBasics.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
@ -228,19 +228,19 @@ class CivilizationInfo {
fun getEquivalentBuilding(buildingName:String): Building {
val baseBuilding = gameInfo.gameBasics.Buildings[buildingName]!!.getBaseBuilding(gameInfo.gameBasics)
val baseBuilding = gameInfo.ruleSet.Buildings[buildingName]!!.getBaseBuilding(gameInfo.ruleSet)
for(building in gameInfo.gameBasics.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.gameBasics.Units.values)
for (unit in gameInfo.ruleSet.Units.values)
if (unit.replaces == baseUnitName && unit.uniqueTo == civName)
return unit
return gameInfo.gameBasics.Units[baseUnitName]!!
return gameInfo.ruleSet.Units[baseUnitName]!!
}
fun meetCivilization(otherCiv: CivilizationInfo) {
@ -295,7 +295,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.gameBasics.Nations[civName]!!
nation = gameInfo.ruleSet.Nations[civName]!!
}
fun setTransients() {

View File

@ -40,7 +40,7 @@ data class LocationAction(var locations: ArrayList<Vector2> = ArrayList()) : Not
/** show tech screen */
class TechAction(val techName: String = "") : NotificationAction {
override fun execute(worldScreen: WorldScreen) {
val tech = worldScreen.gameInfo.gameBasics.Technologies[techName]
val tech = worldScreen.gameInfo.ruleSet.Technologies[techName]
worldScreen.game.setScreen(TechPickerScreen(worldScreen.viewingCiv, tech))
}
}

View File

@ -53,7 +53,7 @@ class PolicyManager {
if (freePolicies == 0 && storedCulture < getCultureNeededForNextPolicy())
return false
val hasAdoptablePolicies = civInfo.gameInfo.gameBasics.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.gameBasics.Units.keys.filter { it.startsWith("Great") }.random()
civInfo.gameInfo.ruleSet.Units.keys.filter { it.startsWith("Great") }.random()
}
civInfo.addGreatPerson(greatPerson)
}

View File

@ -43,7 +43,7 @@ class TechManager {
return toReturn
}
fun getGameBasics() = civInfo.gameInfo.gameBasics
fun getGameBasics() = civInfo.gameInfo.ruleSet
fun costOfTech(techName: String): Int {
var techCost = getGameBasics().Technologies[techName]!!.cost.toFloat()

View File

@ -163,10 +163,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.gameBasics.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.gameBasics.TileResources[offer.name]!!,offer.amount,"Trade")
counter.add(civInfo.gameInfo.ruleSet.TileResources[offer.name]!!,offer.amount,"Trade")
}
return counter
}

View File

@ -113,7 +113,7 @@ class MapUnit {
val uniques = ArrayList<String>()
val baseUnit = baseUnit()
uniques.addAll(baseUnit.uniques)
uniques.addAll(promotions.promotions.map { currentTile.tileMap.gameInfo.gameBasics.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
@ -454,7 +454,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.gameBasics.Technologies.values
val researchableAncientEraTechs = tile.tileMap.gameInfo.ruleSet.Technologies.values
.filter {
!civInfo.tech.isResearched(it.name)
&& civInfo.tech.canBeResearched(it.name)

View File

@ -159,7 +159,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.gameBasics.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

View File

@ -64,7 +64,7 @@ class TileMap {
}
fun placeUnitNearTile(position: Vector2, unitName: String, civInfo: CivilizationInfo): MapUnit? {
val unit = gameInfo.gameBasics.Units[unitName]!!.getMapUnit(gameInfo.gameBasics)
val unit = gameInfo.ruleSet.Units[unitName]!!.getMapUnit(gameInfo.ruleSet)
fun isTileMovePotential(tileInfo:TileInfo): Boolean {
if(unit.type.isWaterUnit()) return tileInfo.isWater || tileInfo.isCityCenter()

View File

@ -36,7 +36,7 @@ class UnitPromotions{
}
fun getAvailablePromotions(): List<Promotion> {
return unit.civInfo.gameInfo.gameBasics.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 } }
}

View File

@ -89,7 +89,7 @@ class BuildLongRoadAction(
val tile = unit.currentTile
if (unit.currentMovement > 0 && isRoadableTile(tile)) {
val roadToBuild = unit.civInfo.tech.getBestRoadAvailable()
roadToBuild.improvement(unit.civInfo.gameInfo.gameBasics)?.let { improvement ->
roadToBuild.improvement(unit.civInfo.gameInfo.ruleSet)?.let { improvement ->
if (tile.roadStatus < roadToBuild && tile.improvementInProgress != improvement.name) {
tile.startWorkingOnImprovement(improvement, unit.civInfo)
return true

View File

@ -117,7 +117,7 @@ class TradeEvaluation{
}
TradeType.Technology ->
return (sqrt(civInfo.gameInfo.gameBasics.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.gameBasics.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.gameBasics.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)

View File

@ -123,7 +123,7 @@ class Building : NamedStats(), IConstruction{
val stats = this.clone()
if(civInfo != null) {
val adoptedPolicies = civInfo.policies.adoptedPolicies
val baseBuildingName = getBaseBuilding(civInfo.gameInfo.gameBasics).name
val baseBuildingName = getBaseBuilding(civInfo.gameInfo.ruleSet).name
if (adoptedPolicies.contains("Organized Religion") && cultureBuildings.contains(baseBuildingName ))
stats.happiness += 1
@ -161,7 +161,7 @@ class Building : NamedStats(), IConstruction{
if(civInfo==null) return stats // initial stats
val adoptedPolicies = civInfo.policies.adoptedPolicies
val baseBuildingName = getBaseBuilding(civInfo.gameInfo.gameBasics).name
val baseBuildingName = getBaseBuilding(civInfo.gameInfo.ruleSet).name
if (adoptedPolicies.contains("Theocracy") && baseBuildingName == "Temple")
stats.gold = 10f
@ -250,7 +250,7 @@ class Building : NamedStats(), IConstruction{
val civInfo = construction.cityInfo.civInfo
if (uniqueTo!=null && uniqueTo!=civInfo.civName) return "Unique to $uniqueTo"
if (civInfo.gameInfo.gameBasics.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
@ -323,7 +323,7 @@ class Building : NamedStats(), IConstruction{
if (providesFreeBuilding != null && !construction.containsBuildingOrEquivalent(providesFreeBuilding!!)) {
var buildingToAdd = providesFreeBuilding!!
for(building in civInfo.gameInfo.gameBasics.Buildings.values)
for(building in civInfo.gameInfo.ruleSet.Buildings.values)
if(building.replaces == buildingToAdd && building.uniqueTo==civInfo.civName)
buildingToAdd = building.name
@ -345,7 +345,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.gameBasics.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){

View File

@ -67,7 +67,7 @@ class Technology {
}
fun getEnabledBuildings(civInfo: CivilizationInfo): List<Building> {
var enabledBuildings = civInfo.gameInfo.gameBasics.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<BaseUnit> {
var enabledUnits = civInfo.gameInfo.gameBasics.Units.values.filter {
var enabledUnits = civInfo.gameInfo.ruleSet.Units.values.filter {
it.requiredTech == name &&
(it.uniqueTo == null || it.uniqueTo == civInfo.civName)
}

View File

@ -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.gameBasics.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"))

View File

@ -133,7 +133,7 @@ class VictoryScreen : PickerScreen() {
fun culturalVictoryColumn():Table{
val t=Table()
t.defaults().pad(5f)
for(branch in playerCivInfo.gameInfo.gameBasics.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()
}

View File

@ -67,7 +67,7 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
wonderDetailsTable.clear()
else{
val detailsString = building.getDescription(true,
cityScreen.city.civInfo, cityScreen.city.civInfo.gameInfo.gameBasics)
cityScreen.city.civInfo, cityScreen.city.civInfo.gameInfo.ruleSet)
wonderDetailsTable.add(detailsString.toLabel().apply { setWrap(true)})
.width(cityScreen.stage.width/4 - 2*pad ).row() // when you set wrap, then you need to manually set the size of the label
if(!building.isWonder && !building.isNationalWonder) {

View File

@ -198,7 +198,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
description = construction.getDescription(true)
else if (construction is Building)
description = construction.getDescription(true, city.civInfo,
city.civInfo.gameInfo.gameBasics)
city.civInfo.gameInfo.ruleSet)
else if(construction is SpecialConstruction)
description = construction.description.tr()
else description="" // Should never happen

View File

@ -52,7 +52,7 @@ class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: CivilizationInfo
topTable.row().pad(30f)
for (branch in viewingCiv.gameInfo.gameBasics.PolicyBranches.values) {
for (branch in viewingCiv.gameInfo.ruleSet.PolicyBranches.values) {
if (branch.name == "Commerce") topTable.addSeparator()
val branchGroup = Table()
branchGroup.row().pad(20f)

View File

@ -42,7 +42,7 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
availablePromotionsGroup.space(10f)
val unitType = unit.type
val promotionsForUnitType = unit.civInfo.gameInfo.gameBasics.UnitPromotions.values.filter { it.unitTypes.contains(unitType.toString()) }
val promotionsForUnitType = unit.civInfo.gameInfo.ruleSet.UnitPromotions.values.filter { it.unitTypes.contains(unitType.toString()) }
val unitAvailablePromotions = unit.promotions.getAvailablePromotions()
for (promotion in promotionsForUnitType) {

View File

@ -42,7 +42,7 @@ class TechButton(techName:String, val techManager: TechManager, isWorldScreen: B
techEnabledIcons.defaults().pad(5f)
val civName = techManager.civInfo.civName
val gameBasics = techManager.civInfo.gameInfo.gameBasics
val gameBasics = techManager.civInfo.gameInfo.ruleSet
val tech = gameBasics.Technologies[techName]!!

View File

@ -24,7 +24,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
private var lines=ArrayList<Image>()
// All these are to counter performance problems when updating buttons for all techs.
private var researchableTechs = civInfo.gameInfo.gameBasics.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.gameBasics.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.gameBasics.Technologies.values.map { it.column!!.columnNumber}.max()!! +1
val columns = civInfo.gameInfo.ruleSet.Technologies.values.map { it.column!!.columnNumber}.max()!! +1
val techMatrix = Array<Array<Technology?>>(columns) { arrayOfNulls(10) } // Divided into columns, then rows
for (technology in civInfo.gameInfo.gameBasics.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.gameBasics.Technologies.values) {
for (tech in civInfo.gameInfo.ruleSet.Technologies.values) {
val techButton = techNameToButton[tech.name]!!
for (prerequisite in tech.prerequisites) {
val prerequisiteButton = techNameToButton[prerequisite]!!
@ -176,7 +176,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
private fun selectTechnology(tech: Technology?, center: Boolean = false, switchfromWorldScreen: Boolean = true) {
selectedTech = tech
descriptionLabel.setText(tech?.getDescription(civInfo.gameInfo.gameBasics))
descriptionLabel.setText(tech?.getDescription(civInfo.gameInfo.ruleSet))
if (!switchfromWorldScreen)
return

View File

@ -149,19 +149,19 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
add(getCloseButton("Very well."))
}
AlertType.WonderBuilt -> {
val wonder = worldScreen.gameInfo.gameBasics.Buildings[popupAlert.value]!!
val wonder = worldScreen.gameInfo.ruleSet.Buildings[popupAlert.value]!!
addGoodSizedLabel(wonder.name)
addSeparator()
val centerTable = Table()
centerTable.add(wonder.quote.toLabel().apply { setWrap(true) }).width(worldScreen.stage.width/3)
centerTable.add(ImageGetter.getConstructionImage(wonder.name).surroundWithCircle(100f)).pad(20f)
centerTable.add(wonder.getShortDescription(worldScreen.gameInfo.gameBasics)
centerTable.add(wonder.getShortDescription(worldScreen.gameInfo.ruleSet)
.toLabel().apply { setWrap(true) }).width(worldScreen.stage.width/3)
add(centerTable).row()
add(getCloseButton("Close"))
}
AlertType.TechResearched -> {
val gameBasics = worldScreen.gameInfo.gameBasics
val gameBasics = worldScreen.gameInfo.ruleSet
val tech = gameBasics.Technologies[popupAlert.value]!!
addGoodSizedLabel(tech.name)
addSeparator()

View File

@ -254,7 +254,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
techButtonHolder.isVisible = viewingCiv.cities.isNotEmpty()
techButtonHolder.clearChildren()
val researchableTechs = viewingCiv.gameInfo.gameBasics.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)

View File

@ -57,7 +57,7 @@ class WorldScreenTopBar(val screen: WorldScreen) : Table() {
private fun getResourceTable(): Table {
val resourceTable = Table()
resourceTable.defaults().pad(5f)
val revealedStrategicResources = screen.gameInfo.gameBasics.TileResources.values
val revealedStrategicResources = screen.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 screen: WorldScreen) : Table() {
internal fun update(civInfo: CivilizationInfo) {
val revealedStrategicResources = civInfo.gameInfo.gameBasics.TileResources.values
val revealedStrategicResources = civInfo.gameInfo.ruleSet.TileResources.values
.filter { it.resourceType == ResourceType.Strategic }
val civResources = civInfo.getCivResources()
for (resource in revealedStrategicResources) {

View File

@ -7,12 +7,13 @@ import com.badlogic.gdx.scenes.scene2d.ui.*
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
import com.badlogic.gdx.utils.Array
import com.unciv.UncivGame
import com.unciv.models.gamebasics.RuleSet
import com.unciv.models.gamebasics.tr
import com.unciv.ui.utils.*
import com.unciv.ui.worldscreen.WorldScreen
import kotlin.concurrent.thread
class Language(val language:String){
class Language(val language:String, ruleSet: RuleSet){
val percentComplete:Int
init{
val availableTranslations = UncivGame.Current.ruleSet.Translations.count { it.value.containsKey(language) }
@ -263,7 +264,8 @@ class WorldScreenOptionsTable(val worldScreen:WorldScreen) : PopupTable(worldScr
innerTable.add("Language".toLabel())
val languageSelectBox = SelectBox<Language>(skin)
val languageArray = Array<Language>()
UncivGame.Current.ruleSet.Translations.getLanguages().map { Language(it) }
val ruleSet = worldScreen.gameInfo.ruleSet
ruleSet.Translations.getLanguages().map { Language(it, ruleSet) }
.sortedByDescending { it.percentComplete }
.forEach { languageArray.add(it) }
languageSelectBox.items = languageArray

View File

@ -142,7 +142,7 @@ class UnitActions {
actionList += UnitAction("Construct improvement",
unit.currentMovement > 0
&& !tile.isCityCenter()
&& unit.civInfo.gameInfo.gameBasics.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 }) }
@ -161,7 +161,7 @@ class UnitActions {
&& tile.roadStatus==RoadStatus.None
&& tile.improvementInProgress != "Road"
&& tile.isLand
&& unit.civInfo.tech.isResearched(RoadStatus.Road.improvement(unit.civInfo.gameInfo.gameBasics)!!.techRequired!!))
&& unit.civInfo.tech.isResearched(RoadStatus.Road.improvement(unit.civInfo.gameInfo.ruleSet)!!.techRequired!!))
actionList+=UnitAction("Construct road", unit.currentMovement >0){
tile.improvementInProgress="Road"
tile.turnsToImprovement=4
@ -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.gameBasics.TileImprovements[improvement]!!.techRequired!!)
&& unit.civInfo.tech.isResearched(unit.civInfo.gameInfo.ruleSet.TileImprovements[improvement]!!.techRequired!!)
)
actionList += UnitAction("Create [$improvement]", unit.currentMovement >0) {
tile.improvement = improvement