mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 06:51:30 -04:00
WorldScreen now accepts player as parameter - important for multiplayer so people could see their own map even when it's someone else's turn
This commit is contained in:
parent
f3ba4b5486
commit
7b37e426a9
@ -2,6 +2,7 @@ package com.unciv
|
|||||||
|
|
||||||
import com.badlogic.gdx.Game
|
import com.badlogic.gdx.Game
|
||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
|
import com.badlogic.gdx.Input
|
||||||
import com.unciv.logic.GameInfo
|
import com.unciv.logic.GameInfo
|
||||||
import com.unciv.logic.GameSaver
|
import com.unciv.logic.GameSaver
|
||||||
import com.unciv.models.gamebasics.GameBasics
|
import com.unciv.models.gamebasics.GameBasics
|
||||||
@ -26,7 +27,7 @@ class UnCivGame(val version: String) : Game() {
|
|||||||
|
|
||||||
override fun create() {
|
override fun create() {
|
||||||
Current = this
|
Current = this
|
||||||
Gdx.input.isCatchBackKey=true
|
Gdx.input.setCatchKey(Input.Keys.BACK, true)
|
||||||
GameBasics.run { } // just to initialize the GameBasics
|
GameBasics.run { } // just to initialize the GameBasics
|
||||||
settings = GameSaver().getGeneralSettings()
|
settings = GameSaver().getGeneralSettings()
|
||||||
if (GameSaver().getSave("Autosave").exists()) {
|
if (GameSaver().getSave("Autosave").exists()) {
|
||||||
@ -41,7 +42,7 @@ class UnCivGame(val version: String) : Game() {
|
|||||||
|
|
||||||
fun loadGame(gameInfo:GameInfo){
|
fun loadGame(gameInfo:GameInfo){
|
||||||
this.gameInfo = gameInfo
|
this.gameInfo = gameInfo
|
||||||
worldScreen = WorldScreen()
|
worldScreen = WorldScreen(gameInfo.currentPlayerCiv)
|
||||||
setWorldScreen()
|
setWorldScreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ class UnCivGame(val version: String) : Game() {
|
|||||||
val newGame = GameStarter().startNewGame(GameParameters().apply { difficulty="Chieftain" })
|
val newGame = GameStarter().startNewGame(GameParameters().apply { difficulty="Chieftain" })
|
||||||
gameInfo = newGame
|
gameInfo = newGame
|
||||||
|
|
||||||
worldScreen = WorldScreen()
|
worldScreen = WorldScreen(gameInfo.currentPlayerCiv)
|
||||||
setWorldScreen()
|
setWorldScreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +77,7 @@ class UnCivGame(val version: String) : Game() {
|
|||||||
return create()
|
return create()
|
||||||
|
|
||||||
if(::worldScreen.isInitialized) worldScreen.dispose() // I hope this will solve some of the many OuOfMemory exceptions...
|
if(::worldScreen.isInitialized) worldScreen.dispose() // I hope this will solve some of the many OuOfMemory exceptions...
|
||||||
worldScreen = WorldScreen()
|
worldScreen = WorldScreen(gameInfo.currentPlayerCiv)
|
||||||
setWorldScreen()
|
setWorldScreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import com.badlogic.gdx.math.Vector2
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
|
import kotlin.math.sqrt
|
||||||
|
|
||||||
class HexMath {
|
class HexMath {
|
||||||
|
|
||||||
@ -24,8 +25,8 @@ class HexMath {
|
|||||||
|
|
||||||
fun hex2WorldCoords(hexCoord: Vector2): Vector2 {
|
fun hex2WorldCoords(hexCoord: Vector2): Vector2 {
|
||||||
// Distance between cells = 2* normal of triangle = 2* (sqrt(3)/2) = sqrt(3)
|
// Distance between cells = 2* normal of triangle = 2* (sqrt(3)/2) = sqrt(3)
|
||||||
val xVector = getVectorByClockHour(10).scl(Math.sqrt(3.0).toFloat())
|
val xVector = getVectorByClockHour(10).scl(sqrt(3.0).toFloat())
|
||||||
val yVector = getVectorByClockHour(2).scl(Math.sqrt(3.0).toFloat())
|
val yVector = getVectorByClockHour(2).scl(sqrt(3.0).toFloat())
|
||||||
return xVector.scl(hexCoord.x).add(yVector.scl(hexCoord.y))
|
return xVector.scl(hexCoord.x).add(yVector.scl(hexCoord.y))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,13 +16,19 @@ import com.unciv.models.stats.Stats
|
|||||||
|
|
||||||
class CityStats {
|
class CityStats {
|
||||||
|
|
||||||
@Transient var baseStatList = LinkedHashMap<String, Stats>()
|
@Transient
|
||||||
@Transient var statPercentBonusList = LinkedHashMap<String, Stats>()
|
var baseStatList = LinkedHashMap<String, Stats>()
|
||||||
@Transient var happinessList = LinkedHashMap<String, Float>()
|
@Transient
|
||||||
@Transient var foodEaten=0f
|
var statPercentBonusList = LinkedHashMap<String, Stats>()
|
||||||
|
@Transient
|
||||||
|
var happinessList = LinkedHashMap<String, Float>()
|
||||||
|
@Transient
|
||||||
|
var foodEaten = 0f
|
||||||
|
|
||||||
@Transient var currentCityStats: Stats = Stats() // This is so we won't have to calculate this multiple times - takes a lot of time, especially on phones
|
@Transient
|
||||||
@Transient lateinit var cityInfo: CityInfo
|
var currentCityStats: Stats = Stats() // This is so we won't have to calculate this multiple times - takes a lot of time, especially on phones
|
||||||
|
@Transient
|
||||||
|
lateinit var cityInfo: CityInfo
|
||||||
|
|
||||||
//region pure fuctions
|
//region pure fuctions
|
||||||
private fun getStatsFromTiles(): Stats {
|
private fun getStatsFromTiles(): Stats {
|
||||||
@ -38,7 +44,7 @@ class CityStats {
|
|||||||
if (!cityInfo.isCapital() && cityInfo.isConnectedToCapital()) {
|
if (!cityInfo.isCapital() && cityInfo.isConnectedToCapital()) {
|
||||||
val civInfo = cityInfo.civInfo
|
val civInfo = cityInfo.civInfo
|
||||||
var goldFromTradeRoute = civInfo.getCapital().population.population * 0.15 + cityInfo.population.population * 1.1 - 1 // Calculated by http://civilization.wikia.com/wiki/Trade_route_(Civ5)
|
var goldFromTradeRoute = civInfo.getCapital().population.population * 0.15 + cityInfo.population.population * 1.1 - 1 // Calculated by http://civilization.wikia.com/wiki/Trade_route_(Civ5)
|
||||||
if(civInfo.getNation().unique=="+1 Gold from each Trade Route, Oil resources provide double quantity") goldFromTradeRoute += 1
|
if (civInfo.getNation().unique == "+1 Gold from each Trade Route, Oil resources provide double quantity") goldFromTradeRoute += 1
|
||||||
if (civInfo.policies.isAdopted("Trade Unions")) goldFromTradeRoute += 2
|
if (civInfo.policies.isAdopted("Trade Unions")) goldFromTradeRoute += 2
|
||||||
if (civInfo.containsBuildingUnique("Gold from all trade routes +25%")) goldFromTradeRoute *= 1.25 // Machu Pichu speciality
|
if (civInfo.containsBuildingUnique("Gold from all trade routes +25%")) goldFromTradeRoute *= 1.25 // Machu Pichu speciality
|
||||||
stats.gold += goldFromTradeRoute.toFloat()
|
stats.gold += goldFromTradeRoute.toFloat()
|
||||||
@ -116,7 +122,7 @@ class CityStats {
|
|||||||
val stats = Stats()
|
val stats = Stats()
|
||||||
|
|
||||||
val civUnique = cityInfo.civInfo.getNation().unique
|
val civUnique = cityInfo.civInfo.getNation().unique
|
||||||
if(civUnique == "+2 Culture per turn from cities before discovering Steam Power")
|
if (civUnique == "+2 Culture per turn from cities before discovering Steam Power")
|
||||||
stats.culture += 2
|
stats.culture += 2
|
||||||
|
|
||||||
return stats
|
return stats
|
||||||
@ -141,15 +147,15 @@ class CityStats {
|
|||||||
|
|
||||||
val civUnique = cityInfo.civInfo.getNation().unique
|
val civUnique = cityInfo.civInfo.getNation().unique
|
||||||
val currentConstruction = cityInfo.cityConstructions.getCurrentConstruction()
|
val currentConstruction = cityInfo.cityConstructions.getCurrentConstruction()
|
||||||
if(civUnique=="+25% Production towards any buildings that already exist in the Capital"
|
if (civUnique == "+25% Production towards any buildings that already exist in the Capital"
|
||||||
&& currentConstruction is Building
|
&& currentConstruction is Building
|
||||||
&& cityInfo.civInfo.getCapital().cityConstructions.builtBuildings
|
&& cityInfo.civInfo.getCapital().cityConstructions.builtBuildings
|
||||||
.contains(currentConstruction.name))
|
.contains(currentConstruction.name))
|
||||||
stats.production+=25f
|
stats.production += 25f
|
||||||
|
|
||||||
if(civUnique=="+20% production towards Wonder construction"
|
if (civUnique == "+20% production towards Wonder construction"
|
||||||
&& currentConstruction is Building && currentConstruction.isWonder)
|
&& currentConstruction is Building && currentConstruction.isWonder)
|
||||||
stats.production+=20
|
stats.production += 20
|
||||||
|
|
||||||
return stats
|
return stats
|
||||||
}
|
}
|
||||||
@ -167,18 +173,18 @@ class CityStats {
|
|||||||
// needs to be a separate function because we need to know the global happiness state
|
// needs to be a separate function because we need to know the global happiness state
|
||||||
// in order to determine how much food is produced in a city!
|
// in order to determine how much food is produced in a city!
|
||||||
// -3 happiness per city
|
// -3 happiness per city
|
||||||
fun updateCityHappiness(){
|
fun updateCityHappiness() {
|
||||||
val civInfo = cityInfo.civInfo
|
val civInfo = cityInfo.civInfo
|
||||||
val newHappinessList = LinkedHashMap<String,Float>()
|
val newHappinessList = LinkedHashMap<String, Float>()
|
||||||
var unhappinessModifier = civInfo.getDifficulty().unhappinessModifier
|
var unhappinessModifier = civInfo.getDifficulty().unhappinessModifier
|
||||||
if(!civInfo.isPlayerCivilization())
|
if (!civInfo.isPlayerCivilization())
|
||||||
unhappinessModifier *= civInfo.gameInfo.getDifficulty().aiUnhappinessModifier
|
unhappinessModifier *= civInfo.gameInfo.getDifficulty().aiUnhappinessModifier
|
||||||
|
|
||||||
var unhappinessFromCity=-3f
|
|
||||||
if (civInfo.getNation().unique=="Unhappiness from number of Cities doubled, Unhappiness from number of Citizens halved.")
|
|
||||||
unhappinessFromCity*=2f//doubled for the Indian
|
|
||||||
|
|
||||||
newHappinessList ["Cities"] = unhappinessFromCity * unhappinessModifier
|
var unhappinessFromCity = -3f
|
||||||
|
if (civInfo.getNation().unique == "Unhappiness from number of Cities doubled, Unhappiness from number of Citizens halved.")
|
||||||
|
unhappinessFromCity *= 2f//doubled for the Indian
|
||||||
|
|
||||||
|
newHappinessList["Cities"] = unhappinessFromCity * unhappinessModifier
|
||||||
|
|
||||||
var unhappinessFromCitizens = cityInfo.population.population.toFloat()
|
var unhappinessFromCitizens = cityInfo.population.population.toFloat()
|
||||||
if (civInfo.policies.isAdopted("Democracy"))
|
if (civInfo.policies.isAdopted("Democracy"))
|
||||||
@ -187,7 +193,7 @@ class CityStats {
|
|||||||
unhappinessFromCitizens *= 0.9f
|
unhappinessFromCitizens *= 0.9f
|
||||||
if (civInfo.policies.isAdopted("Meritocracy"))
|
if (civInfo.policies.isAdopted("Meritocracy"))
|
||||||
unhappinessFromCitizens *= 0.95f
|
unhappinessFromCitizens *= 0.95f
|
||||||
if (civInfo.getNation().unique=="Unhappiness from number of Cities doubled, Unhappiness from number of Citizens halved.")
|
if (civInfo.getNation().unique == "Unhappiness from number of Cities doubled, Unhappiness from number of Citizens halved.")
|
||||||
unhappinessFromCitizens *= 0.5f //halved for the Indian
|
unhappinessFromCitizens *= 0.5f //halved for the Indian
|
||||||
|
|
||||||
newHappinessList["Population"] = -unhappinessFromCitizens * unhappinessModifier
|
newHappinessList["Population"] = -unhappinessFromCitizens * unhappinessModifier
|
||||||
@ -199,38 +205,38 @@ class CityStats {
|
|||||||
happinessFromPolicies += (cityInfo.population.population / 2).toFloat()
|
happinessFromPolicies += (cityInfo.population.population / 2).toFloat()
|
||||||
if (civInfo.policies.isAdopted("Meritocracy") && cityInfo.isConnectedToCapital())
|
if (civInfo.policies.isAdopted("Meritocracy") && cityInfo.isConnectedToCapital())
|
||||||
happinessFromPolicies += 1f
|
happinessFromPolicies += 1f
|
||||||
if(civInfo.policies.isAdopted("Military Caste") && cityInfo.getCenterTile().militaryUnit!=null)
|
if (civInfo.policies.isAdopted("Military Caste") && cityInfo.getCenterTile().militaryUnit != null)
|
||||||
happinessFromPolicies+=1
|
happinessFromPolicies += 1
|
||||||
|
|
||||||
newHappinessList ["Policies"] = happinessFromPolicies
|
newHappinessList["Policies"] = happinessFromPolicies
|
||||||
|
|
||||||
val happinessFromBuildings = cityInfo.cityConstructions.getStats().happiness.toInt().toFloat()
|
val happinessFromBuildings = cityInfo.cityConstructions.getStats().happiness.toInt().toFloat()
|
||||||
newHappinessList ["Buildings"] = happinessFromBuildings
|
newHappinessList["Buildings"] = happinessFromBuildings
|
||||||
|
|
||||||
if(civInfo.containsBuildingUnique("+1 happiness in each city"))
|
if (civInfo.containsBuildingUnique("+1 happiness in each city"))
|
||||||
newHappinessList["Wonders"] = 1f
|
newHappinessList["Wonders"] = 1f
|
||||||
|
|
||||||
// we don't want to modify the existing happiness list because that leads
|
// we don't want to modify the existing happiness list because that leads
|
||||||
// to concurrency problems if we iterate on it while changing
|
// to concurrency problems if we iterate on it while changing
|
||||||
happinessList=newHappinessList
|
happinessList = newHappinessList
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getStatsOfSpecialist(stat:Stat, policies: HashSet<String>): Stats {
|
fun getStatsOfSpecialist(stat: Stat, policies: HashSet<String>): Stats {
|
||||||
val stats = Stats()
|
val stats = Stats()
|
||||||
if(stat==Stat.Culture||stat==Stat.Science) stats.add(stat,3f)
|
if (stat == Stat.Culture || stat == Stat.Science) stats.add(stat, 3f)
|
||||||
else stats.add(stat,2f) // science and gold specialists
|
else stats.add(stat, 2f) // science and gold specialists
|
||||||
|
|
||||||
if (policies.contains("Commerce Complete")) stats.gold += 1
|
if (policies.contains("Commerce Complete")) stats.gold += 1
|
||||||
if (policies.contains("Secularism")) stats.science += 2
|
if (policies.contains("Secularism")) stats.science += 2
|
||||||
if(cityInfo.containsBuildingUnique("+1 Production from specialists"))
|
if (cityInfo.containsBuildingUnique("+1 Production from specialists"))
|
||||||
stats.production += 1
|
stats.production += 1
|
||||||
return stats
|
return stats
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getStatsFromSpecialists(specialists: Stats, policies: HashSet<String>): Stats {
|
private fun getStatsFromSpecialists(specialists: Stats, policies: HashSet<String>): Stats {
|
||||||
val stats = Stats()
|
val stats = Stats()
|
||||||
for(entry in specialists.toHashMap().filter { it.value>0 })
|
for (entry in specialists.toHashMap().filter { it.value > 0 })
|
||||||
stats.add(getStatsOfSpecialist(entry.key,policies)*entry.value)
|
stats.add(getStatsOfSpecialist(entry.key, policies) * entry.value)
|
||||||
return stats
|
return stats
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,7 +254,7 @@ class CityStats {
|
|||||||
stats.culture += 1f
|
stats.culture += 1f
|
||||||
if (adoptedPolicies.contains("Republic"))
|
if (adoptedPolicies.contains("Republic"))
|
||||||
stats.production += 1f
|
stats.production += 1f
|
||||||
if(adoptedPolicies.contains("Military Caste") && cityInfo.getCenterTile().militaryUnit!=null)
|
if (adoptedPolicies.contains("Military Caste") && cityInfo.getCenterTile().militaryUnit != null)
|
||||||
stats.culture += 2
|
stats.culture += 2
|
||||||
if (adoptedPolicies.contains("Universal Suffrage"))
|
if (adoptedPolicies.contains("Universal Suffrage"))
|
||||||
stats.production += (cityInfo.population.population / 5).toFloat()
|
stats.production += (cityInfo.population.population / 5).toFloat()
|
||||||
@ -272,15 +278,15 @@ class CityStats {
|
|||||||
if (cityInfo.civInfo.containsBuildingUnique("Culture in all cities increased by 25%")) stats.culture += 25f
|
if (cityInfo.civInfo.containsBuildingUnique("Culture in all cities increased by 25%")) stats.culture += 25f
|
||||||
|
|
||||||
val currentConstruction = cityInfo.cityConstructions.getCurrentConstruction()
|
val currentConstruction = cityInfo.cityConstructions.getCurrentConstruction()
|
||||||
if(currentConstruction is Building && currentConstruction.uniques.contains("Spaceship part")){
|
if (currentConstruction is Building && currentConstruction.uniques.contains("Spaceship part")) {
|
||||||
if(cityInfo.civInfo.containsBuildingUnique("Increases production of spaceship parts by 25%"))
|
if (cityInfo.civInfo.containsBuildingUnique("Increases production of spaceship parts by 25%"))
|
||||||
stats.production += 25
|
stats.production += 25
|
||||||
if(cityInfo.containsBuildingUnique("Increases production of spaceship parts by 50%"))
|
if (cityInfo.containsBuildingUnique("Increases production of spaceship parts by 50%"))
|
||||||
stats.production += 50
|
stats.production += 50
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentConstruction is BaseUnit && currentConstruction.unitType==UnitType.Mounted
|
if (currentConstruction is BaseUnit && currentConstruction.unitType == UnitType.Mounted
|
||||||
&& cityInfo.containsBuildingUnique("+15% Production when building Mounted Units in this city"))
|
&& cityInfo.containsBuildingUnique("+15% Production when building Mounted Units in this city"))
|
||||||
stats.production += 15
|
stats.production += 15
|
||||||
|
|
||||||
return stats
|
return stats
|
||||||
@ -295,10 +301,10 @@ class CityStats {
|
|||||||
stats.production += 50f
|
stats.production += 50f
|
||||||
if (policies.contains("Republic") && currentConstruction is Building)
|
if (policies.contains("Republic") && currentConstruction is Building)
|
||||||
stats.production += 5f
|
stats.production += 5f
|
||||||
if(policies.contains("Warrior Code") && currentConstruction is BaseUnit && currentConstruction.unitType.isMelee())
|
if (policies.contains("Warrior Code") && currentConstruction is BaseUnit && currentConstruction.unitType.isMelee())
|
||||||
stats.production += 20
|
stats.production += 20
|
||||||
if (policies.contains("Piety")
|
if (policies.contains("Piety")
|
||||||
&& listOf("Monument", "Temple", "Opera House", "Museum", "Broadcast Tower").contains(currentConstruction.name))
|
&& listOf("Monument", "Temple", "Opera House", "Museum", "Broadcast Tower").contains(currentConstruction.name))
|
||||||
stats.production += 15f
|
stats.production += 15f
|
||||||
if (policies.contains("Reformation") && cityConstructions.getBuiltBuildings().any { it.isWonder })
|
if (policies.contains("Reformation") && cityConstructions.getBuiltBuildings().any { it.isWonder })
|
||||||
stats.culture += 33f
|
stats.culture += 33f
|
||||||
@ -306,7 +312,7 @@ class CityStats {
|
|||||||
stats.gold += 25f
|
stats.gold += 25f
|
||||||
if (policies.contains("Sovereignty") && cityInfo.civInfo.getHappiness() >= 0)
|
if (policies.contains("Sovereignty") && cityInfo.civInfo.getHappiness() >= 0)
|
||||||
stats.science += 15f
|
stats.science += 15f
|
||||||
if (policies.contains("Total War") && currentConstruction is BaseUnit && !currentConstruction.unitType.isCivilian() )
|
if (policies.contains("Total War") && currentConstruction is BaseUnit && !currentConstruction.unitType.isCivilian())
|
||||||
stats.production += 15f
|
stats.production += 15f
|
||||||
if (policies.contains("Aristocracy")
|
if (policies.contains("Aristocracy")
|
||||||
&& currentConstruction is Building
|
&& currentConstruction is Building
|
||||||
@ -319,10 +325,10 @@ class CityStats {
|
|||||||
fun isConnectedToCapital(roadType: RoadStatus): Boolean {
|
fun isConnectedToCapital(roadType: RoadStatus): Boolean {
|
||||||
if (cityInfo.civInfo.cities.count() < 2) return false// first city!
|
if (cityInfo.civInfo.cities.count() < 2) return false// first city!
|
||||||
|
|
||||||
if(roadType==RoadStatus.Road) return cityInfo.isConnectedToCapital() // this transient is not applicable to connection via railroad.
|
if (roadType == RoadStatus.Road) return cityInfo.isConnectedToCapital() // this transient is not applicable to connection via railroad.
|
||||||
|
|
||||||
val capitalTile = cityInfo.civInfo.getCapital().getCenterTile()
|
val capitalTile = cityInfo.civInfo.getCapital().getCenterTile()
|
||||||
val bfs = BFS(capitalTile){it.roadStatus == roadType}
|
val bfs = BFS(capitalTile) { it.roadStatus == roadType }
|
||||||
|
|
||||||
val cityTile = cityInfo.getCenterTile()
|
val cityTile = cityInfo.getCenterTile()
|
||||||
bfs.stepUntilDestination(cityTile)
|
bfs.stepUntilDestination(cityTile)
|
||||||
@ -330,12 +336,14 @@ class CityStats {
|
|||||||
}
|
}
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
fun updateBaseStatList(){
|
fun updateBaseStatList() {
|
||||||
val newBaseStatList = LinkedHashMap<String, Stats>() // we don't edit the existing baseStatList directly, in order to avoid concurrency exceptions
|
val newBaseStatList = LinkedHashMap<String, Stats>() // we don't edit the existing baseStatList directly, in order to avoid concurrency exceptions
|
||||||
val civInfo = cityInfo.civInfo
|
val civInfo = cityInfo.civInfo
|
||||||
|
|
||||||
newBaseStatList["Population"] = Stats().add(Stat.Science, cityInfo.population.population.toFloat())
|
newBaseStatList["Population"] = Stats().apply {
|
||||||
.add(Stat.Production, cityInfo.population.getFreePopulation().toFloat())
|
science = cityInfo.population.population.toFloat()
|
||||||
|
production = cityInfo.population.getFreePopulation().toFloat()
|
||||||
|
}
|
||||||
newBaseStatList["Tile yields"] = getStatsFromTiles()
|
newBaseStatList["Tile yields"] = getStatsFromTiles()
|
||||||
newBaseStatList["Specialists"] = getStatsFromSpecialists(cityInfo.population.specialists, civInfo.policies.adoptedPolicies)
|
newBaseStatList["Specialists"] = getStatsFromSpecialists(cityInfo.population.specialists, civInfo.policies.adoptedPolicies)
|
||||||
newBaseStatList["Trade routes"] = getStatsFromTradeRoute()
|
newBaseStatList["Trade routes"] = getStatsFromTradeRoute()
|
||||||
@ -347,6 +355,7 @@ class CityStats {
|
|||||||
baseStatList = newBaseStatList
|
baseStatList = newBaseStatList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun updateStatPercentBonusList(){
|
fun updateStatPercentBonusList(){
|
||||||
val newStatPercentBonusList = LinkedHashMap<String,Stats>()
|
val newStatPercentBonusList = LinkedHashMap<String,Stats>()
|
||||||
newStatPercentBonusList["Golden Age"]=getStatPercentBonusesFromGoldenAge(cityInfo.civInfo.goldenAges.isGoldenAge())
|
newStatPercentBonusList["Golden Age"]=getStatPercentBonusesFromGoldenAge(cityInfo.civInfo.goldenAges.isGoldenAge())
|
||||||
|
@ -308,7 +308,7 @@ class NewGameScreen: PickerScreen(){
|
|||||||
override fun render(delta: Float) {
|
override fun render(delta: Float) {
|
||||||
if(newGame!=null){
|
if(newGame!=null){
|
||||||
game.gameInfo=newGame!!
|
game.gameInfo=newGame!!
|
||||||
game.worldScreen = WorldScreen()
|
game.worldScreen = WorldScreen(newGame!!.currentPlayerCiv)
|
||||||
game.setWorldScreen()
|
game.setWorldScreen()
|
||||||
}
|
}
|
||||||
super.render(delta)
|
super.render(delta)
|
||||||
|
@ -271,14 +271,14 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
|
|||||||
|
|
||||||
val civColor = tileInfo.getOwner()!!.getNation().getColor()
|
val civColor = tileInfo.getOwner()!!.getNation().getColor()
|
||||||
for (neighbor in tileInfo.neighbors) {
|
for (neighbor in tileInfo.neighbors) {
|
||||||
val neigborOwner = neighbor.getOwner()
|
val neighborOwner = neighbor.getOwner()
|
||||||
if (neigborOwner == tileOwner && borderImages.containsKey(neighbor)) // the neighbor used to not belong to us, but now it's ours
|
if (neighborOwner == tileOwner && borderImages.containsKey(neighbor)) // the neighbor used to not belong to us, but now it's ours
|
||||||
{
|
{
|
||||||
for (image in borderImages[neighbor]!!)
|
for (image in borderImages[neighbor]!!)
|
||||||
image.remove()
|
image.remove()
|
||||||
borderImages.remove(neighbor)
|
borderImages.remove(neighbor)
|
||||||
}
|
}
|
||||||
if (neigborOwner != tileOwner && !borderImages.containsKey(neighbor)) { // there should be a border here but there isn't
|
if (neighborOwner != tileOwner && !borderImages.containsKey(neighbor)) { // there should be a border here but there isn't
|
||||||
|
|
||||||
val relativeHexPosition = tileInfo.position.cpy().sub(neighbor.position)
|
val relativeHexPosition = tileInfo.position.cpy().sub(neighbor.position)
|
||||||
val relativeWorldPosition = HexMath().hex2WorldCoords(relativeHexPosition)
|
val relativeWorldPosition = HexMath().hex2WorldCoords(relativeHexPosition)
|
||||||
|
@ -16,7 +16,7 @@ class PlayerReadyScreen(currentPlayerCiv: CivilizationInfo) : CameraStageBaseScr
|
|||||||
.setFontColor(currentPlayerCiv.getNation().getSecondaryColor()))
|
.setFontColor(currentPlayerCiv.getNation().getSecondaryColor()))
|
||||||
|
|
||||||
table.onClick {
|
table.onClick {
|
||||||
UnCivGame.Current.worldScreen = WorldScreen().apply {
|
UnCivGame.Current.worldScreen = WorldScreen(currentPlayerCiv).apply {
|
||||||
shouldUpdate = true
|
shouldUpdate = true
|
||||||
}
|
}
|
||||||
UnCivGame.Current.setWorldScreen()
|
UnCivGame.Current.setWorldScreen()
|
||||||
|
@ -27,9 +27,8 @@ import com.unciv.ui.worldscreen.bottombar.BattleTable
|
|||||||
import com.unciv.ui.worldscreen.bottombar.WorldScreenBottomBar
|
import com.unciv.ui.worldscreen.bottombar.WorldScreenBottomBar
|
||||||
import com.unciv.ui.worldscreen.unit.UnitActionsTable
|
import com.unciv.ui.worldscreen.unit.UnitActionsTable
|
||||||
|
|
||||||
class WorldScreen : CameraStageBaseScreen() {
|
class WorldScreen(val currentPlayerCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||||
val gameInfo = game.gameInfo
|
val gameInfo = game.gameInfo
|
||||||
internal val currentPlayerCiv: CivilizationInfo = gameInfo.getCurrentPlayerCivilization()
|
|
||||||
|
|
||||||
val tileMapHolder: TileMapHolder = TileMapHolder(this, gameInfo.tileMap)
|
val tileMapHolder: TileMapHolder = TileMapHolder(this, gameInfo.tileMap)
|
||||||
val minimapWrapper = MinimapHolder(tileMapHolder)
|
val minimapWrapper = MinimapHolder(tileMapHolder)
|
||||||
@ -319,7 +318,7 @@ class WorldScreen : CameraStageBaseScreen() {
|
|||||||
override fun resize(width: Int, height: Int) {
|
override fun resize(width: Int, height: Int) {
|
||||||
if (stage.viewport.screenWidth != width || stage.viewport.screenHeight != height) {
|
if (stage.viewport.screenWidth != width || stage.viewport.screenHeight != height) {
|
||||||
super.resize(width, height)
|
super.resize(width, height)
|
||||||
game.worldScreen = WorldScreen() // start over.
|
game.worldScreen = WorldScreen(currentPlayerCiv) // start over.
|
||||||
game.setWorldScreen()
|
game.setWorldScreen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ class Language(val language:String){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
class WorldScreenOptionsTable(val worldScreen:WorldScreen) : PopupTable(worldScreen){
|
||||||
var selectedLanguage: String = "English"
|
var selectedLanguage: String = "English"
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@ -142,7 +142,7 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
|||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||||
UnCivGame.Current.settings.resolution = resolutionSelectBox.selected
|
UnCivGame.Current.settings.resolution = resolutionSelectBox.selected
|
||||||
UnCivGame.Current.settings.save()
|
UnCivGame.Current.settings.save()
|
||||||
UnCivGame.Current.worldScreen = WorldScreen()
|
UnCivGame.Current.worldScreen = WorldScreen(worldScreen.currentPlayerCiv)
|
||||||
UnCivGame.Current.setWorldScreen()
|
UnCivGame.Current.setWorldScreen()
|
||||||
WorldScreenOptionsTable(UnCivGame.Current.worldScreen)
|
WorldScreenOptionsTable(UnCivGame.Current.worldScreen)
|
||||||
}
|
}
|
||||||
@ -165,7 +165,7 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
|||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||||
UnCivGame.Current.settings.tileSet = tileSetSelectBox.selected
|
UnCivGame.Current.settings.tileSet = tileSetSelectBox.selected
|
||||||
UnCivGame.Current.settings.save()
|
UnCivGame.Current.settings.save()
|
||||||
UnCivGame.Current.worldScreen = WorldScreen()
|
UnCivGame.Current.worldScreen = WorldScreen(worldScreen.currentPlayerCiv)
|
||||||
UnCivGame.Current.setWorldScreen()
|
UnCivGame.Current.setWorldScreen()
|
||||||
WorldScreenOptionsTable(UnCivGame.Current.worldScreen)
|
WorldScreenOptionsTable(UnCivGame.Current.worldScreen)
|
||||||
}
|
}
|
||||||
@ -248,7 +248,7 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
|||||||
|
|
||||||
CameraStageBaseScreen.resetFonts()
|
CameraStageBaseScreen.resetFonts()
|
||||||
|
|
||||||
UnCivGame.Current.worldScreen = WorldScreen()
|
UnCivGame.Current.worldScreen = WorldScreen(worldScreen.currentPlayerCiv)
|
||||||
UnCivGame.Current.setWorldScreen()
|
UnCivGame.Current.setWorldScreen()
|
||||||
WorldScreenOptionsTable(UnCivGame.Current.worldScreen)
|
WorldScreenOptionsTable(UnCivGame.Current.worldScreen)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user