Tied the unit upkeep scaling to game speed (#1870)

* Tied the unit upkeep scaling to game speed

* Refactor: Modifier and TurnLimit are now fields

* Turn limit will be derived from the GameSpeed.modifier and base game duration
This commit is contained in:
lyrjie 2020-02-08 21:51:45 +03:00 committed by GitHub
parent edf0294dfd
commit 096e1c2beb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 24 additions and 26 deletions

View File

@ -2,6 +2,7 @@ package com.unciv.logic.civilization
import com.unciv.logic.civilization.diplomacy.RelationshipLevel import com.unciv.logic.civilization.diplomacy.RelationshipLevel
import com.unciv.logic.map.RoadStatus import com.unciv.logic.map.RoadStatus
import com.unciv.models.metadata.BASE_GAME_DURATION_TURNS
import com.unciv.models.ruleset.tile.ResourceType import com.unciv.models.ruleset.tile.ResourceType
import com.unciv.models.stats.Stat import com.unciv.models.stats.Stat
import com.unciv.models.stats.StatMap import com.unciv.models.stats.StatMap
@ -30,8 +31,8 @@ class CivInfoStats(val civInfo: CivilizationInfo){
numberOfUnitsToPayFor -= 0.25f * numberOfUnitsWithDiscount numberOfUnitsToPayFor -= 0.25f * numberOfUnitsWithDiscount
} }
val turnLimit = BASE_GAME_DURATION_TURNS * civInfo.gameInfo.gameParameters.gameSpeed.modifier
val gameProgress = civInfo.gameInfo.turns/400f // as game progresses Maintenance cost rises val gameProgress = civInfo.gameInfo.turns / turnLimit // as game progresses Maintenance cost rises
var cost = baseUnitCost*numberOfUnitsToPayFor*(1+gameProgress) var cost = baseUnitCost*numberOfUnitsToPayFor*(1+gameProgress)
cost = cost.pow(1+gameProgress/3) // Why 3? To spread 1 to 1.33 cost = cost.pow(1+gameProgress/3) // Why 3? To spread 1 to 1.33
if(!civInfo.isPlayerCivilization()) if(!civInfo.isPlayerCivilization())

View File

