mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-24 14:49:23 +07:00
Add Big Ben.
This commit is contained in:
@ -36,7 +36,7 @@ class NextTurnAutomation{
|
||||
for (city in civInfo.cities.sortedByDescending{ it.population.population }) {
|
||||
val construction = city.cityConstructions.getCurrentConstruction()
|
||||
if (construction.canBePurchased()
|
||||
&& city.civInfo.gold / 3 >= construction.getGoldCost(civInfo.policies.getAdoptedPolicies()) ) {
|
||||
&& city.civInfo.gold / 3 >= construction.getGoldCost(civInfo) ) {
|
||||
city.cityConstructions.purchaseBuilding(construction.name)
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ class Battle(val gameInfo:GameInfo) {
|
||||
|
||||
if(defender.isDefeated() && defender is MapUnitCombatant && !defender.getUnitType().isCivilian()
|
||||
&& attacker.getCivInfo().policies.isAdopted("Honor Complete"))
|
||||
attacker.getCivInfo().gold += defender.unit.baseUnit.getGoldCost(hashSetOf()) / 10
|
||||
attacker.getCivInfo().gold += defender.unit.baseUnit.getGoldCost(attacker.getCivInfo(), true) / 10
|
||||
|
||||
if(attacker is MapUnitCombatant && attacker.unit.action!=null && attacker.unit.action!!.startsWith("moveTo"))
|
||||
attacker.unit.action=null
|
||||
|
@ -196,7 +196,7 @@ class CityConstructions {
|
||||
}
|
||||
|
||||
fun purchaseBuilding(buildingName: String) {
|
||||
cityInfo.civInfo.gold -= getConstruction(buildingName).getGoldCost(cityInfo.civInfo.policies.adoptedPolicies)
|
||||
cityInfo.civInfo.gold -= getConstruction(buildingName).getGoldCost(cityInfo.civInfo)
|
||||
getConstruction(buildingName).postBuildEvent(this)
|
||||
if (currentConstruction == buildingName) {
|
||||
currentConstruction = ""
|
||||
|
@ -1,11 +1,12 @@
|
||||
package com.unciv.logic.city
|
||||
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.models.gamebasics.ICivilopedia
|
||||
import com.unciv.models.stats.INamed
|
||||
|
||||
interface IConstruction : INamed, ICivilopedia {
|
||||
fun getProductionCost(adoptedPolicies: HashSet<String>): Int
|
||||
fun getGoldCost(adoptedPolicies: HashSet<String>): Int
|
||||
fun getGoldCost(civInfo: CivilizationInfo, baseCost: Boolean = false): Int
|
||||
fun isBuildable(construction: CityConstructions): Boolean
|
||||
fun shouldBeDisplayed(construction: CityConstructions): Boolean
|
||||
fun postBuildEvent(construction: CityConstructions) // Yes I'm hilarious.
|
||||
@ -48,7 +49,7 @@ open class SpecialConstruction(override var name: String, override val descripti
|
||||
throw Exception("Impossible!")
|
||||
}
|
||||
|
||||
override fun getGoldCost(adoptedPolicies: HashSet<String>): Int {
|
||||
override fun getGoldCost(civInfo: CivilizationInfo, baseCost: Boolean): Int {
|
||||
throw Exception("Impossible!")
|
||||
}
|
||||
|
||||
|
@ -169,12 +169,19 @@ class Building : NamedStats(), IConstruction{
|
||||
else cost
|
||||
}
|
||||
|
||||
override fun getGoldCost(adoptedPolicies: HashSet<String>): Int {
|
||||
override fun getGoldCost(civInfo: CivilizationInfo, baseCost: Boolean): Int {
|
||||
// https://forums.civfanatics.com/threads/rush-buying-formula.393892/
|
||||
var cost = Math.pow((30 * getProductionCost(adoptedPolicies)).toDouble(), 0.75) * (1 + hurryCostModifier / 100)
|
||||
if (adoptedPolicies.contains("Mercantilism")) cost *= 0.75
|
||||
if (adoptedPolicies.contains("Patronage")
|
||||
&& listOf("Monument", "Temple", "Opera House", "Museum").contains(name) ) cost *= 0.5
|
||||
var cost: Double
|
||||
if (baseCost) {
|
||||
cost = Math.pow((30 * getProductionCost(hashSetOf())).toDouble(), 0.75) * (1 + hurryCostModifier / 100)
|
||||
} else {
|
||||
cost = Math.pow((30 * getProductionCost(civInfo.policies.adoptedPolicies)).toDouble(), 0.75) * (1 + hurryCostModifier / 100)
|
||||
if (civInfo.policies.adoptedPolicies.contains("Mercantilism")) cost *= 0.75
|
||||
if (civInfo.getBuildingUniques().contains("-15% to purchasing items in cities")) cost *= 0.85
|
||||
if (civInfo.policies.adoptedPolicies.contains("Patronage")
|
||||
&& listOf("Monument", "Temple", "Opera House", "Museum").contains(name)) cost *= 0.5
|
||||
}
|
||||
|
||||
return (cost / 10).toInt() * 10
|
||||
}
|
||||
|
||||
|
@ -99,10 +99,13 @@ class BaseUnit : INamed, IConstruction, ICivilopedia {
|
||||
|
||||
fun getBaseGoldCost() = Math.pow((30 * cost).toDouble(), 0.75) * (1 + hurryCostModifier / 100)
|
||||
|
||||
override fun getGoldCost(adoptedPolicies: HashSet<String>): Int {
|
||||
override fun getGoldCost(civInfo: CivilizationInfo, baseCost: Boolean): Int {
|
||||
var cost = getBaseGoldCost()
|
||||
if(adoptedPolicies.contains("Mercantilism")) cost *= 0.75
|
||||
if(adoptedPolicies.contains("Militarism")) cost *= 0.66f
|
||||
if (!baseCost) {
|
||||
if(civInfo.policies.adoptedPolicies.contains("Mercantilism")) cost *= 0.75
|
||||
if(civInfo.policies.adoptedPolicies.contains("Militarism")) cost *= 0.66f
|
||||
if (civInfo.getBuildingUniques().contains("-15% to purchasing items in cities")) cost *= 0.85
|
||||
}
|
||||
return (cost / 10).toInt() * 10 // rounded down o nearest ten
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
||||
row()
|
||||
val purchaseConstructionButton: TextButton
|
||||
if (construction.canBePurchased()) {
|
||||
val buildingGoldCost = construction.getGoldCost(city.civInfo.policies.getAdoptedPolicies())
|
||||
val buildingGoldCost = construction.getGoldCost(city.civInfo)
|
||||
purchaseConstructionButton = TextButton("Buy for [$buildingGoldCost] gold".tr(), CameraStageBaseScreen.skin)
|
||||
purchaseConstructionButton.onClick("coin") {
|
||||
YesNoPopupTable("Would you like to purchase [${construction.name}] for [$buildingGoldCost] gold?".tr(), {
|
||||
|
Reference in New Issue
Block a user