Code cleanup - ruleset maps are now lowercased
This commit is contained in:
parent
4b15200487
commit
87830bf8b2
48 changed files with 198 additions and 198 deletions
|
@ -168,13 +168,13 @@ class GameInfo {
|
||||||
fun placeBarbarianUnit(tileToPlace: TileInfo) {
|
fun placeBarbarianUnit(tileToPlace: TileInfo) {
|
||||||
// if we don't make this into a separate list then the retain() will happen on the Tech keys,
|
// 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
|
// 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() }) {
|
for (civ in civilizations.filter { !it.isBarbarian() && !it.isDefeated() }) {
|
||||||
allResearchedTechs.retainAll(civ.tech.techsResearched)
|
allResearchedTechs.retainAll(civ.tech.techsResearched)
|
||||||
}
|
}
|
||||||
val barbarianCiv = getBarbarianCivilization()
|
val barbarianCiv = getBarbarianCivilization()
|
||||||
barbarianCiv.tech.techsResearched = allResearchedTechs.toHashSet()
|
barbarianCiv.tech.techsResearched = allResearchedTechs.toHashSet()
|
||||||
val unitList = ruleSet.Units.values
|
val unitList = ruleSet.units.values
|
||||||
.filter { !it.unitType.isCivilian()}
|
.filter { !it.unitType.isCivilian()}
|
||||||
.filter { it.isBuildable(barbarianCiv) }
|
.filter { it.isBuildable(barbarianCiv) }
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ class GameInfo {
|
||||||
getCurrentPlayerCivilization().playerType=PlayerType.Human
|
getCurrentPlayerCivilization().playerType=PlayerType.Human
|
||||||
if(getCurrentPlayerCivilization().difficulty!="Chieftain")
|
if(getCurrentPlayerCivilization().difficulty!="Chieftain")
|
||||||
difficulty= getCurrentPlayerCivilization().difficulty
|
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,
|
// 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,
|
// because updating leads to getting the building uniques from the civ info,
|
||||||
|
|
|
@ -41,7 +41,7 @@ class GameStarter{
|
||||||
for (tech in gameInfo.getDifficulty().aiFreeTechs)
|
for (tech in gameInfo.getDifficulty().aiFreeTechs)
|
||||||
civInfo.tech.addTechnology(tech)
|
civInfo.tech.addTechnology(tech)
|
||||||
|
|
||||||
for (tech in gameBasics.Technologies.values
|
for (tech in gameBasics.technologies.values
|
||||||
.filter { it.era() < newGameParameters.startingEra })
|
.filter { it.era() < newGameParameters.startingEra })
|
||||||
if (!civInfo.tech.isResearched(tech.name))
|
if (!civInfo.tech.isResearched(tech.name))
|
||||||
civInfo.tech.addTechnology(tech.name)
|
civInfo.tech.addTechnology(tech.name)
|
||||||
|
@ -57,7 +57,7 @@ class GameStarter{
|
||||||
|
|
||||||
private fun addCivilizations(newGameParameters: GameParameters, gameInfo: GameInfo, ruleset: Ruleset) {
|
private fun addCivilizations(newGameParameters: GameParameters, gameInfo: GameInfo, ruleset: Ruleset) {
|
||||||
val availableCivNames = Stack<String>()
|
val availableCivNames = Stack<String>()
|
||||||
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.removeAll(newGameParameters.players.map { it.chosenCiv })
|
||||||
availableCivNames.remove("Barbarians")
|
availableCivNames.remove("Barbarians")
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class GameStarter{
|
||||||
val availableCityStatesNames = Stack<String>()
|
val availableCityStatesNames = Stack<String>()
|
||||||
// since we shuffle and then order by, we end up with all the city states with starting tiles first in a random order,
|
// 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!
|
// 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 })
|
.shuffled().sortedByDescending { it in cityStatesWithStartingLocations })
|
||||||
|
|
||||||
for (cityStateName in availableCityStatesNames.take(newGameParameters.numberOfCityStates)) {
|
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
|
// For later starting eras, or for civs like Polynesia with a different Warrior, we need different starting units
|
||||||
fun getWarriorEquivalent(civ: CivilizationInfo): String {
|
fun getWarriorEquivalent(civ: CivilizationInfo): String {
|
||||||
val availableMilitaryUnits = gameInfo.ruleSet.Units.values.filter {
|
val availableMilitaryUnits = gameInfo.ruleSet.units.values.filter {
|
||||||
it.isBuildable(civ)
|
it.isBuildable(civ)
|
||||||
&& it.unitType.isLandUnit()
|
&& it.unitType.isLandUnit()
|
||||||
&& !it.unitType.isCivilian()
|
&& !it.unitType.isCivilian()
|
||||||
|
|
|
@ -170,7 +170,7 @@ class NextTurnAutomation{
|
||||||
|
|
||||||
private fun chooseTechToResearch(civInfo: CivilizationInfo) {
|
private fun chooseTechToResearch(civInfo: CivilizationInfo) {
|
||||||
if (civInfo.tech.techsToResearch.isEmpty()) {
|
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) }
|
.filter { !civInfo.tech.isResearched(it.name) && civInfo.tech.canBeResearched(it.name) }
|
||||||
val techsGroups = researchableTechs.groupBy { it.cost }
|
val techsGroups = researchableTechs.groupBy { it.cost }
|
||||||
val costs = techsGroups.keys.sorted()
|
val costs = techsGroups.keys.sorted()
|
||||||
|
@ -198,7 +198,7 @@ class NextTurnAutomation{
|
||||||
private fun adoptPolicy(civInfo: CivilizationInfo) {
|
private fun adoptPolicy(civInfo: CivilizationInfo) {
|
||||||
while (civInfo.policies.canAdoptPolicy()) {
|
while (civInfo.policies.canAdoptPolicy()) {
|
||||||
|
|
||||||
val adoptablePolicies = civInfo.gameInfo.ruleSet.PolicyBranches.values
|
val adoptablePolicies = civInfo.gameInfo.ruleSet.policyBranches.values
|
||||||
.flatMap { it.policies.union(listOf(it)) }
|
.flatMap { it.policies.union(listOf(it)) }
|
||||||
.filter { civInfo.policies.isAdoptable(it) }
|
.filter { civInfo.policies.isAdoptable(it) }
|
||||||
|
|
||||||
|
|
|
@ -291,7 +291,7 @@ class UnitAutomation{
|
||||||
|
|
||||||
private fun tryUpgradeUnit(unit: MapUnit, unitActions: List<UnitAction>): Boolean {
|
private fun tryUpgradeUnit(unit: MapUnit, unitActions: List<UnitAction>): Boolean {
|
||||||
if (unit.baseUnit().upgradesTo != null) {
|
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)) {
|
if (upgradedUnit.isBuildable(unit.civInfo)) {
|
||||||
val upgradeAction = unitActions.firstOrNull { it.name.startsWith("Upgrade to") }
|
val upgradeAction = unitActions.firstOrNull { it.name.startsWith("Upgrade to") }
|
||||||
if (upgradeAction != null && upgradeAction.canAct) {
|
if (upgradeAction != null && upgradeAction.canAct) {
|
||||||
|
|
|
@ -202,7 +202,7 @@ class WorkerAutomation(val unit: MapUnit) {
|
||||||
else -> throw Exception("No improvement found for "+tile.baseTerrain)
|
else -> throw Exception("No improvement found for "+tile.baseTerrain)
|
||||||
}
|
}
|
||||||
if (improvementString == null) return null
|
if (improvementString == null) return null
|
||||||
return unit.civInfo.gameInfo.ruleSet.TileImprovements[improvementString]!!
|
return unit.civInfo.gameInfo.ruleSet.tileImprovements[improvementString]!!
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -41,7 +41,7 @@ class CityCombatant(val city: CityInfo) : ICombatant {
|
||||||
if(cityTile.baseTerrain== Constants.hill) strength+=5
|
if(cityTile.baseTerrain== Constants.hill) strength+=5
|
||||||
// as tech progresses so does city strength
|
// as tech progresses so does city strength
|
||||||
val techsPercentKnown: Float = city.civInfo.tech.techsResearched.count().toFloat() /
|
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()
|
strength += (techsPercentKnown * 5.5).pow(2.8).toFloat()
|
||||||
|
|
||||||
// The way all of this adds up...
|
// The way all of this adds up...
|
||||||
|
|
|
@ -33,10 +33,10 @@ class CityConstructions {
|
||||||
return toReturn
|
return toReturn
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun getBuildableBuildings(): List<Building> = cityInfo.getRuleset().Buildings.values
|
internal fun getBuildableBuildings(): List<Building> = cityInfo.getRuleset().buildings.values
|
||||||
.filter { it.isBuildable(this) }
|
.filter { it.isBuildable(this) }
|
||||||
|
|
||||||
fun getConstructableUnits() = cityInfo.getRuleset().Units.values
|
fun getConstructableUnits() = cityInfo.getRuleset().units.values
|
||||||
.filter { it.isBuildable(this) }
|
.filter { it.isBuildable(this) }
|
||||||
|
|
||||||
fun getStats(): Stats {
|
fun getStats(): Stats {
|
||||||
|
@ -95,10 +95,10 @@ class CityConstructions {
|
||||||
|
|
||||||
internal fun getConstruction(constructionName: String): IConstruction {
|
internal fun getConstruction(constructionName: String): IConstruction {
|
||||||
val gameBasics = cityInfo.getRuleset()
|
val gameBasics = cityInfo.getRuleset()
|
||||||
if (gameBasics.Buildings.containsKey(constructionName))
|
if (gameBasics.buildings.containsKey(constructionName))
|
||||||
return gameBasics.Buildings[constructionName]!!
|
return gameBasics.buildings[constructionName]!!
|
||||||
else if (gameBasics.Units.containsKey(constructionName))
|
else if (gameBasics.units.containsKey(constructionName))
|
||||||
return gameBasics.Units[constructionName]!!
|
return gameBasics.units[constructionName]!!
|
||||||
else{
|
else{
|
||||||
if(constructionName=="") return getConstruction("Nothing")
|
if(constructionName=="") return getConstruction("Nothing")
|
||||||
val special = SpecialConstruction.getSpecialConstructions().firstOrNull{it.name==constructionName}
|
val special = SpecialConstruction.getSpecialConstructions().firstOrNull{it.name==constructionName}
|
||||||
|
@ -155,7 +155,7 @@ class CityConstructions {
|
||||||
|
|
||||||
//region state changing functions
|
//region state changing functions
|
||||||
fun setTransients(){
|
fun setTransients(){
|
||||||
builtBuildingObjects = ArrayList(builtBuildings.map { cityInfo.getRuleset().Buildings[it]!! })
|
builtBuildingObjects = ArrayList(builtBuildings.map { cityInfo.getRuleset().buildings[it]!! })
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addProductionPoints(productionToAdd: Int) {
|
fun addProductionPoints(productionToAdd: Int) {
|
||||||
|
@ -217,13 +217,13 @@ class CityConstructions {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addBuilding(buildingName:String){
|
fun addBuilding(buildingName:String){
|
||||||
val buildingObject = cityInfo.getRuleset().Buildings[buildingName]!!
|
val buildingObject = cityInfo.getRuleset().buildings[buildingName]!!
|
||||||
builtBuildingObjects = builtBuildingObjects.withItem(buildingObject)
|
builtBuildingObjects = builtBuildingObjects.withItem(buildingObject)
|
||||||
builtBuildings.add(buildingName)
|
builtBuildings.add(buildingName)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun removeBuilding(buildingName:String){
|
fun removeBuilding(buildingName:String){
|
||||||
val buildingObject = cityInfo.getRuleset().Buildings[buildingName]!!
|
val buildingObject = cityInfo.getRuleset().buildings[buildingName]!!
|
||||||
builtBuildingObjects = builtBuildingObjects.withoutItem(buildingObject)
|
builtBuildingObjects = builtBuildingObjects.withoutItem(buildingObject)
|
||||||
builtBuildings.remove(buildingName)
|
builtBuildings.remove(buildingName)
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,7 +139,7 @@ class CityInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (building in cityConstructions.getBuiltBuildings().filter { it.requiredResource != null }) {
|
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")
|
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
|
// 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){
|
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
|
if(improvement.techRequired!=null && !civInfo.tech.isResearched(improvement.techRequired!!)) return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,15 +483,15 @@ class CityInfo {
|
||||||
|
|
||||||
private fun tryUpdateRoadStatus(){
|
private fun tryUpdateRoadStatus(){
|
||||||
if(getCenterTile().roadStatus==RoadStatus.None
|
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
|
getCenterTile().roadStatus=RoadStatus.Road
|
||||||
|
|
||||||
else if(getCenterTile().roadStatus!=RoadStatus.Railroad
|
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
|
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){
|
fun sellBuilding(buildingName:String){
|
||||||
cityConstructions.builtBuildings.remove(buildingName)
|
cityConstructions.builtBuildings.remove(buildingName)
|
||||||
|
|
|
@ -74,7 +74,7 @@ class CityStats {
|
||||||
|
|
||||||
private fun getStatPercentBonusesFromRailroad(): Stats {
|
private fun getStatPercentBonusesFromRailroad(): Stats {
|
||||||
val stats = 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,
|
// 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.
|
// 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)
|
if (cityInfo.civInfo.tech.isResearched(techEnablingRailroad)
|
||||||
|
|
|
@ -210,7 +210,7 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo){
|
||||||
|
|
||||||
for (dip in civInfo.diplomacy.values) newDetailedCivResources.add(dip.resourcesFromTrade())
|
for (dip in civInfo.diplomacy.values) newDetailedCivResources.add(dip.resourcesFromTrade())
|
||||||
for(resource in civInfo.getCivUnits().mapNotNull { it.baseUnit.requiredResource }
|
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")
|
newDetailedCivResources.add(resource,-1,"Units")
|
||||||
civInfo.detailedCivResources = newDetailedCivResources
|
civInfo.detailedCivResources = newDetailedCivResources
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ class CivilizationInfo {
|
||||||
//region pure functions
|
//region pure functions
|
||||||
fun getDifficulty():Difficulty {
|
fun getDifficulty():Difficulty {
|
||||||
if (isPlayerCivilization()) return gameInfo.getDifficulty()
|
if (isPlayerCivilization()) return gameInfo.getDifficulty()
|
||||||
return gameInfo.ruleSet.Difficulties["Chieftain"]!!
|
return gameInfo.ruleSet.difficulties["Chieftain"]!!
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getTranslatedNation(): Nation {
|
fun getTranslatedNation(): Nation {
|
||||||
|
@ -174,7 +174,7 @@ class CivilizationInfo {
|
||||||
*/
|
*/
|
||||||
fun getCivResourcesByName():HashMap<String,Int>{
|
fun getCivResourcesByName():HashMap<String,Int>{
|
||||||
val hashMap = HashMap<String,Int>()
|
val hashMap = HashMap<String,Int>()
|
||||||
for(resource in gameInfo.ruleSet.TileResources.keys) hashMap[resource]=0
|
for(resource in gameInfo.ruleSet.tileResources.keys) hashMap[resource]=0
|
||||||
for(entry in getCivResources())
|
for(entry in getCivResources())
|
||||||
hashMap[entry.resource.name] = entry.amount
|
hashMap[entry.resource.name] = entry.amount
|
||||||
return hashMap
|
return hashMap
|
||||||
|
@ -232,19 +232,19 @@ class CivilizationInfo {
|
||||||
|
|
||||||
|
|
||||||
fun getEquivalentBuilding(buildingName:String): Building {
|
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)
|
if(building.replaces==baseBuilding.name && building.uniqueTo==civName)
|
||||||
return building
|
return building
|
||||||
return baseBuilding
|
return baseBuilding
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getEquivalentUnit(baseUnitName:String):BaseUnit {
|
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)
|
if (unit.replaces == baseUnitName && unit.uniqueTo == civName)
|
||||||
return unit
|
return unit
|
||||||
return gameInfo.ruleSet.Units[baseUnitName]!!
|
return gameInfo.ruleSet.units[baseUnitName]!!
|
||||||
}
|
}
|
||||||
|
|
||||||
fun meetCivilization(otherCiv: CivilizationInfo) {
|
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 =\
|
* And if they civs on't yet know who they are then they don;t know if they're barbarians =\
|
||||||
* */
|
* */
|
||||||
fun setNationTransient(){
|
fun setNationTransient(){
|
||||||
nation = gameInfo.ruleSet.Nations[civName]!!
|
nation = gameInfo.ruleSet.nations[civName]!!
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setTransients() {
|
fun setTransients() {
|
||||||
|
|
|
@ -40,7 +40,7 @@ data class LocationAction(var locations: ArrayList<Vector2> = ArrayList()) : Not
|
||||||
/** show tech screen */
|
/** show tech screen */
|
||||||
class TechAction(val techName: String = "") : NotificationAction {
|
class TechAction(val techName: String = "") : NotificationAction {
|
||||||
override fun execute(worldScreen: WorldScreen) {
|
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))
|
worldScreen.game.setScreen(TechPickerScreen(worldScreen.viewingCiv, tech))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ class PolicyManager {
|
||||||
if (freePolicies == 0 && storedCulture < getCultureNeededForNextPolicy())
|
if (freePolicies == 0 && storedCulture < getCultureNeededForNextPolicy())
|
||||||
return false
|
return false
|
||||||
|
|
||||||
val hasAdoptablePolicies = civInfo.gameInfo.ruleSet.PolicyBranches.values
|
val hasAdoptablePolicies = civInfo.gameInfo.ruleSet.policyBranches.values
|
||||||
.flatMap { it.policies.union(listOf(it)) }
|
.flatMap { it.policies.union(listOf(it)) }
|
||||||
.any { civInfo.policies.isAdoptable(it) }
|
.any { civInfo.policies.isAdoptable(it) }
|
||||||
return hasAdoptablePolicies
|
return hasAdoptablePolicies
|
||||||
|
@ -100,7 +100,7 @@ class PolicyManager {
|
||||||
VictoryType.Cultural -> "Great Artist"
|
VictoryType.Cultural -> "Great Artist"
|
||||||
VictoryType.Scientific -> "Great Scientist"
|
VictoryType.Scientific -> "Great Scientist"
|
||||||
VictoryType.Domination,VictoryType.Neutral ->
|
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)
|
civInfo.addGreatPerson(greatPerson)
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ class TechManager {
|
||||||
fun getRuleset() = civInfo.gameInfo.ruleSet
|
fun getRuleset() = civInfo.gameInfo.ruleSet
|
||||||
|
|
||||||
fun costOfTech(techName: String): Int {
|
fun costOfTech(techName: String): Int {
|
||||||
var techCost = getRuleset().Technologies[techName]!!.cost.toFloat()
|
var techCost = getRuleset().technologies[techName]!!.cost.toFloat()
|
||||||
if (civInfo.isPlayerCivilization())
|
if (civInfo.isPlayerCivilization())
|
||||||
techCost *= civInfo.getDifficulty().researchCostModifier
|
techCost *= civInfo.getDifficulty().researchCostModifier
|
||||||
techCost *= civInfo.gameInfo.gameParameters.gameSpeed.getModifier()
|
techCost *= civInfo.gameInfo.gameParameters.gameSpeed.getModifier()
|
||||||
|
@ -74,7 +74,7 @@ class TechManager {
|
||||||
fun currentTechnology(): Technology? {
|
fun currentTechnology(): Technology? {
|
||||||
val currentTechnologyName = currentTechnologyName()
|
val currentTechnologyName = currentTechnologyName()
|
||||||
if (currentTechnologyName == null) return null
|
if (currentTechnologyName == null) return null
|
||||||
return getRuleset().Technologies[currentTechnologyName]
|
return getRuleset().technologies[currentTechnologyName]
|
||||||
}
|
}
|
||||||
|
|
||||||
fun currentTechnologyName(): String? {
|
fun currentTechnologyName(): String? {
|
||||||
|
@ -94,7 +94,7 @@ class TechManager {
|
||||||
fun isResearched(TechName: String): Boolean = techsResearched.contains(TechName)
|
fun isResearched(TechName: String): Boolean = techsResearched.contains(TechName)
|
||||||
|
|
||||||
fun canBeResearched(TechName: String): Boolean {
|
fun canBeResearched(TechName: String): Boolean {
|
||||||
return getRuleset().Technologies[TechName]!!.prerequisites.all { isResearched(it) }
|
return getRuleset().technologies[TechName]!!.prerequisites.all { isResearched(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getTechUniques() = researchedTechUniques
|
fun getTechUniques() = researchedTechUniques
|
||||||
|
@ -115,7 +115,7 @@ class TechManager {
|
||||||
(isResearched(techToCheck.name) || prerequisites.contains(techToCheck)) )
|
(isResearched(techToCheck.name) || prerequisites.contains(techToCheck)) )
|
||||||
continue //no need to add or check prerequisites
|
continue //no need to add or check prerequisites
|
||||||
for (prerequisite in techToCheck.prerequisites)
|
for (prerequisite in techToCheck.prerequisites)
|
||||||
checkPrerequisites.add(getRuleset().Technologies[prerequisite]!!)
|
checkPrerequisites.add(getRuleset().technologies[prerequisite]!!)
|
||||||
prerequisites.add(techToCheck)
|
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,
|
// Apparently yes, we care about the absolute tech cost, not the actual calculated-for-this-player tech cost,
|
||||||
// so don't change to costOfTech()
|
// so don't change to costOfTech()
|
||||||
return min(overflowscience, max(civInfo.statsForNextTurn.science.toInt() * 5,
|
return min(overflowscience, max(civInfo.statsForNextTurn.science.toInt() * 5,
|
||||||
getRuleset().Technologies[currentTechnologyName()]!!.cost))
|
getRuleset().technologies[currentTechnologyName()]!!.cost))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nextTurn(scienceForNewTurn: Int) {
|
fun nextTurn(scienceForNewTurn: Int) {
|
||||||
|
@ -194,7 +194,7 @@ class TechManager {
|
||||||
techsResearched.add(techName)
|
techsResearched.add(techName)
|
||||||
|
|
||||||
// this is to avoid concurrent modification problems
|
// this is to avoid concurrent modification problems
|
||||||
val newTech = getRuleset().Technologies[techName]!!
|
val newTech = getRuleset().technologies[techName]!!
|
||||||
researchedTechnologies = researchedTechnologies.withItem(newTech)
|
researchedTechnologies = researchedTechnologies.withItem(newTech)
|
||||||
for(unique in newTech.uniques)
|
for(unique in newTech.uniques)
|
||||||
researchedTechUniques = researchedTechUniques.withItem(unique)
|
researchedTechUniques = researchedTechUniques.withItem(unique)
|
||||||
|
@ -206,11 +206,11 @@ class TechManager {
|
||||||
val currentEra = civInfo.getEra()
|
val currentEra = civInfo.getEra()
|
||||||
if (previousEra < currentEra) {
|
if (previousEra < currentEra) {
|
||||||
civInfo.addNotification("You have entered the [$currentEra era]!", null, Color.GOLD)
|
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) }
|
.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
|
for (tileInfo in civInfo.gameInfo.tileMap.values
|
||||||
.filter { it.resource == revealedResource.name && civInfo == it.getOwner() }) {
|
.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)
|
for (city in civInfo.cities)
|
||||||
if (city.cityConstructions.getCurrentConstruction() in obsoleteUnits) {
|
if (city.cityConstructions.getCurrentConstruction() in obsoleteUnits) {
|
||||||
val currentConstructionUnit = city.cityConstructions.getCurrentConstruction() as BaseUnit
|
val currentConstructionUnit = city.cityConstructions.getCurrentConstruction() as BaseUnit
|
||||||
|
@ -260,7 +260,7 @@ class TechManager {
|
||||||
techsToResearch = newTechToReseach
|
techsToResearch = newTechToReseach
|
||||||
}
|
}
|
||||||
|
|
||||||
researchedTechnologies.addAll(techsResearched.map { getRuleset().Technologies[it]!! })
|
researchedTechnologies.addAll(techsResearched.map { getRuleset().technologies[it]!! })
|
||||||
researchedTechUniques.addAll(researchedTechnologies.flatMap { it.uniques })
|
researchedTechUniques.addAll(researchedTechnologies.flatMap { it.uniques })
|
||||||
updateTransientBooleans()
|
updateTransientBooleans()
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,10 +191,10 @@ class DiplomacyManager() {
|
||||||
for(trade in trades){
|
for(trade in trades){
|
||||||
for(offer in trade.ourOffers)
|
for(offer in trade.ourOffers)
|
||||||
if(offer.type== TradeType.Strategic_Resource || offer.type== TradeType.Luxury_Resource)
|
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)
|
for(offer in trade.theirOffers)
|
||||||
if(offer.type== TradeType.Strategic_Resource || offer.type== TradeType.Luxury_Resource)
|
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
|
return counter
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ class MapGenerator {
|
||||||
fun divideIntoBiomes(map: TileMap, averageTilesPerArea: Int, waterPercent: Float, distance: Int, ruleset: Ruleset) {
|
fun divideIntoBiomes(map: TileMap, averageTilesPerArea: Int, waterPercent: Float, distance: Int, ruleset: Ruleset) {
|
||||||
val areas = ArrayList<Area>()
|
val areas = ArrayList<Area>()
|
||||||
|
|
||||||
val terrains = ruleset.Terrains.values
|
val terrains = ruleset.terrains.values
|
||||||
.filter { it.type === TerrainType.Land && it.name != Constants.lakes && it.name != Constants.mountain }
|
.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
|
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) {
|
fun addRandomTerrainFeature(tileInfo: TileInfo, ruleset: Ruleset) {
|
||||||
if (tileInfo.getBaseTerrain().canHaveOverlay && Math.random() > 0.7f) {
|
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) }
|
.filter { it.type === TerrainType.TerrainFeature && it.occursOn != null && it.occursOn.contains(tileInfo.baseTerrain) }
|
||||||
if (secondaryTerrains.any()) tileInfo.terrainFeature = secondaryTerrains.random().name
|
if (secondaryTerrains.any()) tileInfo.terrainFeature = secondaryTerrains.random().name
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,7 @@ class MapGenerator {
|
||||||
val numberToSpawn = round(mapRadius * 0.13133208f - 0.56128831f).toInt()
|
val numberToSpawn = round(mapRadius * 0.13133208f - 0.56128831f).toInt()
|
||||||
|
|
||||||
val toBeSpawned = ArrayList<Terrain>()
|
val toBeSpawned = ArrayList<Terrain>()
|
||||||
val allNaturalWonders = ruleset.Terrains.values
|
val allNaturalWonders = ruleset.terrains.values
|
||||||
.filter { it.type == TerrainType.NaturalWonder }.toMutableList()
|
.filter { it.type == TerrainType.NaturalWonder }.toMutableList()
|
||||||
|
|
||||||
while (allNaturalWonders.isNotEmpty() && toBeSpawned.size < numberToSpawn) {
|
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
|
of 2 mountains and a maximum of 4 hills and mountains; avoids oceans; becomes mountain
|
||||||
*/
|
*/
|
||||||
private fun spawnBarringerCrater(mapToReturn: TileMap, ruleset: Ruleset) {
|
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
|
val suitableLocations = mapToReturn.values.filter { it.resource == null && it.improvement == null
|
||||||
&& wonder.occursOn!!.contains(it.getLastTerrain().name)
|
&& wonder.occursOn!!.contains(it.getLastTerrain().name)
|
||||||
&& it.neighbors.none { neighbor -> neighbor.getBaseTerrain().name == Constants.grassland }
|
&& 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
|
can be adjacent to a maximum of 2 hills; becomes mountain
|
||||||
*/
|
*/
|
||||||
private fun spawnMountFuji(mapToReturn: TileMap, ruleset: Ruleset) {
|
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
|
val suitableLocations = mapToReturn.values.filter { it.resource == null && it.improvement == null
|
||||||
&& wonder.occursOn!!.contains(it.getLastTerrain().name)
|
&& wonder.occursOn!!.contains(it.getLastTerrain().name)
|
||||||
&& it.neighbors.none { neighbor -> neighbor.getBaseTerrain().name == Constants.tundra }
|
&& 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
|
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) {
|
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
|
val suitableLocations = mapToReturn.values.filter { it.resource == null && it.improvement == null
|
||||||
&& wonder.occursOn!!.contains(it.getLastTerrain().name)
|
&& wonder.occursOn!!.contains(it.getLastTerrain().name)
|
||||||
&& it.neighbors.count{ neighbor -> neighbor.getBaseTerrain().name == Constants.hill } >= 2
|
&& it.neighbors.count{ neighbor -> neighbor.getBaseTerrain().name == Constants.hill } >= 2
|
||||||
|
@ -344,7 +344,7 @@ class MapGenerator {
|
||||||
TODO: investigate Great Barrier Reef placement requirements
|
TODO: investigate Great Barrier Reef placement requirements
|
||||||
*/
|
*/
|
||||||
private fun spawnGreatBarrierReef(mapToReturn: TileMap, ruleset: Ruleset) {
|
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
|
val suitableLocations = mapToReturn.values.filter { it.resource == null && it.improvement == null
|
||||||
&& wonder.occursOn!!.contains(it.getLastTerrain().name)
|
&& wonder.occursOn!!.contains(it.getLastTerrain().name)
|
||||||
&& it.neighbors.none{ neighbor -> neighbor.getBaseTerrain().name == Constants.tundra }
|
&& it.neighbors.none{ neighbor -> neighbor.getBaseTerrain().name == Constants.tundra }
|
||||||
|
@ -379,7 +379,7 @@ class MapGenerator {
|
||||||
TODO: cannot be adjacent to ice
|
TODO: cannot be adjacent to ice
|
||||||
*/
|
*/
|
||||||
private fun spawnKrakatoa(mapToReturn: TileMap, ruleset: Ruleset) {
|
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
|
val suitableLocations = mapToReturn.values.filter { it.resource == null && it.improvement == null
|
||||||
&& wonder.occursOn!!.contains(it.getLastTerrain().name)
|
&& wonder.occursOn!!.contains(it.getLastTerrain().name)
|
||||||
&& it.neighbors.any { neighbor -> neighbor.getBaseTerrain().name == Constants.coast }
|
&& it.neighbors.any { neighbor -> neighbor.getBaseTerrain().name == Constants.coast }
|
||||||
|
@ -411,7 +411,7 @@ class MapGenerator {
|
||||||
TODO: investigate Rock of Gibraltar placement requirements
|
TODO: investigate Rock of Gibraltar placement requirements
|
||||||
*/
|
*/
|
||||||
private fun spawnRockOfGibraltar(mapToReturn: TileMap, ruleset: Ruleset) {
|
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
|
val suitableLocations = mapToReturn.values.filter { it.resource == null && it.improvement == null
|
||||||
&& wonder.occursOn!!.contains(it.getLastTerrain().name)
|
&& wonder.occursOn!!.contains(it.getLastTerrain().name)
|
||||||
&& it.neighbors.any { neighbor -> neighbor.getBaseTerrain().name == Constants.coast }
|
&& it.neighbors.any { neighbor -> neighbor.getBaseTerrain().name == Constants.coast }
|
||||||
|
@ -445,7 +445,7 @@ class MapGenerator {
|
||||||
avoids oceans; becomes mountain
|
avoids oceans; becomes mountain
|
||||||
*/
|
*/
|
||||||
private fun spawnOldFaithful(mapToReturn: TileMap, ruleset: Ruleset) {
|
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
|
val suitableLocations = mapToReturn.values.filter { it.resource == null && it.improvement == null
|
||||||
&& wonder.occursOn!!.contains(it.getLastTerrain().name)
|
&& wonder.occursOn!!.contains(it.getLastTerrain().name)
|
||||||
&& it.neighbors.count { neighbor -> neighbor.getBaseTerrain().name == Constants.mountain } <= 4
|
&& 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
|
Cerro de Potosi: Must be adjacent to at least 1 hill; avoids oceans; becomes mountain
|
||||||
*/
|
*/
|
||||||
private fun spawnCerroDePotosi(mapToReturn: TileMap, ruleset: Ruleset) {
|
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
|
val suitableLocations = mapToReturn.values.filter { it.resource == null && it.improvement == null
|
||||||
&& wonder.occursOn!!.contains(it.getLastTerrain().name)
|
&& wonder.occursOn!!.contains(it.getLastTerrain().name)
|
||||||
&& it.neighbors.any { neighbor -> neighbor.getBaseTerrain().name == Constants.hill }
|
&& 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
|
El Dorado: Must be next to at least 1 jungle tile; avoids oceans; becomes flatland plains
|
||||||
*/
|
*/
|
||||||
private fun spawnElDorado(mapToReturn: TileMap, ruleset: Ruleset) {
|
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
|
val suitableLocations = mapToReturn.values.filter { it.resource == null && it.improvement == null
|
||||||
&& wonder.occursOn!!.contains(it.getLastTerrain().name)
|
&& wonder.occursOn!!.contains(it.getLastTerrain().name)
|
||||||
&& it.neighbors.any { neighbor -> neighbor.getLastTerrain().name == Constants.jungle }
|
&& it.neighbors.any { neighbor -> neighbor.getLastTerrain().name == Constants.jungle }
|
||||||
|
@ -512,7 +512,7 @@ class MapGenerator {
|
||||||
Fountain of Youth: Avoids oceans; becomes flatland plains
|
Fountain of Youth: Avoids oceans; becomes flatland plains
|
||||||
*/
|
*/
|
||||||
private fun spawnFountainOfYouth(mapToReturn: TileMap, ruleset: Ruleset) {
|
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
|
val suitableLocations = mapToReturn.values.filter { it.resource == null && it.improvement == null
|
||||||
&& wonder.occursOn!!.contains(it.getLastTerrain().name) }
|
&& 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
|
// 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) {
|
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) {
|
for (resource in resourcesOfType) {
|
||||||
val suitableTiles = mapToReturn.values
|
val suitableTiles = mapToReturn.values
|
||||||
.filter { it.resource == null && resource.terrainsCanBeFoundOn.contains(it.getLastTerrain().name) }
|
.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
|
// 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) {
|
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
|
val suitableTiles = mapToReturn.values
|
||||||
.filter { it.resource == null && resourcesOfType.any { r -> r.terrainsCanBeFoundOn.contains(it.getLastTerrain().name) } }
|
.filter { it.resource == null && resourcesOfType.any { r -> r.terrainsCanBeFoundOn.contains(it.getLastTerrain().name) } }
|
||||||
|
|
|
@ -114,7 +114,7 @@ class MapUnit {
|
||||||
val uniques = ArrayList<String>()
|
val uniques = ArrayList<String>()
|
||||||
val baseUnit = baseUnit()
|
val baseUnit = baseUnit()
|
||||||
uniques.addAll(baseUnit.uniques)
|
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
|
tempUniques = uniques
|
||||||
|
|
||||||
if("Ignores terrain cost" in uniques) ignoresTerrainCost=true
|
if("Ignores terrain cost" in uniques) ignoresTerrainCost=true
|
||||||
|
@ -269,7 +269,7 @@ class MapUnit {
|
||||||
fun setTransients(ruleset: Ruleset) {
|
fun setTransients(ruleset: Ruleset) {
|
||||||
promotions.unit=this
|
promotions.unit=this
|
||||||
mapUnitAction?.unit = this
|
mapUnitAction?.unit = this
|
||||||
baseUnit=ruleset.Units[name]!!
|
baseUnit=ruleset.units[name]!!
|
||||||
updateUniques()
|
updateUniques()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,7 +469,7 @@ class MapUnit {
|
||||||
city.population.autoAssignPopulation()
|
city.population.autoAssignPopulation()
|
||||||
civInfo.addNotification("We have found survivors in the ruins - population added to ["+city.name+"]",tile.position, Color.GREEN)
|
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 {
|
.filter {
|
||||||
!civInfo.tech.isResearched(it.name)
|
!civInfo.tech.isResearched(it.name)
|
||||||
&& civInfo.tech.canBeResearched(it.name)
|
&& civInfo.tech.canBeResearched(it.name)
|
||||||
|
|
|
@ -15,6 +15,6 @@ enum class RoadStatus {
|
||||||
Railroad;
|
Railroad;
|
||||||
|
|
||||||
/** returns null for [None] */
|
/** returns null for [None] */
|
||||||
fun improvement(ruleset: Ruleset) = ruleset.TileImprovements[this.name]
|
fun improvement(ruleset: Ruleset) = ruleset.tileImprovements[this.name]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,16 +87,16 @@ open class TileInfo {
|
||||||
|
|
||||||
fun getTileResource(): TileResource =
|
fun getTileResource(): TileResource =
|
||||||
if (resource == null) throw Exception("No resource exists for this tile!")
|
if (resource == null) throw Exception("No resource exists for this tile!")
|
||||||
else ruleset.TileResources[resource!!]!!
|
else ruleset.tileResources[resource!!]!!
|
||||||
|
|
||||||
fun getNaturalWonder() : Terrain =
|
fun getNaturalWonder() : Terrain =
|
||||||
if (naturalWonder == null) throw Exception("No natural wonder exists for this tile!")
|
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 isCityCenter(): Boolean = getCity()?.location == position
|
||||||
fun isNaturalWonder() : Boolean = naturalWonder != null
|
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,
|
// 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? {
|
fun getTerrainFeature(): Terrain? {
|
||||||
return if (terrainFeature == null) null else ruleset.Terrains[terrainFeature!!]
|
return if (terrainFeature == null) null else ruleset.terrains[terrainFeature!!]
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isWorked(): Boolean {
|
fun isWorked(): Boolean {
|
||||||
|
@ -176,7 +176,7 @@ open class TileInfo {
|
||||||
val resource = getTileResource()
|
val resource = getTileResource()
|
||||||
stats.add(getTileResource()) // resource base
|
stats.add(getTileResource()) // resource base
|
||||||
if (resource.building != null && city != null && city.cityConstructions.isBuilt(resource.building!!)) {
|
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
|
stats.add(resourceBuilding.resourceBonusStats!!) // resource-specific building (eg forge, stable) bonus
|
||||||
}
|
}
|
||||||
if(resource.resourceType==ResourceType.Strategic
|
if(resource.resourceType==ResourceType.Strategic
|
||||||
|
@ -328,7 +328,7 @@ open class TileInfo {
|
||||||
|
|
||||||
//region state-changing functions
|
//region state-changing functions
|
||||||
fun setTransients(){
|
fun setTransients(){
|
||||||
baseTerrainObject = ruleset.Terrains[baseTerrain]!! // This is a HACK.
|
baseTerrainObject = ruleset.terrains[baseTerrain]!! // This is a HACK.
|
||||||
isWater = getBaseTerrain().type==TerrainType.Water
|
isWater = getBaseTerrain().type==TerrainType.Water
|
||||||
isLand = getBaseTerrain().type==TerrainType.Land
|
isLand = getBaseTerrain().type==TerrainType.Land
|
||||||
isOcean = baseTerrain == Constants.ocean
|
isOcean = baseTerrain == Constants.ocean
|
||||||
|
|
|
@ -65,7 +65,7 @@ class TileMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun placeUnitNearTile(position: Vector2, unitName: String, civInfo: CivilizationInfo): MapUnit? {
|
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 {
|
fun isTileMovePotential(tileInfo:TileInfo): Boolean {
|
||||||
if(unit.type.isWaterUnit()) return tileInfo.isWater || tileInfo.isCityCenter()
|
if(unit.type.isWaterUnit()) return tileInfo.isWater || tileInfo.isCityCenter()
|
||||||
|
|
|
@ -36,7 +36,7 @@ class UnitPromotions{
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAvailablePromotions(): List<Promotion> {
|
fun getAvailablePromotions(): List<Promotion> {
|
||||||
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 { unit.type.toString() in it.unitTypes && it.name !in promotions }
|
||||||
.filter { it.prerequisites.isEmpty() || it.prerequisites.any { p->p in promotions } }
|
.filter { it.prerequisites.isEmpty() || it.prerequisites.any { p->p in promotions } }
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ class TradeEvaluation{
|
||||||
}
|
}
|
||||||
|
|
||||||
TradeType.Technology ->
|
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
|
* civInfo.gameInfo.gameParameters.gameSpeed.getModifier()).toInt()*20
|
||||||
TradeType.Introduction -> return 250
|
TradeType.Introduction -> return 250
|
||||||
TradeType.WarDeclaration -> {
|
TradeType.WarDeclaration -> {
|
||||||
|
@ -167,7 +167,7 @@ class TradeEvaluation{
|
||||||
TradeType.Strategic_Resource -> {
|
TradeType.Strategic_Resource -> {
|
||||||
if(!civInfo.isAtWar()) return 50*offer.amount
|
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) }
|
.any { it.requiredResource==offer.name && it.isBuildable(civInfo) }
|
||||||
if(!canUseForUnits) return 50*offer.amount
|
if(!canUseForUnits) return 50*offer.amount
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ class TradeEvaluation{
|
||||||
}
|
}
|
||||||
return totalCost
|
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.Introduction -> return 250
|
||||||
TradeType.WarDeclaration -> {
|
TradeType.WarDeclaration -> {
|
||||||
val civToDeclareWarOn = civInfo.gameInfo.getCivilization(offer.name)
|
val civToDeclareWarOn = civInfo.gameInfo.getCivilization(offer.name)
|
||||||
|
|
|
@ -53,7 +53,7 @@ class Building : NamedStats(), IConstruction{
|
||||||
for(stat in getStatPercentageBonuses(null).toHashMap())
|
for(stat in getStatPercentageBonuses(null).toHashMap())
|
||||||
if(stat.value!=0f) infoList+="+${stat.value.toInt()}% ${stat.key.toString().tr()}"
|
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()){
|
if(improvedResources.isNotEmpty()){
|
||||||
// buildings that improve resources
|
// buildings that improve resources
|
||||||
infoList += improvedResources.joinToString()+ " {provide} ".tr()+ resourceBonusStats.toString()
|
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 (gpp.culture != 0f) stringBuilder.appendln("+" + gpp.culture.toInt() + " "+"[Great Artist] points".tr())
|
||||||
}
|
}
|
||||||
if (resourceBonusStats != null) {
|
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())
|
stringBuilder.appendln("$resources {provide} $resourceBonusStats".tr())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ class Building : NamedStats(), IConstruction{
|
||||||
|
|
||||||
val civInfo = construction.cityInfo.civInfo
|
val civInfo = construction.cityInfo.civInfo
|
||||||
if (uniqueTo!=null && uniqueTo!=civInfo.civName) return "Unique to $uniqueTo"
|
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"
|
if (requiredTech != null && !civInfo.tech.isResearched(requiredTech!!)) return "$requiredTech not researched"
|
||||||
|
|
||||||
// Regular wonders
|
// Regular wonders
|
||||||
|
@ -329,7 +329,7 @@ class Building : NamedStats(), IConstruction{
|
||||||
if (providesFreeBuilding != null && !construction.containsBuildingOrEquivalent(providesFreeBuilding!!)) {
|
if (providesFreeBuilding != null && !construction.containsBuildingOrEquivalent(providesFreeBuilding!!)) {
|
||||||
var buildingToAdd = 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)
|
if(building.replaces == buildingToAdd && building.uniqueTo==civInfo.civName)
|
||||||
buildingToAdd = building.name
|
buildingToAdd = building.name
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ class Building : NamedStats(), IConstruction{
|
||||||
if ("Free Social Policy" in uniques) civInfo.policies.freePolicies++
|
if ("Free Social Policy" in uniques) civInfo.policies.freePolicies++
|
||||||
if ("Free Great Person" in uniques) {
|
if ("Free Great Person" in uniques) {
|
||||||
if (civInfo.isPlayerCivilization()) civInfo.greatPeople.freeGreatPeople++
|
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) {
|
if ("+1 population in each city" in uniques) {
|
||||||
for(city in civInfo.cities){
|
for(city in civInfo.cities){
|
||||||
|
@ -375,6 +375,6 @@ class Building : NamedStats(), IConstruction{
|
||||||
|
|
||||||
fun getBaseBuilding(ruleset: Ruleset): Building {
|
fun getBaseBuilding(ruleset: Ruleset): Building {
|
||||||
if(replaces==null) return this
|
if(replaces==null) return this
|
||||||
else return ruleset.Buildings[replaces!!]!!
|
else return ruleset.buildings[replaces!!]!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,9 +97,9 @@ class Nation : INamed {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addUniqueBuildingsText(textList: ArrayList<String>, ruleset: Ruleset) {
|
private fun addUniqueBuildingsText(textList: ArrayList<String>, ruleset: Ruleset) {
|
||||||
for (building in ruleset.Buildings.values
|
for (building in ruleset.buildings.values
|
||||||
.filter { it.uniqueTo == name }) {
|
.filter { it.uniqueTo == name }) {
|
||||||
val originalBuilding = ruleset.Buildings[building.replaces!!]!!
|
val originalBuilding = ruleset.buildings[building.replaces!!]!!
|
||||||
|
|
||||||
textList += building.name.tr() + " - {replaces} " + originalBuilding.name.tr()
|
textList += building.name.tr() + " - {replaces} " + originalBuilding.name.tr()
|
||||||
val originalBuildingStatMap = originalBuilding.toHashMap()
|
val originalBuildingStatMap = originalBuilding.toHashMap()
|
||||||
|
@ -122,9 +122,9 @@ class Nation : INamed {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addUniqueUnitsText(textList: ArrayList<String>, ruleset: Ruleset) {
|
private fun addUniqueUnitsText(textList: ArrayList<String>, ruleset: Ruleset) {
|
||||||
for (unit in ruleset.Units.values
|
for (unit in ruleset.units.values
|
||||||
.filter { it.uniqueTo == name }) {
|
.filter { it.uniqueTo == name }) {
|
||||||
val originalUnit = ruleset.Units[unit.replaces!!]!!
|
val originalUnit = ruleset.units[unit.replaces!!]!!
|
||||||
|
|
||||||
textList += unit.name.tr() + " - {replaces} " + originalUnit.name.tr()
|
textList += unit.name.tr() + " - {replaces} " + originalUnit.name.tr()
|
||||||
if (unit.cost != originalUnit.cost)
|
if (unit.cost != originalUnit.cost)
|
||||||
|
@ -144,14 +144,14 @@ class Nation : INamed {
|
||||||
for (unique in originalUnit.uniques.filterNot { it in unit.uniques })
|
for (unique in originalUnit.uniques.filterNot { it in unit.uniques })
|
||||||
textList += " " + "Lost ability".tr() + "(vs " + originalUnit.name.tr() + "): " + Translations.translateBonusOrPenalty(unique)
|
textList += " " + "Lost ability".tr() + "(vs " + originalUnit.name.tr() + "): " + Translations.translateBonusOrPenalty(unique)
|
||||||
for (promotion in unit.promotions.filter { it !in originalUnit.promotions })
|
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 += ""
|
textList += ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addUniqueImprovementsText(textList: ArrayList<String>, ruleset: Ruleset) {
|
private fun addUniqueImprovementsText(textList: ArrayList<String>, ruleset: Ruleset) {
|
||||||
for (improvement in ruleset.TileImprovements.values
|
for (improvement in ruleset.tileImprovements.values
|
||||||
.filter { it.uniqueTo == name }) {
|
.filter { it.uniqueTo == name }) {
|
||||||
|
|
||||||
textList += improvement.name.tr()
|
textList += improvement.name.tr()
|
||||||
|
|
|
@ -13,16 +13,17 @@ import com.unciv.models.stats.INamed
|
||||||
import kotlin.collections.set
|
import kotlin.collections.set
|
||||||
|
|
||||||
class Ruleset {
|
class Ruleset {
|
||||||
val Buildings = LinkedHashMap<String, Building>()
|
val mods = ArrayList<String>()
|
||||||
val Terrains = LinkedHashMap<String, Terrain>()
|
val buildings = LinkedHashMap<String, Building>()
|
||||||
val TileResources = LinkedHashMap<String, TileResource>()
|
val terrains = LinkedHashMap<String, Terrain>()
|
||||||
val TileImprovements = LinkedHashMap<String, TileImprovement>()
|
val tileResources = LinkedHashMap<String, TileResource>()
|
||||||
val Technologies = LinkedHashMap<String, Technology>()
|
val tileImprovements = LinkedHashMap<String, TileImprovement>()
|
||||||
val Units = LinkedHashMap<String, BaseUnit>()
|
val technologies = LinkedHashMap<String, Technology>()
|
||||||
val UnitPromotions = LinkedHashMap<String, Promotion>()
|
val units = LinkedHashMap<String, BaseUnit>()
|
||||||
val Nations = LinkedHashMap<String, Nation>()
|
val unitPromotions = LinkedHashMap<String, Promotion>()
|
||||||
val PolicyBranches = LinkedHashMap<String, PolicyBranch>()
|
val nations = LinkedHashMap<String, Nation>()
|
||||||
val Difficulties = LinkedHashMap<String, Difficulty>()
|
val policyBranches = LinkedHashMap<String, PolicyBranch>()
|
||||||
|
val difficulties = LinkedHashMap<String, Difficulty>()
|
||||||
|
|
||||||
fun <T> getFromJson(tClass: Class<T>, filePath:String): T {
|
fun <T> getFromJson(tClass: Class<T>, filePath:String): T {
|
||||||
val jsonText = Gdx.files.internal(filePath).readString(Charsets.UTF_8.name())
|
val jsonText = Gdx.files.internal(filePath).readString(Charsets.UTF_8.name())
|
||||||
|
@ -38,17 +39,17 @@ class Ruleset {
|
||||||
|
|
||||||
fun clone(): Ruleset{
|
fun clone(): Ruleset{
|
||||||
val newRuleset = Ruleset(false)
|
val newRuleset = Ruleset(false)
|
||||||
newRuleset.Buildings.putAll(Buildings)
|
newRuleset.buildings.putAll(buildings)
|
||||||
newRuleset.Difficulties.putAll(Difficulties)
|
newRuleset.difficulties.putAll(difficulties)
|
||||||
newRuleset.Nations .putAll(Nations)
|
newRuleset.nations .putAll(nations)
|
||||||
newRuleset.PolicyBranches.putAll(PolicyBranches)
|
newRuleset.policyBranches.putAll(policyBranches)
|
||||||
newRuleset.Technologies.putAll(Technologies)
|
newRuleset.technologies.putAll(technologies)
|
||||||
newRuleset.Buildings.putAll(Buildings)
|
newRuleset.buildings.putAll(buildings)
|
||||||
newRuleset.Terrains.putAll(Terrains)
|
newRuleset.terrains.putAll(terrains)
|
||||||
newRuleset.TileImprovements.putAll(TileImprovements)
|
newRuleset.tileImprovements.putAll(tileImprovements)
|
||||||
newRuleset.TileResources.putAll(TileResources)
|
newRuleset.tileResources.putAll(tileResources)
|
||||||
newRuleset.UnitPromotions.putAll(UnitPromotions)
|
newRuleset.unitPromotions.putAll(unitPromotions)
|
||||||
newRuleset.Units.putAll(Units)
|
newRuleset.units.putAll(units)
|
||||||
return newRuleset
|
return newRuleset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,26 +65,26 @@ class Ruleset {
|
||||||
for (tech in techColumn.techs) {
|
for (tech in techColumn.techs) {
|
||||||
if (tech.cost==0) tech.cost = techColumn.techCost
|
if (tech.cost==0) tech.cost = techColumn.techCost
|
||||||
tech.column = techColumn
|
tech.column = techColumn
|
||||||
Technologies[tech.name] = tech
|
technologies[tech.name] = tech
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Buildings += createHashmap(getFromJson(Array<Building>::class.java, "$folderPath/Buildings.json"))
|
buildings += createHashmap(getFromJson(Array<Building>::class.java, "$folderPath/Buildings.json"))
|
||||||
for (building in Buildings.values) {
|
for (building in buildings.values) {
|
||||||
if (building.requiredTech == null) continue
|
if (building.requiredTech == null) continue
|
||||||
val column = Technologies[building.requiredTech!!]!!.column
|
val column = technologies[building.requiredTech!!]!!.column
|
||||||
if (building.cost == 0)
|
if (building.cost == 0)
|
||||||
building.cost = if (building.isWonder || building.isNationalWonder) column!!.wonderCost else column!!.buildingCost
|
building.cost = if (building.isWonder || building.isNationalWonder) column!!.wonderCost else column!!.buildingCost
|
||||||
}
|
}
|
||||||
|
|
||||||
Terrains += createHashmap(getFromJson(Array<Terrain>::class.java, "$folderPath/Terrains.json"))
|
terrains += createHashmap(getFromJson(Array<Terrain>::class.java, "$folderPath/Terrains.json"))
|
||||||
TileResources += createHashmap(getFromJson(Array<TileResource>::class.java, "$folderPath/TileResources.json"))
|
tileResources += createHashmap(getFromJson(Array<TileResource>::class.java, "$folderPath/TileResources.json"))
|
||||||
TileImprovements += createHashmap(getFromJson(Array<TileImprovement>::class.java, "$folderPath/TileImprovements.json"))
|
tileImprovements += createHashmap(getFromJson(Array<TileImprovement>::class.java, "$folderPath/TileImprovements.json"))
|
||||||
Units += createHashmap(getFromJson(Array<BaseUnit>::class.java, "$folderPath/Units.json"))
|
units += createHashmap(getFromJson(Array<BaseUnit>::class.java, "$folderPath/Units.json"))
|
||||||
UnitPromotions += createHashmap(getFromJson(Array<Promotion>::class.java, "$folderPath/UnitPromotions.json"))
|
unitPromotions += createHashmap(getFromJson(Array<Promotion>::class.java, "$folderPath/UnitPromotions.json"))
|
||||||
|
|
||||||
PolicyBranches += createHashmap(getFromJson(Array<PolicyBranch>::class.java, "$folderPath/Policies.json"))
|
policyBranches += createHashmap(getFromJson(Array<PolicyBranch>::class.java, "$folderPath/Policies.json"))
|
||||||
for (branch in PolicyBranches.values) {
|
for (branch in policyBranches.values) {
|
||||||
branch.requires = ArrayList()
|
branch.requires = ArrayList()
|
||||||
branch.branch = branch
|
branch.branch = branch
|
||||||
for (policy in branch.policies) {
|
for (policy in branch.policies) {
|
||||||
|
@ -93,10 +94,10 @@ class Ruleset {
|
||||||
branch.policies.last().name = branch.name + " Complete"
|
branch.policies.last().name = branch.name + " Complete"
|
||||||
}
|
}
|
||||||
|
|
||||||
Nations += createHashmap(getFromJson(Array<Nation>::class.java, "$folderPath/Nations/Nations.json"))
|
nations += createHashmap(getFromJson(Array<Nation>::class.java, "$folderPath/Nations/Nations.json"))
|
||||||
for(nation in Nations.values) nation.setTransients()
|
for(nation in nations.values) nation.setTransients()
|
||||||
|
|
||||||
Difficulties += createHashmap(getFromJson(Array<Difficulty>::class.java, "$folderPath/Difficulties.json"))
|
difficulties += createHashmap(getFromJson(Array<Difficulty>::class.java, "$folderPath/Difficulties.json"))
|
||||||
|
|
||||||
val gameBasicsLoadTime = System.currentTimeMillis() - gameBasicsStartTime
|
val gameBasicsLoadTime = System.currentTimeMillis() - gameBasicsStartTime
|
||||||
println("Loading game basics - "+gameBasicsLoadTime+"ms")
|
println("Loading game basics - "+gameBasicsLoadTime+"ms")
|
||||||
|
|
|
@ -24,7 +24,7 @@ class Technology {
|
||||||
val lineList = ArrayList<String>() // more readable than StringBuilder, with same performance for our use-case
|
val lineList = ArrayList<String>() // more readable than StringBuilder, with same performance for our use-case
|
||||||
for (unique in uniques) lineList += unique.tr()
|
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() }
|
.filter { it.improvingTech == name }.groupBy { it.improvingTechStats.toString() }
|
||||||
for (improvement in improvedImprovements) {
|
for (improvement in improvedImprovements) {
|
||||||
val impimpString = improvement.value.joinToString { it.name.tr() } +
|
val impimpString = improvement.value.joinToString { it.name.tr() } +
|
||||||
|
@ -56,10 +56,10 @@ class Technology {
|
||||||
lineList += " * " + wonder.name.tr() + " (" + wonder.getShortDescription(ruleset) + ")"
|
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()
|
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())
|
if (tileImprovements.isNotEmpty())
|
||||||
lineList += "{Tile improvements enabled}: " + tileImprovements.joinToString { it.name.tr() }
|
lineList += "{Tile improvements enabled}: " + tileImprovements.joinToString { it.name.tr() }
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ class Technology {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getEnabledBuildings(civInfo: CivilizationInfo): List<Building> {
|
fun getEnabledBuildings(civInfo: CivilizationInfo): List<Building> {
|
||||||
var enabledBuildings = civInfo.gameInfo.ruleSet.Buildings.values.filter {
|
var enabledBuildings = civInfo.gameInfo.ruleSet.buildings.values.filter {
|
||||||
it.requiredTech == name &&
|
it.requiredTech == name &&
|
||||||
(it.uniqueTo == null || it.uniqueTo == civInfo.civName)
|
(it.uniqueTo == null || it.uniqueTo == civInfo.civName)
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ class Technology {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getEnabledUnits(civInfo:CivilizationInfo): List<BaseUnit> {
|
fun getEnabledUnits(civInfo:CivilizationInfo): List<BaseUnit> {
|
||||||
var enabledUnits = civInfo.gameInfo.ruleSet.Units.values.filter {
|
var enabledUnits = civInfo.gameInfo.ruleSet.units.values.filter {
|
||||||
it.requiredTech == name &&
|
it.requiredTech == name &&
|
||||||
(it.uniqueTo == null || it.uniqueTo == civInfo.civName)
|
(it.uniqueTo == null || it.uniqueTo == civInfo.civName)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Terrain : NamedStats() {
|
||||||
if (occursOn != null) {
|
if (occursOn != null) {
|
||||||
sb.appendln("Occurs on [${occursOn.joinToString(", ")}]".tr())
|
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()) {
|
if (resourcesFound.isNotEmpty()) {
|
||||||
sb.appendln("May contain [${resourcesFound.joinToString(", ") { it.name.tr() }}]".tr())
|
sb.appendln("May contain [${resourcesFound.joinToString(", ") { it.name.tr() }}]".tr())
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ class TileImprovement : NamedStats() {
|
||||||
stringBuilder.appendln("Can be built on ".tr() + terrainsCanBeBuiltOnString.joinToString(", "))//language can be changed when setting changes.
|
stringBuilder.appendln("Can be built on ".tr() + terrainsCanBeBuiltOnString.joinToString(", "))//language can be changed when setting changes.
|
||||||
}
|
}
|
||||||
val statsToResourceNames = HashMap<String, ArrayList<String>>()
|
val statsToResourceNames = HashMap<String, ArrayList<String>>()
|
||||||
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()
|
val statsString = tr.improvementStats.toString()
|
||||||
if (!statsToResourceNames.containsKey(statsString))
|
if (!statsToResourceNames.containsKey(statsString))
|
||||||
statsToResourceNames[statsString] = ArrayList()
|
statsToResourceNames[statsString] = ArrayList()
|
||||||
|
|
|
@ -131,7 +131,7 @@ class BaseUnit : INamed, IConstruction {
|
||||||
if (requiredTech!=null && !civInfo.tech.isResearched(requiredTech!!)) return "$requiredTech not researched"
|
if (requiredTech!=null && !civInfo.tech.isResearched(requiredTech!!)) return "$requiredTech not researched"
|
||||||
if (obsoleteTech!=null && civInfo.tech.isResearched(obsoleteTech!!)) return "Obsolete by $obsoleteTech"
|
if (obsoleteTech!=null && civInfo.tech.isResearched(obsoleteTech!!)) return "Obsolete by $obsoleteTech"
|
||||||
if (uniqueTo!=null && uniqueTo!=civInfo.civName) return "Unique to $uniqueTo"
|
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
|
if (!UncivGame.Current.settings.nuclearWeaponEnabled
|
||||||
&& (name == "Manhattan Project" || uniques.contains("Requires Manhattan Project"))) return "Disabled by setting"
|
&& (name == "Manhattan Project" || uniques.contains("Requires Manhattan Project"))) return "Disabled by setting"
|
||||||
if (uniques.contains("Requires Manhattan Project") && !civInfo.containsBuildingUnique("Enables nuclear weapon"))
|
if (uniques.contains("Requires Manhattan Project") && !civInfo.containsBuildingUnique("Enables nuclear weapon"))
|
||||||
|
|
|
@ -61,29 +61,29 @@ class CivilopediaScreen(ruleset: Ruleset) : CameraStageBaseScreen() {
|
||||||
|
|
||||||
description.setWrap(true)
|
description.setWrap(true)
|
||||||
|
|
||||||
categoryToEntries["Buildings"] = ruleset.Buildings.values
|
categoryToEntries["Buildings"] = ruleset.buildings.values
|
||||||
.map { CivilopediaEntry(it.name,it.getDescription(false, null,ruleset),
|
.map { CivilopediaEntry(it.name,it.getDescription(false, null,ruleset),
|
||||||
ImageGetter.getConstructionImage(it.name)) }
|
ImageGetter.getConstructionImage(it.name)) }
|
||||||
categoryToEntries["Resources"] = ruleset.TileResources.values
|
categoryToEntries["Resources"] = ruleset.tileResources.values
|
||||||
.map { CivilopediaEntry(it.name,it.getDescription(),
|
.map { CivilopediaEntry(it.name,it.getDescription(),
|
||||||
ImageGetter.getResourceImage(it.name,50f)) }
|
ImageGetter.getResourceImage(it.name,50f)) }
|
||||||
categoryToEntries["Terrains"] = ruleset.Terrains.values
|
categoryToEntries["Terrains"] = ruleset.terrains.values
|
||||||
.map { CivilopediaEntry(it.name,it.getDescription(ruleset)) }
|
.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),
|
.map { CivilopediaEntry(it.name,it.getDescription(ruleset),
|
||||||
ImageGetter.getImprovementIcon(it.name,50f)) }
|
ImageGetter.getImprovementIcon(it.name,50f)) }
|
||||||
categoryToEntries["Units"] = ruleset.Units.values
|
categoryToEntries["Units"] = ruleset.units.values
|
||||||
.map { CivilopediaEntry(it.name,it.getDescription(false),
|
.map { CivilopediaEntry(it.name,it.getDescription(false),
|
||||||
ImageGetter.getConstructionImage(it.name)) }
|
ImageGetter.getConstructionImage(it.name)) }
|
||||||
categoryToEntries["Nations"] = ruleset.Nations.values
|
categoryToEntries["Nations"] = ruleset.nations.values
|
||||||
.filter { it.isMajorCiv() }
|
.filter { it.isMajorCiv() }
|
||||||
.map { CivilopediaEntry(it.name,it.getUniqueString(ruleset),
|
.map { CivilopediaEntry(it.name,it.getUniqueString(ruleset),
|
||||||
ImageGetter.getNationIndicator(it,50f)) }
|
ImageGetter.getNationIndicator(it,50f)) }
|
||||||
categoryToEntries["Technologies"] = ruleset.Technologies.values
|
categoryToEntries["Technologies"] = ruleset.technologies.values
|
||||||
.map { CivilopediaEntry(it.name,it.getDescription(ruleset),
|
.map { CivilopediaEntry(it.name,it.getDescription(ruleset),
|
||||||
ImageGetter.getTechIconGroup(it.name,50f)) }
|
ImageGetter.getTechIconGroup(it.name,50f)) }
|
||||||
categoryToEntries["Promotions"] = ruleset.UnitPromotions.values
|
categoryToEntries["Promotions"] = ruleset.unitPromotions.values
|
||||||
.map { CivilopediaEntry(it.name,it.getDescription(ruleset.UnitPromotions.values, true),
|
.map { CivilopediaEntry(it.name,it.getDescription(ruleset.unitPromotions.values, true),
|
||||||
Table().apply { add(ImageGetter.getPromotionIcon(it.name)) }) }
|
Table().apply { add(ImageGetter.getPromotionIcon(it.name)) }) }
|
||||||
|
|
||||||
categoryToEntries["Tutorials"] = tutorialMiner.getCivilopediaTutorials(UncivGame.Current.settings.language)
|
categoryToEntries["Tutorials"] = tutorialMiner.getCivilopediaTutorials(UncivGame.Current.settings.language)
|
||||||
|
|
|
@ -133,7 +133,7 @@ class VictoryScreen : PickerScreen() {
|
||||||
fun culturalVictoryColumn():Table{
|
fun culturalVictoryColumn():Table{
|
||||||
val t=Table()
|
val t=Table()
|
||||||
t.defaults().pad(5f)
|
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
|
val finisher = branch.policies.last().name
|
||||||
t.add(getMilestone(finisher, playerCivInfo.policies.isAdopted(finisher))).row()
|
t.add(getMilestone(finisher, playerCivInfo.policies.isAdopted(finisher))).row()
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
||||||
constructionPickerTable.background = ImageGetter.getBackground(Color.BLACK)
|
constructionPickerTable.background = ImageGetter.getBackground(Color.BLACK)
|
||||||
|
|
||||||
val units = ArrayList<Table>()
|
val units = ArrayList<Table>()
|
||||||
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)
|
val turnsToUnit = cityConstructions.turnsToConstruction(unit.name)
|
||||||
units += getProductionButton(unit.name,
|
units += getProductionButton(unit.name,
|
||||||
unit.name.tr() + "\r\n" + turnsToUnit + (if(turnsToUnit>1) " {turns}".tr() else " {turn}".tr()),
|
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<Table>()
|
val buildableNationalWonders = ArrayList<Table>()
|
||||||
val buildableBuildings = ArrayList<Table>()
|
val buildableBuildings = ArrayList<Table>()
|
||||||
|
|
||||||
for (building in city.getRuleset().Buildings.values) {
|
for (building in city.getRuleset().buildings.values) {
|
||||||
if (!building.shouldBeDisplayed(cityConstructions) && building.name != cityConstructions.currentConstruction) continue
|
if (!building.shouldBeDisplayed(cityConstructions) && building.name != cityConstructions.currentConstruction) continue
|
||||||
val turnsToBuilding = cityConstructions.turnsToConstruction(building.name)
|
val turnsToBuilding = cityConstructions.turnsToConstruction(building.name)
|
||||||
val productionTextButton = getProductionButton(building.name,
|
val productionTextButton = getProductionButton(building.name,
|
||||||
|
|
|
@ -74,7 +74,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
||||||
}
|
}
|
||||||
}).row()
|
}).row()
|
||||||
|
|
||||||
for(improvement in ruleSet.TileImprovements.values){
|
for(improvement in ruleSet.tileImprovements.values){
|
||||||
if(improvement.name.startsWith("Remove")) continue
|
if(improvement.name.startsWith("Remove")) continue
|
||||||
val improvementImage = getHex(Color.WHITE,ImageGetter.getImprovementIcon(improvement.name,40f))
|
val improvementImage = getHex(Color.WHITE,ImageGetter.getImprovementIcon(improvement.name,40f))
|
||||||
improvementImage.onClick {
|
improvementImage.onClick {
|
||||||
|
@ -88,7 +88,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
||||||
editorPickTable.add(ScrollPane(improvementsTable)).height(mapEditorScreen.stage.height*0.7f)
|
editorPickTable.add(ScrollPane(improvementsTable)).height(mapEditorScreen.stage.height*0.7f)
|
||||||
|
|
||||||
val nationsTable = Table()
|
val nationsTable = Table()
|
||||||
for(nation in ruleSet.Nations.values){
|
for(nation in ruleSet.nations.values){
|
||||||
val nationImage = getHex(Color.WHITE,ImageGetter.getNationIndicator(nation,40f))
|
val nationImage = getHex(Color.WHITE,ImageGetter.getNationIndicator(nation,40f))
|
||||||
nationImage.onClick {
|
nationImage.onClick {
|
||||||
clearSelection()
|
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))
|
val resourceHex = getHex(Color.WHITE, ImageGetter.getResourceImage(resource.name, 40f))
|
||||||
resourceHex.onClick {
|
resourceHex.onClick {
|
||||||
clearSelection()
|
clearSelection()
|
||||||
|
@ -160,7 +160,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
||||||
tileInfo.ruleset = mapEditorScreen.ruleSet
|
tileInfo.ruleset = mapEditorScreen.ruleSet
|
||||||
|
|
||||||
val terrain = resource.terrainsCanBeFoundOn.first()
|
val terrain = resource.terrainsCanBeFoundOn.first()
|
||||||
val terrainObject = ruleSet.Terrains[terrain]!!
|
val terrainObject = ruleSet.terrains[terrain]!!
|
||||||
if (terrainObject.type == TerrainType.TerrainFeature) {
|
if (terrainObject.type == TerrainType.TerrainFeature) {
|
||||||
tileInfo.baseTerrain = when {
|
tileInfo.baseTerrain = when {
|
||||||
terrainObject.occursOn == null -> terrainObject.occursOn!!.first()
|
terrainObject.occursOn == null -> terrainObject.occursOn!!.first()
|
||||||
|
@ -179,7 +179,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addTerrainOptions(terrainFeaturesTable: Table, baseTerrainTable: Table) {
|
private fun addTerrainOptions(terrainFeaturesTable: Table, baseTerrainTable: Table) {
|
||||||
for (terrain in ruleSet.Terrains.values) {
|
for (terrain in ruleSet.terrains.values) {
|
||||||
val tileInfo = TileInfo()
|
val tileInfo = TileInfo()
|
||||||
tileInfo.ruleset = mapEditorScreen.ruleSet
|
tileInfo.ruleset = mapEditorScreen.ruleSet
|
||||||
if (terrain.type == TerrainType.TerrainFeature) {
|
if (terrain.type == TerrainType.TerrainFeature) {
|
||||||
|
|
|
@ -8,11 +8,11 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
|
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
|
||||||
import com.badlogic.gdx.utils.Array
|
import com.badlogic.gdx.utils.Array
|
||||||
import com.unciv.logic.MapSaver
|
import com.unciv.logic.MapSaver
|
||||||
|
import com.unciv.models.metadata.GameSpeed
|
||||||
import com.unciv.models.ruleset.Ruleset
|
import com.unciv.models.ruleset.Ruleset
|
||||||
import com.unciv.models.ruleset.VictoryType
|
import com.unciv.models.ruleset.VictoryType
|
||||||
import com.unciv.models.ruleset.tech.TechEra
|
import com.unciv.models.ruleset.tech.TechEra
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
import com.unciv.models.metadata.GameSpeed
|
|
||||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||||
import com.unciv.ui.utils.toLabel
|
import com.unciv.ui.utils.toLabel
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ class NewGameScreenOptionsTable(val newGameScreen: NewGameScreen, val onMultipla
|
||||||
val cityStatesSelectBox = SelectBox<Int>(CameraStageBaseScreen.skin)
|
val cityStatesSelectBox = SelectBox<Int>(CameraStageBaseScreen.skin)
|
||||||
val cityStatesArray = Array<Int>()
|
val cityStatesArray = Array<Int>()
|
||||||
|
|
||||||
(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.items = cityStatesArray
|
||||||
cityStatesSelectBox.selected = newGameParameters.numberOfCityStates
|
cityStatesSelectBox.selected = newGameParameters.numberOfCityStates
|
||||||
add(cityStatesSelectBox).pad(10f).row()
|
add(cityStatesSelectBox).pad(10f).row()
|
||||||
|
@ -157,7 +157,7 @@ class NewGameScreenOptionsTable(val newGameScreen: NewGameScreen, val onMultipla
|
||||||
|
|
||||||
private fun addDifficultySelectBox() {
|
private fun addDifficultySelectBox() {
|
||||||
add("{Difficulty}:".tr())
|
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() {
|
difficultySelectBox.addListener(object : ChangeListener() {
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||||
newGameParameters.difficulty = difficultySelectBox.selected.value
|
newGameParameters.difficulty = difficultySelectBox.selected.value
|
||||||
|
@ -221,9 +221,8 @@ class NewGameScreenOptionsTable(val newGameScreen: NewGameScreen, val onMultipla
|
||||||
|
|
||||||
fun addModCheckboxes() {
|
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 modCheckboxTable = Table().apply { defaults().pad(10f) }
|
||||||
|
|
||||||
val mods = Gdx.files.local("mods")
|
val mods = Gdx.files.local("mods")
|
||||||
|
|
|
@ -33,7 +33,7 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
|
||||||
val gameBasics = newGameScreen.ruleSet // when we add mods, this will need to change
|
val gameBasics = newGameScreen.ruleSet // when we add mods, this will need to change
|
||||||
for (player in newGameParameters.players)
|
for (player in newGameParameters.players)
|
||||||
playerListTable.add(getPlayerTable(player,gameBasics)).pad(10f).row()
|
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) }
|
playerListTable.add("+".toLabel(Color.BLACK,30).apply { this.setAlignment(Align.center) }
|
||||||
.surroundWithCircle(50f).onClick { newGameParameters.players.add(Player()); update() })
|
.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)
|
val nationImage = if (player.chosenCiv == "Random") "?".toLabel(Color.BLACK,30)
|
||||||
.apply { this.setAlignment(Align.center) }
|
.apply { this.setAlignment(Align.center) }
|
||||||
.surroundWithCircle(50f)
|
.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(nationImage)
|
||||||
nationTable.add(player.chosenCiv.toLabel()).pad(20f)
|
nationTable.add(player.chosenCiv.toLabel()).pad(20f)
|
||||||
nationTable.touchable = Touchable.enabled
|
nationTable.touchable = Touchable.enabled
|
||||||
|
@ -137,7 +137,7 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
|
||||||
nationListTable.add(randomPlayerTable).pad(10f).width(nationsPopupWidth).row()
|
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 })
|
if (player.chosenCiv != nation.name && newGameParameters.players.any { it.chosenCiv == nation.name })
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ class GreatPersonPickerScreen(val civInfo:CivilizationInfo) : PickerScreen() {
|
||||||
init {
|
init {
|
||||||
closeButton.isVisible=false
|
closeButton.isVisible=false
|
||||||
rightSideButton.setText("Choose a free great person".tr())
|
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"})
|
.filter { it.name in GreatPersonManager().statToGreatPersonMapping.values || it.name == "Great General"})
|
||||||
{
|
{
|
||||||
val button = Button(skin)
|
val button = Button(skin)
|
||||||
|
|
|
@ -38,7 +38,7 @@ class ImprovementPickerScreen(tileInfo: TileInfo, onAccept: ()->Unit) : PickerSc
|
||||||
val regularImprovements = VerticalGroup()
|
val regularImprovements = VerticalGroup()
|
||||||
regularImprovements.space(10f)
|
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 (!tileInfo.canBuildImprovement(improvement, currentPlayerCiv)) continue
|
||||||
if(improvement.name == tileInfo.improvement) continue
|
if(improvement.name == tileInfo.improvement) continue
|
||||||
if(improvement.name==tileInfo.improvementInProgress) continue
|
if(improvement.name==tileInfo.improvementInProgress) continue
|
||||||
|
|
|
@ -53,7 +53,7 @@ class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: CivilizationInfo
|
||||||
|
|
||||||
topTable.row().pad(30f)
|
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()
|
if (branch.name == "Commerce") topTable.addSeparator()
|
||||||
val branchGroup = Table()
|
val branchGroup = Table()
|
||||||
branchGroup.row().pad(20f)
|
branchGroup.row().pad(20f)
|
||||||
|
|
|
@ -41,7 +41,7 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
|
||||||
availablePromotionsGroup.space(10f)
|
availablePromotionsGroup.space(10f)
|
||||||
|
|
||||||
val unitType = unit.type
|
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())
|
it.unitTypes.contains(unitType.toString())
|
||||||
|| unit.promotions.promotions.contains(it.name) }
|
|| unit.promotions.promotions.contains(it.name) }
|
||||||
val unitAvailablePromotions = unit.promotions.getAvailablePromotions()
|
val unitAvailablePromotions = unit.promotions.getAvailablePromotions()
|
||||||
|
|
|
@ -44,7 +44,7 @@ class TechButton(techName:String, val techManager: TechManager, isWorldScreen: B
|
||||||
val civName = techManager.civInfo.civName
|
val civName = techManager.civInfo.civName
|
||||||
val gameBasics = techManager.civInfo.gameInfo.ruleSet
|
val gameBasics = techManager.civInfo.gameInfo.ruleSet
|
||||||
|
|
||||||
val tech = gameBasics.Technologies[techName]!!
|
val tech = gameBasics.technologies[techName]!!
|
||||||
|
|
||||||
for (unit in tech.getEnabledUnits(techManager.civInfo))
|
for (unit in tech.getEnabledUnits(techManager.civInfo))
|
||||||
techEnabledIcons.add(ImageGetter.getConstructionImage(unit.name).surroundWithCircle(30f))
|
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))
|
for (building in tech.getEnabledBuildings(techManager.civInfo))
|
||||||
techEnabledIcons.add(ImageGetter.getConstructionImage(building.name).surroundWithCircle(30f))
|
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.techRequired == techName || it.improvingTech == techName }
|
||||||
.filter { it.uniqueTo==null || it.uniqueTo==civName }) {
|
.filter { it.uniqueTo==null || it.uniqueTo==civName }) {
|
||||||
if (improvement.name.startsWith("Remove"))
|
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))
|
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))
|
techEnabledIcons.add(ImageGetter.getResourceImage(resource.name, 30f))
|
||||||
|
|
||||||
for (unique in tech.uniques)
|
for (unique in tech.uniques)
|
||||||
|
|
|
@ -24,7 +24,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
||||||
private var lines=ArrayList<Image>()
|
private var lines=ArrayList<Image>()
|
||||||
|
|
||||||
// All these are to counter performance problems when updating buttons for all techs.
|
// 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()
|
.filter { civTech.canBeResearched(it) }.toHashSet()
|
||||||
|
|
||||||
private val currentTechColor = colorFromRGB(7,46,43)
|
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 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) {
|
constructor(freeTechPick: Boolean, civInfo: CivilizationInfo) : this(civInfo) {
|
||||||
isFreeTechPick = freeTechPick
|
isFreeTechPick = freeTechPick
|
||||||
|
@ -75,10 +75,10 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createTechTable() {
|
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<Array<Technology?>>(columns) { arrayOfNulls(10) } // Divided into columns, then rows
|
val techMatrix = Array<Array<Technology?>>(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
|
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()
|
for (line in lines) line.remove()
|
||||||
lines.clear()
|
lines.clear()
|
||||||
|
|
||||||
for (tech in civInfo.gameInfo.ruleSet.Technologies.values) {
|
for (tech in civInfo.gameInfo.ruleSet.technologies.values) {
|
||||||
val techButton = techNameToButton[tech.name]!!
|
val techButton = techNameToButton[tech.name]!!
|
||||||
for (prerequisite in tech.prerequisites) {
|
for (prerequisite in tech.prerequisites) {
|
||||||
val prerequisiteButton = techNameToButton[prerequisite]!!
|
val prerequisiteButton = techNameToButton[prerequisite]!!
|
||||||
|
|
|
@ -112,13 +112,13 @@ object ImageGetter {
|
||||||
return getImage("OtherIcons/Stop")
|
return getImage("OtherIcons/Stop")
|
||||||
if(improvementName.startsWith("StartingLocation ")){
|
if(improvementName.startsWith("StartingLocation ")){
|
||||||
val nationName = improvementName.removePrefix("StartingLocation ")
|
val nationName = improvementName.removePrefix("StartingLocation ")
|
||||||
val nation = getRuleSet().Nations[nationName]!!
|
val nation = getRuleSet().nations[nationName]!!
|
||||||
return getNationIndicator(nation,size)
|
return getNationIndicator(nation,size)
|
||||||
}
|
}
|
||||||
|
|
||||||
val iconGroup = getImage("ImprovementIcons/$improvementName").surroundWithCircle(size)
|
val iconGroup = getImage("ImprovementIcons/$improvementName").surroundWithCircle(size)
|
||||||
|
|
||||||
val improvement = getRuleSet().TileImprovements[improvementName]!!
|
val improvement = getRuleSet().tileImprovements[improvementName]!!
|
||||||
when {
|
when {
|
||||||
improvement.food>0 -> iconGroup.circle.color= foodCircleColor
|
improvement.food>0 -> iconGroup.circle.color= foodCircleColor
|
||||||
improvement.production>0 -> iconGroup.circle.color= productionCircleColor
|
improvement.production>0 -> iconGroup.circle.color= productionCircleColor
|
||||||
|
@ -131,8 +131,8 @@ object ImageGetter {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getConstructionImage(construction: String): Image {
|
fun getConstructionImage(construction: String): Image {
|
||||||
if(getRuleSet().Buildings.containsKey(construction)) return getImage("BuildingIcons/$construction")
|
if(getRuleSet().buildings.containsKey(construction)) return getImage("BuildingIcons/$construction")
|
||||||
if(getRuleSet().Units.containsKey(construction)) return getUnitIcon(construction)
|
if(getRuleSet().units.containsKey(construction)) return getUnitIcon(construction)
|
||||||
if(construction=="Nothing") return getImage("OtherIcons/Stop")
|
if(construction=="Nothing") return getImage("OtherIcons/Stop")
|
||||||
return getStatIcon(construction)
|
return getStatIcon(construction)
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ object ImageGetter {
|
||||||
|
|
||||||
fun getResourceImage(resourceName: String, size:Float): Actor {
|
fun getResourceImage(resourceName: String, size:Float): Actor {
|
||||||
val iconGroup = getImage("ResourceIcons/$resourceName").surroundWithCircle(size)
|
val iconGroup = getImage("ResourceIcons/$resourceName").surroundWithCircle(size)
|
||||||
val resource = getRuleSet().TileResources[resourceName]!!
|
val resource = getRuleSet().tileResources[resourceName]!!
|
||||||
when {
|
when {
|
||||||
resource.food>0 -> iconGroup.circle.color= foodCircleColor
|
resource.food>0 -> iconGroup.circle.color= foodCircleColor
|
||||||
resource.production>0 -> iconGroup.circle.color= productionCircleColor
|
resource.production>0 -> iconGroup.circle.color= productionCircleColor
|
||||||
|
@ -204,7 +204,7 @@ object ImageGetter {
|
||||||
|
|
||||||
fun getTechIconGroup(techName: String, circleSize: Float): Group {
|
fun getTechIconGroup(techName: String, circleSize: Float): Group {
|
||||||
var techIconColor = Color.WHITE
|
var techIconColor = Color.WHITE
|
||||||
when (getRuleSet().Technologies[techName]!!.era().name) {
|
when (getRuleSet().technologies[techName]!!.era().name) {
|
||||||
"Ancient" -> techIconColor = colorFromRGB(255, 87, 35)
|
"Ancient" -> techIconColor = colorFromRGB(255, 87, 35)
|
||||||
"Classical" -> techIconColor = colorFromRGB(233, 31, 99)
|
"Classical" -> techIconColor = colorFromRGB(233, 31, 99)
|
||||||
"Medieval" -> techIconColor = colorFromRGB(157, 39, 176)
|
"Medieval" -> techIconColor = colorFromRGB(157, 39, 176)
|
||||||
|
|
|
@ -149,7 +149,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
||||||
add(getCloseButton("Very well."))
|
add(getCloseButton("Very well."))
|
||||||
}
|
}
|
||||||
AlertType.WonderBuilt -> {
|
AlertType.WonderBuilt -> {
|
||||||
val wonder = worldScreen.gameInfo.ruleSet.Buildings[popupAlert.value]!!
|
val wonder = worldScreen.gameInfo.ruleSet.buildings[popupAlert.value]!!
|
||||||
addGoodSizedLabel(wonder.name)
|
addGoodSizedLabel(wonder.name)
|
||||||
addSeparator()
|
addSeparator()
|
||||||
val centerTable = Table()
|
val centerTable = Table()
|
||||||
|
@ -162,7 +162,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
||||||
}
|
}
|
||||||
AlertType.TechResearched -> {
|
AlertType.TechResearched -> {
|
||||||
val gameBasics = worldScreen.gameInfo.ruleSet
|
val gameBasics = worldScreen.gameInfo.ruleSet
|
||||||
val tech = gameBasics.Technologies[popupAlert.value]!!
|
val tech = gameBasics.technologies[popupAlert.value]!!
|
||||||
addGoodSizedLabel(tech.name)
|
addGoodSizedLabel(tech.name)
|
||||||
addSeparator()
|
addSeparator()
|
||||||
val centerTable = Table()
|
val centerTable = Table()
|
||||||
|
|
|
@ -296,7 +296,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||||
techButtonHolder.isVisible = viewingCiv.cities.isNotEmpty()
|
techButtonHolder.isVisible = viewingCiv.cities.isNotEmpty()
|
||||||
techButtonHolder.clearChildren()
|
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())
|
if (viewingCiv.tech.currentTechnology() == null && researchableTechs.isEmpty())
|
||||||
viewingCiv.tech.techsToResearch.add(Constants.futureTech)
|
viewingCiv.tech.techsToResearch.add(Constants.futureTech)
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
||||||
private fun getResourceTable(): Table {
|
private fun getResourceTable(): Table {
|
||||||
val resourceTable = Table()
|
val resourceTable = Table()
|
||||||
resourceTable.defaults().pad(5f)
|
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!!) }
|
.filter { it.resourceType == ResourceType.Strategic } // && currentPlayerCivInfo.tech.isResearched(it.revealedBy!!) }
|
||||||
for (resource in revealedStrategicResources) {
|
for (resource in revealedStrategicResources) {
|
||||||
val resourceImage = ImageGetter.getResourceImage(resource.name,20f)
|
val resourceImage = ImageGetter.getResourceImage(resource.name,20f)
|
||||||
|
@ -105,7 +105,7 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
||||||
|
|
||||||
|
|
||||||
internal fun update(civInfo: CivilizationInfo) {
|
internal fun update(civInfo: CivilizationInfo) {
|
||||||
val revealedStrategicResources = civInfo.gameInfo.ruleSet.TileResources.values
|
val revealedStrategicResources = civInfo.gameInfo.ruleSet.tileResources.values
|
||||||
.filter { it.resourceType == ResourceType.Strategic }
|
.filter { it.resourceType == ResourceType.Strategic }
|
||||||
val civResources = civInfo.getCivResources()
|
val civResources = civInfo.getCivResources()
|
||||||
for (resource in revealedStrategicResources) {
|
for (resource in revealedStrategicResources) {
|
||||||
|
|
|
@ -142,7 +142,7 @@ class UnitActions {
|
||||||
actionList += UnitAction("Construct improvement",
|
actionList += UnitAction("Construct improvement",
|
||||||
unit.currentMovement > 0
|
unit.currentMovement > 0
|
||||||
&& !tile.isCityCenter()
|
&& !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()
|
currentAction = unit.currentTile.hasImprovementInProgress()
|
||||||
) { worldScreen.game.setScreen(ImprovementPickerScreen(tile) { unitTable.selectedUnit = null }) }
|
) { 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.isWater // because fishing boats can enter cities, and if there's oil in the city... ;)
|
||||||
&& tile.improvement==null
|
&& tile.improvement==null
|
||||||
&& tile.getTileResource().improvement == improvement
|
&& 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) {
|
actionList += UnitAction("Create [$improvement]", unit.currentMovement >0) {
|
||||||
tile.improvement = improvement
|
tile.improvement = improvement
|
||||||
|
|
|
@ -20,7 +20,7 @@ class BasicTests {
|
||||||
@Test
|
@Test
|
||||||
fun loadRuleset() {
|
fun loadRuleset() {
|
||||||
Assert.assertTrue("This test will only pass when the jsons can be loaded",
|
Assert.assertTrue("This test will only pass when the jsons can be loaded",
|
||||||
Ruleset(true).Buildings.size > 0)
|
Ruleset(true).buildings.size > 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -34,7 +34,7 @@ class BasicTests {
|
||||||
// and we try to work on its upgrade, we'll get an exception - see techManager
|
// and we try to work on its upgrade, we'll get an exception - see techManager
|
||||||
@Test
|
@Test
|
||||||
fun allObsoletingUnitsHaveUpgrades() {
|
fun allObsoletingUnitsHaveUpgrades() {
|
||||||
val units: Collection<BaseUnit> = Ruleset(true).Units.values
|
val units: Collection<BaseUnit> = Ruleset(true).units.values
|
||||||
var allObsoletingUnitsHaveUpgrades = true
|
var allObsoletingUnitsHaveUpgrades = true
|
||||||
for (unit in units) {
|
for (unit in units) {
|
||||||
if (unit.obsoleteTech != null && unit.upgradesTo == null) {
|
if (unit.obsoleteTech != null && unit.upgradesTo == null) {
|
||||||
|
|
|
@ -30,7 +30,7 @@ class TranslationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun allUnitsHaveTranslation() {
|
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",
|
Assert.assertTrue("This test will only pass when there is a translation for all units",
|
||||||
allUnitsHaveTranslation)
|
allUnitsHaveTranslation)
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ class TranslationTests {
|
||||||
@Test
|
@Test
|
||||||
fun allUnitUniquesHaveTranslation() {
|
fun allUnitUniquesHaveTranslation() {
|
||||||
val strings: MutableSet<String> = HashSet()
|
val strings: MutableSet<String> = 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.startsWith("Penalty")
|
||||||
&& !unique.contains("[")) // templates
|
&& !unique.contains("[")) // templates
|
||||||
strings.add(unique)
|
strings.add(unique)
|
||||||
|
@ -48,7 +48,7 @@ class TranslationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun allBuildingsHaveTranslation() {
|
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",
|
Assert.assertTrue("This test will only pass when there is a translation for all buildings",
|
||||||
allBuildingsHaveTranslation)
|
allBuildingsHaveTranslation)
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ class TranslationTests {
|
||||||
@Test
|
@Test
|
||||||
fun allBuildingUniquesHaveTranslation() {
|
fun allBuildingUniquesHaveTranslation() {
|
||||||
val strings: MutableSet<String> = HashSet()
|
val strings: MutableSet<String> = HashSet()
|
||||||
for (building in ruleSet.Buildings.values) {
|
for (building in ruleSet.buildings.values) {
|
||||||
strings.addAll(building.uniques)
|
strings.addAll(building.uniques)
|
||||||
}
|
}
|
||||||
val allStringsHaveTranslation = allStringAreTranslated(strings)
|
val allStringsHaveTranslation = allStringAreTranslated(strings)
|
||||||
|
@ -66,7 +66,7 @@ class TranslationTests {
|
||||||
@Test
|
@Test
|
||||||
fun allBuildingQuotesHaveTranslation() {
|
fun allBuildingQuotesHaveTranslation() {
|
||||||
val strings: MutableSet<String> = HashSet()
|
val strings: MutableSet<String> = HashSet()
|
||||||
for (building in ruleSet.Buildings.values) {
|
for (building in ruleSet.buildings.values) {
|
||||||
if (building.quote == "") continue
|
if (building.quote == "") continue
|
||||||
strings.add(building.quote)
|
strings.add(building.quote)
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ class TranslationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun allTerrainsHaveTranslation() {
|
fun allTerrainsHaveTranslation() {
|
||||||
val strings: Set<String> = ruleSet.Terrains.keys
|
val strings: Set<String> = ruleSet.terrains.keys
|
||||||
val allStringsHaveTranslation = allStringAreTranslated(strings)
|
val allStringsHaveTranslation = allStringAreTranslated(strings)
|
||||||
Assert.assertTrue("This test will only pass when there is a translation for all buildings",
|
Assert.assertTrue("This test will only pass when there is a translation for all buildings",
|
||||||
allStringsHaveTranslation)
|
allStringsHaveTranslation)
|
||||||
|
@ -84,7 +84,7 @@ class TranslationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun allImprovementsHaveTranslation() {
|
fun allImprovementsHaveTranslation() {
|
||||||
val strings: Set<String> = ruleSet.TileImprovements.keys
|
val strings: Set<String> = ruleSet.tileImprovements.keys
|
||||||
val allStringsHaveTranslation = allStringAreTranslated(strings)
|
val allStringsHaveTranslation = allStringAreTranslated(strings)
|
||||||
Assert.assertTrue("This test will only pass when there is a translation for all improvements",
|
Assert.assertTrue("This test will only pass when there is a translation for all improvements",
|
||||||
allStringsHaveTranslation)
|
allStringsHaveTranslation)
|
||||||
|
@ -93,7 +93,7 @@ class TranslationTests {
|
||||||
@Test
|
@Test
|
||||||
fun allImprovementUniquesHaveTranslation() {
|
fun allImprovementUniquesHaveTranslation() {
|
||||||
val strings: MutableSet<String> = HashSet()
|
val strings: MutableSet<String> = HashSet()
|
||||||
for (improvement in ruleSet.TileImprovements.values) {
|
for (improvement in ruleSet.tileImprovements.values) {
|
||||||
strings.addAll(improvement.uniques)
|
strings.addAll(improvement.uniques)
|
||||||
}
|
}
|
||||||
val allStringsHaveTranslation = allStringAreTranslated(strings)
|
val allStringsHaveTranslation = allStringAreTranslated(strings)
|
||||||
|
@ -102,7 +102,7 @@ class TranslationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun allTechnologiesHaveTranslation() {
|
fun allTechnologiesHaveTranslation() {
|
||||||
val strings: Set<String> = ruleSet.Technologies.keys
|
val strings: Set<String> = ruleSet.technologies.keys
|
||||||
val allStringsHaveTranslation = allStringAreTranslated(strings)
|
val allStringsHaveTranslation = allStringAreTranslated(strings)
|
||||||
Assert.assertTrue("This test will only pass when there is a translation for all technologies",
|
Assert.assertTrue("This test will only pass when there is a translation for all technologies",
|
||||||
allStringsHaveTranslation)
|
allStringsHaveTranslation)
|
||||||
|
@ -111,7 +111,7 @@ class TranslationTests {
|
||||||
@Test
|
@Test
|
||||||
fun allTechnologiesQuotesHaveTranslation() {
|
fun allTechnologiesQuotesHaveTranslation() {
|
||||||
val strings: MutableSet<String> = HashSet()
|
val strings: MutableSet<String> = HashSet()
|
||||||
for (tech in ruleSet.Technologies.values) {
|
for (tech in ruleSet.technologies.values) {
|
||||||
strings.add(tech.quote)
|
strings.add(tech.quote)
|
||||||
}
|
}
|
||||||
val allStringsHaveTranslation = allStringAreTranslated(strings)
|
val allStringsHaveTranslation = allStringAreTranslated(strings)
|
||||||
|
@ -121,7 +121,7 @@ class TranslationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun allPromotionsHaveTranslation() {
|
fun allPromotionsHaveTranslation() {
|
||||||
val strings: Set<String> = ruleSet.UnitPromotions.keys
|
val strings: Set<String> = ruleSet.unitPromotions.keys
|
||||||
val allStringsHaveTranslation = allStringAreTranslated(strings)
|
val allStringsHaveTranslation = allStringAreTranslated(strings)
|
||||||
Assert.assertTrue("This test will only pass when there is a translation for all promotions",
|
Assert.assertTrue("This test will only pass when there is a translation for all promotions",
|
||||||
allStringsHaveTranslation)
|
allStringsHaveTranslation)
|
||||||
|
|
Loading…
Reference in a new issue