diff --git a/core/src/com/unciv/logic/GameInfo.kt b/core/src/com/unciv/logic/GameInfo.kt index 032a13a5c7..b20a7febef 100644 --- a/core/src/com/unciv/logic/GameInfo.kt +++ b/core/src/com/unciv/logic/GameInfo.kt @@ -259,7 +259,7 @@ class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion //check is important or else switchTurn //would skip a turn if an AI civ calls nextTurn //this happens when resigning a multiplayer game - if (thisPlayer.isPlayerCivilization()) { + if (thisPlayer.isHuman()) { endTurn() } @@ -483,7 +483,7 @@ class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion tileMap.setTransients(ruleSet) - if (currentPlayer == "") currentPlayer = civilizations.first { it.isPlayerCivilization() }.civName + if (currentPlayer == "") currentPlayer = civilizations.first { it.isHuman() }.civName currentPlayerCiv = getCivilization(currentPlayer) difficultyObject = ruleSet.difficulties[difficulty]!! diff --git a/core/src/com/unciv/logic/GameStarter.kt b/core/src/com/unciv/logic/GameStarter.kt index c85ab2e619..e4130158a2 100644 --- a/core/src/com/unciv/logic/GameStarter.kt +++ b/core/src/com/unciv/logic/GameStarter.kt @@ -157,7 +157,7 @@ object GameStarter { private fun addCivTechs(gameInfo: GameInfo, ruleset: Ruleset, gameSetupInfo: GameSetupInfo) { for (civInfo in gameInfo.civilizations.filter { !it.isBarbarian() }) { - if (!civInfo.isPlayerCivilization()) + if (!civInfo.isHuman()) for (tech in gameInfo.getDifficulty().aiFreeTechs) civInfo.tech.addTechnology(tech) @@ -330,7 +330,7 @@ object GameStarter { // Add extra units granted by difficulty startingUnits.addAll(when { - civ.isPlayerCivilization() -> gameInfo.getDifficulty().playerBonusStartingUnits + civ.isHuman() -> gameInfo.getDifficulty().playerBonusStartingUnits civ.isMajorCiv() -> gameInfo.getDifficulty().aiMajorCivBonusStartingUnits else -> gameInfo.getDifficulty().aiCityStateBonusStartingUnits }) diff --git a/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt b/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt index b9ed7866c5..0a49bd74cc 100644 --- a/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt +++ b/core/src/com/unciv/logic/automation/unit/WorkerAutomation.kt @@ -48,7 +48,7 @@ class WorkerAutomation( private val bestRoadAvailable: RoadStatus = cloningSource?.bestRoadAvailable ?: //Player can choose not to auto-build roads & railroads. - if (civInfo.isPlayerCivilization() && !UncivGame.Current.settings.autoBuildingRoads) + if (civInfo.isHuman() && !UncivGame.Current.settings.autoBuildingRoads) RoadStatus.None else civInfo.tech.getBestRoadAvailable() @@ -320,7 +320,7 @@ class WorkerAutomation( val junkImprovement = tile.getTileImprovement()?.hasUnique(UniqueType.AutomatedWorkersWillReplace) if (tile.improvement != null && junkImprovement == false && !UncivGame.Current.settings.automatedWorkersReplaceImprovements - && unit.civInfo.isPlayerCivilization()) + && unit.civInfo.isHuman()) return false @@ -399,7 +399,7 @@ class WorkerAutomation( // Defence is more important that civilian improvements // While AI sucks in strategical placement of forts, allow a human does it manually - !civInfo.isPlayerCivilization() && evaluateFortPlacement(tile, civInfo,false) -> Constants.fort + !civInfo.isHuman() && evaluateFortPlacement(tile, civInfo,false) -> Constants.fort // I think we can assume that the unique improvement is better uniqueImprovement != null && tile.canBuildImprovement(uniqueImprovement, civInfo) -> uniqueImprovement.name diff --git a/core/src/com/unciv/logic/battle/Battle.kt b/core/src/com/unciv/logic/battle/Battle.kt index e0a70e59db..b9dd9a8fb4 100644 --- a/core/src/com/unciv/logic/battle/Battle.kt +++ b/core/src/com/unciv/logic/battle/Battle.kt @@ -548,7 +548,7 @@ object Battle { // retaking old capital city.puppetCity(attackerCiv) city.annexCity() - } else if (attackerCiv.isPlayerCivilization()) { + } else if (attackerCiv.isHuman()) { // we're not taking our former capital attackerCiv.popupAlerts.add(PopupAlert(AlertType.CityConquered, city.id)) } else { diff --git a/core/src/com/unciv/logic/city/CityConstructions.kt b/core/src/com/unciv/logic/city/CityConstructions.kt index a1b7ab6f8c..eb7a095ce3 100644 --- a/core/src/com/unciv/logic/city/CityConstructions.kt +++ b/core/src/com/unciv/logic/city/CityConstructions.kt @@ -588,7 +588,7 @@ class CityConstructions : IsPartOfGameInfoSerialization { val isCurrentPlayersTurn = cityInfo.civInfo.gameInfo.isUsersTurn() || !cityInfo.civInfo.gameInfo.gameParameters.isOnlineMultiplayer if ((UncivGame.Current.settings.autoAssignCityProduction && isCurrentPlayersTurn) // only automate if the active human player has the setting to automate production - || !cityInfo.civInfo.isPlayerCivilization() || cityInfo.isPuppet) { + || !cityInfo.civInfo.isHuman() || cityInfo.isPuppet) { ConstructionAutomation(this).chooseNextConstruction() } diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index 3a8a23918b..ea1620db19 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -337,7 +337,7 @@ class CityStats(val cityInfo: CityInfo) { private fun getBuildingMaintenanceCosts(): Float { // Same here - will have a different UI display. var buildingsMaintenance = cityInfo.cityConstructions.getMaintenanceCosts().toFloat() // this is AFTER the bonus calculation! - if (!cityInfo.civInfo.isPlayerCivilization()) { + if (!cityInfo.civInfo.isHuman()) { buildingsMaintenance *= cityInfo.civInfo.gameInfo.getDifficulty().aiBuildingMaintenanceModifier } @@ -376,7 +376,7 @@ class CityStats(val cityInfo: CityInfo) { val civInfo = cityInfo.civInfo val newHappinessList = LinkedHashMap() var unhappinessModifier = civInfo.getDifficulty().unhappinessModifier - if (!civInfo.isPlayerCivilization()) + if (!civInfo.isHuman()) unhappinessModifier *= civInfo.gameInfo.getDifficulty().aiUnhappinessModifier var unhappinessFromCity = -3f // -3 happiness per city diff --git a/core/src/com/unciv/logic/city/PopulationManager.kt b/core/src/com/unciv/logic/city/PopulationManager.kt index a211b98981..c24140375b 100644 --- a/core/src/com/unciv/logic/city/PopulationManager.kt +++ b/core/src/com/unciv/logic/city/PopulationManager.kt @@ -48,7 +48,7 @@ class PopulationManager : IsPartOfGameInfoSerialization { var foodRequired = 15 + 6 * (population - 1) + floor((population - 1).toDouble().pow(1.8)) if (cityInfo.civInfo.isCityState()) foodRequired *= 1.5f - if (!cityInfo.civInfo.isPlayerCivilization()) + if (!cityInfo.civInfo.isHuman()) foodRequired *= cityInfo.civInfo.gameInfo.getDifficulty().aiCityGrowthModifier return foodRequired.toInt() } diff --git a/core/src/com/unciv/logic/civilization/CivInfoStats.kt b/core/src/com/unciv/logic/civilization/CivInfoStats.kt index 92fac8c875..39f181614b 100644 --- a/core/src/com/unciv/logic/civilization/CivInfoStats.kt +++ b/core/src/com/unciv/logic/civilization/CivInfoStats.kt @@ -67,7 +67,7 @@ class CivInfoStats(val civInfo: CivilizationInfo) { var cost = baseUnitCost * numberOfUnitsToPayFor * (1 + gameProgress) cost = cost.pow(1 + gameProgress / 3) // Why 3? To spread 1 to 1.33 - if (!civInfo.isPlayerCivilization()) + if (!civInfo.isHuman()) cost *= civInfo.gameInfo.getDifficulty().aiUnitMaintenanceModifier return cost.toInt() diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 8bd00fd311..467c05eb44 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -313,7 +313,7 @@ class CivilizationInfo : IsPartOfGameInfoSerialization { //region pure functions fun getDifficulty(): Difficulty { - if (isPlayerCivilization()) return gameInfo.getDifficulty() + if (isHuman()) return gameInfo.getDifficulty() // TODO We should be able to mark a difficulty as 'default AI difficulty' somehow val chieftainDifficulty = gameInfo.ruleSet.difficulties["Chieftain"] if (chieftainDifficulty != null) return chieftainDifficulty @@ -347,7 +347,7 @@ class CivilizationInfo : IsPartOfGameInfoSerialization { .thenBy (UncivGame.Current.settings.getCollatorFromLocale()) { it.civName.tr() } ) fun getCapital() = cities.firstOrNull { it.isCapital() } - fun isPlayerCivilization() = playerType == PlayerType.Human + fun isHuman() = playerType == PlayerType.Human fun isOneCityChallenger() = ( playerType == PlayerType.Human && gameInfo.gameParameters.oneCityChallenge) @@ -1234,7 +1234,7 @@ class CivilizationInfo : IsPartOfGameInfoSerialization { if (diplomacyManager != null && (diplomacyManager.hasOpenBorders || diplomacyManager.diplomaticStatus == DiplomaticStatus.War)) return true // Players can always pass through city-state tiles - if (isPlayerCivilization() && otherCiv.isCityState()) return true + if (isHuman() && otherCiv.isCityState()) return true return false } diff --git a/core/src/com/unciv/logic/civilization/PolicyManager.kt b/core/src/com/unciv/logic/civilization/PolicyManager.kt index 18c10adae1..d15595e6f7 100644 --- a/core/src/com/unciv/logic/civilization/PolicyManager.kt +++ b/core/src/com/unciv/logic/civilization/PolicyManager.kt @@ -133,7 +133,7 @@ class PolicyManager : IsPartOfGameInfoSerialization { for (unique in civInfo.getMatchingUniques(UniqueType.LessPolicyCostFromCities)) cityModifier *= 1 - unique.params[0].toFloat() / 100 for (unique in civInfo.getMatchingUniques(UniqueType.LessPolicyCost)) policyCultureCost *= unique.params[0].toPercent() - if (civInfo.isPlayerCivilization()) policyCultureCost *= civInfo.getDifficulty().policyCostModifier + if (civInfo.isHuman()) policyCultureCost *= civInfo.getDifficulty().policyCostModifier policyCultureCost *= civInfo.gameInfo.speed.cultureCostModifier val cost: Int = (policyCultureCost * (1 + cityModifier)).roundToInt() return cost - (cost % 5) diff --git a/core/src/com/unciv/logic/civilization/TechManager.kt b/core/src/com/unciv/logic/civilization/TechManager.kt index da2cc5cb0e..d324d60100 100644 --- a/core/src/com/unciv/logic/civilization/TechManager.kt +++ b/core/src/com/unciv/logic/civilization/TechManager.kt @@ -85,7 +85,7 @@ class TechManager : IsPartOfGameInfoSerialization { fun costOfTech(techName: String): Int { var techCost = getRuleset().technologies[techName]!!.cost.toFloat() - if (civInfo.isPlayerCivilization()) + if (civInfo.isHuman()) techCost *= civInfo.getDifficulty().researchCostModifier techCost *= civInfo.gameInfo.speed.scienceCostModifier val techsResearchedKnownCivs = civInfo.getKnownCivs() @@ -332,7 +332,7 @@ class TechManager : IsPartOfGameInfoSerialization { for (policyBranch in getRuleset().policyBranches.values.filter { it.era == currentEra.name && civInfo.policies.isAdoptable(it) }) { civInfo.addNotification("[" + policyBranch.name + "] policy branch unlocked!", NotificationIcon.Culture) } - + val erasPassed = getRuleset().eras.values .filter { it.eraNumber > previousEra.eraNumber && it.eraNumber <= currentEra.eraNumber } .sortedBy { it.eraNumber } diff --git a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt index e501457c4b..894bb5b4fb 100644 --- a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt +++ b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt @@ -165,10 +165,10 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization { } fun relationshipLevel(): RelationshipLevel { - if (civInfo.isPlayerCivilization() && otherCiv().isPlayerCivilization()) + if (civInfo.isHuman() && otherCiv().isHuman()) return RelationshipLevel.Neutral // People make their own choices. - if (civInfo.isPlayerCivilization()) + if (civInfo.isHuman()) return otherCiv().getDiplomacyManager(civInfo).relationshipLevel() if (civInfo.isCityState()) return when { diff --git a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt index a22191beb1..0523e7d742 100644 --- a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt +++ b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt @@ -809,7 +809,7 @@ class PathfindingCache(private val unit: MapUnit) { private fun isValid(): Boolean = (movement == unit.currentMovement) && (unit.getTile() == currentTile) fun getShortestPathCache(destination: TileInfo): List { - if (unit.civInfo.isPlayerCivilization()) return listOf() + if (unit.civInfo.isHuman()) return listOf() if (isValid() && this.destination == destination) { return shortestPathCache } @@ -817,7 +817,7 @@ class PathfindingCache(private val unit: MapUnit) { } fun setShortestPathCache(destination: TileInfo, newShortestPath: List) { - if (unit.civInfo.isPlayerCivilization()) return + if (unit.civInfo.isHuman()) return if (isValid()) { shortestPathCache = newShortestPath this.destination = destination @@ -825,14 +825,14 @@ class PathfindingCache(private val unit: MapUnit) { } fun getDistanceToTiles(zoneOfControl: Boolean): PathsToTilesWithinTurn? { - if (unit.civInfo.isPlayerCivilization()) return null + if (unit.civInfo.isHuman()) return null if (isValid()) return distanceToTilesCache[zoneOfControl] return null } fun setDistanceToTiles(zoneOfControl: Boolean, paths: PathsToTilesWithinTurn) { - if (unit.civInfo.isPlayerCivilization()) return + if (unit.civInfo.isHuman()) return if (!isValid()) { clear() // we want to reset the entire cache at this point } diff --git a/core/src/com/unciv/logic/trade/TradeLogic.kt b/core/src/com/unciv/logic/trade/TradeLogic.kt index 1e4bffe7c4..f32c25f1b6 100644 --- a/core/src/com/unciv/logic/trade/TradeLogic.kt +++ b/core/src/com/unciv/logic/trade/TradeLogic.kt @@ -98,7 +98,7 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci city.getCenterTile().getUnits().toList().forEach { it.movement.teleportToClosestMoveableTile() } for (tile in city.getTiles()) { for (unit in tile.getUnits().toList()) { - if (!unit.civInfo.canPassThroughTiles(to) && !unit.canEnterForeignTerrain) + if (!unit.civInfo.canPassThroughTiles(to) && !unit.canEnterForeignTerrain) unit.movement.teleportToClosestMoveableTile() } } @@ -106,7 +106,7 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci from.updateViewableTiles() // suggest an option to liberate the city - if (to.isPlayerCivilization() + if (to.isHuman() && city.foundingCiv != "" && from.civName != city.foundingCiv // can't liberate if the city actually belongs to those guys && to.civName != city.foundingCiv) // can't liberate if it's our city @@ -133,4 +133,4 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci transferTrade(ourCivilization, otherCivilization, currentTrade) transferTrade(otherCivilization, ourCivilization, currentTrade.reverse()) } -} \ No newline at end of file +} diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index 9e63ea62d5..8a25d613db 100644 --- a/core/src/com/unciv/models/ruleset/Building.kt +++ b/core/src/com/unciv/models/ruleset/Building.kt @@ -340,7 +340,7 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction { if (civInfo.isCityState()) productionCost *= 1.5f - if (civInfo.isPlayerCivilization()) { + if (civInfo.isHuman()) { if (!isWonder) productionCost *= civInfo.getDifficulty().buildingCostModifier } else { diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt b/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt index f27f4dbb3c..564d2e40dc 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt @@ -174,7 +174,7 @@ object UniqueTriggerActivation { val greatPeople = civInfo.getGreatPeople() if (unique.type == MayanGainGreatPerson && civInfo.greatPeople.longCountGPPool.isEmpty()) civInfo.greatPeople.longCountGPPool = greatPeople.map { it.name }.toHashSet() - if (civInfo.isPlayerCivilization()) { + if (civInfo.isHuman()) { civInfo.greatPeople.freeGreatPeople++ // Anyone an idea for a good icon? if (unique.type == MayanGainGreatPerson) { diff --git a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt index e89e232eb6..48ec50feaa 100644 --- a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt @@ -251,7 +251,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction { var productionCost = cost.toFloat() if (civInfo.isCityState()) productionCost *= 1.5f - productionCost *= if (civInfo.isPlayerCivilization()) + productionCost *= if (civInfo.isHuman()) civInfo.getDifficulty().unitCostModifier else civInfo.gameInfo.getDifficulty().aiUnitCostModifier diff --git a/core/src/com/unciv/ui/trade/DiplomacyScreen.kt b/core/src/com/unciv/ui/trade/DiplomacyScreen.kt index 7aaa4d7956..32459eeb7a 100644 --- a/core/src/com/unciv/ui/trade/DiplomacyScreen.kt +++ b/core/src/com/unciv/ui/trade/DiplomacyScreen.kt @@ -694,7 +694,7 @@ class DiplomacyScreen( if (otherCiv.cities.isNotEmpty() && otherCiv.getCapital() != null && viewingCiv.hasExplored(otherCiv.getCapital()!!.location)) diplomacyTable.add(getGoToOnMapButton(otherCiv)).row() - if (!otherCiv.isPlayerCivilization()) { // human players make their own choices + if (!otherCiv.isHuman()) { // human players make their own choices diplomacyTable.add(getRelationshipTable(otherCivDiplomacyManager)).row() diplomacyTable.add(getDiplomacyModifiersTable(otherCivDiplomacyManager)).row() val promisesTable = getPromisesTable(diplomacyManager, otherCivDiplomacyManager)