mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 06:16:37 -04:00
Added gold-to-science conversion for Civ IV rules
This commit is contained in:
parent
b076f482aa
commit
16356f9d36
@ -450,11 +450,22 @@ class CityStats {
|
|||||||
val isUnhappy = cityInfo.civInfo.getHappiness() < 0
|
val isUnhappy = cityInfo.civInfo.getHappiness() < 0
|
||||||
for (entry in newFinalStatList.values) {
|
for (entry in newFinalStatList.values) {
|
||||||
entry.gold *= 1 + statPercentBonusesSum.gold / 100
|
entry.gold *= 1 + statPercentBonusesSum.gold / 100
|
||||||
entry.science *= 1 + statPercentBonusesSum.science / 100
|
|
||||||
entry.culture *= 1 + statPercentBonusesSum.culture / 100
|
entry.culture *= 1 + statPercentBonusesSum.culture / 100
|
||||||
if (!isUnhappy) entry.food *= 1 + statPercentBonusesSum.food / 100 // Regular food bonus revoked when unhappy per https://forums.civfanatics.com/resources/complete-guide-to-happiness-vanilla.25584/
|
if (!isUnhappy) entry.food *= 1 + statPercentBonusesSum.food / 100 // Regular food bonus revoked when unhappy per https://forums.civfanatics.com/resources/complete-guide-to-happiness-vanilla.25584/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AFTER we've gotten all the gold stats figured out, only THEN do we plonk that gold into Science
|
||||||
|
if (cityInfo.getRuleset().modOptions.uniques.contains("Can convert gold to science with sliders")) {
|
||||||
|
val amountConverted = (newFinalStatList.values.sumByDouble { it.gold.toDouble() }
|
||||||
|
* cityInfo.civInfo.tech.goldPercentConvertedToScience).toInt().toFloat()
|
||||||
|
if (amountConverted > 0) // Don't want you converting negative gold to negative science yaknow
|
||||||
|
newFinalStatList["Gold -> Science"] = Stats().apply { science = amountConverted; gold = -amountConverted }
|
||||||
|
}
|
||||||
|
for (entry in newFinalStatList.values) {
|
||||||
|
entry.science *= 1 + statPercentBonusesSum.science / 100
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
/* Okay, food calculation is complicated.
|
/* Okay, food calculation is complicated.
|
||||||
First we see how much food we generate. Then we apply production bonuses to it.
|
First we see how much food we generate. Then we apply production bonuses to it.
|
||||||
|
@ -40,6 +40,9 @@ class TechManager {
|
|||||||
private var techsInProgress = HashMap<String, Int>()
|
private var techsInProgress = HashMap<String, Int>()
|
||||||
var overflowScience = 0
|
var overflowScience = 0
|
||||||
|
|
||||||
|
/** In civ IV, you can auto-convert a certain percentage of gold in cities to science */
|
||||||
|
var goldPercentConvertedToScience = 0.6f
|
||||||
|
|
||||||
//region state-changing functions
|
//region state-changing functions
|
||||||
fun clone(): TechManager {
|
fun clone(): TechManager {
|
||||||
val toReturn = TechManager()
|
val toReturn = TechManager()
|
||||||
@ -50,6 +53,7 @@ class TechManager {
|
|||||||
toReturn.scienceOfLast8Turns = scienceOfLast8Turns.clone()
|
toReturn.scienceOfLast8Turns = scienceOfLast8Turns.clone()
|
||||||
toReturn.scienceFromResearchAgreements = scienceFromResearchAgreements
|
toReturn.scienceFromResearchAgreements = scienceFromResearchAgreements
|
||||||
toReturn.overflowScience = overflowScience
|
toReturn.overflowScience = overflowScience
|
||||||
|
toReturn.goldPercentConvertedToScience = goldPercentConvertedToScience
|
||||||
return toReturn
|
return toReturn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ class MapUnit {
|
|||||||
var currentMovement: Float = 0f
|
var currentMovement: Float = 0f
|
||||||
var health:Int = 100
|
var health:Int = 100
|
||||||
|
|
||||||
|
// todo: I see this is being serialized, should it be Transient?
|
||||||
var mapUnitAction : MapUnitAction? = null
|
var mapUnitAction : MapUnitAction? = null
|
||||||
|
|
||||||
var action: String? // work, automation, fortifying, I dunno what.
|
var action: String? // work, automation, fortifying, I dunno what.
|
||||||
|
@ -9,7 +9,7 @@ import com.unciv.models.translations.tr
|
|||||||
class Promotion : INamed{
|
class Promotion : INamed{
|
||||||
override lateinit var name: String
|
override lateinit var name: String
|
||||||
var prerequisites = listOf<String>()
|
var prerequisites = listOf<String>()
|
||||||
lateinit var effect:String
|
var effect=""
|
||||||
val unique:Unique by lazy { Unique(effect) }
|
val unique:Unique by lazy { Unique(effect) }
|
||||||
var unitTypes = listOf<String>() // The json parser wouldn't agree to deserialize this as a list of UnitTypes. =(
|
var unitTypes = listOf<String>() // The json parser wouldn't agree to deserialize this as a list of UnitTypes. =(
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import com.badlogic.gdx.scenes.scene2d.Actor
|
|||||||
import com.badlogic.gdx.scenes.scene2d.Group
|
import com.badlogic.gdx.scenes.scene2d.Group
|
||||||
import com.badlogic.gdx.scenes.scene2d.Touchable
|
import com.badlogic.gdx.scenes.scene2d.Touchable
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Slider
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.utils.Align
|
import com.badlogic.gdx.utils.Align
|
||||||
import com.unciv.Constants
|
import com.unciv.Constants
|
||||||
@ -26,6 +27,7 @@ class EmpireOverviewScreen(private var viewingPlayer:CivilizationInfo, defaultPa
|
|||||||
private val topTable = Table().apply { defaults().pad(10f) }
|
private val topTable = Table().apply { defaults().pad(10f) }
|
||||||
private val centerTable = Table().apply { defaults().pad(5f) }
|
private val centerTable = Table().apply { defaults().pad(5f) }
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
onBackButtonClicked { game.setWorldScreen() }
|
onBackButtonClicked { game.setWorldScreen() }
|
||||||
val clicks = HashMap<String,() -> Unit>()
|
val clicks = HashMap<String,() -> Unit>()
|
||||||
@ -46,20 +48,8 @@ class EmpireOverviewScreen(private var viewingPlayer:CivilizationInfo, defaultPa
|
|||||||
topTable.add(setCityInfoButton)
|
topTable.add(setCityInfoButton)
|
||||||
|
|
||||||
val setStatsInfoButton = "Stats".toTextButton()
|
val setStatsInfoButton = "Stats".toTextButton()
|
||||||
val setStats = {
|
clicks["Stats"] = {setStats()}
|
||||||
game.settings.addCompletedTutorialTask("See your stats breakdown")
|
setStatsInfoButton.onClick{setStats()}
|
||||||
centerTable.clear()
|
|
||||||
centerTable.add(ScrollPane(Table().apply {
|
|
||||||
defaults().pad(40f)
|
|
||||||
add(getHappinessTable()).top()
|
|
||||||
add(getGoldTable()).top()
|
|
||||||
add(getScienceTable()).top()
|
|
||||||
add(getGreatPeopleTable()).top()
|
|
||||||
}))
|
|
||||||
centerTable.pack()
|
|
||||||
}
|
|
||||||
clicks["Stats"] = setStats
|
|
||||||
setStatsInfoButton.onClick(setStats)
|
|
||||||
topTable.add(setStatsInfoButton)
|
topTable.add(setStatsInfoButton)
|
||||||
|
|
||||||
val setCurrentTradesButton = "Trades".toTextButton()
|
val setCurrentTradesButton = "Trades".toTextButton()
|
||||||
@ -150,6 +140,19 @@ class EmpireOverviewScreen(private var viewingPlayer:CivilizationInfo, defaultPa
|
|||||||
stage.addActor(table)
|
stage.addActor(table)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setStats() {
|
||||||
|
game.settings.addCompletedTutorialTask("See your stats breakdown")
|
||||||
|
centerTable.clear()
|
||||||
|
centerTable.add(ScrollPane(Table().apply {
|
||||||
|
defaults().pad(40f)
|
||||||
|
add(getHappinessTable()).top()
|
||||||
|
add(getGoldTable()).top()
|
||||||
|
add(getScienceTable()).top()
|
||||||
|
add(getGreatPeopleTable()).top()
|
||||||
|
}))
|
||||||
|
centerTable.pack()
|
||||||
|
}
|
||||||
|
|
||||||
private fun getTradesTable(): Table {
|
private fun getTradesTable(): Table {
|
||||||
val tradesTable = Table().apply { defaults().pad(10f) }
|
val tradesTable = Table().apply { defaults().pad(10f) }
|
||||||
val diplomacies = viewingPlayer.diplomacy.values.filter { it.trades.isNotEmpty() }
|
val diplomacies = viewingPlayer.diplomacy.values.filter { it.trades.isNotEmpty() }
|
||||||
@ -234,6 +237,23 @@ class EmpireOverviewScreen(private var viewingPlayer:CivilizationInfo, defaultPa
|
|||||||
}
|
}
|
||||||
goldTable.add("Total".tr())
|
goldTable.add("Total".tr())
|
||||||
goldTable.add(total.roundToInt().toString()).right()
|
goldTable.add(total.roundToInt().toString()).right()
|
||||||
|
|
||||||
|
if(viewingPlayer.gameInfo.ruleSet.modOptions.uniques.contains("Can convert gold to science with sliders")) {
|
||||||
|
goldTable.addSeparator()
|
||||||
|
val sliderTable = Table()
|
||||||
|
sliderTable.add("Convert gold to science".toLabel()).row()
|
||||||
|
val slider = Slider(0f, 1f, 0.1f, false, skin)
|
||||||
|
slider.value = viewingPlayer.tech.goldPercentConvertedToScience
|
||||||
|
|
||||||
|
slider.onChange {
|
||||||
|
viewingPlayer.tech.goldPercentConvertedToScience = slider.value
|
||||||
|
viewingPlayer.cities.forEach { it.cityStats.update() }
|
||||||
|
setStats()
|
||||||
|
}
|
||||||
|
sliderTable.add(slider)
|
||||||
|
goldTable.add(sliderTable).colspan(2)
|
||||||
|
}
|
||||||
|
|
||||||
goldTable.pack()
|
goldTable.pack()
|
||||||
return goldTable
|
return goldTable
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user