mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-05 21:11:35 +07:00
Scaling purchase costs for faith/culture/science/etc. with speed (#9721)
* Scaling with speed * Changing to float, and allowing a unique to set a gold price
This commit is contained in:
parent
478fb35e57
commit
08a280c29d
@ -384,8 +384,7 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
||||
)
|
||||
}
|
||||
|
||||
override fun getBaseBuyCost(city: City, stat: Stat): Int? {
|
||||
if (stat == Stat.Gold) return getBaseGoldCost(city.civ).toInt()
|
||||
override fun getBaseBuyCost(city: City, stat: Stat): Float? {
|
||||
val conditionalState = StateForConditionals(civInfo = city.civ, city = city)
|
||||
|
||||
return sequence {
|
||||
@ -402,12 +401,12 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
||||
it.params[1].toInt(),
|
||||
it.params[4].toInt(),
|
||||
city.civ.civConstructions.boughtItemsWithIncreasingPrice[name]
|
||||
)
|
||||
) * city.civ.gameInfo.speed.statCostModifiers[stat]!!
|
||||
}
|
||||
)
|
||||
yieldAll(city.getMatchingUniques(UniqueType.BuyBuildingsByProductionCost, conditionalState)
|
||||
.filter { it.params[1] == stat.name && matchesFilter(it.params[0]) }
|
||||
.map { getProductionCost(city.civ) * it.params[2].toInt() }
|
||||
.map { (getProductionCost(city.civ) * it.params[2].toInt()).toFloat() }
|
||||
)
|
||||
if (city.getMatchingUniques(UniqueType.BuyBuildingsWithStat, conditionalState)
|
||||
.any {
|
||||
@ -416,14 +415,14 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
||||
&& city.matchesFilter(it.params[2])
|
||||
}
|
||||
) {
|
||||
yield(city.civ.getEra().baseUnitBuyCost)
|
||||
yield(city.civ.getEra().baseUnitBuyCost * city.civ.gameInfo.speed.statCostModifiers[stat]!!)
|
||||
}
|
||||
yieldAll(city.getMatchingUniques(UniqueType.BuyBuildingsForAmountStat, conditionalState)
|
||||
.filter {
|
||||
it.params[2] == stat.name
|
||||
&& matchesFilter(it.params[0])
|
||||
&& city.matchesFilter(it.params[3])
|
||||
}.map { it.params[1].toInt() }
|
||||
}.map { it.params[1].toInt() * city.civ.gameInfo.speed.statCostModifiers[stat]!! }
|
||||
)
|
||||
}.minOrNull()
|
||||
}
|
||||
|
@ -73,21 +73,21 @@ interface INonPerpetualConstruction : IConstruction, INamed, IHasUniques {
|
||||
return (30.0 * getProductionCost(civInfo)).pow(0.75) * hurryCostModifier.toPercent()
|
||||
}
|
||||
|
||||
fun getBaseBuyCost(city: City, stat: Stat): Int? {
|
||||
if (stat == Stat.Gold) return getBaseGoldCost(city.civ).toInt()
|
||||
|
||||
fun getBaseBuyCost(city: City, stat: Stat): Float? {
|
||||
val conditionalState = StateForConditionals(civInfo = city.civ, city = city)
|
||||
|
||||
// Can be purchased for [amount] [Stat] [cityFilter]
|
||||
val lowestCostUnique = getMatchingUniques(UniqueType.CanBePurchasedForAmountStat, conditionalState)
|
||||
.filter { it.params[1] == stat.name && city.matchesFilter(it.params[2]) }
|
||||
.minByOrNull { it.params[0].toInt() }
|
||||
if (lowestCostUnique != null) return lowestCostUnique.params[0].toInt()
|
||||
if (lowestCostUnique != null) return lowestCostUnique.params[0].toInt() * city.civ.gameInfo.speed.statCostModifiers[stat]!!
|
||||
|
||||
if (stat == Stat.Gold) return getBaseGoldCost(city.civ).toFloat()
|
||||
|
||||
// Can be purchased with [Stat] [cityFilter]
|
||||
if (getMatchingUniques(UniqueType.CanBePurchasedWithStat, conditionalState)
|
||||
.any { it.params[0] == stat.name && city.matchesFilter(it.params[1]) }
|
||||
) return city.civ.getEra().baseUnitBuyCost
|
||||
) return city.civ.getEra().baseUnitBuyCost * city.civ.gameInfo.speed.statCostModifiers[stat]!!
|
||||
return null
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,7 @@ class Speed : RulesetObject(), IsPartOfGameInfoSerialization {
|
||||
Stat.Gold -> goldCostModifier
|
||||
Stat.Science -> scienceCostModifier
|
||||
Stat.Faith -> faithCostModifier
|
||||
Stat.Culture -> cultureCostModifier
|
||||
else -> 1f
|
||||
}
|
||||
map[stat] = modifier
|
||||
|
@ -95,9 +95,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
return super.canBePurchasedWithStat(city, stat)
|
||||
}
|
||||
|
||||
override fun getBaseBuyCost(city: City, stat: Stat): Int? {
|
||||
if (stat == Stat.Gold) return getBaseGoldCost(city.civ).toInt()
|
||||
|
||||
override fun getBaseBuyCost(city: City, stat: Stat): Float? {
|
||||
return sequence {
|
||||
val baseCost = super.getBaseBuyCost(city, stat)
|
||||
if (baseCost != null)
|
||||
|
@ -76,7 +76,7 @@ class BaseUnitCost(val baseUnit: BaseUnit) {
|
||||
}
|
||||
|
||||
|
||||
fun getBaseBuyCosts(city: City, stat: Stat): Sequence<Int> {
|
||||
fun getBaseBuyCosts(city: City, stat: Stat): Sequence<Float> {
|
||||
val conditionalState = StateForConditionals(civInfo = city.civ, city = city)
|
||||
return sequence {
|
||||
yieldAll(city.getMatchingUniques(UniqueType.BuyUnitsIncreasingCost, conditionalState)
|
||||
@ -89,12 +89,12 @@ class BaseUnitCost(val baseUnit: BaseUnit) {
|
||||
it.params[1].toInt(),
|
||||
it.params[4].toInt(),
|
||||
city.civ.civConstructions.boughtItemsWithIncreasingPrice[baseUnit.name]
|
||||
)
|
||||
) * city.civ.gameInfo.speed.statCostModifiers[stat]!!
|
||||
}
|
||||
)
|
||||
yieldAll(city.getMatchingUniques(UniqueType.BuyUnitsByProductionCost, conditionalState)
|
||||
.filter { it.params[1] == stat.name && baseUnit.matchesFilter(it.params[0]) }
|
||||
.map { getProductionCost(city.civ) * it.params[2].toInt() }
|
||||
.map { (getProductionCost(city.civ) * it.params[2].toInt()).toFloat() }
|
||||
)
|
||||
|
||||
if (city.getMatchingUniques(UniqueType.BuyUnitsWithStat, conditionalState)
|
||||
@ -103,14 +103,14 @@ class BaseUnitCost(val baseUnit: BaseUnit) {
|
||||
&& baseUnit.matchesFilter(it.params[0])
|
||||
&& city.matchesFilter(it.params[2])
|
||||
}
|
||||
) yield(city.civ.getEra().baseUnitBuyCost)
|
||||
) yield(city.civ.getEra().baseUnitBuyCost * city.civ.gameInfo.speed.statCostModifiers[stat]!!)
|
||||
|
||||
yieldAll(city.getMatchingUniques(UniqueType.BuyUnitsForAmountStat, conditionalState)
|
||||
.filter {
|
||||
it.params[2] == stat.name
|
||||
&& baseUnit.matchesFilter(it.params[0])
|
||||
&& city.matchesFilter(it.params[3])
|
||||
}.map { it.params[1].toInt() }
|
||||
}.map { it.params[1].toInt() * city.civ.gameInfo.speed.statCostModifiers[stat]!! }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user