mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-09 23:39:40 +07:00
FINALLY managed to un-staticify GameBasics, this means the game can potentially recognize different rulesets!
This commit is contained in:
@ -19,7 +19,7 @@ import java.util.*
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
class UncivGame(val version: String) : Game() {
|
||||
var gameInfo: GameInfo = GameInfo()
|
||||
lateinit var gameInfo: GameInfo
|
||||
lateinit var settings : GameSettings
|
||||
/**
|
||||
* This exists so that when debugging we can see the entire map.
|
||||
@ -36,24 +36,26 @@ class UncivGame(val version: String) : Game() {
|
||||
val musicLocation = "music/thatched-villagers.mp3"
|
||||
var isInitialized=false
|
||||
|
||||
lateinit var gameBasics:GameBasics
|
||||
|
||||
override fun create() {
|
||||
Current = this
|
||||
gameBasics = GameBasics()
|
||||
|
||||
if(Gdx.app.type!= Application.ApplicationType.Desktop)
|
||||
viewEntireMapForDebug=false
|
||||
Gdx.input.setCatchKey(Input.Keys.BACK, true)
|
||||
GameBasics.run { } // just to initialize the GameBasics
|
||||
settings = GameSaver().getGeneralSettings()
|
||||
if(settings.userId=="") { // assign permanent user id
|
||||
settings.userId = UUID.randomUUID().toString()
|
||||
settings.save()
|
||||
}
|
||||
if (GameSaver().getSave("Autosave").exists()) {
|
||||
try {
|
||||
// try {
|
||||
loadGame("Autosave")
|
||||
} catch (ex: Exception) { // silent fail if we can't read the autosave
|
||||
startNewGame()
|
||||
}
|
||||
// } catch (ex: Exception) { // silent fail if we can't read the autosave
|
||||
// startNewGame()
|
||||
// }
|
||||
}
|
||||
else setScreen(LanguagePickerScreen())
|
||||
|
||||
|
@ -11,7 +11,6 @@ import com.unciv.logic.civilization.PlayerType
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.logic.map.TileMap
|
||||
import com.unciv.models.gamebasics.Difficulty
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.metadata.GameParameters
|
||||
import java.util.*
|
||||
|
||||
@ -21,6 +20,7 @@ class GameInfo {
|
||||
/** This is used in multiplayer games, where I may have a saved game state on my phone
|
||||
* that is inconsistent with the saved game on the cloud */
|
||||
@Transient var isUpToDate=false
|
||||
@Transient var gameBasics = UncivGame.Current.gameBasics
|
||||
|
||||
var civilizations = mutableListOf<CivilizationInfo>()
|
||||
var difficulty="Chieftain" // difficulty is game-wide, think what would happen if 2 human players could play on different difficulties?
|
||||
@ -165,13 +165,13 @@ class GameInfo {
|
||||
fun placeBarbarianUnit(tileToPlace: TileInfo) {
|
||||
// if we don't make this into a separate list then the retain() will happen on the Tech keys,
|
||||
// which effectively removes those techs from the game and causes all sorts of problems
|
||||
val allResearchedTechs = GameBasics.Technologies.keys.toMutableList()
|
||||
val allResearchedTechs = gameBasics.Technologies.keys.toMutableList()
|
||||
for (civ in civilizations.filter { !it.isBarbarian() && !it.isDefeated() }) {
|
||||
allResearchedTechs.retainAll(civ.tech.techsResearched)
|
||||
}
|
||||
val barbarianCiv = getBarbarianCivilization()
|
||||
barbarianCiv.tech.techsResearched = allResearchedTechs.toHashSet()
|
||||
val unitList = GameBasics.Units.values
|
||||
val unitList = gameBasics.Units.values
|
||||
.filter { !it.unitType.isCivilian()}
|
||||
.filter { it.isBuildable(barbarianCiv) }
|
||||
|
||||
@ -203,7 +203,7 @@ class GameInfo {
|
||||
}
|
||||
}
|
||||
|
||||
tileMap.setTransients()
|
||||
tileMap.setTransients(gameBasics)
|
||||
|
||||
if(currentPlayer=="") currentPlayer=civilizations.first { it.isPlayerCivilization() }.civName
|
||||
currentPlayerCiv=getCivilization(currentPlayer)
|
||||
@ -217,7 +217,7 @@ class GameInfo {
|
||||
getCurrentPlayerCivilization().playerType=PlayerType.Human
|
||||
if(getCurrentPlayerCivilization().difficulty!="Chieftain")
|
||||
difficulty= getCurrentPlayerCivilization().difficulty
|
||||
difficultyObject = GameBasics.Difficulties[difficulty]!!
|
||||
difficultyObject = gameBasics.Difficulties[difficulty]!!
|
||||
|
||||
// We have to remove all deprecated buildings from all cities BEFORE we update a single one, or run setTransients on the civs,
|
||||
// because updating leads to getting the building uniques from the civ info,
|
||||
|
@ -2,6 +2,7 @@ package com.unciv.logic
|
||||
|
||||
import com.badlogic.gdx.math.Vector2
|
||||
import com.unciv.Constants
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.map.*
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
@ -16,18 +17,19 @@ class GameStarter{
|
||||
val gameInfo = GameInfo()
|
||||
|
||||
gameInfo.gameParameters = newGameParameters
|
||||
val gameBasics = UncivGame.Current.gameBasics
|
||||
|
||||
if(newGameParameters.mapType==MapType.file)
|
||||
gameInfo.tileMap = MapSaver().loadMap(newGameParameters.mapFileName!!)
|
||||
else gameInfo.tileMap = MapGenerator().generateMap(newGameParameters)
|
||||
else gameInfo.tileMap = MapGenerator().generateMap(newGameParameters, gameBasics)
|
||||
|
||||
gameInfo.tileMap.setTransients()
|
||||
gameInfo.tileMap.setTransients(gameBasics)
|
||||
|
||||
gameInfo.tileMap.gameInfo = gameInfo // need to set this transient before placing units in the map
|
||||
gameInfo.difficulty = newGameParameters.difficulty
|
||||
|
||||
|
||||
addCivilizations(newGameParameters, gameInfo)
|
||||
addCivilizations(newGameParameters, gameInfo,gameBasics) // this is before the setTransients so gameInfo doesn't yet have the gameBasics
|
||||
|
||||
gameInfo.setTransients() // needs to be before placeBarbarianUnit because it depends on the tilemap having its gameinfo set
|
||||
|
||||
@ -38,7 +40,7 @@ class GameStarter{
|
||||
for (tech in gameInfo.getDifficulty().aiFreeTechs)
|
||||
civInfo.tech.addTechnology(tech)
|
||||
|
||||
for (tech in GameBasics.Technologies.values
|
||||
for (tech in gameBasics.Technologies.values
|
||||
.filter { it.era() < newGameParameters.startingEra })
|
||||
if (!civInfo.tech.isResearched(tech.name))
|
||||
civInfo.tech.addTechnology(tech.name)
|
||||
@ -52,9 +54,9 @@ class GameStarter{
|
||||
return gameInfo
|
||||
}
|
||||
|
||||
private fun addCivilizations(newGameParameters: GameParameters, gameInfo: GameInfo) {
|
||||
private fun addCivilizations(newGameParameters: GameParameters, gameInfo: GameInfo, gameBasics: GameBasics) {
|
||||
val availableCivNames = Stack<String>()
|
||||
availableCivNames.addAll(GameBasics.Nations.filter { !it.value.isCityState() }.keys.shuffled())
|
||||
availableCivNames.addAll(gameBasics.Nations.filter { !it.value.isCityState() }.keys.shuffled())
|
||||
availableCivNames.removeAll(newGameParameters.players.map { it.chosenCiv })
|
||||
availableCivNames.remove("Barbarians")
|
||||
|
||||
@ -80,7 +82,7 @@ class GameStarter{
|
||||
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,
|
||||
// and then all the other city states in a random order! Because the sortedBy function is stable!
|
||||
availableCityStatesNames.addAll(GameBasics.Nations.filter { it.value.isCityState() }.keys
|
||||
availableCityStatesNames.addAll(gameBasics.Nations.filter { it.value.isCityState() }.keys
|
||||
.shuffled().sortedByDescending { it in cityStatesWithStartingLocations })
|
||||
|
||||
for (cityStateName in availableCityStatesNames.take(newGameParameters.numberOfCityStates)) {
|
||||
@ -97,7 +99,7 @@ class GameStarter{
|
||||
|
||||
// For later starting eras, or for civs like Polynesia with a different Warrior, we need different starting units
|
||||
fun getWarriorEquivalent(civ: CivilizationInfo): String {
|
||||
val availableMilitaryUnits = GameBasics.Units.values.filter {
|
||||
val availableMilitaryUnits = gameInfo.gameBasics.Units.values.filter {
|
||||
it.isBuildable(civ)
|
||||
&& it.unitType.isLandUnit()
|
||||
&& !it.unitType.isCivilian()
|
||||
|
@ -257,7 +257,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
||||
|
||||
private fun addFoodBuildingChoice() {
|
||||
val foodBuilding = buildableNotWonders.filter { it.isStatRelated(Stat.Food)
|
||||
|| it.getBaseBuilding().name == "Aqueduct" || it.getBaseBuilding().name == "Medical Lab"} // only stat related in unique
|
||||
|| it.getBaseBuilding(civInfo.gameInfo.gameBasics).name == "Aqueduct" || it.getBaseBuilding(civInfo.gameInfo.gameBasics).name == "Medical Lab"} // only stat related in unique
|
||||
.minBy { it.cost }
|
||||
if (foodBuilding != null) {
|
||||
var modifier = 1f
|
||||
|
@ -10,7 +10,6 @@ import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
|
||||
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
||||
import com.unciv.logic.map.MapUnit
|
||||
import com.unciv.logic.trade.*
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.VictoryType
|
||||
import com.unciv.models.gamebasics.tech.Technology
|
||||
import com.unciv.models.gamebasics.tr
|
||||
@ -171,7 +170,8 @@ class NextTurnAutomation{
|
||||
|
||||
private fun chooseTechToResearch(civInfo: CivilizationInfo) {
|
||||
if (civInfo.tech.techsToResearch.isEmpty()) {
|
||||
val researchableTechs = GameBasics.Technologies.values.filter { !civInfo.tech.isResearched(it.name) && civInfo.tech.canBeResearched(it.name) }
|
||||
val researchableTechs = civInfo.gameInfo.gameBasics.Technologies.values
|
||||
.filter { !civInfo.tech.isResearched(it.name) && civInfo.tech.canBeResearched(it.name) }
|
||||
val techsGroups = researchableTechs.groupBy { it.cost }
|
||||
val costs = techsGroups.keys.sorted()
|
||||
|
||||
@ -198,7 +198,7 @@ class NextTurnAutomation{
|
||||
private fun adoptPolicy(civInfo: CivilizationInfo) {
|
||||
while (civInfo.policies.canAdoptPolicy()) {
|
||||
|
||||
val adoptablePolicies = GameBasics.PolicyBranches.values
|
||||
val adoptablePolicies = civInfo.gameInfo.gameBasics.PolicyBranches.values
|
||||
.flatMap { it.policies.union(listOf(it)) }
|
||||
.filter { civInfo.policies.isAdoptable(it) }
|
||||
|
||||
@ -215,7 +215,10 @@ class NextTurnAutomation{
|
||||
VictoryType.Neutral -> listOf()
|
||||
}
|
||||
val policiesByPreference = adoptablePolicies
|
||||
.groupBy { if(it.branch in policyBranchPriority) policyBranchPriority.indexOf(it.branch) else 10 }
|
||||
.groupBy {
|
||||
if (it.branch.name in policyBranchPriority)
|
||||
policyBranchPriority.indexOf(it.branch.name) else 10
|
||||
}
|
||||
|
||||
val preferredPolicies = policiesByPreference.minBy { it.key }!!.value
|
||||
|
||||
|
@ -10,7 +10,6 @@ import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
|
||||
import com.unciv.logic.map.MapUnit
|
||||
import com.unciv.logic.map.PathsToTilesWithinTurn
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.unit.UnitType
|
||||
import com.unciv.ui.worldscreen.unit.UnitAction
|
||||
import com.unciv.ui.worldscreen.unit.UnitActions
|
||||
@ -267,7 +266,7 @@ class UnitAutomation{
|
||||
|
||||
private fun tryUpgradeUnit(unit: MapUnit, unitActions: List<UnitAction>): Boolean {
|
||||
if (unit.baseUnit().upgradesTo != null) {
|
||||
val upgradedUnit = GameBasics.Units[unit.baseUnit().upgradesTo!!]!!
|
||||
val upgradedUnit = unit.civInfo.gameInfo.gameBasics.Units[unit.baseUnit().upgradesTo!!]!!
|
||||
if (upgradedUnit.isBuildable(unit.civInfo)) {
|
||||
val upgradeAction = unitActions.firstOrNull { it.name.startsWith("Upgrade to") }
|
||||
if (upgradeAction != null && upgradeAction.canAct) {
|
||||
|
@ -7,7 +7,6 @@ import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.map.BFS
|
||||
import com.unciv.logic.map.MapUnit
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tile.TileImprovement
|
||||
|
||||
class WorkerAutomation(val unit: MapUnit) {
|
||||
@ -106,8 +105,10 @@ class WorkerAutomation(val unit: MapUnit) {
|
||||
unit.movement.headTowards(tileToConstructRoadOn)
|
||||
}
|
||||
if(unit.currentMovement>0 && unit.currentTile==tileToConstructRoadOn
|
||||
&& unit.currentTile.improvementInProgress!=targetRoad.name)
|
||||
tileToConstructRoadOn.startWorkingOnImprovement(targetRoad.improvement()!!,unit.civInfo)
|
||||
&& unit.currentTile.improvementInProgress!=targetRoad.name) {
|
||||
val improvement = targetRoad.improvement(unit.civInfo.gameInfo.gameBasics)!!
|
||||
tileToConstructRoadOn.startWorkingOnImprovement(improvement, unit.civInfo)
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -198,7 +199,7 @@ class WorkerAutomation(val unit: MapUnit) {
|
||||
else -> throw Exception("No improvement found for "+tile.baseTerrain)
|
||||
}
|
||||
if (improvementString == null) return null
|
||||
return GameBasics.TileImprovements[improvementString]!!
|
||||
return unit.civInfo.gameInfo.gameBasics.TileImprovements[improvementString]!!
|
||||
}
|
||||
|
||||
}
|
@ -4,8 +4,8 @@ import com.unciv.Constants
|
||||
import com.unciv.logic.city.CityInfo
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.unit.UnitType
|
||||
import kotlin.math.pow
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class CityCombatant(val city: CityInfo) : ICombatant {
|
||||
@ -41,8 +41,8 @@ class CityCombatant(val city: CityInfo) : ICombatant {
|
||||
if(cityTile.baseTerrain== Constants.hill) strength+=5
|
||||
// as tech progresses so does city strength
|
||||
val techsPercentKnown: Float = city.civInfo.tech.techsResearched.count().toFloat() /
|
||||
GameBasics.Technologies.count()
|
||||
strength += Math.pow(techsPercentKnown*5.5, 2.8).toFloat()
|
||||
getCivInfo().gameInfo.gameBasics.Technologies.count()
|
||||
strength += (techsPercentKnown * 5.5).pow(2.8).toFloat()
|
||||
|
||||
// The way all of this adds up...
|
||||
// All ancient techs - 0.5 extra, Classical - 2.7, Medieval - 8, Renaissance - 17.5,
|
||||
|
@ -6,7 +6,6 @@ import com.unciv.logic.automation.ConstructionAutomation
|
||||
import com.unciv.logic.civilization.AlertType
|
||||
import com.unciv.logic.civilization.PopupAlert
|
||||
import com.unciv.models.gamebasics.Building
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.models.stats.Stats
|
||||
import com.unciv.ui.utils.withItem
|
||||
@ -34,10 +33,10 @@ class CityConstructions {
|
||||
return toReturn
|
||||
}
|
||||
|
||||
internal fun getBuildableBuildings(): List<Building> = GameBasics.Buildings.values
|
||||
internal fun getBuildableBuildings(): List<Building> = cityInfo.getGameBasics().Buildings.values
|
||||
.filter { it.isBuildable(this) }
|
||||
|
||||
fun getConstructableUnits() = GameBasics.Units.values
|
||||
fun getConstructableUnits() = cityInfo.getGameBasics().Units.values
|
||||
.filter { it.isBuildable(this) }
|
||||
|
||||
fun getStats(): Stats {
|
||||
@ -95,10 +94,11 @@ class CityConstructions {
|
||||
}
|
||||
|
||||
internal fun getConstruction(constructionName: String): IConstruction {
|
||||
if (GameBasics.Buildings.containsKey(constructionName))
|
||||
return GameBasics.Buildings[constructionName]!!
|
||||
else if (GameBasics.Units.containsKey(constructionName))
|
||||
return GameBasics.Units[constructionName]!!
|
||||
val gameBasics = cityInfo.getGameBasics()
|
||||
if (gameBasics.Buildings.containsKey(constructionName))
|
||||
return gameBasics.Buildings[constructionName]!!
|
||||
else if (gameBasics.Units.containsKey(constructionName))
|
||||
return gameBasics.Units[constructionName]!!
|
||||
else{
|
||||
if(constructionName=="") return getConstruction("Nothing")
|
||||
val special = SpecialConstruction.getSpecialConstructions().firstOrNull{it.name==constructionName}
|
||||
@ -155,7 +155,7 @@ class CityConstructions {
|
||||
|
||||
//region state changing functions
|
||||
fun setTransients(){
|
||||
builtBuildingObjects = ArrayList(builtBuildings.map { GameBasics.Buildings[it]!! })
|
||||
builtBuildingObjects = ArrayList(builtBuildings.map { cityInfo.getGameBasics().Buildings[it]!! })
|
||||
}
|
||||
|
||||
fun addProductionPoints(productionToAdd: Int) {
|
||||
@ -218,13 +218,13 @@ class CityConstructions {
|
||||
}
|
||||
|
||||
fun addBuilding(buildingName:String){
|
||||
val buildingObject = GameBasics.Buildings[buildingName]!!
|
||||
val buildingObject = cityInfo.getGameBasics().Buildings[buildingName]!!
|
||||
builtBuildingObjects = builtBuildingObjects.withItem(buildingObject)
|
||||
builtBuildings.add(buildingName)
|
||||
}
|
||||
|
||||
fun removeBuilding(buildingName:String){
|
||||
val buildingObject = GameBasics.Buildings[buildingName]!!
|
||||
val buildingObject = cityInfo.getGameBasics().Buildings[buildingName]!!
|
||||
builtBuildingObjects = builtBuildingObjects.withoutItem(buildingObject)
|
||||
builtBuildings.remove(buildingName)
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ import com.unciv.logic.map.TileMap
|
||||
import com.unciv.logic.trade.TradeLogic
|
||||
import com.unciv.logic.trade.TradeOffer
|
||||
import com.unciv.logic.trade.TradeType
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tile.ResourceSupplyList
|
||||
import com.unciv.models.gamebasics.tile.ResourceType
|
||||
import com.unciv.models.stats.Stats
|
||||
@ -120,6 +119,8 @@ class CityInfo {
|
||||
fun getTiles(): List<TileInfo> = tiles.map { tileMap[it] }
|
||||
fun getWorkableTiles() = getTiles().filter { it in tilesInRange }
|
||||
|
||||
fun getGameBasics() = civInfo.gameInfo.gameBasics
|
||||
|
||||
fun getCityResources(): ResourceSupplyList {
|
||||
val cityResources = ResourceSupplyList()
|
||||
|
||||
@ -133,7 +134,7 @@ class CityInfo {
|
||||
}
|
||||
|
||||
for (building in cityConstructions.getBuiltBuildings().filter { it.requiredResource != null }) {
|
||||
val resource = GameBasics.TileResources[building.requiredResource]!!
|
||||
val resource = getGameBasics().TileResources[building.requiredResource]!!
|
||||
cityResources.add(resource, -1, "Buildings")
|
||||
}
|
||||
|
||||
@ -160,7 +161,7 @@ class CityInfo {
|
||||
|
||||
// Even if the improvement exists (we conquered an enemy city or somesuch) or we have a city on it, we won't get the resource until the correct tech is researched
|
||||
if (resource.improvement!=null){
|
||||
val improvement = GameBasics.TileImprovements[resource.improvement!!]!!
|
||||
val improvement = getGameBasics().TileImprovements[resource.improvement!!]!!
|
||||
if(improvement.techRequired!=null && !civInfo.tech.isResearched(improvement.techRequired!!)) return 0
|
||||
}
|
||||
|
||||
@ -474,15 +475,15 @@ class CityInfo {
|
||||
|
||||
private fun tryUpdateRoadStatus(){
|
||||
if(getCenterTile().roadStatus==RoadStatus.None
|
||||
&& GameBasics.TileImprovements["Road"]!!.techRequired in civInfo.tech.techsResearched)
|
||||
&& getGameBasics().TileImprovements["Road"]!!.techRequired in civInfo.tech.techsResearched)
|
||||
getCenterTile().roadStatus=RoadStatus.Road
|
||||
|
||||
else if(getCenterTile().roadStatus!=RoadStatus.Railroad
|
||||
&& GameBasics.TileImprovements["Railroad"]!!.techRequired in civInfo.tech.techsResearched)
|
||||
&& getGameBasics().TileImprovements["Railroad"]!!.techRequired in civInfo.tech.techsResearched)
|
||||
getCenterTile().roadStatus=RoadStatus.Railroad
|
||||
}
|
||||
|
||||
fun getGoldForSellingBuilding(buildingName:String) = GameBasics.Buildings[buildingName]!!.cost / 10
|
||||
fun getGoldForSellingBuilding(buildingName:String) = getGameBasics().Buildings[buildingName]!!.cost / 10
|
||||
|
||||
fun sellBuilding(buildingName:String){
|
||||
cityConstructions.builtBuildings.remove(buildingName)
|
||||
|
@ -7,7 +7,6 @@ import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
||||
import com.unciv.logic.map.BFS
|
||||
import com.unciv.logic.map.RoadStatus
|
||||
import com.unciv.models.gamebasics.Building
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.unit.BaseUnit
|
||||
import com.unciv.models.gamebasics.unit.UnitType
|
||||
import com.unciv.models.stats.Stat
|
||||
@ -75,7 +74,7 @@ class CityStats {
|
||||
|
||||
private fun getStatPercentBonusesFromRailroad(): Stats {
|
||||
val stats = Stats()
|
||||
val techEnablingRailroad = GameBasics.TileImprovements["Railroad"]!!.techRequired!!
|
||||
val techEnablingRailroad = cityInfo.getGameBasics().TileImprovements["Railroad"]!!.techRequired!!
|
||||
// If we conquered enemy cities connected by railroad, but we don't yet have that tech,
|
||||
// we shouldn't get bonuses, it's as if the tracks aare layed out but we can't operate them.
|
||||
if (cityInfo.civInfo.tech.isResearched(techEnablingRailroad)
|
||||
|
@ -4,7 +4,6 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.unciv.logic.city.CityInfo
|
||||
import com.unciv.logic.map.BFS
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tile.ResourceSupplyList
|
||||
import java.util.*
|
||||
import kotlin.collections.HashMap
|
||||
@ -163,7 +162,8 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo){
|
||||
}
|
||||
|
||||
for (dip in civInfo.diplomacy.values) newDetailedCivResources.add(dip.resourcesFromTrade())
|
||||
for(resource in civInfo.getCivUnits().mapNotNull { it.baseUnit.requiredResource }.map { GameBasics.TileResources[it]!! })
|
||||
for(resource in civInfo.getCivUnits().mapNotNull { it.baseUnit.requiredResource }
|
||||
.map { civInfo.gameInfo.gameBasics.TileResources[it]!! })
|
||||
newDetailedCivResources.add(resource,-1,"Units")
|
||||
civInfo.detailedCivResources = newDetailedCivResources
|
||||
}
|
||||
|
@ -107,13 +107,13 @@ class CivilizationInfo {
|
||||
//region pure functions
|
||||
fun getDifficulty():Difficulty {
|
||||
if (isPlayerCivilization()) return gameInfo.getDifficulty()
|
||||
return GameBasics.Difficulties["Chieftain"]!!
|
||||
return gameInfo.gameBasics.Difficulties["Chieftain"]!!
|
||||
}
|
||||
|
||||
fun getTranslatedNation(): Nation {
|
||||
val language = UncivGame.Current.settings.language.replace(" ","_")
|
||||
if(!Gdx.files.internal("jsons/Nations/Nations_$language.json").exists()) return nation
|
||||
val translatedNation = GameBasics.getFromJson(Array<Nation>::class.java, "Nations/Nations_$language")
|
||||
val translatedNation = gameInfo.gameBasics.getFromJson(Array<Nation>::class.java, "Nations/Nations_$language")
|
||||
.firstOrNull { it.name==civName}
|
||||
if(translatedNation==null) // this language's trnslation doesn't contain this nation yet,
|
||||
return nation // default to english
|
||||
@ -170,7 +170,7 @@ class CivilizationInfo {
|
||||
*/
|
||||
fun getCivResourcesByName():HashMap<String,Int>{
|
||||
val hashMap = HashMap<String,Int>()
|
||||
for(resource in GameBasics.TileResources.keys) hashMap[resource]=0
|
||||
for(resource in gameInfo.gameBasics.TileResources.keys) hashMap[resource]=0
|
||||
for(entry in getCivResources())
|
||||
hashMap[entry.resource.name] = entry.amount
|
||||
return hashMap
|
||||
@ -228,19 +228,19 @@ class CivilizationInfo {
|
||||
|
||||
|
||||
fun getEquivalentBuilding(buildingName:String): Building {
|
||||
val baseBuilding = GameBasics.Buildings[buildingName]!!.getBaseBuilding()
|
||||
val baseBuilding = gameInfo.gameBasics.Buildings[buildingName]!!.getBaseBuilding(gameInfo.gameBasics)
|
||||
|
||||
for(building in GameBasics.Buildings.values)
|
||||
for(building in gameInfo.gameBasics.Buildings.values)
|
||||
if(building.replaces==baseBuilding.name && building.uniqueTo==civName)
|
||||
return building
|
||||
return baseBuilding
|
||||
}
|
||||
|
||||
fun getEquivalentUnit(baseUnitName:String):BaseUnit {
|
||||
for (unit in GameBasics.Units.values)
|
||||
for (unit in gameInfo.gameBasics.Units.values)
|
||||
if (unit.replaces == baseUnitName && unit.uniqueTo == civName)
|
||||
return unit
|
||||
return GameBasics.Units[baseUnitName]!!
|
||||
return gameInfo.gameBasics.Units[baseUnitName]!!
|
||||
}
|
||||
|
||||
fun meetCivilization(otherCiv: CivilizationInfo) {
|
||||
@ -295,7 +295,7 @@ class CivilizationInfo {
|
||||
* And if they civs on't yet know who they are then they don;t know if they're barbarians =\
|
||||
* */
|
||||
fun setNationTransient(){
|
||||
nation = GameBasics.Nations[civName]!!
|
||||
nation = gameInfo.gameBasics.Nations[civName]!!
|
||||
}
|
||||
|
||||
fun setTransients() {
|
||||
|
@ -2,7 +2,6 @@ package com.unciv.logic.civilization
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.math.Vector2
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.ui.cityscreen.CityScreen
|
||||
import com.unciv.ui.pickerscreens.TechPickerScreen
|
||||
import com.unciv.ui.worldscreen.WorldScreen
|
||||
@ -41,7 +40,7 @@ data class LocationAction(var locations: ArrayList<Vector2> = ArrayList()) : Not
|
||||
/** show tech screen */
|
||||
class TechAction(val techName: String = "") : NotificationAction {
|
||||
override fun execute(worldScreen: WorldScreen) {
|
||||
val tech = GameBasics.Technologies[techName]
|
||||
val tech = worldScreen.gameInfo.gameBasics.Technologies[techName]
|
||||
worldScreen.game.setScreen(TechPickerScreen(worldScreen.viewingCiv, tech))
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.unciv.logic.civilization
|
||||
|
||||
import com.unciv.Constants
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.Policy
|
||||
import com.unciv.models.gamebasics.VictoryType
|
||||
import kotlin.math.min
|
||||
@ -46,7 +45,7 @@ class PolicyManager {
|
||||
if(isAdopted(policy.name)) return false
|
||||
if (policy.name.endsWith("Complete")) return false
|
||||
if (!getAdoptedPolicies().containsAll(policy.requires!!)) return false
|
||||
if (policy.getBranch().era > civInfo.getEra()) return false
|
||||
if (policy.branch.era > civInfo.getEra()) return false
|
||||
return true
|
||||
}
|
||||
|
||||
@ -54,7 +53,7 @@ class PolicyManager {
|
||||
if (freePolicies == 0 && storedCulture < getCultureNeededForNextPolicy())
|
||||
return false
|
||||
|
||||
val hasAdoptablePolicies = GameBasics.PolicyBranches.values
|
||||
val hasAdoptablePolicies = civInfo.gameInfo.gameBasics.PolicyBranches.values
|
||||
.flatMap { it.policies.union(listOf(it)) }
|
||||
.any { civInfo.policies.isAdoptable(it) }
|
||||
return hasAdoptablePolicies
|
||||
@ -76,7 +75,7 @@ class PolicyManager {
|
||||
adoptedPolicies.add(policy.name)
|
||||
|
||||
if (!branchCompletion) {
|
||||
val branch = policy.getBranch()
|
||||
val branch = policy.branch
|
||||
if (branch.policies.count { isAdopted(it.name) } == branch.policies.size - 1) { // All done apart from branch completion
|
||||
adopt(branch.policies.last(), true) // add branch completion!
|
||||
}
|
||||
@ -101,7 +100,7 @@ class PolicyManager {
|
||||
VictoryType.Cultural -> "Great Artist"
|
||||
VictoryType.Scientific -> "Great Scientist"
|
||||
VictoryType.Domination,VictoryType.Neutral ->
|
||||
GameBasics.Units.keys.filter { it.startsWith("Great") }.random()
|
||||
civInfo.gameInfo.gameBasics.Units.keys.filter { it.startsWith("Great") }.random()
|
||||
}
|
||||
civInfo.addGreatPerson(greatPerson)
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.unciv.Constants
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.map.RoadStatus
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tech.Technology
|
||||
import com.unciv.models.gamebasics.unit.BaseUnit
|
||||
import com.unciv.ui.utils.withItem
|
||||
@ -44,8 +43,10 @@ class TechManager {
|
||||
return toReturn
|
||||
}
|
||||
|
||||
fun getGameBasics() = civInfo.gameInfo.gameBasics
|
||||
|
||||
fun costOfTech(techName: String): Int {
|
||||
var techCost = GameBasics.Technologies[techName]!!.cost.toFloat()
|
||||
var techCost = getGameBasics().Technologies[techName]!!.cost.toFloat()
|
||||
if (civInfo.isPlayerCivilization())
|
||||
techCost *= civInfo.getDifficulty().researchCostModifier
|
||||
techCost *= civInfo.gameInfo.gameParameters.gameSpeed.getModifier()
|
||||
@ -68,7 +69,7 @@ class TechManager {
|
||||
fun currentTechnology(): Technology? {
|
||||
val currentTechnologyName = currentTechnologyName()
|
||||
if (currentTechnologyName == null) return null
|
||||
return GameBasics.Technologies[currentTechnologyName]
|
||||
return getGameBasics().Technologies[currentTechnologyName]
|
||||
}
|
||||
|
||||
fun currentTechnologyName(): String? {
|
||||
@ -88,7 +89,7 @@ class TechManager {
|
||||
fun isResearched(TechName: String): Boolean = techsResearched.contains(TechName)
|
||||
|
||||
fun canBeResearched(TechName: String): Boolean {
|
||||
return GameBasics.Technologies[TechName]!!.prerequisites.all { isResearched(it) }
|
||||
return getGameBasics().Technologies[TechName]!!.prerequisites.all { isResearched(it) }
|
||||
}
|
||||
|
||||
fun getTechUniques() = researchedTechUniques
|
||||
@ -109,7 +110,7 @@ class TechManager {
|
||||
(isResearched(techToCheck.name) || prerequisites.contains(techToCheck)) )
|
||||
continue //no need to add or check prerequisites
|
||||
for (prerequisite in techToCheck.prerequisites)
|
||||
checkPrerequisites.add(GameBasics.Technologies[prerequisite]!!)
|
||||
checkPrerequisites.add(getGameBasics().Technologies[prerequisite]!!)
|
||||
prerequisites.add(techToCheck)
|
||||
}
|
||||
|
||||
@ -131,8 +132,8 @@ class TechManager {
|
||||
// We finished it!
|
||||
// http://www.civclub.net/bbs/forum.php?mod=viewthread&tid=123976
|
||||
overflowScience = techsInProgress[currentTechnology]!! - costOfTech(currentTechnology)
|
||||
if(overflowScience > max(scienceForNewTurn * 5, GameBasics.Technologies[currentTechnology]!!.cost))
|
||||
overflowScience = max(scienceForNewTurn * 5, GameBasics.Technologies[currentTechnology]!!.cost)
|
||||
if(overflowScience > max(scienceForNewTurn * 5, getGameBasics().Technologies[currentTechnology]!!.cost))
|
||||
overflowScience = max(scienceForNewTurn * 5, getGameBasics().Technologies[currentTechnology]!!.cost)
|
||||
addTechnology(currentTechnology)
|
||||
}
|
||||
|
||||
@ -150,7 +151,7 @@ class TechManager {
|
||||
techsResearched.add(techName)
|
||||
|
||||
// this is to avoid concurrent modification problems
|
||||
val newTech = GameBasics.Technologies[techName]!!
|
||||
val newTech = getGameBasics().Technologies[techName]!!
|
||||
researchedTechnologies = researchedTechnologies.withItem(newTech)
|
||||
for(unique in newTech.uniques)
|
||||
researchedTechUniques = researchedTechUniques.withItem(unique)
|
||||
@ -162,11 +163,11 @@ class TechManager {
|
||||
val currentEra = civInfo.getEra()
|
||||
if (previousEra < currentEra) {
|
||||
civInfo.addNotification("You have entered the [$currentEra era]!", null, Color.GOLD)
|
||||
GameBasics.PolicyBranches.values.filter { it.era == currentEra }
|
||||
getGameBasics().PolicyBranches.values.filter { it.era == currentEra }
|
||||
.forEach { civInfo.addNotification("[" + it.name + "] policy branch unlocked!", null, Color.PURPLE) }
|
||||
}
|
||||
|
||||
for(revealedResource in GameBasics.TileResources.values.filter{ techName == it.revealedBy }){
|
||||
for(revealedResource in getGameBasics().TileResources.values.filter{ techName == it.revealedBy }){
|
||||
for (tileInfo in civInfo.gameInfo.tileMap.values
|
||||
.filter { it.resource == revealedResource.name && civInfo == it.getOwner() }) {
|
||||
|
||||
@ -180,7 +181,7 @@ class TechManager {
|
||||
}
|
||||
}
|
||||
|
||||
val obsoleteUnits = GameBasics.Units.values.filter { it.obsoleteTech == techName }
|
||||
val obsoleteUnits = getGameBasics().Units.values.filter { it.obsoleteTech == techName }
|
||||
for (city in civInfo.cities)
|
||||
if (city.cityConstructions.getCurrentConstruction() in obsoleteUnits) {
|
||||
val currentConstructionUnit = city.cityConstructions.getCurrentConstruction() as BaseUnit
|
||||
@ -216,7 +217,7 @@ class TechManager {
|
||||
techsToResearch = newTechToReseach
|
||||
}
|
||||
|
||||
researchedTechnologies.addAll(techsResearched.map { GameBasics.Technologies[it]!! })
|
||||
researchedTechnologies.addAll(techsResearched.map { getGameBasics().Technologies[it]!! })
|
||||
researchedTechUniques.addAll(researchedTechnologies.flatMap { it.uniques })
|
||||
updateTransientBooleans()
|
||||
}
|
||||
@ -234,9 +235,9 @@ class TechManager {
|
||||
}
|
||||
|
||||
fun getBestRoadAvailable(): RoadStatus {
|
||||
if (!isResearched(RoadStatus.Road.improvement()!!.techRequired!!)) return RoadStatus.None
|
||||
if (!isResearched(RoadStatus.Road.improvement(getGameBasics())!!.techRequired!!)) return RoadStatus.None
|
||||
|
||||
val techEnablingRailroad = RoadStatus.Railroad.improvement()!!.techRequired!!
|
||||
val techEnablingRailroad = RoadStatus.Railroad.improvement(getGameBasics())!!.techRequired!!
|
||||
val canBuildRailroad = isResearched(techEnablingRailroad)
|
||||
|
||||
return if (canBuildRailroad) RoadStatus.Railroad else RoadStatus.Road
|
||||
|
@ -8,7 +8,6 @@ import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.civilization.PopupAlert
|
||||
import com.unciv.logic.trade.Trade
|
||||
import com.unciv.logic.trade.TradeType
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tile.ResourceSupplyList
|
||||
|
||||
enum class RelationshipLevel{
|
||||
@ -164,10 +163,10 @@ class DiplomacyManager() {
|
||||
for(trade in trades){
|
||||
for(offer in trade.ourOffers)
|
||||
if(offer.type== TradeType.Strategic_Resource || offer.type== TradeType.Luxury_Resource)
|
||||
counter.add(GameBasics.TileResources[offer.name]!!,-offer.amount,"Trade")
|
||||
counter.add(civInfo.gameInfo.gameBasics.TileResources[offer.name]!!,-offer.amount,"Trade")
|
||||
for(offer in trade.theirOffers)
|
||||
if(offer.type== TradeType.Strategic_Resource || offer.type== TradeType.Luxury_Resource)
|
||||
counter.add(GameBasics.TileResources[offer.name]!!,offer.amount,"Trade")
|
||||
counter.add(civInfo.gameInfo.gameBasics.TileResources[offer.name]!!,offer.amount,"Trade")
|
||||
}
|
||||
return counter
|
||||
}
|
||||
|
@ -27,33 +27,31 @@ class MapType {
|
||||
|
||||
class MapGenerator {
|
||||
|
||||
fun generateMap(gameParameters: GameParameters): TileMap {
|
||||
fun generateMap(gameParameters: GameParameters, gameBasics: GameBasics): TileMap {
|
||||
val mapRadius = gameParameters.mapRadius
|
||||
val mapType = gameParameters.mapType
|
||||
|
||||
val map = TileMap(mapRadius)
|
||||
val map = TileMap(mapRadius, gameBasics)
|
||||
|
||||
// Step one - separate land and water, in form of Grasslands and Oceans
|
||||
if(mapType == MapType.perlin)
|
||||
if (mapType == MapType.perlin)
|
||||
MapLandmassGenerator().generateLandPerlin(map)
|
||||
else MapLandmassGenerator().generateLandCellularAutomata(map, mapRadius, mapType)
|
||||
|
||||
else MapLandmassGenerator().generateLandCellularAutomata(map,mapRadius, mapType)
|
||||
divideIntoBiomes(map, 6, 0.05f, mapRadius, gameBasics)
|
||||
|
||||
divideIntoBiomes(map,6, 0.05f, mapRadius)
|
||||
|
||||
for(tile in map.values) tile.setTransients()
|
||||
for (tile in map.values) tile.setTransients()
|
||||
|
||||
setWaterTiles(map)
|
||||
|
||||
for(tile in map.values) randomizeTile(tile,gameParameters)
|
||||
for (tile in map.values) randomizeTile(tile, gameParameters, gameBasics)
|
||||
|
||||
randomizeResources(map, mapRadius)
|
||||
randomizeResources(map, mapRadius, gameBasics)
|
||||
|
||||
return map
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun setWaterTiles(map: TileMap) {
|
||||
|
||||
//define lakes
|
||||
@ -95,28 +93,28 @@ class MapGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
fun randomizeTile(tileInfo: TileInfo,gameParameters : GameParameters){
|
||||
if(tileInfo.getBaseTerrain().type==TerrainType.Land && Math.random()<0.05f){
|
||||
fun randomizeTile(tileInfo: TileInfo, gameParameters: GameParameters, gameBasics: GameBasics) {
|
||||
if (tileInfo.getBaseTerrain().type == TerrainType.Land && Math.random() < 0.05f) {
|
||||
tileInfo.baseTerrain = Constants.mountain
|
||||
tileInfo.setTransients()
|
||||
}
|
||||
addRandomTerrainFeature(tileInfo)
|
||||
maybeAddAncientRuins(tileInfo,gameParameters)
|
||||
addRandomTerrainFeature(tileInfo, gameBasics)
|
||||
maybeAddAncientRuins(tileInfo, gameParameters)
|
||||
}
|
||||
|
||||
fun getLatitude(vector: Vector2): Float {
|
||||
return (sin(3.1416/3) * vector.y).toFloat()
|
||||
return (sin(3.1416 / 3) * vector.y).toFloat()
|
||||
}
|
||||
|
||||
fun divideIntoBiomes(map: TileMap, averageTilesPerArea: Int, waterPercent: Float, distance: Int) {
|
||||
fun divideIntoBiomes(map: TileMap, averageTilesPerArea: Int, waterPercent: Float, distance: Int, gameBasics: GameBasics) {
|
||||
val areas = ArrayList<Area>()
|
||||
|
||||
val terrains = GameBasics.Terrains.values
|
||||
.filter { it.type === TerrainType.Land && it.name != Constants.lakes && it.name != Constants.mountain}
|
||||
val terrains = gameBasics.Terrains.values
|
||||
.filter { it.type === TerrainType.Land && it.name != Constants.lakes && it.name != Constants.mountain }
|
||||
|
||||
for(tile in map.values.filter { it.baseTerrain==Constants.grassland }) tile.baseTerrain="" // So we know it's not chosen
|
||||
for (tile in map.values.filter { it.baseTerrain == Constants.grassland }) tile.baseTerrain = "" // So we know it's not chosen
|
||||
|
||||
while(map.values.any { it.baseTerrain=="" }) // the world could be split into lots off tiny islands, and every island deserves land types
|
||||
while (map.values.any { it.baseTerrain == "" }) // the world could be split into lots off tiny islands, and every island deserves land types
|
||||
{
|
||||
val emptyTiles = map.values.filter { it.baseTerrain == "" }.toMutableList()
|
||||
val numberOfSeeds = ceil(emptyTiles.size / averageTilesPerArea.toFloat()).toInt()
|
||||
@ -157,14 +155,14 @@ class MapGenerator {
|
||||
|
||||
while (expandableAreas.isNotEmpty()) {
|
||||
val areaToExpand = expandableAreas.random()
|
||||
if(areaToExpand.tiles.size>=20){
|
||||
if (areaToExpand.tiles.size >= 20) {
|
||||
expandableAreas -= areaToExpand
|
||||
continue
|
||||
}
|
||||
|
||||
val availableExpansionTiles = areaToExpand.tiles
|
||||
.flatMap { it.neighbors }.distinct()
|
||||
.filter { it.baseTerrain=="" }
|
||||
.filter { it.baseTerrain == "" }
|
||||
|
||||
if (availableExpansionTiles.isEmpty()) expandableAreas -= areaToExpand
|
||||
else {
|
||||
@ -186,10 +184,10 @@ class MapGenerator {
|
||||
}
|
||||
|
||||
|
||||
fun addRandomTerrainFeature(tileInfo: TileInfo) {
|
||||
fun addRandomTerrainFeature(tileInfo: TileInfo, gameBasics: GameBasics) {
|
||||
if (tileInfo.getBaseTerrain().canHaveOverlay && Math.random() > 0.7f) {
|
||||
val secondaryTerrains = GameBasics.Terrains.values
|
||||
.filter { it.type === TerrainType.TerrainFeature && it.occursOn != null && it.occursOn!!.contains(tileInfo.baseTerrain) }
|
||||
val secondaryTerrains = gameBasics.Terrains.values
|
||||
.filter { it.type === TerrainType.TerrainFeature && it.occursOn != null && it.occursOn.contains(tileInfo.baseTerrain) }
|
||||
if (secondaryTerrains.any()) tileInfo.terrainFeature = secondaryTerrains.random().name
|
||||
}
|
||||
}
|
||||
@ -197,24 +195,24 @@ class MapGenerator {
|
||||
|
||||
fun maybeAddAncientRuins(tile: TileInfo, gameParameters: GameParameters) {
|
||||
val baseTerrain = tile.getBaseTerrain()
|
||||
if(!gameParameters.noRuins && baseTerrain.type!=TerrainType.Water && !baseTerrain.impassable && Random().nextDouble() < 1f/100)
|
||||
if (!gameParameters.noRuins && baseTerrain.type != TerrainType.Water && !baseTerrain.impassable && Random().nextDouble() < 1f / 100)
|
||||
tile.improvement = Constants.ancientRuins
|
||||
}
|
||||
|
||||
|
||||
fun randomizeResources(mapToReturn: TileMap, distance: Int) {
|
||||
for(tile in mapToReturn.values)
|
||||
if(tile.resource!=null)
|
||||
tile.resource=null
|
||||
fun randomizeResources(mapToReturn: TileMap, distance: Int, gameBasics: GameBasics) {
|
||||
for (tile in mapToReturn.values)
|
||||
if (tile.resource != null)
|
||||
tile.resource = null
|
||||
|
||||
randomizeStrategicResources(mapToReturn, distance)
|
||||
randomizeResource(mapToReturn, distance, ResourceType.Luxury)
|
||||
randomizeResource(mapToReturn, distance, ResourceType.Bonus)
|
||||
randomizeStrategicResources(mapToReturn, distance, gameBasics)
|
||||
randomizeResource(mapToReturn, distance, ResourceType.Luxury, gameBasics)
|
||||
randomizeResource(mapToReturn, distance, ResourceType.Bonus, gameBasics)
|
||||
}
|
||||
|
||||
// Here, we need each specific resource to be spread over the map - it matters less if specific resources are near each other
|
||||
private fun randomizeStrategicResources(mapToReturn: TileMap, distance: Int) {
|
||||
val resourcesOfType = GameBasics.TileResources.values.filter { it.resourceType == ResourceType.Strategic }
|
||||
private fun randomizeStrategicResources(mapToReturn: TileMap, distance: Int, gameBasics: GameBasics) {
|
||||
val resourcesOfType = gameBasics.TileResources.values.filter { it.resourceType == ResourceType.Strategic }
|
||||
for (resource in resourcesOfType) {
|
||||
val suitableTiles = mapToReturn.values
|
||||
.filter { it.resource == null && resource.terrainsCanBeFoundOn.contains(it.getLastTerrain().name) }
|
||||
@ -229,41 +227,41 @@ class MapGenerator {
|
||||
}
|
||||
|
||||
// Here, we need there to be some luxury/bonus resource - it matters less what
|
||||
private fun randomizeResource(mapToReturn: TileMap, distance: Int, resourceType: ResourceType) {
|
||||
val resourcesOfType = GameBasics.TileResources.values.filter { it.resourceType == resourceType }
|
||||
private fun randomizeResource(mapToReturn: TileMap, distance: Int, resourceType: ResourceType, gameBasics: GameBasics) {
|
||||
val resourcesOfType = gameBasics.TileResources.values.filter { it.resourceType == resourceType }
|
||||
|
||||
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) } }
|
||||
val numberOfResources = mapToReturn.values.count { it.isLand && !it.getBaseTerrain().impassable } / 15
|
||||
val locations = chooseSpreadOutLocations(numberOfResources, suitableTiles, distance)
|
||||
|
||||
val resourceToNumber = Counter<String>()
|
||||
|
||||
for(tile in locations){
|
||||
for (tile in locations) {
|
||||
val possibleResources = resourcesOfType
|
||||
.filter { it.terrainsCanBeFoundOn.contains(tile.getLastTerrain().name) }
|
||||
.map { it.name }
|
||||
if(possibleResources.isEmpty()) continue
|
||||
if (possibleResources.isEmpty()) continue
|
||||
val resourceWithLeastAssignments = possibleResources.minBy { resourceToNumber[it]!! }!!
|
||||
resourceToNumber.add(resourceWithLeastAssignments, 1)
|
||||
tile.resource = resourceWithLeastAssignments
|
||||
}
|
||||
}
|
||||
|
||||
fun chooseSpreadOutLocations(numberOfResources: Int, suitableTiles: List<TileInfo>, initialDistance:Int): ArrayList<TileInfo> {
|
||||
fun chooseSpreadOutLocations(numberOfResources: Int, suitableTiles: List<TileInfo>, initialDistance: Int): ArrayList<TileInfo> {
|
||||
|
||||
for(distanceBetweenResources in initialDistance downTo 1){
|
||||
for (distanceBetweenResources in initialDistance downTo 1) {
|
||||
var availableTiles = suitableTiles.toList()
|
||||
val chosenTiles = ArrayList<TileInfo>()
|
||||
|
||||
for(i in 1..numberOfResources){
|
||||
if(availableTiles.isEmpty()) break
|
||||
for (i in 1..numberOfResources) {
|
||||
if (availableTiles.isEmpty()) break
|
||||
val chosenTile = availableTiles.random()
|
||||
availableTiles = availableTiles.filter { it.arialDistanceTo(chosenTile)>distanceBetweenResources }
|
||||
availableTiles = availableTiles.filter { it.arialDistanceTo(chosenTile) > distanceBetweenResources }
|
||||
chosenTiles.add(chosenTile)
|
||||
}
|
||||
// Either we got them all, or we're not going to get anything better
|
||||
if(chosenTiles.size == numberOfResources || distanceBetweenResources==1) return chosenTiles
|
||||
if (chosenTiles.size == numberOfResources || distanceBetweenResources == 1) return chosenTiles
|
||||
}
|
||||
throw Exception("Couldn't choose suitable tiles for $numberOfResources resources!")
|
||||
}
|
||||
@ -278,7 +276,7 @@ class MapLandmassGenerator {
|
||||
//init
|
||||
for (tile in tileMap.values) {
|
||||
val terrainType = getInitialTerrainCellularAutomata(tile, mapRadius, mapType)
|
||||
if(terrainType==TerrainType.Land) tile.baseTerrain = Constants.grassland
|
||||
if (terrainType == TerrainType.Land) tile.baseTerrain = Constants.grassland
|
||||
else tile.baseTerrain = Constants.ocean
|
||||
tile.setTransients()
|
||||
}
|
||||
@ -290,7 +288,7 @@ class MapLandmassGenerator {
|
||||
for (loop in 0..numSmooth) {
|
||||
for (tileInfo in tileMap.values) {
|
||||
if (HexMath().getDistance(Vector2.Zero, tileInfo.position) < mapRadius) {
|
||||
val numberOfLandNeighbors = tileInfo.neighbors.count { it.baseTerrain==grassland }
|
||||
val numberOfLandNeighbors = tileInfo.neighbors.count { it.baseTerrain == grassland }
|
||||
if (tileInfo.baseTerrain == grassland) { // land tile
|
||||
if (numberOfLandNeighbors < 3)
|
||||
tileInfo.baseTerrain = ocean
|
||||
@ -305,15 +303,15 @@ class MapLandmassGenerator {
|
||||
|
||||
if (mapType == MapType.continents) { //keep a ocean column in the middle
|
||||
for (y in -mapRadius..mapRadius) {
|
||||
tileMap.get(Vector2((y / 2).toFloat(), y.toFloat())).baseTerrain=ocean
|
||||
tileMap.get(Vector2((y / 2 +1).toFloat(), y.toFloat())).baseTerrain=ocean
|
||||
tileMap.get(Vector2((y / 2).toFloat(), y.toFloat())).baseTerrain = ocean
|
||||
tileMap.get(Vector2((y / 2 + 1).toFloat(), y.toFloat())).baseTerrain = ocean
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun getInitialTerrainCellularAutomata(tileInfo: TileInfo, mapRadius: Int, mapType: String):TerrainType {
|
||||
private fun getInitialTerrainCellularAutomata(tileInfo: TileInfo, mapRadius: Int, mapType: String): TerrainType {
|
||||
|
||||
val landProbability = 0.55f
|
||||
|
||||
@ -343,16 +341,15 @@ class MapLandmassGenerator {
|
||||
|
||||
|
||||
private fun getDistanceWeightForContinents(origin: Vector2, destination: Vector2): Float {
|
||||
val relative_x = 2*(origin.x-destination.x)
|
||||
val relative_y = origin.y-destination.y
|
||||
val relative_x = 2 * (origin.x - destination.x)
|
||||
val relative_y = origin.y - destination.y
|
||||
if (relative_x * relative_y >= 0)
|
||||
return max(abs(relative_x),abs(relative_y))
|
||||
return max(abs(relative_x), abs(relative_y))
|
||||
else
|
||||
return (abs(relative_x) + abs(relative_y))
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This generator simply generates Perlin noise,
|
||||
* "spreads" it out according to the ratio in generateTile,
|
||||
@ -360,17 +357,17 @@ class MapLandmassGenerator {
|
||||
* Tiles below a certain height threshold (determined in generateTile, currently 50%)
|
||||
* are considered water tiles, the rest are land tiles
|
||||
*/
|
||||
fun generateLandPerlin(tileMap: TileMap){
|
||||
fun generateLandPerlin(tileMap: TileMap) {
|
||||
val mapRandomSeed = Random().nextDouble() // without this, all the "random" maps would look the same
|
||||
for(tile in tileMap.values){
|
||||
val ratio = 1/10.0
|
||||
for (tile in tileMap.values) {
|
||||
val ratio = 1 / 10.0
|
||||
val vector = tile.position
|
||||
val height = Perlin.noise(vector.x*ratio,vector.y*ratio,mapRandomSeed)
|
||||
+ Perlin.noise(vector.x*ratio*2,vector.y*ratio*2,mapRandomSeed)/2
|
||||
+ Perlin.noise(vector.x*ratio*4,vector.y*ratio*4,mapRandomSeed)/4
|
||||
val height = Perlin.noise(vector.x * ratio, vector.y * ratio, mapRandomSeed)
|
||||
+Perlin.noise(vector.x * ratio * 2, vector.y * ratio * 2, mapRandomSeed) / 2
|
||||
+Perlin.noise(vector.x * ratio * 4, vector.y * ratio * 4, mapRandomSeed) / 4
|
||||
when { // If we want to change water levels, we could raise or lower the >0
|
||||
height>0 -> tile.baseTerrain = Constants.grassland
|
||||
else -> tile.baseTerrain = Constants.ocean
|
||||
height > 0 -> tile.baseTerrain = Constants.grassland
|
||||
else -> tile.baseTerrain = Constants.ocean
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ class MapUnit {
|
||||
val uniques = ArrayList<String>()
|
||||
val baseUnit = baseUnit()
|
||||
uniques.addAll(baseUnit.uniques)
|
||||
uniques.addAll(promotions.promotions.map { GameBasics.UnitPromotions[it]!!.effect })
|
||||
uniques.addAll(promotions.promotions.map { currentTile.tileMap.gameInfo.gameBasics.UnitPromotions[it]!!.effect })
|
||||
tempUniques = uniques
|
||||
|
||||
if("Ignores terrain cost" in uniques) ignoresTerrainCost=true
|
||||
@ -265,10 +265,10 @@ class MapUnit {
|
||||
//endregion
|
||||
|
||||
//region state-changing functions
|
||||
fun setTransients(){
|
||||
fun setTransients(gameBasics: GameBasics) {
|
||||
promotions.unit=this
|
||||
mapUnitAction?.unit = this
|
||||
baseUnit=GameBasics.Units[name]!!
|
||||
baseUnit=gameBasics.Units[name]!!
|
||||
updateUniques()
|
||||
}
|
||||
|
||||
@ -454,7 +454,7 @@ class MapUnit {
|
||||
city.population.autoAssignPopulation()
|
||||
civInfo.addNotification("We have found survivors in the ruins - population added to ["+city.name+"]",tile.position, Color.GREEN)
|
||||
}
|
||||
val researchableAncientEraTechs = GameBasics.Technologies.values
|
||||
val researchableAncientEraTechs = tile.tileMap.gameInfo.gameBasics.Technologies.values
|
||||
.filter {
|
||||
!civInfo.tech.isResearched(it.name)
|
||||
&& civInfo.tech.canBeResearched(it.name)
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.unciv.logic.map
|
||||
|
||||
import com.unciv.logic.map.RoadStatus.Railroad
|
||||
import com.unciv.logic.map.RoadStatus.Road
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
|
||||
/**
|
||||
@ -13,6 +15,6 @@ enum class RoadStatus {
|
||||
Railroad;
|
||||
|
||||
/** returns null for [None] */
|
||||
fun improvement() = GameBasics.TileImprovements[this.name]
|
||||
fun improvement(gameBasics: GameBasics) = gameBasics.TileImprovements[this.name]
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import kotlin.math.abs
|
||||
|
||||
open class TileInfo {
|
||||
@Transient lateinit var tileMap: TileMap
|
||||
@Transient lateinit var gameBasics: GameBasics // a tile can be a tile with a ruleset, even without a map.
|
||||
@Transient var owningCity:CityInfo?=null
|
||||
@Transient private lateinit var baseTerrainObject:Terrain
|
||||
|
||||
@ -84,11 +85,11 @@ open class TileInfo {
|
||||
|
||||
fun getTileResource(): TileResource =
|
||||
if (resource == null) throw Exception("No resource exists for this tile!")
|
||||
else GameBasics.TileResources[resource!!]!!
|
||||
else gameBasics.TileResources[resource!!]!!
|
||||
|
||||
fun isCityCenter(): Boolean = getCity()?.location == position
|
||||
|
||||
fun getTileImprovement(): TileImprovement? = if (improvement == null) null else GameBasics.TileImprovements[improvement!!]
|
||||
fun getTileImprovement(): TileImprovement? = if (improvement == null) null else gameBasics.TileImprovements[improvement!!]
|
||||
|
||||
|
||||
// This is for performance - since we access the neighbors of a tile ALL THE TIME,
|
||||
@ -117,7 +118,7 @@ open class TileInfo {
|
||||
}
|
||||
|
||||
fun getTerrainFeature(): Terrain? {
|
||||
return if (terrainFeature == null) null else GameBasics.Terrains[terrainFeature!!]
|
||||
return if (terrainFeature == null) null else gameBasics.Terrains[terrainFeature!!]
|
||||
}
|
||||
|
||||
fun isWorked(): Boolean {
|
||||
@ -158,7 +159,8 @@ open class TileInfo {
|
||||
val resource = getTileResource()
|
||||
stats.add(getTileResource()) // resource base
|
||||
if (resource.building != null && city != null && city.cityConstructions.isBuilt(resource.building!!)) {
|
||||
stats.add(resource.getBuilding()!!.resourceBonusStats!!) // resource-specific building (eg forge, stable) bonus
|
||||
val resourceBuilding = tileMap.gameInfo.gameBasics.Buildings[resource.building!!]!!
|
||||
stats.add(resourceBuilding.resourceBonusStats!!) // resource-specific building (eg forge, stable) bonus
|
||||
}
|
||||
if(resource.resourceType==ResourceType.Strategic
|
||||
&& observingCiv.nation.unique=="Strategic Resources provide +1 Production, and Horses, Iron and Uranium Resources provide double quantity")
|
||||
@ -179,7 +181,7 @@ open class TileInfo {
|
||||
val improvement = getTileImprovement()
|
||||
if (improvement != null) {
|
||||
if (hasViewableResource(observingCiv) && getTileResource().improvement == improvement.name)
|
||||
stats.add(getTileResource().improvementStats!!) // resource-specifc improvement
|
||||
stats.add(getTileResource().improvementStats!!) // resource-specific improvement
|
||||
else
|
||||
stats.add(improvement) // basic improvement
|
||||
|
||||
@ -240,10 +242,6 @@ open class TileInfo {
|
||||
return resource != null && (getTileResource().revealedBy == null || civInfo.tech.isResearched(getTileResource().revealedBy!!))
|
||||
}
|
||||
|
||||
fun hasIdleUnit(): Boolean {
|
||||
return getUnits().any{it.isIdle()}
|
||||
}
|
||||
|
||||
fun getViewableTiles(distance:Int, ignoreCurrentTileHeight:Boolean = false): MutableList<TileInfo> {
|
||||
return tileMap.getViewableTiles(this.position,distance,ignoreCurrentTileHeight)
|
||||
}
|
||||
@ -312,7 +310,7 @@ open class TileInfo {
|
||||
|
||||
//region state-changing functions
|
||||
fun setTransients(){
|
||||
baseTerrainObject = GameBasics.Terrains[baseTerrain]!!
|
||||
baseTerrainObject = gameBasics.Terrains[baseTerrain]!! // This is a HACK.
|
||||
isWater = getBaseTerrain().type==TerrainType.Water
|
||||
isLand = getBaseTerrain().type==TerrainType.Land
|
||||
isOcean = baseTerrain == Constants.ocean
|
||||
@ -320,7 +318,7 @@ open class TileInfo {
|
||||
for (unit in getUnits()) {
|
||||
unit.currentTile = this
|
||||
unit.assignOwner(tileMap.gameInfo.getCivilization(unit.owner),false)
|
||||
unit.setTransients()
|
||||
unit.setTransients(gameBasics)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,10 +32,10 @@ class TileMap {
|
||||
|
||||
|
||||
|
||||
constructor(radius:Int){
|
||||
constructor(radius:Int, gameBasics: GameBasics){
|
||||
for(vector in HexMath().getVectorsInDistance(Vector2.Zero, radius))
|
||||
tileList.add(TileInfo().apply { position = vector; baseTerrain= Constants.grassland })
|
||||
setTransients()
|
||||
setTransients(gameBasics)
|
||||
}
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ class TileMap {
|
||||
}
|
||||
|
||||
fun placeUnitNearTile(position: Vector2, unitName: String, civInfo: CivilizationInfo): MapUnit? {
|
||||
val unit = GameBasics.Units[unitName]!!.getMapUnit()
|
||||
val unit = gameInfo.gameBasics.Units[unitName]!!.getMapUnit(gameInfo.gameBasics)
|
||||
|
||||
fun isTileMovePotential(tileInfo:TileInfo): Boolean {
|
||||
if(unit.type.isWaterUnit()) return tileInfo.isWater || tileInfo.isCityCenter()
|
||||
@ -146,7 +146,7 @@ class TileMap {
|
||||
return viewableTiles
|
||||
}
|
||||
|
||||
fun setTransients() {
|
||||
fun setTransients(gameBasics: GameBasics) {
|
||||
if(tiles.any())
|
||||
tileList.addAll(tiles.values)
|
||||
|
||||
@ -164,6 +164,7 @@ class TileMap {
|
||||
for (tileInfo in values){
|
||||
tileMatrix[tileInfo.position.x.toInt()-leftX][tileInfo.position.y.toInt()-bottomY] = tileInfo
|
||||
tileInfo.tileMap = this
|
||||
tileInfo.gameBasics = gameBasics
|
||||
tileInfo.setTransients()
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.unciv.logic.map
|
||||
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.unit.Promotion
|
||||
import com.unciv.models.gamebasics.unit.UnitType
|
||||
|
||||
@ -37,7 +36,7 @@ class UnitPromotions{
|
||||
}
|
||||
|
||||
fun getAvailablePromotions(): List<Promotion> {
|
||||
return GameBasics.UnitPromotions.values
|
||||
return unit.civInfo.gameInfo.gameBasics.UnitPromotions.values
|
||||
.filter { unit.type.toString() in it.unitTypes && it.name !in promotions }
|
||||
.filter { it.prerequisites.isEmpty() || it.prerequisites.any { p->p in promotions } }
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class BuildLongRoadAction(
|
||||
val tile = unit.currentTile
|
||||
if (unit.currentMovement > 0 && isRoadableTile(tile)) {
|
||||
val roadToBuild = unit.civInfo.tech.getBestRoadAvailable()
|
||||
roadToBuild.improvement()?.let { improvement ->
|
||||
roadToBuild.improvement(unit.civInfo.gameInfo.gameBasics)?.let { improvement ->
|
||||
if (tile.roadStatus < roadToBuild && tile.improvementInProgress != improvement.name) {
|
||||
tile.startWorkingOnImprovement(improvement, unit.civInfo)
|
||||
return true
|
||||
|
@ -5,7 +5,6 @@ import com.unciv.logic.automation.Automation
|
||||
import com.unciv.logic.automation.ThreatLevel
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tile.ResourceType
|
||||
import kotlin.math.min
|
||||
import kotlin.math.sqrt
|
||||
@ -118,7 +117,7 @@ class TradeEvaluation{
|
||||
}
|
||||
|
||||
TradeType.Technology ->
|
||||
return (sqrt(GameBasics.Technologies[offer.name]!!.cost.toDouble())
|
||||
return (sqrt(civInfo.gameInfo.gameBasics.Technologies[offer.name]!!.cost.toDouble())
|
||||
* civInfo.gameInfo.gameParameters.gameSpeed.getModifier()).toInt()*20
|
||||
TradeType.Introduction -> return 250
|
||||
TradeType.WarDeclaration -> {
|
||||
@ -168,7 +167,7 @@ class TradeEvaluation{
|
||||
TradeType.Strategic_Resource -> {
|
||||
if(!civInfo.isAtWar()) return 50*offer.amount
|
||||
|
||||
val canUseForUnits = GameBasics.Units.values
|
||||
val canUseForUnits = civInfo.gameInfo.gameBasics.Units.values
|
||||
.any { it.requiredResource==offer.name && it.isBuildable(civInfo) }
|
||||
if(!canUseForUnits) return 50*offer.amount
|
||||
|
||||
@ -189,7 +188,7 @@ class TradeEvaluation{
|
||||
}
|
||||
return totalCost
|
||||
}
|
||||
TradeType.Technology -> return sqrt(GameBasics.Technologies[offer.name]!!.cost.toDouble()).toInt()*20
|
||||
TradeType.Technology -> return sqrt(civInfo.gameInfo.gameBasics.Technologies[offer.name]!!.cost.toDouble()).toInt()*20
|
||||
TradeType.Introduction -> return 250
|
||||
TradeType.WarDeclaration -> {
|
||||
val civToDeclareWarOn = civInfo.gameInfo.getCivilization(offer.name)
|
||||
|
@ -4,7 +4,6 @@ import com.unciv.Constants
|
||||
import com.unciv.logic.city.CityConstructions
|
||||
import com.unciv.logic.city.IConstruction
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.models.gamebasics.tech.Technology
|
||||
import com.unciv.models.stats.NamedStats
|
||||
import com.unciv.models.stats.Stat
|
||||
import com.unciv.models.stats.Stats
|
||||
@ -45,16 +44,15 @@ class Building : NamedStats(), IConstruction{
|
||||
*/
|
||||
var resourceBonusStats: Stats? = null
|
||||
|
||||
fun getRequiredTech(): Technology = GameBasics.Technologies[requiredTech]!!
|
||||
|
||||
fun getShortDescription(): String { // should fit in one line
|
||||
fun getShortDescription(gameBasics: GameBasics): String { // should fit in one line
|
||||
val infoList= mutableListOf<String>()
|
||||
val str = getStats(null).toString()
|
||||
if(str.isNotEmpty()) infoList += str
|
||||
for(stat in getStatPercentageBonuses(null).toHashMap())
|
||||
if(stat.value!=0f) infoList+="+${stat.value.toInt()}% ${stat.key.toString().tr()}"
|
||||
|
||||
val improvedResources = GameBasics.TileResources.values.filter { it.building==name }.map { it.name.tr() }
|
||||
val improvedResources = gameBasics.TileResources.values.filter { it.building==name }.map { it.name.tr() }
|
||||
if(improvedResources.isNotEmpty()){
|
||||
// buildings that improve resources
|
||||
infoList += improvedResources.joinToString()+ " {provide} ".tr()+ resourceBonusStats.toString()
|
||||
@ -68,7 +66,7 @@ class Building : NamedStats(), IConstruction{
|
||||
return infoList.joinToString()
|
||||
}
|
||||
|
||||
fun getDescription(forBuildingPickerScreen: Boolean, civInfo: CivilizationInfo?): String {
|
||||
fun getDescription(forBuildingPickerScreen: Boolean, civInfo: CivilizationInfo?, gameBasics: GameBasics): String {
|
||||
val stats = getStats(civInfo)
|
||||
val stringBuilder = StringBuilder()
|
||||
if(uniqueTo!=null) stringBuilder.appendln("Unique to [$uniqueTo], replaces [$replaces]".tr())
|
||||
@ -104,7 +102,7 @@ class Building : NamedStats(), IConstruction{
|
||||
if (gpp.culture != 0f) stringBuilder.appendln("+" + gpp.culture.toInt() + " "+"[Great Artist] points".tr())
|
||||
}
|
||||
if (resourceBonusStats != null) {
|
||||
val resources = GameBasics.TileResources.values.filter { name == it.building }.joinToString { it.name.tr() }
|
||||
val resources = gameBasics.TileResources.values.filter { name == it.building }.joinToString { it.name.tr() }
|
||||
stringBuilder.appendln("$resources {provide} $resourceBonusStats".tr())
|
||||
}
|
||||
|
||||
@ -125,7 +123,7 @@ class Building : NamedStats(), IConstruction{
|
||||
val stats = this.clone()
|
||||
if(civInfo != null) {
|
||||
val adoptedPolicies = civInfo.policies.adoptedPolicies
|
||||
val baseBuildingName = getBaseBuilding().name
|
||||
val baseBuildingName = getBaseBuilding(civInfo.gameInfo.gameBasics).name
|
||||
|
||||
if (adoptedPolicies.contains("Organized Religion") && cultureBuildings.contains(baseBuildingName ))
|
||||
stats.happiness += 1
|
||||
@ -163,7 +161,7 @@ class Building : NamedStats(), IConstruction{
|
||||
if(civInfo==null) return stats // initial stats
|
||||
|
||||
val adoptedPolicies = civInfo.policies.adoptedPolicies
|
||||
val baseBuildingName = getBaseBuilding().name
|
||||
val baseBuildingName = getBaseBuilding(civInfo.gameInfo.gameBasics).name
|
||||
|
||||
if (adoptedPolicies.contains("Theocracy") && baseBuildingName == "Temple")
|
||||
stats.gold = 10f
|
||||
@ -252,7 +250,7 @@ class Building : NamedStats(), IConstruction{
|
||||
|
||||
val civInfo = construction.cityInfo.civInfo
|
||||
if (uniqueTo!=null && uniqueTo!=civInfo.civName) return "Unique to $uniqueTo"
|
||||
if (GameBasics.Buildings.values.any { it.uniqueTo==civInfo.civName && it.replaces==name }) return "Our unique building replaces this"
|
||||
if (civInfo.gameInfo.gameBasics.Buildings.values.any { it.uniqueTo==civInfo.civName && it.replaces==name }) return "Our unique building replaces this"
|
||||
if (requiredTech != null && !civInfo.tech.isResearched(requiredTech!!)) return "$requiredTech not researched"
|
||||
|
||||
// Regular wonders
|
||||
@ -325,7 +323,7 @@ class Building : NamedStats(), IConstruction{
|
||||
if (providesFreeBuilding != null && !construction.containsBuildingOrEquivalent(providesFreeBuilding!!)) {
|
||||
var buildingToAdd = providesFreeBuilding!!
|
||||
|
||||
for(building in GameBasics.Buildings.values)
|
||||
for(building in civInfo.gameInfo.gameBasics.Buildings.values)
|
||||
if(building.replaces == buildingToAdd && building.uniqueTo==civInfo.civName)
|
||||
buildingToAdd = building.name
|
||||
|
||||
@ -347,7 +345,7 @@ class Building : NamedStats(), IConstruction{
|
||||
if ("Free Social Policy" in uniques) civInfo.policies.freePolicies++
|
||||
if ("Free Great Person" in uniques) {
|
||||
if (civInfo.isPlayerCivilization()) civInfo.greatPeople.freeGreatPeople++
|
||||
else civInfo.addGreatPerson(GameBasics.Units.keys.filter { it.startsWith("Great") }.random())
|
||||
else civInfo.addGreatPerson(civInfo.gameInfo.gameBasics.Units.keys.filter { it.startsWith("Great") }.random())
|
||||
}
|
||||
if ("+1 population in each city" in uniques) {
|
||||
for(city in civInfo.cities){
|
||||
@ -369,8 +367,8 @@ class Building : NamedStats(), IConstruction{
|
||||
return false
|
||||
}
|
||||
|
||||
fun getBaseBuilding(): Building {
|
||||
fun getBaseBuilding(gameBasics: GameBasics): Building {
|
||||
if(replaces==null) return this
|
||||
else return GameBasics.Buildings[replaces!!]!!
|
||||
else return gameBasics.Buildings[replaces!!]!!
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import com.unciv.models.gamebasics.unit.Promotion
|
||||
import com.unciv.models.stats.INamed
|
||||
import kotlin.collections.set
|
||||
|
||||
object GameBasics {
|
||||
class GameBasics {
|
||||
val Buildings = LinkedHashMap<String, Building>()
|
||||
val Terrains = LinkedHashMap<String, Terrain>()
|
||||
val TileResources = LinkedHashMap<String, TileResource>()
|
||||
@ -30,7 +30,7 @@ object GameBasics {
|
||||
return Json().apply { ignoreUnknownFields = true }.fromJson(tClass, jsonText)
|
||||
}
|
||||
|
||||
fun <T : INamed> createHashmap(items: Array<T>): LinkedHashMap<String, T> {
|
||||
private fun <T : INamed> createHashmap(items: Array<T>): LinkedHashMap<String, T> {
|
||||
val hashMap = LinkedHashMap<String, T>()
|
||||
for (item in items)
|
||||
hashMap[item.name] = item
|
||||
@ -52,7 +52,7 @@ object GameBasics {
|
||||
Buildings += createHashmap(getFromJson(Array<Building>::class.java, "Buildings"))
|
||||
for (building in Buildings.values) {
|
||||
if (building.requiredTech == null) continue
|
||||
val column = building.getRequiredTech().column
|
||||
val column = Technologies[building.requiredTech!!]!!.column
|
||||
if (building.cost == 0)
|
||||
building.cost = if (building.isWonder || building.isNationalWonder) column!!.wonderCost else column!!.buildingCost
|
||||
}
|
||||
@ -66,9 +66,9 @@ object GameBasics {
|
||||
PolicyBranches += createHashmap(getFromJson(Array<PolicyBranch>::class.java, "Policies"))
|
||||
for (branch in PolicyBranches.values) {
|
||||
branch.requires = ArrayList()
|
||||
branch.branch = branch.name
|
||||
branch.branch = branch
|
||||
for (policy in branch.policies) {
|
||||
policy.branch = branch.name
|
||||
policy.branch = branch
|
||||
if (policy.requires == null) policy.requires = arrayListOf(branch.name)
|
||||
}
|
||||
branch.policies.last().name = branch.name + " Complete"
|
||||
|
@ -3,17 +3,14 @@ package com.unciv.models.gamebasics
|
||||
import com.unciv.models.stats.INamed
|
||||
|
||||
open class Policy : INamed {
|
||||
lateinit var branch: PolicyBranch // not in json - added in gameBasics
|
||||
|
||||
override lateinit var name: String
|
||||
lateinit var description: String
|
||||
var branch: String? = null
|
||||
var row: Int = 0
|
||||
var column: Int = 0
|
||||
var requires: ArrayList<String>? = null
|
||||
|
||||
fun getBranch():PolicyBranch{
|
||||
return GameBasics.PolicyBranches[branch]!!
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return name
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ fun String.tr(): String {
|
||||
|
||||
val translationStringWithSquareBracketsOnly = replace(squareBraceRegex,"[]")
|
||||
|
||||
val translationEntry = GameBasics.Translations.values
|
||||
val translationEntry = UncivGame.Current.gameBasics.Translations.values
|
||||
.firstOrNull { translationStringWithSquareBracketsOnly == it.entryWithShortenedSquareBrackets }
|
||||
|
||||
if(translationEntry==null ||
|
||||
@ -115,6 +115,6 @@ fun String.tr(): String {
|
||||
return Regex("\\{(.*?)\\}").replace(this) { it.groups[1]!!.value.tr() }
|
||||
}
|
||||
|
||||
val translation = GameBasics.Translations.get(this, UncivGame.Current.settings.language) // single word
|
||||
val translation = UncivGame.Current.gameBasics.Translations.get(this, UncivGame.Current.settings.language) // single word
|
||||
return translation
|
||||
}
|
||||
|
@ -20,11 +20,11 @@ class Technology {
|
||||
var row: Int = 0
|
||||
var quote=""
|
||||
|
||||
fun getDescription(): String {
|
||||
fun getDescription(gameBasics: GameBasics): String {
|
||||
val lineList = ArrayList<String>() // more readable than StringBuilder, with same performance for our use-case
|
||||
for (unique in uniques) lineList += unique.tr()
|
||||
|
||||
val improvedImprovements = GameBasics.TileImprovements.values
|
||||
val improvedImprovements = gameBasics.TileImprovements.values
|
||||
.filter { it.improvingTech == name }.groupBy { it.improvingTechStats.toString() }
|
||||
for (improvement in improvedImprovements) {
|
||||
val impimpString = improvement.value.joinToString { it.name.tr() } +
|
||||
@ -40,26 +40,26 @@ class Technology {
|
||||
lineList += " * " + unit.name.tr() + " (" + unit.getShortDescription() + ")"
|
||||
}
|
||||
|
||||
var enabledBuildings = getEnabledBuildings(viewingCiv)
|
||||
val enabledBuildings = getEnabledBuildings(viewingCiv)
|
||||
|
||||
val regularBuildings = enabledBuildings.filter { !it.isWonder && !it.isNationalWonder }
|
||||
if (regularBuildings.isNotEmpty()) {
|
||||
lineList += "{Buildings enabled}: "
|
||||
for (building in regularBuildings)
|
||||
lineList += "* " + building.name.tr() + " (" + building.getShortDescription() + ")"
|
||||
lineList += "* " + building.name.tr() + " (" + building.getShortDescription(gameBasics) + ")"
|
||||
}
|
||||
|
||||
val wonders = enabledBuildings.filter { it.isWonder || it.isNationalWonder }
|
||||
if (wonders.isNotEmpty()) {
|
||||
lineList += "{Wonders enabled}: "
|
||||
for (wonder in wonders)
|
||||
lineList += " * " + wonder.name.tr() + " (" + wonder.getShortDescription() + ")"
|
||||
lineList += " * " + wonder.name.tr() + " (" + wonder.getShortDescription(gameBasics) + ")"
|
||||
}
|
||||
|
||||
val revealedResource = GameBasics.TileResources.values.filter { it.revealedBy == name }.map { it.name }.firstOrNull() // can only be one
|
||||
val revealedResource = gameBasics.TileResources.values.filter { it.revealedBy == name }.map { it.name }.firstOrNull() // can only be one
|
||||
if (revealedResource != null) lineList += "Reveals [$revealedResource] on the map".tr()
|
||||
|
||||
val tileImprovements = GameBasics.TileImprovements.values.filter { it.techRequired == name }
|
||||
val tileImprovements = gameBasics.TileImprovements.values.filter { it.techRequired == name }
|
||||
if (tileImprovements.isNotEmpty())
|
||||
lineList += "{Tile improvements enabled}: " + tileImprovements.joinToString { it.name.tr() }
|
||||
|
||||
@ -67,7 +67,7 @@ class Technology {
|
||||
}
|
||||
|
||||
fun getEnabledBuildings(civInfo: CivilizationInfo): List<Building> {
|
||||
var enabledBuildings = GameBasics.Buildings.values.filter {
|
||||
var enabledBuildings = civInfo.gameInfo.gameBasics.Buildings.values.filter {
|
||||
it.requiredTech == name &&
|
||||
(it.uniqueTo == null || it.uniqueTo == civInfo.civName)
|
||||
}
|
||||
@ -81,7 +81,7 @@ class Technology {
|
||||
}
|
||||
|
||||
fun getEnabledUnits(civInfo:CivilizationInfo): List<BaseUnit> {
|
||||
var enabledUnits = GameBasics.Units.values.filter {
|
||||
var enabledUnits = civInfo.gameInfo.gameBasics.Units.values.filter {
|
||||
it.requiredTech == name &&
|
||||
(it.uniqueTo == null || it.uniqueTo == civInfo.civName)
|
||||
}
|
||||
|
@ -7,13 +7,13 @@ import com.unciv.models.stats.NamedStats
|
||||
import com.unciv.ui.utils.colorFromRGB
|
||||
|
||||
class Terrain : NamedStats() {
|
||||
fun getDescription(): String {
|
||||
fun getDescription(gameBasics: GameBasics): String {
|
||||
val sb = StringBuilder()
|
||||
sb.appendln(this.clone().toString())
|
||||
if (occursOn != null) {
|
||||
sb.appendln("Occurs on [${occursOn.joinToString(", ")}]".tr())
|
||||
}
|
||||
val resourcesFound = GameBasics.TileResources.values.filter { it.terrainsCanBeFoundOn.contains(name) }
|
||||
val resourcesFound = gameBasics.TileResources.values.filter { it.terrainsCanBeFoundOn.contains(name) }
|
||||
if (resourcesFound.isNotEmpty()) {
|
||||
sb.appendln("May contain [${resourcesFound.joinToString(", ") { it.name.tr() }}]".tr())
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.models.stats.NamedStats
|
||||
import com.unciv.models.stats.Stats
|
||||
import java.util.*
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class TileImprovement : NamedStats() {
|
||||
|
||||
@ -26,10 +27,10 @@ class TileImprovement : NamedStats() {
|
||||
realTurnsToBuild *= 0.75f
|
||||
if (civInfo.policies.isAdopted("Citizenship"))
|
||||
realTurnsToBuild *= 0.75f
|
||||
return Math.round(realTurnsToBuild)
|
||||
return realTurnsToBuild.roundToInt()
|
||||
}
|
||||
|
||||
fun getDescription(): String {
|
||||
fun getDescription(gameBasics: GameBasics): String {
|
||||
val stringBuilder = StringBuilder()
|
||||
if (this.clone().toString().isNotEmpty()) stringBuilder.appendln(this.clone().toString())
|
||||
if (!terrainsCanBeBuiltOn.isEmpty()) {
|
||||
@ -40,7 +41,7 @@ class TileImprovement : NamedStats() {
|
||||
stringBuilder.appendln("Can be built on ".tr() + terrainsCanBeBuiltOnString.joinToString(", "))//language can be changed when setting changes.
|
||||
}
|
||||
val statsToResourceNames = HashMap<String, ArrayList<String>>()
|
||||
for (tr: TileResource in GameBasics.TileResources.values.filter { it.improvement == name }) {
|
||||
for (tr: TileResource in gameBasics.TileResources.values.filter { it.improvement == name }) {
|
||||
val statsString = tr.improvementStats.toString()
|
||||
if (!statsToResourceNames.containsKey(statsString))
|
||||
statsToResourceNames[statsString] = ArrayList()
|
||||
|
@ -32,10 +32,6 @@ class TileResource : NamedStats() {
|
||||
*/
|
||||
var building: String? = null
|
||||
var revealedBy: String? = null
|
||||
|
||||
fun getBuilding(): Building? {
|
||||
return if (building == null) null else GameBasics.Buildings[building!!]
|
||||
}
|
||||
}
|
||||
|
||||
data class ResourceSupply(val resource:TileResource,var amount:Int, val origin:String)
|
||||
|
@ -78,11 +78,11 @@ class BaseUnit : INamed, IConstruction {
|
||||
return sb.toString()
|
||||
}
|
||||
|
||||
fun getMapUnit(): MapUnit {
|
||||
fun getMapUnit(gameBasics: GameBasics): MapUnit {
|
||||
val unit = MapUnit()
|
||||
unit.name = name
|
||||
|
||||
unit.setTransients() // must be after setting name because it sets the baseUnit according to the name
|
||||
unit.setTransients(gameBasics) // must be after setting name because it sets the baseUnit according to the name
|
||||
|
||||
return unit
|
||||
}
|
||||
@ -131,7 +131,7 @@ class BaseUnit : INamed, IConstruction {
|
||||
if (requiredTech!=null && !civInfo.tech.isResearched(requiredTech!!)) return "$requiredTech not researched"
|
||||
if (obsoleteTech!=null && civInfo.tech.isResearched(obsoleteTech!!)) return "Obsolete by $obsoleteTech"
|
||||
if (uniqueTo!=null && uniqueTo!=civInfo.civName) return "Unique to $uniqueTo"
|
||||
if (GameBasics.Units.values.any { it.uniqueTo==civInfo.civName && it.replaces==name }) return "Our unique unit replaces this"
|
||||
if (civInfo.gameInfo.gameBasics.Units.values.any { it.uniqueTo==civInfo.civName && it.replaces==name }) return "Our unique unit replaces this"
|
||||
if (!UncivGame.Current.settings.nuclearWeaponEnabled
|
||||
&& (name == "Manhattan Project" || uniques.contains("Requires Manhattan Project"))) return "Disabled by setting"
|
||||
if (uniques.contains("Requires Manhattan Project") && !civInfo.containsBuildingUnique("Enables nuclear weapon"))
|
||||
|
@ -4,7 +4,6 @@ import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.utils.*
|
||||
import java.util.*
|
||||
@ -71,24 +70,24 @@ class CivilopediaScreen : CameraStageBaseScreen() {
|
||||
val basicHelpFileName = if(Gdx.files.internal("jsons/BasicHelp/BasicHelp_$language.json").exists())"BasicHelp/BasicHelp_$language"
|
||||
else "BasicHelp/BasicHelp"
|
||||
|
||||
|
||||
categoryToEntries["Basics"] = GameBasics.getFromJson(kotlin.Array<CivilopediaEntry>::class.java, basicHelpFileName).toList()
|
||||
categoryToEntries["Buildings"] = GameBasics.Buildings.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(false, null),
|
||||
val gameBasics = game.gameBasics
|
||||
categoryToEntries["Basics"] = gameBasics.getFromJson(Array<CivilopediaEntry>::class.java, basicHelpFileName).toList()
|
||||
categoryToEntries["Buildings"] = gameBasics.Buildings.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(false, null,gameBasics),
|
||||
ImageGetter.getConstructionImage(it.name)) }
|
||||
categoryToEntries["Resources"] = GameBasics.TileResources.values
|
||||
categoryToEntries["Resources"] = gameBasics.TileResources.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(),
|
||||
ImageGetter.getResourceImage(it.name,50f)) }
|
||||
categoryToEntries["Terrains"] = GameBasics.Terrains.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription()) }
|
||||
categoryToEntries["Tile Improvements"] = GameBasics.TileImprovements.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(),
|
||||
categoryToEntries["Terrains"] = gameBasics.Terrains.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(gameBasics)) }
|
||||
categoryToEntries["Tile Improvements"] = gameBasics.TileImprovements.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(gameBasics),
|
||||
ImageGetter.getImprovementIcon(it.name,50f)) }
|
||||
categoryToEntries["Units"] = GameBasics.Units.values
|
||||
categoryToEntries["Units"] = gameBasics.Units.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(false),
|
||||
ImageGetter.getConstructionImage(it.name)) }
|
||||
categoryToEntries["Technologies"] = GameBasics.Technologies.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(),
|
||||
categoryToEntries["Technologies"] = gameBasics.Technologies.values
|
||||
.map { CivilopediaEntry(it.name,it.getDescription(gameBasics),
|
||||
ImageGetter.getTechIconGroup(it.name,50f)) }
|
||||
|
||||
categoryToEntries["Tutorials"] = Tutorials().getTutorialsOfLanguage("English").keys
|
||||
|
@ -6,7 +6,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.pickerscreens.PickerScreen
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
@ -24,10 +23,11 @@ class LanguageTable(val language:String,skin: Skin):Table(skin){
|
||||
defaults().pad(10f)
|
||||
if(ImageGetter.imageExists("FlagIcons/$language"))
|
||||
add(ImageGetter.getImage("FlagIcons/$language")).size(40f)
|
||||
val availableTranslations = GameBasics.Translations.filter { it.value.containsKey(language) }
|
||||
val translations = UncivGame.Current.gameBasics.Translations
|
||||
val availableTranslations = translations.filter { it.value.containsKey(language) }
|
||||
|
||||
if(language=="English") percentComplete = 100
|
||||
else percentComplete = (availableTranslations.size*100 / GameBasics.Translations.size) - 5
|
||||
else percentComplete = (availableTranslations.size*100 / translations.size) - 5
|
||||
|
||||
val spaceSplitLang = language.replace("_"," ")
|
||||
add("$spaceSplitLang ($percentComplete%)")
|
||||
@ -60,7 +60,7 @@ class LanguagePickerScreen: PickerScreen(){
|
||||
"If you want to help translating the game into your language, \n"+
|
||||
" instructions are in the Github readme! (Menu > Community > Github)",skin)).pad(10f).row()
|
||||
|
||||
languageTables.addAll(GameBasics.Translations.getLanguages().map { LanguageTable(it,skin) }
|
||||
languageTables.addAll(UncivGame.Current.gameBasics.Translations.getLanguages().map { LanguageTable(it,skin) }
|
||||
.sortedByDescending { it.percentComplete } )
|
||||
|
||||
languageTables.forEach {
|
||||
|
@ -6,7 +6,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.VictoryType
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.newgamescreen.NewGameScreen
|
||||
@ -134,7 +133,7 @@ class VictoryScreen : PickerScreen() {
|
||||
fun culturalVictoryColumn():Table{
|
||||
val t=Table()
|
||||
t.defaults().pad(5f)
|
||||
for(branch in GameBasics.PolicyBranches.values) {
|
||||
for(branch in playerCivInfo.gameInfo.gameBasics.PolicyBranches.values) {
|
||||
val finisher = branch.policies.last().name
|
||||
t.add(getMilestone(finisher, playerCivInfo.policies.isAdopted(finisher))).row()
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
|
||||
wonderDetailsTable.clear()
|
||||
else{
|
||||
val detailsString = building.getDescription(true,
|
||||
cityScreen.city.civInfo)
|
||||
cityScreen.city.civInfo, cityScreen.city.civInfo.gameInfo.gameBasics)
|
||||
wonderDetailsTable.add(detailsString.toLabel().apply { setWrap(true)})
|
||||
.width(cityScreen.stage.width/4 - 2*pad ).row() // when you set wrap, then you need to manually set the size of the label
|
||||
if(!building.isWonder && !building.isNationalWonder) {
|
||||
|
@ -10,7 +10,6 @@ import com.unciv.UncivGame
|
||||
import com.unciv.logic.city.CityInfo
|
||||
import com.unciv.logic.city.SpecialConstruction
|
||||
import com.unciv.models.gamebasics.Building
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.models.gamebasics.unit.BaseUnit
|
||||
import com.unciv.ui.utils.*
|
||||
@ -94,7 +93,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
||||
constructionPickerTable.background = ImageGetter.getBackground(Color.BLACK)
|
||||
|
||||
val units = ArrayList<Table>()
|
||||
for (unit in GameBasics.Units.values.filter { it.shouldBeDisplayed(cityConstructions) }) {
|
||||
for (unit in city.getGameBasics().Units.values.filter { it.shouldBeDisplayed(cityConstructions) }) {
|
||||
val turnsToUnit = cityConstructions.turnsToConstruction(unit.name)
|
||||
units += getProductionButton(unit.name,
|
||||
unit.name.tr() + "\r\n" + turnsToUnit + (if(turnsToUnit>1) " {turns}".tr() else " {turn}".tr()),
|
||||
@ -107,7 +106,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
||||
val buildableNationalWonders = ArrayList<Table>()
|
||||
val buildableBuildings = ArrayList<Table>()
|
||||
|
||||
for (building in GameBasics.Buildings.values) {
|
||||
for (building in city.getGameBasics().Buildings.values) {
|
||||
if (!building.shouldBeDisplayed(cityConstructions) && building.name != cityConstructions.currentConstruction) continue
|
||||
val turnsToBuilding = cityConstructions.turnsToConstruction(building.name)
|
||||
val productionTextButton = getProductionButton(building.name,
|
||||
@ -198,7 +197,8 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
||||
else if (construction is BaseUnit)
|
||||
description = construction.getDescription(true)
|
||||
else if (construction is Building)
|
||||
description = construction.getDescription(true, city.civInfo)
|
||||
description = construction.getDescription(true, city.civInfo,
|
||||
city.civInfo.gameInfo.gameBasics)
|
||||
else if(construction is SpecialConstruction)
|
||||
description = construction.description.tr()
|
||||
else description="" // Should never happen
|
||||
|
@ -40,7 +40,7 @@ class MapEditorScreen(): CameraStageBaseScreen(){
|
||||
}
|
||||
|
||||
fun initialize() {
|
||||
tileMap.setTransients()
|
||||
tileMap.setTransients(game.gameBasics)
|
||||
val mapHolder = getMapHolder(tileMap)
|
||||
|
||||
stage.addActor(mapHolder)
|
||||
|
@ -10,7 +10,6 @@ import com.unciv.Constants
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.map.RoadStatus
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tile.Terrain
|
||||
import com.unciv.models.gamebasics.tile.TerrainType
|
||||
import com.unciv.models.gamebasics.tile.TileImprovement
|
||||
@ -40,6 +39,8 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
||||
|
||||
private var currentHex: Actor = Group()
|
||||
|
||||
val gameBasics = UncivGame.Current.gameBasics
|
||||
|
||||
init{
|
||||
height=mapEditorScreen.stage.height
|
||||
width=mapEditorScreen.stage.width/3
|
||||
@ -73,7 +74,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
||||
}
|
||||
}).row()
|
||||
|
||||
for(improvement in GameBasics.TileImprovements.values){
|
||||
for(improvement in gameBasics.TileImprovements.values){
|
||||
if(improvement.name.startsWith("Remove")) continue
|
||||
val improvementImage = getHex(Color.WHITE,ImageGetter.getImprovementIcon(improvement.name,40f))
|
||||
improvementImage.onClick {
|
||||
@ -87,7 +88,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
||||
editorPickTable.add(ScrollPane(improvementsTable)).height(mapEditorScreen.stage.height*0.7f)
|
||||
|
||||
val nationsTable = Table()
|
||||
for(nation in GameBasics.Nations.values){
|
||||
for(nation in gameBasics.Nations.values){
|
||||
val nationImage = getHex(Color.WHITE,ImageGetter.getNationIndicator(nation,40f))
|
||||
nationImage.onClick {
|
||||
clearSelection()
|
||||
@ -150,7 +151,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
||||
}
|
||||
})
|
||||
|
||||
for (resource in GameBasics.TileResources.values) {
|
||||
for (resource in gameBasics.TileResources.values) {
|
||||
val resourceHex = getHex(Color.WHITE, ImageGetter.getResourceImage(resource.name, 40f))
|
||||
resourceHex.onClick {
|
||||
clearSelection()
|
||||
@ -158,7 +159,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
||||
val tileInfo = TileInfo()
|
||||
|
||||
val terrain = resource.terrainsCanBeFoundOn.first()
|
||||
val terrainObject = GameBasics.Terrains[terrain]!!
|
||||
val terrainObject = gameBasics.Terrains[terrain]!!
|
||||
if (terrainObject.type == TerrainType.TerrainFeature) {
|
||||
tileInfo.baseTerrain = when {
|
||||
terrainObject.occursOn == null -> terrainObject.occursOn!!.first()
|
||||
@ -177,7 +178,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
||||
}
|
||||
|
||||
private fun addTerrainOptions(terrainFeaturesTable: Table, baseTerrainTable: Table) {
|
||||
for (terrain in GameBasics.Terrains.values) {
|
||||
for (terrain in gameBasics.Terrains.values) {
|
||||
val tileInfo = TileInfo()
|
||||
if (terrain.type == TerrainType.TerrainFeature) {
|
||||
tileInfo.baseTerrain = when {
|
||||
|
@ -11,7 +11,7 @@ import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
import com.unciv.ui.utils.toLabel
|
||||
|
||||
class NationTable(val nation: Nation, width:Float)
|
||||
class NationTable(val nation: Nation, width:Float, gameBasics: GameBasics)
|
||||
: Table(CameraStageBaseScreen.skin) {
|
||||
private val innerTable = Table()
|
||||
|
||||
@ -25,12 +25,12 @@ class NationTable(val nation: Nation, width:Float)
|
||||
titleTable.add(nation.getLeaderDisplayName().toLabel(nation.getInnerColor(),24))
|
||||
innerTable.add(titleTable).row()
|
||||
|
||||
innerTable.add(getUniqueLabel(nation).apply { setWrap(true) }).width(width)
|
||||
innerTable.add(getUniqueLabel(nation,gameBasics).apply { setWrap(true) }).width(width)
|
||||
touchable = Touchable.enabled
|
||||
add(innerTable)
|
||||
}
|
||||
|
||||
private fun getUniqueLabel(nation: Nation): Label {
|
||||
private fun getUniqueLabel(nation: Nation, gameBasics: GameBasics): Label {
|
||||
val textList = ArrayList<String>()
|
||||
|
||||
if (nation.unique != null) {
|
||||
@ -38,17 +38,17 @@ class NationTable(val nation: Nation, width:Float)
|
||||
textList += ""
|
||||
}
|
||||
|
||||
addUniqueBuildingsText(nation, textList)
|
||||
addUniqueUnitsText(nation, textList)
|
||||
addUniqueImprovementsText(nation, textList)
|
||||
addUniqueBuildingsText(nation, textList,gameBasics)
|
||||
addUniqueUnitsText(nation, textList,gameBasics)
|
||||
addUniqueImprovementsText(nation, textList,gameBasics)
|
||||
|
||||
return textList.joinToString("\n").tr().trim().toLabel(nation.getInnerColor())
|
||||
}
|
||||
|
||||
private fun addUniqueBuildingsText(nation: Nation, textList: ArrayList<String>) {
|
||||
for (building in GameBasics.Buildings.values
|
||||
private fun addUniqueBuildingsText(nation: Nation, textList: ArrayList<String>, gameBasics: GameBasics) {
|
||||
for (building in gameBasics.Buildings.values
|
||||
.filter { it.uniqueTo == nation.name }) {
|
||||
val originalBuilding = GameBasics.Buildings[building.replaces!!]!!
|
||||
val originalBuilding = gameBasics.Buildings[building.replaces!!]!!
|
||||
|
||||
textList += building.name.tr() + " - {replaces} " + originalBuilding.name.tr()
|
||||
val originalBuildingStatMap = originalBuilding.toHashMap()
|
||||
@ -70,10 +70,10 @@ class NationTable(val nation: Nation, width:Float)
|
||||
}
|
||||
}
|
||||
|
||||
private fun addUniqueUnitsText(nation: Nation, textList: ArrayList<String>) {
|
||||
for (unit in GameBasics.Units.values
|
||||
private fun addUniqueUnitsText(nation: Nation, textList: ArrayList<String>, gameBasics: GameBasics) {
|
||||
for (unit in gameBasics.Units.values
|
||||
.filter { it.uniqueTo == nation.name }) {
|
||||
val originalUnit = GameBasics.Units[unit.replaces!!]!!
|
||||
val originalUnit = gameBasics.Units[unit.replaces!!]!!
|
||||
|
||||
textList += unit.name.tr() + " - {replaces} " + originalUnit.name.tr()
|
||||
if (unit.cost != originalUnit.cost)
|
||||
@ -93,14 +93,14 @@ class NationTable(val nation: Nation, width:Float)
|
||||
for (unique in originalUnit.uniques.filterNot { it in unit.uniques })
|
||||
textList += " " + "Lost ability".tr() + "(vs " + originalUnit.name.tr() + "): " + Translations.translateBonusOrPenalty(unique)
|
||||
for (promotion in unit.promotions.filter { it !in originalUnit.promotions })
|
||||
textList += " " + promotion.tr() + " (" + Translations.translateBonusOrPenalty(GameBasics.UnitPromotions[promotion]!!.effect) + ")"
|
||||
textList += " " + promotion.tr() + " (" + Translations.translateBonusOrPenalty(gameBasics.UnitPromotions[promotion]!!.effect) + ")"
|
||||
|
||||
textList += ""
|
||||
}
|
||||
}
|
||||
|
||||
private fun addUniqueImprovementsText(nation: Nation, textList: ArrayList<String>) {
|
||||
for (improvement in GameBasics.TileImprovements.values
|
||||
private fun addUniqueImprovementsText(nation: Nation, textList: ArrayList<String>, gameBasics: GameBasics) {
|
||||
for (improvement in gameBasics.TileImprovements.values
|
||||
.filter { it.uniqueTo == nation.name }) {
|
||||
|
||||
textList += improvement.name.tr()
|
||||
|
@ -6,9 +6,9 @@ import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
|
||||
import com.badlogic.gdx.utils.Array
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.MapSaver
|
||||
import com.unciv.logic.map.MapType
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.VictoryType
|
||||
import com.unciv.models.gamebasics.tech.TechEra
|
||||
import com.unciv.models.gamebasics.tr
|
||||
@ -127,7 +127,8 @@ class NewGameScreenOptionsTable(val newGameParameters: GameParameters, val onMul
|
||||
add("{Number of city-states}:".tr())
|
||||
val cityStatesSelectBox = SelectBox<Int>(CameraStageBaseScreen.skin)
|
||||
val cityStatesArray = Array<Int>()
|
||||
(0..GameBasics.Nations.filter { it.value.isCityState() }.size).forEach { cityStatesArray.add(it) }
|
||||
|
||||
(0..UncivGame.Current.gameBasics.Nations.filter { it.value.isCityState() }.size).forEach { cityStatesArray.add(it) }
|
||||
cityStatesSelectBox.items = cityStatesArray
|
||||
cityStatesSelectBox.selected = newGameParameters.numberOfCityStates
|
||||
add(cityStatesSelectBox).pad(10f).row()
|
||||
@ -140,7 +141,7 @@ class NewGameScreenOptionsTable(val newGameParameters: GameParameters, val onMul
|
||||
|
||||
private fun addDifficultySelectBox() {
|
||||
add("{Difficulty}:".tr())
|
||||
val difficultySelectBox = TranslatedSelectBox(GameBasics.Difficulties.keys, newGameParameters.difficulty, CameraStageBaseScreen.skin)
|
||||
val difficultySelectBox = TranslatedSelectBox(UncivGame.Current.gameBasics.Difficulties.keys, newGameParameters.difficulty, CameraStageBaseScreen.skin)
|
||||
difficultySelectBox.addListener(object : ChangeListener() {
|
||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||
newGameParameters.difficulty = difficultySelectBox.selected.value
|
||||
|
@ -30,20 +30,21 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
|
||||
|
||||
fun update() {
|
||||
playerListTable.clear()
|
||||
val gameBasics = UncivGame.Current.gameBasics // when we add mods, this will need to change
|
||||
for (player in newGameParameters.players)
|
||||
playerListTable.add(getPlayerTable(player)).pad(10f).row()
|
||||
if(newGameParameters.players.count() < GameBasics.Nations.values.count { it.isMajorCiv() }) {
|
||||
playerListTable.add(getPlayerTable(player,gameBasics)).pad(10f).row()
|
||||
if(newGameParameters.players.count() < gameBasics.Nations.values.count { it.isMajorCiv() }) {
|
||||
playerListTable.add("+".toLabel(Color.BLACK,30).apply { this.setAlignment(Align.center) }
|
||||
.surroundWithCircle(50f).onClick { newGameParameters.players.add(Player()); update() })
|
||||
}
|
||||
}
|
||||
|
||||
fun getPlayerTable(player: Player): Table {
|
||||
fun getPlayerTable(player: Player, gameBasics: GameBasics): Table {
|
||||
val playerTable = Table()
|
||||
playerTable.pad(20f)
|
||||
playerTable.background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.8f))
|
||||
|
||||
val nationTable = getNationTable(player)
|
||||
val nationTable = getNationTable(player,gameBasics)
|
||||
playerTable.add(nationTable)
|
||||
|
||||
val playerTypeTextbutton = TextButton(player.playerType.name, CameraStageBaseScreen.skin)
|
||||
@ -101,22 +102,22 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
|
||||
return playerTable
|
||||
}
|
||||
|
||||
private fun getNationTable(player: Player): Table {
|
||||
private fun getNationTable(player: Player, gameBasics: GameBasics): Table {
|
||||
val nationTable = Table()
|
||||
val nationImage = if (player.chosenCiv == "Random") "?".toLabel(Color.BLACK,30)
|
||||
.apply { this.setAlignment(Align.center) }
|
||||
.surroundWithCircle(50f)
|
||||
else ImageGetter.getNationIndicator(GameBasics.Nations[player.chosenCiv]!!, 50f)
|
||||
else ImageGetter.getNationIndicator(gameBasics.Nations[player.chosenCiv]!!, 50f)
|
||||
nationTable.add(nationImage)
|
||||
nationTable.add(player.chosenCiv.toLabel()).pad(20f)
|
||||
nationTable.touchable = Touchable.enabled
|
||||
nationTable.onClick {
|
||||
popupNationPicker(player)
|
||||
popupNationPicker(player,gameBasics)
|
||||
}
|
||||
return nationTable
|
||||
}
|
||||
|
||||
private fun popupNationPicker(player: Player) {
|
||||
private fun popupNationPicker(player: Player, gameBasics: GameBasics) {
|
||||
val nationsPopup = PopupTable(newGameScreen)
|
||||
val nationListTable = Table()
|
||||
|
||||
@ -136,11 +137,11 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
|
||||
nationListTable.add(randomPlayerTable).pad(10f).width(halfWidth).row()
|
||||
|
||||
|
||||
for (nation in GameBasics.Nations.values.filter { !it.isCityState() && it.name != "Barbarians" }) {
|
||||
for (nation in gameBasics.Nations.values.filter { !it.isCityState() && it.name != "Barbarians" }) {
|
||||
if (player.chosenCiv != nation.name && newGameParameters.players.any { it.chosenCiv == nation.name })
|
||||
continue
|
||||
|
||||
nationListTable.add(NationTable(nation, halfWidth).onClick {
|
||||
nationListTable.add(NationTable(nation, halfWidth,gameBasics).onClick {
|
||||
player.chosenCiv = nation.name
|
||||
nationsPopup.close()
|
||||
update()
|
||||
|
@ -3,7 +3,6 @@ package com.unciv.ui.pickerscreens
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Button
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.civilization.GreatPersonManager
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.models.gamebasics.unit.BaseUnit
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
@ -16,7 +15,7 @@ class GreatPersonPickerScreen : PickerScreen() {
|
||||
init {
|
||||
closeButton.isVisible=false
|
||||
rightSideButton.setText("Choose a free great person".tr())
|
||||
for (unit in GameBasics.Units.values
|
||||
for (unit in game.gameBasics.Units.values
|
||||
.filter { it.name in GreatPersonManager().statToGreatPersonMapping.values || it.name == "Great General"})
|
||||
{
|
||||
val button = Button(skin)
|
||||
|
@ -6,7 +6,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup
|
||||
import com.unciv.logic.map.RoadStatus
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tile.TileImprovement
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
@ -39,7 +38,7 @@ class ImprovementPickerScreen(tileInfo: TileInfo, onAccept: ()->Unit) : PickerSc
|
||||
val regularImprovements = VerticalGroup()
|
||||
regularImprovements.space(10f)
|
||||
|
||||
for (improvement in GameBasics.TileImprovements.values) {
|
||||
for (improvement in game.gameBasics.TileImprovements.values) {
|
||||
if (!tileInfo.canBuildImprovement(improvement, currentPlayerCiv)) continue
|
||||
if(improvement.name == tileInfo.improvement) continue
|
||||
if(improvement.name==tileInfo.improvementInProgress) continue
|
||||
@ -63,7 +62,7 @@ class ImprovementPickerScreen(tileInfo: TileInfo, onAccept: ()->Unit) : PickerSc
|
||||
group.onClick {
|
||||
selectedImprovement = improvement
|
||||
pick(improvement.name.tr())
|
||||
descriptionLabel.setText(improvement.getDescription())
|
||||
descriptionLabel.setText(improvement.getDescription(game.gameBasics))
|
||||
}
|
||||
|
||||
val pickNow = "Pick now!".toLabel()
|
||||
|
@ -6,14 +6,14 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.Policy
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.utils.*
|
||||
import com.unciv.ui.worldscreen.WorldScreen
|
||||
|
||||
|
||||
class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: CivilizationInfo = worldScreen.viewingCiv, switchfromWorldScreen: Boolean = true) : PickerScreen() {
|
||||
class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: CivilizationInfo = worldScreen.viewingCiv,
|
||||
switchfromWorldScreen: Boolean = true) : PickerScreen() {
|
||||
internal val viewingCiv: CivilizationInfo = civInfo
|
||||
private var pickedPolicy: Policy? = null
|
||||
|
||||
@ -52,7 +52,7 @@ class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: CivilizationInfo
|
||||
|
||||
topTable.row().pad(30f)
|
||||
|
||||
for (branch in GameBasics.PolicyBranches.values) {
|
||||
for (branch in viewingCiv.gameInfo.gameBasics.PolicyBranches.values) {
|
||||
if (branch.name == "Commerce") topTable.addSeparator()
|
||||
val branchGroup = Table()
|
||||
branchGroup.row().pad(20f)
|
||||
@ -101,7 +101,7 @@ class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: CivilizationInfo
|
||||
if(policy.requires!!.isNotEmpty())
|
||||
policyText += "{Requires} ".tr() + policy.requires!!.joinToString { it.tr() }
|
||||
else
|
||||
policyText += ("{Unlocked at} {"+policy.getBranch().era.toString()+" era}").tr()
|
||||
policyText += ("{Unlocked at} {"+policy.branch.era.toString()+" era}").tr()
|
||||
}
|
||||
descriptionLabel.setText(policyText)
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class PromotionPickerScreen(val unit: MapUnit) : PickerScreen() {
|
||||
availablePromotionsGroup.space(10f)
|
||||
|
||||
val unitType = unit.type
|
||||
val promotionsForUnitType = GameBasics.UnitPromotions.values.filter { it.unitTypes.contains(unitType.toString()) }
|
||||
val promotionsForUnitType = unit.civInfo.gameInfo.gameBasics.UnitPromotions.values.filter { it.unitTypes.contains(unitType.toString()) }
|
||||
val unitAvailablePromotions = unit.promotions.getAvailablePromotions()
|
||||
|
||||
for (promotion in promotionsForUnitType) {
|
||||
|
@ -5,7 +5,6 @@ import com.badlogic.gdx.scenes.scene2d.Touchable
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.logic.civilization.TechManager
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
import com.unciv.ui.utils.surroundWithCircle
|
||||
@ -43,8 +42,9 @@ class TechButton(techName:String, val techManager: TechManager, isWorldScreen: B
|
||||
techEnabledIcons.defaults().pad(5f)
|
||||
|
||||
val civName = techManager.civInfo.civName
|
||||
val gameBasics = techManager.civInfo.gameInfo.gameBasics
|
||||
|
||||
val tech = GameBasics.Technologies[techName]!!
|
||||
val tech = gameBasics.Technologies[techName]!!
|
||||
|
||||
for (unit in tech.getEnabledUnits(techManager.civInfo))
|
||||
techEnabledIcons.add(ImageGetter.getConstructionImage(unit.name).surroundWithCircle(30f))
|
||||
@ -52,7 +52,7 @@ class TechButton(techName:String, val techManager: TechManager, isWorldScreen: B
|
||||
for (building in tech.getEnabledBuildings(techManager.civInfo))
|
||||
techEnabledIcons.add(ImageGetter.getConstructionImage(building.name).surroundWithCircle(30f))
|
||||
|
||||
for (improvement in GameBasics.TileImprovements.values
|
||||
for (improvement in gameBasics.TileImprovements.values
|
||||
.filter { it.techRequired == techName || it.improvingTech == techName }
|
||||
.filter { it.uniqueTo==null || it.uniqueTo==civName }) {
|
||||
if (improvement.name.startsWith("Remove"))
|
||||
@ -60,7 +60,7 @@ class TechButton(techName:String, val techManager: TechManager, isWorldScreen: B
|
||||
else techEnabledIcons.add(ImageGetter.getImprovementIcon(improvement.name, 30f))
|
||||
}
|
||||
|
||||
for (resource in GameBasics.TileResources.values.filter { it.revealedBy == techName })
|
||||
for (resource in gameBasics.TileResources.values.filter { it.revealedBy == techName })
|
||||
techEnabledIcons.add(ImageGetter.getResourceImage(resource.name, 30f))
|
||||
|
||||
for (unique in tech.uniques)
|
||||
|
@ -8,7 +8,6 @@ import com.unciv.Constants
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.civilization.TechManager
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tech.Technology
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.utils.*
|
||||
@ -25,7 +24,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
||||
private var lines=ArrayList<Image>()
|
||||
|
||||
// All these are to counter performance problems when updating buttons for all techs.
|
||||
private var researchableTechs = GameBasics.Technologies.keys
|
||||
private var researchableTechs = civInfo.gameInfo.gameBasics.Technologies.keys
|
||||
.filter { civTech.canBeResearched(it) }.toHashSet()
|
||||
|
||||
private val currentTechColor = colorFromRGB(7,46,43)
|
||||
@ -34,7 +33,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
||||
private val queuedTechColor = colorFromRGB(39,114,154)
|
||||
|
||||
|
||||
private val turnsToTech = GameBasics.Technologies.values.associateBy ({ it.name },{civTech.turnsToTech(it.name)})
|
||||
private val turnsToTech = civInfo.gameInfo.gameBasics.Technologies.values.associateBy ({ it.name },{civTech.turnsToTech(it.name)})
|
||||
|
||||
constructor(freeTechPick: Boolean, civInfo: CivilizationInfo) : this(civInfo) {
|
||||
isFreeTechPick = freeTechPick
|
||||
@ -76,10 +75,10 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
||||
}
|
||||
|
||||
private fun createTechTable() {
|
||||
val columns = GameBasics.Technologies.values.map { it.column!!.columnNumber}.max()!! +1
|
||||
val columns = civInfo.gameInfo.gameBasics.Technologies.values.map { it.column!!.columnNumber}.max()!! +1
|
||||
val techMatrix = Array<Array<Technology?>>(columns) { arrayOfNulls(10) } // Divided into columns, then rows
|
||||
|
||||
for (technology in GameBasics.Technologies.values) {
|
||||
for (technology in civInfo.gameInfo.gameBasics.Technologies.values) {
|
||||
techMatrix[technology.column!!.columnNumber][technology.row - 1] = technology
|
||||
}
|
||||
|
||||
@ -146,7 +145,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
||||
for (line in lines) line.remove()
|
||||
lines.clear()
|
||||
|
||||
for (tech in GameBasics.Technologies.values) {
|
||||
for (tech in civInfo.gameInfo.gameBasics.Technologies.values) {
|
||||
val techButton = techNameToButton[tech.name]!!
|
||||
for (prerequisite in tech.prerequisites) {
|
||||
val prerequisiteButton = techNameToButton[prerequisite]!!
|
||||
@ -177,7 +176,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
|
||||
private fun selectTechnology(tech: Technology?, center: Boolean = false, switchfromWorldScreen: Boolean = true) {
|
||||
|
||||
selectedTech = tech
|
||||
descriptionLabel.setText(tech?.getDescription())
|
||||
descriptionLabel.setText(tech?.getDescription(civInfo.gameInfo.gameBasics))
|
||||
|
||||
if (!switchfromWorldScreen)
|
||||
return
|
||||
|
@ -3,7 +3,6 @@ package com.unciv.ui.utils
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import core.java.nativefont.NativeFont
|
||||
import core.java.nativefont.NativeFontPaint
|
||||
|
||||
@ -37,7 +36,7 @@ class Fonts {
|
||||
if (Gdx.files.internal("jsons/Tutorials/Tutorials_$language.json").exists())
|
||||
charSet.addAll(Gdx.files.internal("jsons/Tutorials/Tutorials_$language.json").readString().asIterable())
|
||||
|
||||
for (entry in GameBasics.Translations.entries) {
|
||||
for (entry in UncivGame.Current.gameBasics.Translations.entries) {
|
||||
for (lang in entry.value) {
|
||||
if (lang.key == language) charSet.addAll(lang.value.asIterable())
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.Drawable
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.models.gamebasics.Nation
|
||||
import com.unciv.models.gamebasics.tile.ResourceType
|
||||
|
||||
@ -33,6 +33,8 @@ object ImageGetter {
|
||||
setTextureRegionDrawables()
|
||||
}
|
||||
|
||||
fun getGameBasics() = UncivGame.Current.gameBasics
|
||||
|
||||
fun setTextureRegionDrawables(){
|
||||
textureRegionDrawables.clear()
|
||||
for(region in atlas.regions){
|
||||
@ -110,13 +112,13 @@ object ImageGetter {
|
||||
return getImage("OtherIcons/Stop")
|
||||
if(improvementName.startsWith("StartingLocation ")){
|
||||
val nationName = improvementName.removePrefix("StartingLocation ")
|
||||
val nation = GameBasics.Nations[nationName]!!
|
||||
val nation = getGameBasics().Nations[nationName]!!
|
||||
return getNationIndicator(nation,size)
|
||||
}
|
||||
|
||||
val iconGroup = getImage("ImprovementIcons/$improvementName").surroundWithCircle(size)
|
||||
|
||||
val improvement = GameBasics.TileImprovements[improvementName]!!
|
||||
val improvement = getGameBasics().TileImprovements[improvementName]!!
|
||||
when {
|
||||
improvement.food>0 -> iconGroup.circle.color= foodCircleColor
|
||||
improvement.production>0 -> iconGroup.circle.color= productionCircleColor
|
||||
@ -129,8 +131,8 @@ object ImageGetter {
|
||||
}
|
||||
|
||||
fun getConstructionImage(construction: String): Image {
|
||||
if(GameBasics.Buildings.containsKey(construction)) return getImage("BuildingIcons/$construction")
|
||||
if(GameBasics.Units.containsKey(construction)) return getUnitIcon(construction)
|
||||
if(getGameBasics().Buildings.containsKey(construction)) return getImage("BuildingIcons/$construction")
|
||||
if(getGameBasics().Units.containsKey(construction)) return getUnitIcon(construction)
|
||||
if(construction=="Nothing") return getImage("OtherIcons/Stop")
|
||||
return getStatIcon(construction)
|
||||
}
|
||||
@ -178,7 +180,7 @@ object ImageGetter {
|
||||
|
||||
fun getResourceImage(resourceName: String, size:Float): Actor {
|
||||
val iconGroup = getImage("ResourceIcons/$resourceName").surroundWithCircle(size)
|
||||
val resource = GameBasics.TileResources[resourceName]!!
|
||||
val resource = getGameBasics().TileResources[resourceName]!!
|
||||
when {
|
||||
resource.food>0 -> iconGroup.circle.color= foodCircleColor
|
||||
resource.production>0 -> iconGroup.circle.color= productionCircleColor
|
||||
@ -202,7 +204,7 @@ object ImageGetter {
|
||||
|
||||
fun getTechIconGroup(techName: String, circleSize: Float): Group {
|
||||
var techIconColor = Color.WHITE
|
||||
when (GameBasics.Technologies[techName]!!.era().name) {
|
||||
when (getGameBasics().Technologies[techName]!!.era().name) {
|
||||
"Ancient" -> techIconColor = colorFromRGB(255, 87, 35)
|
||||
"Classical" -> techIconColor = colorFromRGB(233, 31, 99)
|
||||
"Medieval" -> techIconColor = colorFromRGB(157, 39, 176)
|
||||
|
@ -4,7 +4,6 @@ import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.badlogic.gdx.utils.Array
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.worldscreen.optionstable.PopupTable
|
||||
import java.util.*
|
||||
@ -42,7 +41,7 @@ class Tutorials{
|
||||
// ...Yes. Disgusting. I wish I didn't have to do this.
|
||||
val x = LinkedHashMap<String, Array<Array<String>>>()
|
||||
val tutorials: LinkedHashMap<String, Array<Array<String>>> =
|
||||
GameBasics.getFromJson(x.javaClass, "Tutorials/Tutorials_$language")
|
||||
UncivGame.Current.gameBasics.getFromJson(x.javaClass, "Tutorials/Tutorials_$language")
|
||||
val tutorialMap = HashMap<String, ArrayList<String>>()
|
||||
for (tutorial in tutorials){
|
||||
val list = ArrayList<String>()
|
||||
|
@ -150,24 +150,26 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
||||
add(getCloseButton("Very well."))
|
||||
}
|
||||
AlertType.WonderBuilt -> {
|
||||
val wonder = GameBasics.Buildings[popupAlert.value]!!
|
||||
val wonder = worldScreen.gameInfo.gameBasics.Buildings[popupAlert.value]!!
|
||||
addGoodSizedLabel(wonder.name)
|
||||
addSeparator()
|
||||
val centerTable = Table()
|
||||
centerTable.add(wonder.quote.toLabel().apply { setWrap(true) }).width(worldScreen.stage.width/3)
|
||||
centerTable.add(ImageGetter.getConstructionImage(wonder.name).surroundWithCircle(100f)).pad(20f)
|
||||
centerTable.add(wonder.getShortDescription().toLabel().apply { setWrap(true) }).width(worldScreen.stage.width/3)
|
||||
centerTable.add(wonder.getShortDescription(worldScreen.gameInfo.gameBasics)
|
||||
.toLabel().apply { setWrap(true) }).width(worldScreen.stage.width/3)
|
||||
add(centerTable).row()
|
||||
add(getCloseButton("Close"))
|
||||
}
|
||||
AlertType.TechResearched -> {
|
||||
val tech = GameBasics.Technologies[popupAlert.value]!!
|
||||
val gameBasics = worldScreen.gameInfo.gameBasics
|
||||
val tech = gameBasics.Technologies[popupAlert.value]!!
|
||||
addGoodSizedLabel(tech.name)
|
||||
addSeparator()
|
||||
val centerTable = Table()
|
||||
centerTable.add(tech.quote.toLabel().apply { setWrap(true) }).width(worldScreen.stage.width/3)
|
||||
centerTable.add(ImageGetter.getTechIconGroup(tech.name,100f)).pad(20f)
|
||||
centerTable.add(tech.getDescription().toLabel().apply { setWrap(true) }).width(worldScreen.stage.width/3)
|
||||
centerTable.add(tech.getDescription(gameBasics).toLabel().apply { setWrap(true) }).width(worldScreen.stage.width/3)
|
||||
add(centerTable).row()
|
||||
add(getCloseButton("Close"))
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import com.unciv.UncivGame
|
||||
import com.unciv.logic.GameSaver
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tile.ResourceType
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.models.gamebasics.unit.UnitType
|
||||
@ -255,7 +254,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
techButtonHolder.isVisible = viewingCiv.cities.isNotEmpty()
|
||||
techButtonHolder.clearChildren()
|
||||
|
||||
val researchableTechs = GameBasics.Technologies.values.filter { !viewingCiv.tech.isResearched(it.name) && viewingCiv.tech.canBeResearched(it.name) }
|
||||
val researchableTechs = viewingCiv.gameInfo.gameBasics.Technologies.values.filter { !viewingCiv.tech.isResearched(it.name) && viewingCiv.tech.canBeResearched(it.name) }
|
||||
if (viewingCiv.tech.currentTechnology() == null && researchableTechs.isEmpty())
|
||||
viewingCiv.tech.techsToResearch.add(Constants.futureTech)
|
||||
|
||||
|
@ -9,7 +9,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tile.ResourceType
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.models.stats.Stats
|
||||
@ -58,7 +57,7 @@ class WorldScreenTopBar(val screen: WorldScreen) : Table() {
|
||||
private fun getResourceTable(): Table {
|
||||
val resourceTable = Table()
|
||||
resourceTable.defaults().pad(5f)
|
||||
val revealedStrategicResources = GameBasics.TileResources.values
|
||||
val revealedStrategicResources = screen.gameInfo.gameBasics.TileResources.values
|
||||
.filter { it.resourceType == ResourceType.Strategic } // && currentPlayerCivInfo.tech.isResearched(it.revealedBy!!) }
|
||||
for (resource in revealedStrategicResources) {
|
||||
val resourceImage = ImageGetter.getResourceImage(resource.name,20f)
|
||||
@ -106,7 +105,7 @@ class WorldScreenTopBar(val screen: WorldScreen) : Table() {
|
||||
|
||||
|
||||
internal fun update(civInfo: CivilizationInfo) {
|
||||
val revealedStrategicResources = GameBasics.TileResources.values
|
||||
val revealedStrategicResources = civInfo.gameInfo.gameBasics.TileResources.values
|
||||
.filter { it.resourceType == ResourceType.Strategic }
|
||||
val civResources = civInfo.getCivResources()
|
||||
for (resource in revealedStrategicResources) {
|
||||
|
@ -71,6 +71,13 @@ class DropBox {
|
||||
dropboxApi("https://api.dropboxapi.com/2/files/delete_v2",
|
||||
"{\"path\":\"$fileName\"}","application/json")
|
||||
}
|
||||
//
|
||||
// fun createTemplate(): String {
|
||||
// val result = dropboxApi("https://api.dropboxapi.com/2/file_properties/templates/add_for_user",
|
||||
// "{\"name\": \"Security\",\"description\": \"These properties describe how confidential this file or folder is.\",\"fields\": [{\"name\": \"Security Policy\",\"description\": \"This is the security policy of the file or folder described.\nPolicies can be Confidential, Public or Internal.\",\"type\": \"string\"}]}"
|
||||
// ,"application/json")
|
||||
// return BufferedReader(InputStreamReader(result)).readText()
|
||||
// }
|
||||
|
||||
|
||||
class FolderList{
|
||||
|
@ -7,7 +7,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.*
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
|
||||
import com.badlogic.gdx.utils.Array
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.utils.*
|
||||
import com.unciv.ui.worldscreen.WorldScreen
|
||||
@ -16,9 +15,9 @@ import kotlin.concurrent.thread
|
||||
class Language(val language:String){
|
||||
val percentComplete:Int
|
||||
init{
|
||||
val availableTranslations = GameBasics.Translations.count { it.value.containsKey(language) }
|
||||
val availableTranslations = UncivGame.Current.gameBasics.Translations.count { it.value.containsKey(language) }
|
||||
if(language=="English") percentComplete = 100
|
||||
else percentComplete = (availableTranslations*100 / GameBasics.Translations.size)
|
||||
else percentComplete = (availableTranslations*100 / UncivGame.Current.gameBasics.Translations.size)
|
||||
}
|
||||
override fun toString(): String {
|
||||
val spaceSplitLang = language.replace("_"," ")
|
||||
@ -264,7 +263,8 @@ class WorldScreenOptionsTable(val worldScreen:WorldScreen) : PopupTable(worldScr
|
||||
innerTable.add("Language".toLabel())
|
||||
val languageSelectBox = SelectBox<Language>(skin)
|
||||
val languageArray = Array<Language>()
|
||||
GameBasics.Translations.getLanguages().map { Language(it) }.sortedByDescending { it.percentComplete }
|
||||
UncivGame.Current.gameBasics.Translations.getLanguages().map { Language(it) }
|
||||
.sortedByDescending { it.percentComplete }
|
||||
.forEach { languageArray.add(it) }
|
||||
languageSelectBox.items = languageArray
|
||||
val matchingLanguage = languageArray.firstOrNull { it.language == UncivGame.Current.settings.language }
|
||||
@ -286,7 +286,8 @@ class WorldScreenOptionsTable(val worldScreen:WorldScreen) : PopupTable(worldScr
|
||||
val missingTextSelectBox = SelectBox<String>(skin)
|
||||
val missingTextArray = Array<String>()
|
||||
val currentLanguage = UncivGame.Current.settings.language
|
||||
GameBasics.Translations.filter { !it.value.containsKey(currentLanguage) }.forEach { missingTextArray.add(it.key) }
|
||||
UncivGame.Current.gameBasics.Translations.filter { !it.value.containsKey(currentLanguage) }
|
||||
.forEach { missingTextArray.add(it.key) }
|
||||
missingTextSelectBox.items = missingTextArray
|
||||
missingTextSelectBox.selected = "Untranslated texts"
|
||||
innerTable.add(missingTextSelectBox).pad(10f)
|
||||
|
@ -9,9 +9,7 @@ import com.unciv.logic.map.MapUnit
|
||||
import com.unciv.logic.map.RoadStatus
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.models.gamebasics.Building
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.models.gamebasics.unit.UnitType
|
||||
import com.unciv.ui.pickerscreens.ImprovementPickerScreen
|
||||
import com.unciv.ui.pickerscreens.PromotionPickerScreen
|
||||
import com.unciv.ui.pickerscreens.TechPickerScreen
|
||||
@ -144,7 +142,7 @@ class UnitActions {
|
||||
actionList += UnitAction("Construct improvement",
|
||||
unit.currentMovement > 0
|
||||
&& !tile.isCityCenter()
|
||||
&& GameBasics.TileImprovements.values.any { tile.canBuildImprovement(it, unit.civInfo) },
|
||||
&& unit.civInfo.gameInfo.gameBasics.TileImprovements.values.any { tile.canBuildImprovement(it, unit.civInfo) },
|
||||
currentAction = unit.currentTile.hasImprovementInProgress()
|
||||
) { worldScreen.game.setScreen(ImprovementPickerScreen(tile) { unitTable.selectedUnit = null }) }
|
||||
|
||||
@ -163,7 +161,7 @@ class UnitActions {
|
||||
&& tile.roadStatus==RoadStatus.None
|
||||
&& tile.improvementInProgress != "Road"
|
||||
&& tile.isLand
|
||||
&& unit.civInfo.tech.isResearched(GameBasics.TileImprovements["Road"]!!.techRequired!!))
|
||||
&& unit.civInfo.tech.isResearched(RoadStatus.Road.improvement(unit.civInfo.gameInfo.gameBasics)!!.techRequired!!))
|
||||
actionList+=UnitAction("Construct road", unit.currentMovement >0){
|
||||
tile.improvementInProgress="Road"
|
||||
tile.turnsToImprovement=4
|
||||
@ -174,7 +172,7 @@ class UnitActions {
|
||||
&& tile.isWater // because fishing boats can enter cities, and if there's oil in the city... ;)
|
||||
&& tile.improvement==null
|
||||
&& tile.getTileResource().improvement == improvement
|
||||
&& unit.civInfo.tech.isResearched(GameBasics.TileImprovements[improvement]!!.techRequired!!)
|
||||
&& unit.civInfo.tech.isResearched(unit.civInfo.gameInfo.gameBasics.TileImprovements[improvement]!!.techRequired!!)
|
||||
)
|
||||
actionList += UnitAction("Create [$improvement]", unit.currentMovement >0) {
|
||||
tile.improvement = improvement
|
||||
|
@ -16,6 +16,7 @@ import kotlin.concurrent.thread
|
||||
internal object DesktopLauncher {
|
||||
@JvmStatic
|
||||
fun main(arg: Array<String>) {
|
||||
|
||||
if (File("../Images").exists()) // So we don't run this from within a fat JAR
|
||||
packImages()
|
||||
|
||||
|
Reference in New Issue
Block a user