mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-20 09:17:47 +07:00
getResearchAgreementCost() don't need variable, make some method private (#3832)
This commit is contained in:
parent
cb9507c76d
commit
adf32dcfe2
@ -293,7 +293,7 @@ object NextTurnAutomation {
|
||||
// Default setting is 5, this will be changed according to different civ.
|
||||
if ((1..10).random() > 5) continue
|
||||
val tradeLogic = TradeLogic(civInfo, otherCiv)
|
||||
val cost = civInfo.getResearchAgreementCost(otherCiv)
|
||||
val cost = civInfo.getResearchAgreementCost()
|
||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.researchAgreement, TradeType.Treaty, cost))
|
||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.researchAgreement, TradeType.Treaty, cost))
|
||||
|
||||
|
@ -118,7 +118,7 @@ class CivilizationInfo {
|
||||
toReturn.victoryManager = victoryManager.clone()
|
||||
toReturn.allyCivName = allyCivName
|
||||
for (diplomacyManager in diplomacy.values.map { it.clone() })
|
||||
toReturn.diplomacy.put(diplomacyManager.otherCivName, diplomacyManager)
|
||||
toReturn.diplomacy[diplomacyManager.otherCivName] = diplomacyManager
|
||||
toReturn.cities = cities.map { it.clone() }
|
||||
|
||||
// This is the only thing that is NOT switched out, which makes it a source of ConcurrentModification errors.
|
||||
@ -165,7 +165,7 @@ class CivilizationInfo {
|
||||
fun isAlive(): Boolean = !isDefeated()
|
||||
fun hasEverBeenFriendWith(otherCiv: CivilizationInfo): Boolean = getDiplomacyManager(otherCiv).everBeenFriends()
|
||||
fun hasMetCivTerritory(otherCiv: CivilizationInfo): Boolean = otherCiv.getCivTerritory().any { it in exploredTiles }
|
||||
fun getCivTerritory() = cities.asSequence().flatMap { it.tiles.asSequence() }
|
||||
private fun getCivTerritory() = cities.asSequence().flatMap { it.tiles.asSequence() }
|
||||
|
||||
fun victoryType(): VictoryType {
|
||||
if (gameInfo.gameParameters.victoryTypes.size == 1)
|
||||
@ -267,7 +267,7 @@ class CivilizationInfo {
|
||||
|
||||
fun getIdleUnits() = getCivUnits().filter { it.isIdle() }
|
||||
|
||||
fun getDueUnits() = getCivUnits().filter { it.due && it.isIdle() }
|
||||
private fun getDueUnits() = getCivUnits().filter { it.due && it.isIdle() }
|
||||
|
||||
fun shouldGoToDueUnit() = UncivGame.Current.settings.checkForDueUnits && getDueUnits().any()
|
||||
|
||||
@ -334,8 +334,8 @@ class CivilizationInfo {
|
||||
/** Returns true if the civ was fully initialized and has no cities remaining */
|
||||
fun isDefeated(): Boolean {
|
||||
// Dirty hack: exploredTiles are empty only before starting units are placed
|
||||
if (exploredTiles.isEmpty() || isBarbarian() || isSpectator()) return false
|
||||
else return cities.isEmpty() // No cities
|
||||
return if (exploredTiles.isEmpty() || isBarbarian() || isSpectator()) false
|
||||
else cities.isEmpty() // No cities
|
||||
&& (citiesCreated > 0 || !getCivUnits().any { it.hasUnique(Constants.settlerUnique) })
|
||||
}
|
||||
|
||||
@ -343,12 +343,11 @@ class CivilizationInfo {
|
||||
if (gameInfo.ruleSet.technologies.isEmpty()) return "None"
|
||||
if (tech.researchedTechnologies.isEmpty())
|
||||
return gameInfo.ruleSet.getEras().first()
|
||||
val maxEraOfTech = tech.researchedTechnologies
|
||||
return tech.researchedTechnologies
|
||||
.asSequence()
|
||||
.map { it.column!! }
|
||||
.maxByOrNull { it.columnNumber }!!
|
||||
.era
|
||||
return maxEraOfTech
|
||||
}
|
||||
|
||||
fun getEraNumber(): Int = gameInfo.ruleSet.getEraNumber(getEra())
|
||||
@ -383,7 +382,7 @@ class CivilizationInfo {
|
||||
|
||||
fun canSignResearchAgreementsWith(otherCiv: CivilizationInfo): Boolean {
|
||||
val diplomacyManager = getDiplomacyManager(otherCiv)
|
||||
val cost = getResearchAgreementCost(otherCiv)
|
||||
val cost = getResearchAgreementCost()
|
||||
return canSignResearchAgreement() && otherCiv.canSignResearchAgreement()
|
||||
&& diplomacyManager.hasFlag(DiplomacyFlags.DeclarationOfFriendship)
|
||||
&& !diplomacyManager.hasFlag(DiplomacyFlags.ResearchAgreement)
|
||||
@ -619,7 +618,7 @@ class CivilizationInfo {
|
||||
updateStatsForNextTurn()
|
||||
}
|
||||
|
||||
fun getResearchAgreementCost(otherCiv: CivilizationInfo): Int {
|
||||
fun getResearchAgreementCost(): Int {
|
||||
// https://forums.civfanatics.com/resources/research-agreements-bnw.25568/
|
||||
val basicGoldCostOfSignResearchAgreement = when (getEra()) {
|
||||
Constants.medievalEra, Constants.renaissanceEra -> 250
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.unciv.logic.civilization
|
||||
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.unciv.logic.map.MapSize
|
||||
import com.unciv.logic.map.RoadStatus
|
||||
import com.unciv.models.ruleset.Unique
|
||||
@ -70,7 +68,7 @@ class TechManager {
|
||||
|
||||
fun getNumberOfTechsResearched(): Int = techsResearched.size
|
||||
|
||||
fun getRuleset() = civInfo.gameInfo.ruleSet
|
||||
private fun getRuleset() = civInfo.gameInfo.ruleSet
|
||||
|
||||
fun costOfTech(techName: String): Int {
|
||||
var techCost = getRuleset().technologies[techName]!!.cost.toFloat()
|
||||
@ -156,7 +154,7 @@ class TechManager {
|
||||
return (scienceOfLast8Turns.sum() * civInfo.gameInfo.gameParameters.gameSpeed.modifier).toInt()
|
||||
}
|
||||
|
||||
fun addCurrentScienceToScienceOfLast8Turns() {
|
||||
private fun addCurrentScienceToScienceOfLast8Turns() {
|
||||
// The Science the Great Scientist generates does not include Science from Policies, Trade routes and City-States.
|
||||
var allCitiesScience = 0f
|
||||
civInfo.cities.forEach { it ->
|
||||
@ -167,11 +165,11 @@ class TechManager {
|
||||
scienceOfLast8Turns[civInfo.gameInfo.turns % 8] = allCitiesScience.toInt()
|
||||
}
|
||||
|
||||
fun limitOverflowScience(overflowscience: Int): Int {
|
||||
private fun limitOverflowScience(overflowScience: Int): Int {
|
||||
// http://www.civclub.net/bbs/forum.php?mod=viewthread&tid=123976
|
||||
// Apparently yes, we care about the absolute tech cost, not the actual calculated-for-this-player tech cost,
|
||||
// so don't change to costOfTech()
|
||||
return min(overflowscience, max(civInfo.statsForNextTurn.science.toInt() * 5,
|
||||
return min(overflowScience, max(civInfo.statsForNextTurn.science.toInt() * 5,
|
||||
getRuleset().technologies[currentTechnologyName()]!!.cost))
|
||||
}
|
||||
|
||||
@ -280,11 +278,10 @@ class TechManager {
|
||||
val oldQueue = city.cityConstructions.constructionQueue.toList() // copy, since we're changing the queue
|
||||
city.cityConstructions.constructionQueue.clear()
|
||||
for (constructionName in oldQueue) {
|
||||
val newConstructionName = constructionName
|
||||
if (constructionName in obsoleteUnits) {
|
||||
val text = "[$constructionName] has been obsolete and will be removed from construction queue in [${city.name}]!"
|
||||
civInfo.addNotification(text, city.location, NotificationIcon.Construction)
|
||||
} else city.cityConstructions.constructionQueue.add(newConstructionName)
|
||||
} else city.cityConstructions.constructionQueue.add(constructionName)
|
||||
}
|
||||
}
|
||||
|
||||
@ -300,7 +297,7 @@ class TechManager {
|
||||
updateTransientBooleans()
|
||||
}
|
||||
|
||||
fun updateTransientBooleans() {
|
||||
private fun updateTransientBooleans() {
|
||||
wayfinding = civInfo.hasUnique("Can embark and move over Coasts and Oceans immediately")
|
||||
unitsCanEmbark = wayfinding || civInfo.hasUnique("Enables embarkation for land units")
|
||||
|
||||
|
@ -26,10 +26,10 @@ import com.unciv.ui.utils.AutoScrollPane as ScrollPane
|
||||
|
||||
class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
|
||||
|
||||
val leftSideTable = Table().apply { defaults().pad(10f) }
|
||||
val rightSideTable = Table()
|
||||
private val leftSideTable = Table().apply { defaults().pad(10f) }
|
||||
private val rightSideTable = Table()
|
||||
|
||||
fun isNotPlayersTurn() = !UncivGame.Current.worldScreen.isPlayersTurn
|
||||
private fun isNotPlayersTurn() = !UncivGame.Current.worldScreen.isPlayersTurn
|
||||
|
||||
init {
|
||||
onBackButtonClicked { UncivGame.Current.setWorldScreen() }
|
||||
@ -285,7 +285,7 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
|
||||
if (viewingCiv.canSignResearchAgreementsWith(otherCiv)) {
|
||||
val researchAgreementButton = "Research Agreement".toTextButton()
|
||||
|
||||
val requiredGold = viewingCiv.getResearchAgreementCost(otherCiv)
|
||||
val requiredGold = viewingCiv.getResearchAgreementCost()
|
||||
researchAgreementButton.onClick {
|
||||
val tradeTable = setTrade(otherCiv)
|
||||
val researchAgreement = TradeOffer(Constants.researchAgreement, TradeType.Treaty, requiredGold)
|
||||
@ -390,7 +390,7 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
|
||||
return demandsTable
|
||||
}
|
||||
|
||||
fun getRelationshipTable(otherCivDiplomacyManager: DiplomacyManager): Table {
|
||||
private fun getRelationshipTable(otherCivDiplomacyManager: DiplomacyManager): Table {
|
||||
val relationshipTable = Table()
|
||||
|
||||
val opinionOfUs = if (otherCivDiplomacyManager.civInfo.isCityState()) otherCivDiplomacyManager.influence.toInt()
|
||||
|
Loading…
Reference in New Issue
Block a user