Nation changed to transient in CivInfo

This commit is contained in:
Yair Morgenstern 2019-08-15 10:43:15 +03:00
parent d84863d2dd
commit 365cb6f1b9
26 changed files with 97 additions and 84 deletions

View file

@ -83,7 +83,7 @@ class GameStarter{
gameInfo.setTransients() // needs to be before placeBarbarianUnit because it depends on the tilemap having its gameinfo set gameInfo.setTransients() // needs to be before placeBarbarianUnit because it depends on the tilemap having its gameinfo set
for (civInfo in gameInfo.civilizations.filter {!it.isBarbarianCivilization() && !it.isPlayerCivilization()}) { for (civInfo in gameInfo.civilizations.filter {!it.isBarbarian() && !it.isPlayerCivilization()}) {
for (tech in gameInfo.getDifficulty().aiFreeTechs) for (tech in gameInfo.getDifficulty().aiFreeTechs)
civInfo.tech.addTechnology(tech) civInfo.tech.addTechnology(tech)
} }
@ -92,10 +92,10 @@ class GameStarter{
val startingLocations = getStartingLocations( val startingLocations = getStartingLocations(
gameInfo.civilizations.filter { !it.isBarbarianCivilization() }, gameInfo.civilizations.filter { !it.isBarbarian() },
gameInfo.tileMap) gameInfo.tileMap)
for (civ in gameInfo.civilizations.filter { !it.isBarbarianCivilization() }) { for (civ in gameInfo.civilizations.filter { !it.isBarbarian() }) {
val startingLocation = startingLocations[civ]!! val startingLocation = startingLocations[civ]!!
civ.placeUnitNearTile(startingLocation.position, Constants.settler) civ.placeUnitNearTile(startingLocation.position, Constants.settler)
@ -133,7 +133,7 @@ class GameStarter{
val civsOrderedByAvailableLocations = civs.sortedBy {civ -> val civsOrderedByAvailableLocations = civs.sortedBy {civ ->
when { when {
tilesWithStartingLocations.any { it.improvement=="StartingLocation "+civ.civName } -> 1 // harshest requirements tilesWithStartingLocations.any { it.improvement=="StartingLocation "+civ.civName } -> 1 // harshest requirements
civ.getNation().startBias.isNotEmpty() -> 2 // less harsh civ.nation.startBias.isNotEmpty() -> 2 // less harsh
else -> 3 else -> 3
} // no requirements } // no requirements
} }
@ -146,7 +146,7 @@ class GameStarter{
if (freeTiles.isEmpty()) break // we failed to get all the starting locations with this minimum distance if (freeTiles.isEmpty()) break // we failed to get all the starting locations with this minimum distance
var preferredTiles = freeTiles.toList() var preferredTiles = freeTiles.toList()
for (startBias in civ.getNation().startBias) { for (startBias in civ.nation.startBias) {
if (startBias.startsWith("Avoid ")) { if (startBias.startsWith("Avoid ")) {
val tileToAvoid = startBias.removePrefix("Avoid ") val tileToAvoid = startBias.removePrefix("Avoid ")
preferredTiles = preferredTiles.filter { it.baseTerrain != tileToAvoid && it.terrainFeature != tileToAvoid } preferredTiles = preferredTiles.filter { it.baseTerrain != tileToAvoid && it.terrainFeature != tileToAvoid }

View file

@ -127,7 +127,7 @@ class GameInfo {
fun placeBarbarianEncampment(existingEncampments: List<TileInfo>): TileInfo? { fun placeBarbarianEncampment(existingEncampments: List<TileInfo>): TileInfo? {
// Barbarians will only spawn in places that no one can see // Barbarians will only spawn in places that no one can see
val allViewableTiles = civilizations.filterNot { it.isBarbarianCivilization() } val allViewableTiles = civilizations.filterNot { it.isBarbarian() }
.flatMap { it.viewableTiles }.toHashSet() .flatMap { it.viewableTiles }.toHashSet()
val tilesWithin3ofExistingEncampment = existingEncampments.flatMap { it.getTilesInDistance(3) } val tilesWithin3ofExistingEncampment = existingEncampments.flatMap { it.getTilesInDistance(3) }
val viableTiles = tileMap.values.filter { val viableTiles = tileMap.values.filter {
@ -146,7 +146,7 @@ class GameInfo {
// if we don't make this into a separate list then the retain() will happen on the Tech keys, // if we don't make this into a separate list then the retain() will happen on the Tech keys,
// which effectively removes those techs from the game and causes all sorts of problems // which effectively removes those techs from the game and causes all sorts of problems
val allResearchedTechs = GameBasics.Technologies.keys.toMutableList() val allResearchedTechs = GameBasics.Technologies.keys.toMutableList()
for (civ in civilizations.filter { !it.isBarbarianCivilization() && !it.isDefeated() }) { for (civ in civilizations.filter { !it.isBarbarian() && !it.isDefeated() }) {
allResearchedTechs.retainAll(civ.tech.techsResearched) allResearchedTechs.retainAll(civ.tech.techsResearched)
} }
val barbarianCiv = getBarbarianCivilization() val barbarianCiv = getBarbarianCivilization()
@ -209,13 +209,13 @@ class GameInfo {
} }
} }
for (civInfo in civilizations) { for (civInfo in civilizations) civInfo.setNationTransient()
civInfo.setTransients() for (civInfo in civilizations) civInfo.setTransients()
for(unit in civInfo.getCivUnits())
unit.updateViewableTiles() // this needs to be done after all the units are assigned to their civs and all other transients are set
}
for (civInfo in civilizations){ for (civInfo in civilizations){
for(unit in civInfo.getCivUnits())
unit.updateViewableTiles() // this needs to be done after all the units are assigned to their civs and all other transients are set
// Since this depends on the cities of ALL civilizations, // Since this depends on the cities of ALL civilizations,
// we need to wait until we've set the transients of all the cities before we can run this. // we need to wait until we've set the transients of all the cities before we can run this.
// Hence why it's not in CivInfo.setTransients(). // Hence why it's not in CivInfo.setTransients().

View file

@ -306,7 +306,7 @@ class NextTurnAutomation{
val ourCombatStrength = Automation().evaluteCombatStrength(civInfo) val ourCombatStrength = Automation().evaluteCombatStrength(civInfo)
val enemiesCiv = civInfo.diplomacy.filter { it.value.diplomaticStatus == DiplomaticStatus.War } val enemiesCiv = civInfo.diplomacy.filter { it.value.diplomaticStatus == DiplomaticStatus.War }
.map { it.value.otherCiv() } .map { it.value.otherCiv() }
.filterNot { it == civInfo || it.isBarbarianCivilization() || it.cities.isEmpty() } .filterNot { it == civInfo || it.isBarbarian() || it.cities.isEmpty() }
.filter { !civInfo.getDiplomacyManager(it).hasFlag(DiplomacyFlags.DeclinedPeace) } .filter { !civInfo.getDiplomacyManager(it).hasFlag(DiplomacyFlags.DeclinedPeace) }
for (enemy in enemiesCiv) { for (enemy in enemiesCiv) {

View file

@ -48,7 +48,7 @@ class UnitAutomation{
val unitActions = UnitActions().getUnitActions(unit,UnCivGame.Current.worldScreen) val unitActions = UnitActions().getUnitActions(unit,UnCivGame.Current.worldScreen)
var unitDistanceToTiles = unit.movement.getDistanceToTiles() var unitDistanceToTiles = unit.movement.getDistanceToTiles()
if(unit.civInfo.isBarbarianCivilization() && if(unit.civInfo.isBarbarian() &&
unit.currentTile.improvement==Constants.barbarianEncampment && unit.type.isLandUnit()) { unit.currentTile.improvement==Constants.barbarianEncampment && unit.type.isLandUnit()) {
if(unit.canFortify()) unit.fortify() if(unit.canFortify()) unit.fortify()
return // stay in the encampment return // stay in the encampment
@ -75,7 +75,7 @@ class UnitAutomation{
if (tryAttackNearbyEnemy(unit)) return if (tryAttackNearbyEnemy(unit)) return
// Barbarians try to pillage improvements if no targets reachable // Barbarians try to pillage improvements if no targets reachable
if (unit.civInfo.isBarbarianCivilization() && tryPillageImprovement(unit, unitDistanceToTiles)) return if (unit.civInfo.isBarbarian() && tryPillageImprovement(unit, unitDistanceToTiles)) return
if (tryGarrisoningUnit(unit)) return if (tryGarrisoningUnit(unit)) return
@ -95,12 +95,12 @@ class UnitAutomation{
if(tryExplore(unit,unitDistanceToTiles)) return if(tryExplore(unit,unitDistanceToTiles)) return
// Barbarians just wander all over the place // Barbarians just wander all over the place
if(unit.civInfo.isBarbarianCivilization()) if(unit.civInfo.isBarbarian())
wander(unit,unitDistanceToTiles) wander(unit,unitDistanceToTiles)
} }
private fun tryHeadTowardsEncampment(unit: MapUnit): Boolean { private fun tryHeadTowardsEncampment(unit: MapUnit): Boolean {
if(unit.civInfo.isBarbarianCivilization()) return false if(unit.civInfo.isBarbarian()) return false
val knownEncampments = unit.civInfo.gameInfo.tileMap.values.asSequence() val knownEncampments = unit.civInfo.gameInfo.tileMap.values.asSequence()
.filter { it.improvement==Constants.barbarianEncampment && unit.civInfo.exploredTiles.contains(it.position) } .filter { it.improvement==Constants.barbarianEncampment && unit.civInfo.exploredTiles.contains(it.position) }
val cities = unit.civInfo.cities val cities = unit.civInfo.cities

View file

@ -104,9 +104,9 @@ class Battle(val gameInfo:GameInfo) {
// German unique - needs to be checked before we try to move to the enemy tile, since the encampment disappears after we move in // German unique - needs to be checked before we try to move to the enemy tile, since the encampment disappears after we move in
if(defender.isDefeated() && defender.getCivInfo().isBarbarianCivilization() if(defender.isDefeated() && defender.getCivInfo().isBarbarian()
&& attackedTile.improvement==Constants.barbarianEncampment && attackedTile.improvement==Constants.barbarianEncampment
&& attacker.getCivInfo().getNation().unique== "67% chance to earn 25 Gold and recruit a Barbarian unit from a conquered encampment, -25% land units maintenance." && attacker.getCivInfo().nation.unique== "67% chance to earn 25 Gold and recruit a Barbarian unit from a conquered encampment, -25% land units maintenance."
&& Random().nextDouble() > 0.67){ && Random().nextDouble() > 0.67){
attacker.getCivInfo().placeUnitNearTile(attackedTile.position, defender.getName()) attacker.getCivInfo().placeUnitNearTile(attackedTile.position, defender.getName())
attacker.getCivInfo().gold += 25 attacker.getCivInfo().gold += 25
@ -115,7 +115,7 @@ class Battle(val gameInfo:GameInfo) {
// Similarly, Ottoman unique // Similarly, Ottoman unique
if(defender.isDefeated() && defender.getUnitType().isWaterUnit() && attacker.isMelee() && attacker.getUnitType().isWaterUnit() if(defender.isDefeated() && defender.getUnitType().isWaterUnit() && attacker.isMelee() && attacker.getUnitType().isWaterUnit()
&& attacker.getCivInfo().getNation().unique== "Pay only one third the usual cost for naval unit maintenance. Melee naval units have a 1/3 chance to capture defeated naval units." && attacker.getCivInfo().nation.unique== "Pay only one third the usual cost for naval unit maintenance. Melee naval units have a 1/3 chance to capture defeated naval units."
&& Random().nextDouble() > 0.33){ && Random().nextDouble() > 0.33){
attacker.getCivInfo().placeUnitNearTile(attackedTile.position, defender.getName()) attacker.getCivInfo().placeUnitNearTile(attackedTile.position, defender.getName())
} }
@ -165,7 +165,7 @@ class Battle(val gameInfo:GameInfo) {
// Add culture when defeating a barbarian when Honor policy is adopted (can be either attacker or defender!) // Add culture when defeating a barbarian when Honor policy is adopted (can be either attacker or defender!)
fun tryGetCultureFromHonor(civUnit:ICombatant, barbarianUnit:ICombatant){ fun tryGetCultureFromHonor(civUnit:ICombatant, barbarianUnit:ICombatant){
if(barbarianUnit.isDefeated() && barbarianUnit is MapUnitCombatant if(barbarianUnit.isDefeated() && barbarianUnit is MapUnitCombatant
&& barbarianUnit.getCivInfo().isBarbarianCivilization() && barbarianUnit.getCivInfo().isBarbarian()
&& civUnit.getCivInfo().policies.isAdopted("Honor")) && civUnit.getCivInfo().policies.isAdopted("Honor"))
civUnit.getCivInfo().policies.storedCulture += civUnit.getCivInfo().policies.storedCulture +=
max(barbarianUnit.unit.baseUnit.strength,barbarianUnit.unit.baseUnit.rangedStrength) max(barbarianUnit.unit.baseUnit.strength,barbarianUnit.unit.baseUnit.rangedStrength)
@ -185,13 +185,13 @@ class Battle(val gameInfo:GameInfo) {
// XP! // XP!
fun addXp(thisCombatant:ICombatant, amount:Int, otherCombatant:ICombatant){ fun addXp(thisCombatant:ICombatant, amount:Int, otherCombatant:ICombatant){
if(thisCombatant !is MapUnitCombatant) return if(thisCombatant !is MapUnitCombatant) return
if(thisCombatant.unit.promotions.totalXpProduced() >= 30 && otherCombatant.getCivInfo().isBarbarianCivilization()) if(thisCombatant.unit.promotions.totalXpProduced() >= 30 && otherCombatant.getCivInfo().isBarbarian())
return return
var amountToAdd = amount var amountToAdd = amount
if(thisCombatant.getCivInfo().policies.isAdopted("Military Tradition")) amountToAdd = (amountToAdd * 1.5f).toInt() if(thisCombatant.getCivInfo().policies.isAdopted("Military Tradition")) amountToAdd = (amountToAdd * 1.5f).toInt()
thisCombatant.unit.promotions.XP += amountToAdd thisCombatant.unit.promotions.XP += amountToAdd
if(thisCombatant.getCivInfo().getNation().unique if(thisCombatant.getCivInfo().nation.unique
== "Great general provides double combat bonus, and spawns 50% faster") == "Great general provides double combat bonus, and spawns 50% faster")
amountToAdd = (amountToAdd * 1.5f).toInt() amountToAdd = (amountToAdd * 1.5f).toInt()
if(thisCombatant.unit.hasUnique("Combat very likely to create Great Generals")) if(thisCombatant.unit.hasUnique("Combat very likely to create Great Generals"))
@ -274,7 +274,7 @@ class Battle(val gameInfo:GameInfo) {
} }
fun captureCivilianUnit(attacker: ICombatant, defender: ICombatant){ fun captureCivilianUnit(attacker: ICombatant, defender: ICombatant){
if(attacker.getCivInfo().isBarbarianCivilization() if(attacker.getCivInfo().isBarbarian()
|| (attacker.getCivInfo().isCityState() && defender.getName()==Constants.settler)){ || (attacker.getCivInfo().isCityState() && defender.getName()==Constants.settler)){
defender.takeDamage(100) defender.takeDamage(100)
return return

View file

@ -66,7 +66,7 @@ class BattleDamage{
val requiredResource = combatant.unit.baseUnit.requiredResource val requiredResource = combatant.unit.baseUnit.requiredResource
if(requiredResource!=null && combatant.getCivInfo().getCivResourcesByName()[requiredResource]!!<0 if(requiredResource!=null && combatant.getCivInfo().getCivResourcesByName()[requiredResource]!!<0
&& !combatant.getCivInfo().isBarbarianCivilization()){ && !combatant.getCivInfo().isBarbarian()){
modifiers["Missing resource"]=-0.25f modifiers["Missing resource"]=-0.25f
} }
@ -76,14 +76,14 @@ class BattleDamage{
.filter {it.civilianUnit?.civInfo == combatant.unit.civInfo} .filter {it.civilianUnit?.civInfo == combatant.unit.civInfo}
.map {it.civilianUnit} .map {it.civilianUnit}
if (nearbyCivUnits.any { it!!.hasUnique("Bonus for units in 2 tile radius 15%") }) { if (nearbyCivUnits.any { it!!.hasUnique("Bonus for units in 2 tile radius 15%") }) {
modifiers["Great General"]= if (combatant.unit.civInfo.getNation().unique == modifiers["Great General"]= if (combatant.unit.civInfo.nation.unique ==
"Great general provides double combat bonus, and spawns 50% faster") 0.3f "Great general provides double combat bonus, and spawns 50% faster") 0.3f
else 0.15f else 0.15f
} }
} }
} }
if (combatant.getCivInfo().policies.isAdopted("Honor") && enemy.getCivInfo().isBarbarianCivilization()) if (combatant.getCivInfo().policies.isAdopted("Honor") && enemy.getCivInfo().isBarbarian())
modifiers["vs Barbarians"] = 0.25f modifiers["vs Barbarians"] = 0.25f
return modifiers return modifiers
@ -202,7 +202,7 @@ class BattleDamage{
private fun getHealthDependantDamageRatio(combatant: ICombatant): Float { private fun getHealthDependantDamageRatio(combatant: ICombatant): Float {
if (combatant.getUnitType() == UnitType.City if (combatant.getUnitType() == UnitType.City
|| combatant.getCivInfo().getNation().unique == "Units fight as though they were at full strength even when damaged") || combatant.getCivInfo().nation.unique == "Units fight as though they were at full strength even when damaged")
return 1f return 1f
return 1/2f + combatant.getHealth()/200f // Each point of health reduces damage dealt by 0.5% return 1/2f + combatant.getHealth()/200f // Each point of health reduces damage dealt by 0.5%
} }

View file

@ -54,7 +54,7 @@ class CityExpansionManager {
if(cityInfo.containsBuildingUnique("Culture and Gold costs of acquiring new tiles reduced by 25% in this city")) if(cityInfo.containsBuildingUnique("Culture and Gold costs of acquiring new tiles reduced by 25% in this city"))
cost *= 0.75 // Specialty of Krepost cost *= 0.75 // Specialty of Krepost
if(cityInfo.civInfo.getNation().unique=="All land military units have +1 sight, 50% discount when purchasing tiles") if(cityInfo.civInfo.nation.unique=="All land military units have +1 sight, 50% discount when purchasing tiles")
cost /= 2 cost /= 2
return cost.toInt() return cost.toInt()
} }

View file

@ -117,10 +117,10 @@ class CityInfo {
if(resource.resourceType == ResourceType.Strategic){ if(resource.resourceType == ResourceType.Strategic){
amountToAdd = 2 amountToAdd = 2
if(civInfo.policies.isAdopted("Facism")) amountToAdd*=2 if(civInfo.policies.isAdopted("Facism")) amountToAdd*=2
if(civInfo.getNation().unique=="Strategic Resources provide +1 Production, and Horses, Iron and Uranium Resources provide double quantity" if(civInfo.nation.unique=="Strategic Resources provide +1 Production, and Horses, Iron and Uranium Resources provide double quantity"
&& resource.name in listOf("Horses","Iron","Uranium")) && resource.name in listOf("Horses","Iron","Uranium"))
amountToAdd *= 2 amountToAdd *= 2
if(resource.name=="Oil" && civInfo.getNation().unique=="+1 Gold from each Trade Route, Oil resources provide double quantity") if(resource.name=="Oil" && civInfo.nation.unique=="+1 Gold from each Trade Route, Oil resources provide double quantity")
amountToAdd *= 2 amountToAdd *= 2
} }
if(resource.resourceType == ResourceType.Luxury if(resource.resourceType == ResourceType.Luxury
@ -156,7 +156,7 @@ class CityInfo {
stats["Buildings"] = buildingStats stats["Buildings"] = buildingStats
for(entry in stats){ for(entry in stats){
if(civInfo.getNation().unique=="Receive free Great Scientist when you discover Writing, Earn Great Scientists 50% faster") if(civInfo.nation.unique=="Receive free Great Scientist when you discover Writing, Earn Great Scientists 50% faster")
entry.value.science *= 1.5f entry.value.science *= 1.5f
if (civInfo.policies.isAdopted("Entrepreneurship")) if (civInfo.policies.isAdopted("Entrepreneurship"))
entry.value.gold *= 1.25f entry.value.gold *= 1.25f

View file

@ -44,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.nation.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()
@ -121,7 +121,7 @@ class CityStats {
private fun getStatsFromNationUnique(): Stats { private fun getStatsFromNationUnique(): Stats {
val stats = Stats() val stats = Stats()
val civUnique = cityInfo.civInfo.getNation().unique val civUnique = cityInfo.civInfo.nation.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
@ -145,7 +145,7 @@ class CityStats {
private fun getStatPercentBonusesFromNationUnique(): Stats { private fun getStatPercentBonusesFromNationUnique(): Stats {
val stats = Stats() val stats = Stats()
val civUnique = cityInfo.civInfo.getNation().unique val civUnique = cityInfo.civInfo.nation.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
@ -181,7 +181,7 @@ class CityStats {
unhappinessModifier *= civInfo.gameInfo.getDifficulty().aiUnhappinessModifier unhappinessModifier *= civInfo.gameInfo.getDifficulty().aiUnhappinessModifier
var unhappinessFromCity = -3f var unhappinessFromCity = -3f
if (civInfo.getNation().unique == "Unhappiness from number of Cities doubled, Unhappiness from number of Citizens halved.") if (civInfo.nation.unique == "Unhappiness from number of Cities doubled, Unhappiness from number of Citizens halved.")
unhappinessFromCity *= 2f//doubled for the Indian unhappinessFromCity *= 2f//doubled for the Indian
newHappinessList["Cities"] = unhappinessFromCity * unhappinessModifier newHappinessList["Cities"] = unhappinessFromCity * unhappinessModifier
@ -193,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.nation.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

View file

@ -20,7 +20,7 @@ class CivInfoStats(val civInfo: CivilizationInfo){
if(civInfo.policies.isAdopted("Oligarchy")) unitsToPayFor = unitsToPayFor.filterNot { it.getTile().isCityCenter() } if(civInfo.policies.isAdopted("Oligarchy")) unitsToPayFor = unitsToPayFor.filterNot { it.getTile().isCityCenter() }
var numberOfUnitsToPayFor = max(0f, unitsToPayFor.count().toFloat() - freeUnits) var numberOfUnitsToPayFor = max(0f, unitsToPayFor.count().toFloat() - freeUnits)
if(civInfo.getNation().unique=="67% chance to earn 25 Gold and recruit a Barbarian unit from a conquered encampment, -25% land units maintenance."){ if(civInfo.nation.unique=="67% chance to earn 25 Gold and recruit a Barbarian unit from a conquered encampment, -25% land units maintenance."){
val numberOfUnitsWithDiscount = min(numberOfUnitsToPayFor, unitsToPayFor.count { it.type.isLandUnit() }.toFloat()) val numberOfUnitsWithDiscount = min(numberOfUnitsToPayFor, unitsToPayFor.count { it.type.isLandUnit() }.toFloat())
numberOfUnitsToPayFor -= 0.25f * numberOfUnitsWithDiscount numberOfUnitsToPayFor -= 0.25f * numberOfUnitsWithDiscount
} }

View file

@ -52,8 +52,8 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo){
for(unit in tile.getUnits()) viewedCivs+=unit.civInfo for(unit in tile.getUnits()) viewedCivs+=unit.civInfo
} }
if(!civInfo.isBarbarianCivilization()) { if(!civInfo.isBarbarian()) {
for (otherCiv in viewedCivs.filterNot { it == civInfo || it.isBarbarianCivilization() }) for (otherCiv in viewedCivs.filterNot { it == civInfo || it.isBarbarian() })
if (!civInfo.diplomacy.containsKey(otherCiv.civName)) { if (!civInfo.diplomacy.containsKey(otherCiv.civName)) {
civInfo.meetCivilization(otherCiv) civInfo.meetCivilization(otherCiv)
civInfo.addNotification("We have encountered [${otherCiv.civName}]!".tr(), null, Color.GOLD) civInfo.addNotification("We have encountered [${otherCiv.civName}]!".tr(), null, Color.GOLD)

View file

@ -24,6 +24,7 @@ import kotlin.math.roundToInt
class CivilizationInfo { class CivilizationInfo {
@Transient lateinit var gameInfo: GameInfo @Transient lateinit var gameInfo: GameInfo
@Transient lateinit var nation:Nation
/** /**
* We never add or remove from here directly, could cause comodification problems. * We never add or remove from here directly, could cause comodification problems.
* Instead, we create a copy list with the change, and replace this list. * Instead, we create a copy list with the change, and replace this list.
@ -99,14 +100,13 @@ class CivilizationInfo {
return GameBasics.Difficulties["Chieftain"]!! return GameBasics.Difficulties["Chieftain"]!!
} }
fun getNation() = GameBasics.Nations[civName]!!
fun getTranslatedNation(): Nation { fun getTranslatedNation(): Nation {
val language = UnCivGame.Current.settings.language.replace(" ","_") val language = UnCivGame.Current.settings.language.replace(" ","_")
if(!Gdx.files.internal("jsons/Nations_$language.json").exists()) return getNation() if(!Gdx.files.internal("jsons/Nations_$language.json").exists()) return nation
val translatedNation = GameBasics.getFromJson(Array<Nation>::class.java, "Nations_$language") val translatedNation = GameBasics.getFromJson(Array<Nation>::class.java, "Nations_$language")
.firstOrNull { it.name==civName} .firstOrNull { it.name==civName}
if(translatedNation==null) // this language's trnslation doesn't contain this nation yet, if(translatedNation==null) // this language's trnslation doesn't contain this nation yet,
return getNation() // default to english return nation // default to english
return translatedNation return translatedNation
} }
@ -119,15 +119,15 @@ class CivilizationInfo {
fun getCapital()=cities.first { it.isCapital() } fun getCapital()=cities.first { it.isCapital() }
fun isPlayerCivilization() = playerType==PlayerType.Human fun isPlayerCivilization() = playerType==PlayerType.Human
fun isCurrentPlayer() = gameInfo.getCurrentPlayerCivilization()==this fun isCurrentPlayer() = gameInfo.getCurrentPlayerCivilization()==this
fun isBarbarianCivilization() = civName=="Barbarians" fun isBarbarian() = nation.isBarbarian()
fun isCityState(): Boolean = getNation().isCityState() fun isCityState(): Boolean = nation.isCityState()
fun getCityStateType(): CityStateType = getNation().cityStateType!! fun getCityStateType(): CityStateType = nation.cityStateType!!
fun isMajorCiv() = !isBarbarianCivilization() && !isCityState() fun isMajorCiv() = nation.isMajorCiv()
fun victoryType(): VictoryType { fun victoryType(): VictoryType {
if(gameInfo.gameParameters.victoryTypes.size==1) if(gameInfo.gameParameters.victoryTypes.size==1)
return gameInfo.gameParameters.victoryTypes.first() // That is the most relevant one return gameInfo.gameParameters.victoryTypes.first() // That is the most relevant one
val victoryType = getNation().preferredVictoryType val victoryType = nation.preferredVictoryType
if(gameInfo.gameParameters.victoryTypes.contains(victoryType)) return victoryType if(gameInfo.gameParameters.victoryTypes.contains(victoryType)) return victoryType
else return VictoryType.Neutral else return VictoryType.Neutral
} }
@ -249,7 +249,7 @@ class CivilizationInfo {
} }
fun isAtWarWith(otherCiv:CivilizationInfo): Boolean { fun isAtWarWith(otherCiv:CivilizationInfo): Boolean {
if(otherCiv.isBarbarianCivilization() || isBarbarianCivilization()) return true if(otherCiv.isBarbarian() || isBarbarian()) return true
if(!diplomacy.containsKey(otherCiv.civName)) // not encountered yet if(!diplomacy.containsKey(otherCiv.civName)) // not encountered yet
return false return false
return getDiplomacyManager(otherCiv).diplomaticStatus == DiplomaticStatus.War return getDiplomacyManager(otherCiv).diplomaticStatus == DiplomaticStatus.War
@ -269,6 +269,15 @@ class CivilizationInfo {
//endregion //endregion
//region state-changing functions //region state-changing functions
/** This is separate because the REGULAR setTransients updates the viewable ties,
* and the updateViewableTiles tries to meet civs...
* 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]!!
}
fun setTransients() { fun setTransients() {
goldenAges.civInfo = this goldenAges.civInfo = this
policies.civInfo = this policies.civInfo = this
@ -276,7 +285,7 @@ class CivilizationInfo {
policies.numberOfAdoptedPolicies = policies.adoptedPolicies.count { !it.endsWith("Complete") } policies.numberOfAdoptedPolicies = policies.adoptedPolicies.count { !it.endsWith("Complete") }
if(citiesCreated==0 && cities.any()) if(citiesCreated==0 && cities.any())
citiesCreated = cities.filter { it.name in getNation().cities }.count() citiesCreated = cities.filter { it.name in nation.cities }.count()
tech.civInfo = this tech.civInfo = this
tech.setTransients() tech.setTransients()
@ -329,7 +338,7 @@ class CivilizationInfo {
policies.endTurn(nextTurnStats.culture.toInt()) policies.endTurn(nextTurnStats.culture.toInt())
// disband units until there are none left OR the gold values are normal // disband units until there are none left OR the gold values are normal
if(!isBarbarianCivilization() && gold < -100 && nextTurnStats.gold.toInt() < 0) { if(!isBarbarian() && gold < -100 && nextTurnStats.gold.toInt() < 0) {
for (i in 1 until (gold / -100)) { for (i in 1 until (gold / -100)) {
var civMilitaryUnits = getCivUnits().filter { !it.type.isCivilian() } var civMilitaryUnits = getCivUnits().filter { !it.type.isCivilian() }
if (civMilitaryUnits.isNotEmpty()) { if (civMilitaryUnits.isNotEmpty()) {

View file

@ -161,7 +161,7 @@ class TechManager {
city.cityConstructions.currentConstruction = currentConstructionUnit.upgradesTo!! city.cityConstructions.currentConstruction = currentConstructionUnit.upgradesTo!!
} }
if(techName=="Writing" && civInfo.getNation().unique=="Receive free Great Scientist when you discover Writing, Earn Great Scientists 50% faster" if(techName=="Writing" && civInfo.nation.unique=="Receive free Great Scientist when you discover Writing, Earn Great Scientists 50% faster"
&& civInfo.cities.any()) && civInfo.cities.any())
civInfo.addGreatPerson("Great Scientist") civInfo.addGreatPerson("Great Scientist")
} }

View file

@ -91,7 +91,7 @@ class MapUnit {
&& civInfo.containsBuildingUnique("All military naval units receive +1 movement and +1 sight")) && civInfo.containsBuildingUnique("All military naval units receive +1 movement and +1 sight"))
movement += 1 movement += 1
if(type.isWaterUnit() && civInfo.getNation().unique=="+2 movement for all naval units") if(type.isWaterUnit() && civInfo.nation.unique=="+2 movement for all naval units")
movement+=2 movement+=2
return movement return movement
@ -133,7 +133,7 @@ class MapUnit {
var visibilityRange = 2 var visibilityRange = 2
visibilityRange += getUniques().count { it == "+1 Visibility Range" } visibilityRange += getUniques().count { it == "+1 Visibility Range" }
if (hasUnique("Limited Visibility")) visibilityRange -= 1 if (hasUnique("Limited Visibility")) visibilityRange -= 1
if (civInfo.getNation().unique == "All land military units have +1 sight, 50% discount when purchasing tiles") if (civInfo.nation.unique == "All land military units have +1 sight, 50% discount when purchasing tiles")
visibilityRange += 1 visibilityRange += 1
if (type.isWaterUnit() && !type.isCivilian() if (type.isWaterUnit() && !type.isCivilian()
&& civInfo.containsBuildingUnique("All military naval units receive +1 movement and +1 sight")) && civInfo.containsBuildingUnique("All military naval units receive +1 movement and +1 sight"))
@ -398,7 +398,7 @@ class MapUnit {
fun moveThroughTile(tile: TileInfo){ fun moveThroughTile(tile: TileInfo){
if(tile.improvement==Constants.ancientRuins && civInfo.isMajorCiv()) if(tile.improvement==Constants.ancientRuins && civInfo.isMajorCiv())
getAncientRuinBonus(tile) getAncientRuinBonus(tile)
if(tile.improvement==Constants.barbarianEncampment && !civInfo.isBarbarianCivilization()) if(tile.improvement==Constants.barbarianEncampment && !civInfo.isBarbarian())
clearEncampment(tile) clearEncampment(tile)
currentTile = tile currentTile = tile

View file

@ -155,7 +155,7 @@ open class TileInfo {
stats.add(resource.getBuilding()!!.resourceBonusStats!!) // resource-specific building (eg forge, stable) bonus stats.add(resource.getBuilding()!!.resourceBonusStats!!) // resource-specific building (eg forge, stable) bonus
} }
if(resource.resourceType==ResourceType.Strategic if(resource.resourceType==ResourceType.Strategic
&& observingCiv.getNation().unique=="Strategic Resources provide +1 Production, and Horses, Iron and Uranium Resources provide double quantity") && observingCiv.nation.unique=="Strategic Resources provide +1 Production, and Horses, Iron and Uranium Resources provide double quantity")
stats.production+=1 stats.production+=1
if(resource.name=="Oil" && city!=null if(resource.name=="Oil" && city!=null
&& city.containsBuildingUnique("+2 Gold for each source of Oil and oasis")) && city.containsBuildingUnique("+2 Gold for each source of Oil and oasis"))

View file

@ -60,6 +60,8 @@ class Nation : INamed {
} }
fun isCityState()= cityStateType != null fun isCityState()= cityStateType != null
fun isMajorCiv() = !isBarbarian() && !isCityState()
fun isBarbarian() = name=="Barbarians"
lateinit var cities: List<String> lateinit var cities: List<String>
} }

View file

@ -122,12 +122,12 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
private fun createOffersTable(civ: CivilizationInfo, offersList: TradeOffersList, numberOfOtherSidesOffers: Int): Table { private fun createOffersTable(civ: CivilizationInfo, offersList: TradeOffersList, numberOfOtherSidesOffers: Int): Table {
val table = Table() val table = Table()
table.defaults().pad(10f) table.defaults().pad(10f)
table.background = ImageGetter.getBackground(civ.getNation().getColor()) table.background = ImageGetter.getBackground(civ.nation.getColor())
table.add(civ.civName.toLabel().setFontColor(civ.getNation().getSecondaryColor())).row() table.add(civ.civName.toLabel().setFontColor(civ.nation.getSecondaryColor())).row()
table.addSeparator() table.addSeparator()
for(offer in offersList){ for(offer in offersList){
val offerText = offer.getOfferText() val offerText = offer.getOfferText()
table.add(offerText.toLabel().setFontColor(civ.getNation().getSecondaryColor())).row() table.add(offerText.toLabel().setFontColor(civ.nation.getSecondaryColor())).row()
} }
for(i in 1..numberOfOtherSidesOffers - offersList.size) for(i in 1..numberOfOtherSidesOffers - offersList.size)
table.add("".toLabel()).row() // we want both sides of the general table to have the same number of rows table.add("".toLabel()).row() // we want both sides of the general table to have the same number of rows
@ -329,7 +329,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
currentPlayerCivInfo.diplomacy.containsKey(civ.civName) currentPlayerCivInfo.diplomacy.containsKey(civ.civName)
fun getDiplomacyGroup(): Group { fun getDiplomacyGroup(): Group {
val relevantCivs = currentPlayerCivInfo.gameInfo.civilizations.filter { !it.isBarbarianCivilization() && !it.isCityState() } val relevantCivs = currentPlayerCivInfo.gameInfo.civilizations.filter { !it.isBarbarian() && !it.isCityState() }
val groupSize = 500f val groupSize = 500f
val group = Group() val group = Group()
group.setSize(groupSize,groupSize) group.setSize(groupSize,groupSize)
@ -349,7 +349,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
for(civ in relevantCivs.filter { playerKnows(it) && !it.isDefeated() }) for(civ in relevantCivs.filter { playerKnows(it) && !it.isDefeated() })
for(diplomacy in civ.diplomacy.values. for(diplomacy in civ.diplomacy.values.
filter { !it.otherCiv().isBarbarianCivilization() && !it.otherCiv().isCityState() filter { !it.otherCiv().isBarbarian() && !it.otherCiv().isCityState()
&& playerKnows(it.otherCiv()) && !it.otherCiv().isDefeated()}){ && playerKnows(it.otherCiv()) && !it.otherCiv().isDefeated()}){
val civGroup = civGroups[civ.civName]!! val civGroup = civGroups[civ.civName]!!
val otherCivGroup = civGroups[diplomacy.otherCivName]!! val otherCivGroup = civGroups[diplomacy.otherCivName]!!
@ -415,9 +415,9 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
civGroup.background = civGroupBackground.tint(Color.LIGHT_GRAY) civGroup.background = civGroupBackground.tint(Color.LIGHT_GRAY)
label.setFontColor(Color.BLACK) label.setFontColor(Color.BLACK)
} else if (currentPlayer==civ || currentPlayer.knows(civ)) { } else if (currentPlayer==civ || currentPlayer.knows(civ)) {
civGroup.add(ImageGetter.getNationIndicator(civ.getNation(), 30f)) civGroup.add(ImageGetter.getNationIndicator(civ.nation, 30f))
civGroup.background = civGroupBackground.tint(civ.getNation().getColor()) civGroup.background = civGroupBackground.tint(civ.nation.getColor())
label.setFontColor(civ.getNation().getSecondaryColor()) label.setFontColor(civ.nation.getSecondaryColor())
} else { } else {
civGroup.background = civGroupBackground.tint(Color.DARK_GRAY) civGroup.background = civGroupBackground.tint(Color.DARK_GRAY)
label.setText("???") label.setText("???")

View file

@ -135,7 +135,7 @@ class VictoryScreen : PickerScreen() {
val table=Table() val table=Table()
table.defaults().pad(5f) table.defaults().pad(5f)
for (civ in playerCivInfo.gameInfo.civilizations) { for (civ in playerCivInfo.gameInfo.civilizations) {
if (civ.isPlayerCivilization() || civ.isBarbarianCivilization() || civ.isCityState()) continue if (civ.isCurrentPlayer() || !civ.isMajorCiv()) continue
val civName = val civName =
if (playerCivInfo.diplomacy.containsKey(civ.civName)) civ.civName if (playerCivInfo.diplomacy.containsKey(civ.civName)) civ.civName
else "???" else "???"

View file

@ -28,9 +28,11 @@ class PlayerPickerTable(val newGameScreen: NewGameScreen, val newGameParameters:
playerListTable.clear() playerListTable.clear()
for (player in newGameParameters.players) for (player in newGameParameters.players)
playerListTable.add(getPlayerTable(player)).pad(10f).row() playerListTable.add(getPlayerTable(player)).pad(10f).row()
if(newGameParameters.players.count() < GameBasics.Nations.values.count { it.isMajorCiv() }) {
playerListTable.add("+".toLabel().setFontSize(30).apply { this.setAlignment(Align.center) } playerListTable.add("+".toLabel().setFontSize(30).apply { this.setAlignment(Align.center) }
.setFontColor(Color.BLACK).surroundWithCircle(50f).onClick { newGameParameters.players.add(Player()); update() }) .setFontColor(Color.BLACK).surroundWithCircle(50f).onClick { newGameParameters.players.add(Player()); update() })
} }
}
fun getPlayerTable(player: Player): Table { fun getPlayerTable(player: Player): Table {
val table = Table() val table = Table()

View file

@ -45,10 +45,10 @@ class CityButton(val city: CityInfo, internal val tileGroup: WorldTileGroup, ski
private fun addAirUnitTable() { private fun addAirUnitTable() {
if (!tileGroup.tileInfo.airUnits.isNotEmpty()) return if (!tileGroup.tileInfo.airUnits.isNotEmpty()) return
val secondarycolor = city.civInfo.getNation().getSecondaryColor() val secondarycolor = city.civInfo.nation.getSecondaryColor()
val airUnitTable = Table().apply { defaults().pad(5f) } val airUnitTable = Table().apply { defaults().pad(5f) }
airUnitTable.background = ImageGetter.getDrawable("OtherIcons/civTableBackground") airUnitTable.background = ImageGetter.getDrawable("OtherIcons/civTableBackground")
.tint(city.civInfo.getNation().getColor()) .tint(city.civInfo.nation.getColor())
val aircraftImage = ImageGetter.getImage("OtherIcons/Aircraft") val aircraftImage = ImageGetter.getImage("OtherIcons/Aircraft")
aircraftImage.color = secondarycolor aircraftImage.color = secondarycolor
airUnitTable.add(aircraftImage).size(15f) airUnitTable.add(aircraftImage).size(15f)
@ -89,11 +89,11 @@ class CityButton(val city: CityInfo, internal val tileGroup: WorldTileGroup, ski
} }
private fun getIconTable(): Table { private fun getIconTable(): Table {
val secondaryColor = city.civInfo.getNation().getSecondaryColor() val secondaryColor = city.civInfo.nation.getSecondaryColor()
val iconTable = Table() val iconTable = Table()
iconTable.touchable=Touchable.enabled iconTable.touchable=Touchable.enabled
iconTable.background = ImageGetter.getDrawable("OtherIcons/civTableBackground") iconTable.background = ImageGetter.getDrawable("OtherIcons/civTableBackground")
.tint(city.civInfo.getNation().getColor()) .tint(city.civInfo.nation.getColor())
if (city.resistanceCounter > 0) { if (city.resistanceCounter > 0) {
val resistanceImage = ImageGetter.getImage("StatIcons/Resistance") val resistanceImage = ImageGetter.getImage("StatIcons/Resistance")
@ -128,7 +128,7 @@ class CityButton(val city: CityInfo, internal val tileGroup: WorldTileGroup, ski
if (UnCivGame.Current.viewEntireMapForDebug || city.civInfo.isCurrentPlayer()) if (UnCivGame.Current.viewEntireMapForDebug || city.civInfo.isCurrentPlayer())
iconTable.add(getConstructionGroup(city.cityConstructions)).padRight(10f) iconTable.add(getConstructionGroup(city.cityConstructions)).padRight(10f)
else if (city.civInfo.isMajorCiv()) { else if (city.civInfo.isMajorCiv()) {
val nationIcon = ImageGetter.getNationIcon(city.civInfo.getNation().name) val nationIcon = ImageGetter.getNationIcon(city.civInfo.nation.name)
nationIcon.color = secondaryColor nationIcon.color = secondaryColor
iconTable.add(nationIcon).size(20f).padRight(10f) iconTable.add(nationIcon).size(20f).padRight(10f)
} }
@ -170,7 +170,7 @@ class CityButton(val city: CityInfo, internal val tileGroup: WorldTileGroup, ski
group.addActor(circle) group.addActor(circle)
group.addActor(image) group.addActor(image)
val secondaryColor = cityConstructions.cityInfo.civInfo.getNation().getSecondaryColor() val secondaryColor = cityConstructions.cityInfo.civInfo.nation.getSecondaryColor()
val cityCurrentConstruction = cityConstructions.getCurrentConstruction() val cityCurrentConstruction = cityConstructions.getCurrentConstruction()
if(cityCurrentConstruction !is SpecialConstruction) { if(cityCurrentConstruction !is SpecialConstruction) {
val turnsToConstruction = cityConstructions.turnsToConstruction(cityCurrentConstruction.name) val turnsToConstruction = cityConstructions.turnsToConstruction(cityCurrentConstruction.name)

View file

@ -269,7 +269,7 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
previousTileOwner = tileOwner previousTileOwner = tileOwner
if (tileOwner == null) return if (tileOwner == null) return
val civColor = tileInfo.getOwner()!!.getNation().getColor() val civColor = tileInfo.getOwner()!!.nation.getColor()
for (neighbor in tileInfo.neighbors) { for (neighbor in tileInfo.neighbors) {
val neighborOwner = neighbor.getOwner() val neighborOwner = neighbor.getOwner()
if (neighborOwner == 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

View file

@ -55,10 +55,10 @@ class DiplomacyScreen:CameraStageBaseScreen() {
leftSideTable.clear() leftSideTable.clear()
val currentPlayerCiv = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization() val currentPlayerCiv = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization()
for (civ in UnCivGame.Current.gameInfo.civilizations for (civ in UnCivGame.Current.gameInfo.civilizations
.filterNot { it.isDefeated() || it == currentPlayerCiv || it.isBarbarianCivilization() }) { .filterNot { it.isDefeated() || it == currentPlayerCiv || it.isBarbarian() }) {
if (!currentPlayerCiv.knows(civ)) continue if (!currentPlayerCiv.knows(civ)) continue
val civIndicator = ImageGetter.getNationIndicator(civ.getNation(),100f) val civIndicator = ImageGetter.getNationIndicator(civ.nation,100f)
val relationship = ImageGetter.getCircle() val relationship = ImageGetter.getCircle()
if(currentPlayerCiv.isAtWarWith(civ)) relationship.color = Color.RED if(currentPlayerCiv.isAtWarWith(civ)) relationship.color = Color.RED

View file

@ -11,12 +11,12 @@ class UnitGroup(val unit: MapUnit, val size: Float): Group() {
var blackSpinningCircle:Image?=null var blackSpinningCircle:Image?=null
init { init {
val unitBaseImage = ImageGetter.getUnitIcon(unit.name, unit.civInfo.getNation().getSecondaryColor()) val unitBaseImage = ImageGetter.getUnitIcon(unit.name, unit.civInfo.nation.getSecondaryColor())
.apply { setSize(size * 0.75f, size * 0.75f) } .apply { setSize(size * 0.75f, size * 0.75f) }
val background = getBackgroundImageForUnit(unit) val background = getBackgroundImageForUnit(unit)
background.apply { background.apply {
this.color = unit.civInfo.getNation().getColor() this.color = unit.civInfo.nation.getColor()
setSize(size, size) setSize(size, size)
} }
setSize(size, size) setSize(size, size)

View file

@ -78,9 +78,9 @@ class Minimap(val tileMapHolder: TileMapHolder) : ScrollPane(null){
if (!(UnCivGame.Current.viewEntireMapForDebug || cloneCivilization.exploredTiles.contains(tileInfo.position))) if (!(UnCivGame.Current.viewEntireMapForDebug || cloneCivilization.exploredTiles.contains(tileInfo.position)))
hex.color = Color.DARK_GRAY hex.color = Color.DARK_GRAY
else if (tileInfo.isCityCenter() && !tileInfo.isWater) else if (tileInfo.isCityCenter() && !tileInfo.isWater)
hex.color = tileInfo.getOwner()!!.getNation().getSecondaryColor() hex.color = tileInfo.getOwner()!!.nation.getSecondaryColor()
else if (tileInfo.getCity() != null && !tileInfo.isWater) else if (tileInfo.getCity() != null && !tileInfo.isWater)
hex.color = tileInfo.getOwner()!!.getNation().getColor() hex.color = tileInfo.getOwner()!!.nation.getColor()
else hex.color = tileInfo.getBaseTerrain().getColor().lerp(Color.GRAY, 0.5f) else hex.color = tileInfo.getBaseTerrain().getColor().lerp(Color.GRAY, 0.5f)
} }
} }

View file

@ -10,10 +10,10 @@ class PlayerReadyScreen(currentPlayerCiv: CivilizationInfo) : CameraStageBaseScr
init { init {
val table= Table() val table= Table()
table.touchable= Touchable.enabled table.touchable= Touchable.enabled
table.background= ImageGetter.getBackground(currentPlayerCiv.getNation().getColor()) table.background= ImageGetter.getBackground(currentPlayerCiv.nation.getColor())
table.add("[$currentPlayerCiv] ready?".toLabel().setFontSize(24) table.add("[$currentPlayerCiv] ready?".toLabel().setFontSize(24)
.setFontColor(currentPlayerCiv.getNation().getSecondaryColor())) .setFontColor(currentPlayerCiv.nation.getSecondaryColor()))
table.onClick { table.onClick {
UnCivGame.Current.worldScreen = WorldScreen(currentPlayerCiv) UnCivGame.Current.worldScreen = WorldScreen(currentPlayerCiv)

View file

@ -182,7 +182,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
private fun updateDiplomacyButton(civInfo: CivilizationInfo) { private fun updateDiplomacyButton(civInfo: CivilizationInfo) {
diplomacyButtonWrapper.clear() diplomacyButtonWrapper.clear()
if(civInfo.getKnownCivs() if(civInfo.getKnownCivs()
.filterNot { it.isDefeated() || it==viewingCiv || it.isBarbarianCivilization() } .filterNot { it.isDefeated() || it==viewingCiv || it.isBarbarian() }
.any()) { .any()) {
displayTutorials("OtherCivEncountered") displayTutorials("OtherCivEncountered")
val btn = TextButton("Diplomacy".tr(), skin) val btn = TextButton("Diplomacy".tr(), skin)
@ -355,7 +355,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
val shownTutorials = UnCivGame.Current.settings.tutorialsShown val shownTutorials = UnCivGame.Current.settings.tutorialsShown
displayTutorials("NextTurn") displayTutorials("NextTurn")
if("BarbarianEncountered" !in shownTutorials if("BarbarianEncountered" !in shownTutorials
&& viewingCiv.viewableTiles.any { it.getUnits().any { unit -> unit.civInfo.isBarbarianCivilization() } }) && viewingCiv.viewableTiles.any { it.getUnits().any { unit -> unit.civInfo.isBarbarian() } })
displayTutorials("BarbarianEncountered") displayTutorials("BarbarianEncountered")
if(viewingCiv.cities.size > 2) displayTutorials("SecondCity") if(viewingCiv.cities.size > 2) displayTutorials("SecondCity")
if(viewingCiv.getHappiness() < 5) displayTutorials("HappinessGettingLow") if(viewingCiv.getHappiness() < 5) displayTutorials("HappinessGettingLow")