@ -513,7 +513,7 @@ class CivilizationInfo {
TechEra.Information, TechEra.Future -> 400 TechEra.Information, TechEra.Future -> 400
else -> 0 else -> 0
} }
return (basicGoldCostOfSignResearchAgreement * gameInfo.gameParameters.gameSpeed.getModifier()).toInt() return (basicGoldCostOfSignResearchAgreement * gameInfo.gameParameters.gameSpeed.modifier).toInt()
} }
fun giftMilitaryUnitTo(otherCiv: CivilizationInfo) { fun giftMilitaryUnitTo(otherCiv: CivilizationInfo) {

View File

@ -30,7 +30,7 @@ class GoldenAgeManager{
if(civInfo.nation.unique=="Golden Ages last 50% longer. During a Golden Age, units receive +1 Movement and +10% Strength") if(civInfo.nation.unique=="Golden Ages last 50% longer. During a Golden Age, units receive +1 Movement and +10% Strength")
turnsToGoldenAge*=1.5 turnsToGoldenAge*=1.5
if (civInfo.policies.isAdopted("Freedom Complete")) turnsToGoldenAge *= 1.5 if (civInfo.policies.isAdopted("Freedom Complete")) turnsToGoldenAge *= 1.5
turnsToGoldenAge *= civInfo.gameInfo.gameParameters.gameSpeed.getModifier() turnsToGoldenAge *= civInfo.gameInfo.gameParameters.gameSpeed.modifier
turnsLeftForCurrentGoldenAge += turnsToGoldenAge.toInt() turnsLeftForCurrentGoldenAge += turnsToGoldenAge.toInt()
civInfo.addNotification("You have entered a golden age!", null, Color.GOLD) civInfo.addNotification("You have entered a golden age!", null, Color.GOLD)
civInfo.popupAlerts.add(PopupAlert(AlertType.GoldenAge,"")) civInfo.popupAlerts.add(PopupAlert(AlertType.GoldenAge,""))

View File

@ -55,7 +55,7 @@ class PolicyManager {
policyCultureCost *= 0.9 policyCultureCost *= 0.9
if (civInfo.isPlayerCivilization()) if (civInfo.isPlayerCivilization())
policyCultureCost *= civInfo.getDifficulty().policyCostModifier policyCultureCost *= civInfo.getDifficulty().policyCostModifier
policyCultureCost *= civInfo.gameInfo.gameParameters.gameSpeed.getModifier() policyCultureCost *= civInfo.gameInfo.gameParameters.gameSpeed.modifier
val cost: Int = (policyCultureCost * (1 + cityModifier)).roundToInt() val cost: Int = (policyCultureCost * (1 + cityModifier)).roundToInt()
return cost - (cost % 5) return cost - (cost % 5)
} }

View File

@ -57,7 +57,7 @@ class TechManager {
var techCost = getRuleset().technologies[techName]!!.cost.toFloat() var techCost = getRuleset().technologies[techName]!!.cost.toFloat()
if (civInfo.isPlayerCivilization()) if (civInfo.isPlayerCivilization())
techCost *= civInfo.getDifficulty().researchCostModifier techCost *= civInfo.getDifficulty().researchCostModifier
techCost *= civInfo.gameInfo.gameParameters.gameSpeed.getModifier() techCost *= civInfo.gameInfo.gameParameters.gameSpeed.modifier
val techsResearchedKnownCivs = civInfo.getKnownCivs().count { it.isMajorCiv() && it.tech.isResearched(techName) } val techsResearchedKnownCivs = civInfo.getKnownCivs().count { it.isMajorCiv() && it.tech.isResearched(techName) }
val undefeatedCivs = UncivGame.Current.gameInfo.civilizations.count { it.isMajorCiv() && !it.isDefeated() } val undefeatedCivs = UncivGame.Current.gameInfo.civilizations.count { it.isMajorCiv() && !it.isDefeated() }
// https://forums.civfanatics.com/threads/the-mechanics-of-overflow-inflation.517970/ // https://forums.civfanatics.com/threads/the-mechanics-of-overflow-inflation.517970/
@ -127,7 +127,7 @@ class TechManager {
fun getScienceFromGreatScientist(): Int { fun getScienceFromGreatScientist(): Int {
// https://civilization.fandom.com/wiki/Great_Scientist_(Civ5) // https://civilization.fandom.com/wiki/Great_Scientist_(Civ5)
return (scienceOfLast8Turns.sum() * civInfo.gameInfo.gameParameters.gameSpeed.getModifier()).toInt() return (scienceOfLast8Turns.sum() * civInfo.gameInfo.gameParameters.gameSpeed.modifier).toInt()
} }
fun addCurrentScienceToScienceOfLast8Turns() { fun addCurrentScienceToScienceOfLast8Turns() {

View File

@ -507,7 +507,7 @@ class MapUnit {
private fun clearEncampment(tile: TileInfo) { private fun clearEncampment(tile: TileInfo) {
tile.improvement = null tile.improvement = null
var goldGained = civInfo.getDifficulty().clearBarbarianCampReward * civInfo.gameInfo.gameParameters.gameSpeed.getModifier() var goldGained = civInfo.getDifficulty().clearBarbarianCampReward * civInfo.gameInfo.gameParameters.gameSpeed.modifier
if (civInfo.nation.unique == "Receive triple Gold from Barbarian encampments and pillaging Cities. Embarked units can defend themselves.") if (civInfo.nation.unique == "Receive triple Gold from Barbarian encampments and pillaging Cities. Embarked units can defend themselves.")
goldGained *= 3f goldGained *= 3f

View File

@ -121,7 +121,7 @@ class TradeEvaluation{
TradeType.Technology -> TradeType.Technology ->
return (sqrt(civInfo.gameInfo.ruleSet.technologies[offer.name]!!.cost.toDouble()) return (sqrt(civInfo.gameInfo.ruleSet.technologies[offer.name]!!.cost.toDouble())
* civInfo.gameInfo.gameParameters.gameSpeed.getModifier()).toInt()*20 * civInfo.gameInfo.gameParameters.gameSpeed.modifier).toInt()*20
TradeType.Introduction -> return 250 TradeType.Introduction -> return 250
TradeType.WarDeclaration -> { TradeType.WarDeclaration -> {
val civToDeclareWarOn = civInfo.gameInfo.getCivilization(offer.name) val civToDeclareWarOn = civInfo.gameInfo.getCivilization(offer.name)

View File

@ -1,17 +1,14 @@
package com.unciv.models.metadata package com.unciv.models.metadata
enum class GameSpeed{ const val BASE_GAME_DURATION_TURNS = 500f
Quick,
Standard,
Epic,
Marathon;
fun getModifier(): Float { /** Game speed
when(this) { *
Quick -> return 0.67f * @param modifier cost modifier
Standard -> return 1f * */
Epic -> return 1.5f enum class GameSpeed(val modifier: Float) {
Marathon -> return 3f Quick(0.67f),
} Standard(1f),
} Epic(1.5f),
Marathon(3f);
} }

View File

@ -205,7 +205,7 @@ class Building : NamedStats(), IConstruction{
productionCost *= civInfo.gameInfo.getDifficulty().aiBuildingCostModifier productionCost *= civInfo.gameInfo.getDifficulty().aiBuildingCostModifier
} }
} }
productionCost *= civInfo.gameInfo.gameParameters.gameSpeed.getModifier() productionCost *= civInfo.gameInfo.gameParameters.gameSpeed.modifier
return productionCost.toInt() return productionCost.toInt()
} }

View File

@ -22,7 +22,7 @@ class TileImprovement : NamedStats() {
fun getTurnsToBuild(civInfo: CivilizationInfo): Int { fun getTurnsToBuild(civInfo: CivilizationInfo): Int {
var realTurnsToBuild = turnsToBuild.toFloat() * civInfo.gameInfo.gameParameters.gameSpeed.getModifier() var realTurnsToBuild = turnsToBuild.toFloat() * civInfo.gameInfo.gameParameters.gameSpeed.modifier
if (civInfo.containsBuildingUnique("Worker construction increased 25%")) if (civInfo.containsBuildingUnique("Worker construction increased 25%"))
realTurnsToBuild *= 0.75f realTurnsToBuild *= 0.75f
if (civInfo.policies.isAdopted("Citizenship")) if (civInfo.policies.isAdopted("Citizenship"))

View File

@ -97,7 +97,7 @@ class BaseUnit : INamed, IConstruction {
productionCost *= civInfo.getDifficulty().unitCostModifier productionCost *= civInfo.getDifficulty().unitCostModifier
else else
productionCost *= civInfo.gameInfo.getDifficulty().aiUnitCostModifier productionCost *= civInfo.gameInfo.getDifficulty().aiUnitCostModifier
productionCost *= civInfo.gameInfo.gameParameters.gameSpeed.getModifier() productionCost *= civInfo.gameInfo.gameParameters.gameSpeed.modifier
return productionCost.toInt() return productionCost.toInt()
} }

View File

@ -282,7 +282,7 @@ class UnitActions {
uncivSound = UncivSound.Chimes, uncivSound = UncivSound.Chimes,
action = { action = {
// http://civilization.wikia.com/wiki/Great_Merchant_(Civ5) // http://civilization.wikia.com/wiki/Great_Merchant_(Civ5)
var goldEarned = (350 + 50 * unit.civInfo.getEra().ordinal) * unit.civInfo.gameInfo.gameParameters.gameSpeed.getModifier() var goldEarned = (350 + 50 * unit.civInfo.getEra().ordinal) * unit.civInfo.gameInfo.gameParameters.gameSpeed.modifier
if (unit.civInfo.policies.isAdopted("Commerce Complete")) if (unit.civInfo.policies.isAdopted("Commerce Complete"))
goldEarned *= 2 goldEarned *= 2
unit.civInfo.gold += goldEarned.toInt() unit.civInfo.gold += goldEarned.toInt()