mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-16 10:49:17 +07:00
Parametrized "Maintenance on roads & railroads reduced by []%"
This commit is contained in:
@ -635,7 +635,8 @@
|
||||
"outerColor": [255,184,33],
|
||||
"innerColor": [3,115,86],
|
||||
"uniqueName": "Great Andean Road",
|
||||
"uniques": ["Units ignore terrain costs when moving into any tile with Hills", "50% Maintenance costs reduction",
|
||||
"uniques": ["Units ignore terrain costs when moving into any tile with Hills",
|
||||
"Maintenance on roads & railroads reduced by [50]%",
|
||||
"No Maintenance costs for improvements in Hills"],
|
||||
"cities": ["Cuzco","Tiwanaku","Machu","Ollantaytambo","Corihuayrachina","Huamanga","Rumicucho","Vilcabamba","Vitcos",
|
||||
"Andahuaylas","Ica","Arequipa","Nasca","Atico","Juli","Chuito","Chuquiapo","Huanuco Pampa","Tamboccocha",
|
||||
|
@ -218,7 +218,7 @@
|
||||
"policies": [
|
||||
{
|
||||
"name": "Trade Unions",
|
||||
"uniques": ["Maintenance on roads & railroads reduced by 33%", "[+2 Gold] from each Trade Route"],
|
||||
"uniques": ["Maintenance on roads & railroads reduced by [33]%", "[+2 Gold] from each Trade Route"],
|
||||
"row": 1,
|
||||
"column": 2
|
||||
},
|
||||
|
@ -12,7 +12,7 @@ import kotlin.math.min
|
||||
import kotlin.math.pow
|
||||
|
||||
/** CivInfo class was getting too crowded */
|
||||
class CivInfoStats(val civInfo: CivilizationInfo){
|
||||
class CivInfoStats(val civInfo: CivilizationInfo) {
|
||||
|
||||
private fun getUnitMaintenance(): Int {
|
||||
val baseUnitCost = 0.5f
|
||||
@ -49,13 +49,13 @@ class CivInfoStats(val civInfo: CivilizationInfo){
|
||||
// just to go over them once is a waste of memory - there are low-end phones who don't have much ram
|
||||
|
||||
val ignoredTileTypes = civInfo.getMatchingUniques("No Maintenance costs for improvements in []")
|
||||
.map { it.params[0] }.toHashSet() // needs to be .toHashSet()ed,
|
||||
.map { it.params[0] }.toHashSet() // needs to be .toHashSet()ed,
|
||||
// Because we go over every tile in every city and check if it's in this list, which can get real heavy.
|
||||
|
||||
// accounting for both the old way and the new way of doing no maintenance in hills
|
||||
val ignoreHillTiles = civInfo.hasUnique("No Maintenance costs for improvements in Hills")|| "Hills" in ignoredTileTypes
|
||||
val ignoreHillTiles = civInfo.hasUnique("No Maintenance costs for improvements in Hills") || "Hills" in ignoredTileTypes
|
||||
|
||||
for (city in civInfo.cities) {
|
||||
for (city in civInfo.cities) {
|
||||
for (tile in city.getTiles()) {
|
||||
if (tile.isCityCenter()) continue
|
||||
if (ignoreHillTiles && tile.isHill()) continue
|
||||
@ -65,21 +65,28 @@ class CivInfoStats(val civInfo: CivilizationInfo){
|
||||
}
|
||||
|
||||
val tileUpkeep =
|
||||
when (tile.roadStatus) {
|
||||
RoadStatus.Road -> 1
|
||||
RoadStatus.Railroad -> 2
|
||||
RoadStatus.None -> 0
|
||||
}
|
||||
when (tile.roadStatus) {
|
||||
RoadStatus.Road -> 1
|
||||
RoadStatus.Railroad -> 2
|
||||
RoadStatus.None -> 0
|
||||
}
|
||||
transportationUpkeep += tileUpkeep
|
||||
}
|
||||
}
|
||||
// Inca unique according to https://civilization.fandom.com/wiki/Incan_%28Civ5%29
|
||||
// Deprecated as of 3.12. in favor of "Maintenance on roads & railroads reduced by [50]%"
|
||||
if (civInfo.hasUnique("50% Maintenance costs reduction"))
|
||||
transportationUpkeep /= 2
|
||||
|
||||
// Deprecated as of 3.12. in favor of "Maintenance on roads & railroads reduced by [33]%"
|
||||
if (civInfo.hasUnique("Maintenance on roads & railroads reduced by 33%")
|
||||
//presume we want to deprecate the old one at some point?
|
||||
||civInfo.hasUnique("Maintenance on roads & railroads reduced by 33%, +2 gold from all trade routes"))
|
||||
|| civInfo.hasUnique("Maintenance on roads & railroads reduced by 33%, +2 gold from all trade routes"))
|
||||
transportationUpkeep = (transportationUpkeep * 2 / 3f).toInt()
|
||||
|
||||
for (unique in civInfo.getMatchingUniques("Maintenance on roads & railroads reduced by []%"))
|
||||
transportationUpkeep = (transportationUpkeep * (100f - unique.params[0].toInt()) / 100).toInt()
|
||||
|
||||
return transportationUpkeep
|
||||
}
|
||||
|
||||
@ -103,12 +110,12 @@ class CivInfoStats(val civInfo: CivilizationInfo){
|
||||
}
|
||||
}
|
||||
|
||||
statMap["Transportation upkeep"] = Stats().apply { gold=- getTransportationUpkeep().toFloat()}
|
||||
statMap["Unit upkeep"] = Stats().apply { gold=- getUnitMaintenance().toFloat()}
|
||||
statMap["Transportation upkeep"] = Stats().apply { gold = -getTransportationUpkeep().toFloat() }
|
||||
statMap["Unit upkeep"] = Stats().apply { gold = -getUnitMaintenance().toFloat() }
|
||||
|
||||
if (civInfo.hasUnique("50% of excess happiness added to culture towards policies")) {
|
||||
val happiness = civInfo.getHappiness()
|
||||
if(happiness>0) statMap.add("Policies", Stats().apply { culture=happiness/2f })
|
||||
if (happiness > 0) statMap.add("Policies", Stats().apply { culture = happiness / 2f })
|
||||
}
|
||||
|
||||
// negative gold hurts science
|
||||
@ -120,8 +127,8 @@ class CivInfoStats(val civInfo: CivilizationInfo){
|
||||
statMap["Treasury deficit"] = Stats().apply { science = scienceDeficit }
|
||||
}
|
||||
val goldDifferenceFromTrade = civInfo.diplomacy.values.sumBy { it.goldPerTurn() }
|
||||
if(goldDifferenceFromTrade!=0)
|
||||
statMap["Trade"] = Stats().apply { gold= goldDifferenceFromTrade.toFloat() }
|
||||
if (goldDifferenceFromTrade != 0)
|
||||
statMap["Trade"] = Stats().apply { gold = goldDifferenceFromTrade.toFloat() }
|
||||
|
||||
return statMap
|
||||
}
|
||||
@ -133,15 +140,15 @@ class CivInfoStats(val civInfo: CivilizationInfo){
|
||||
|
||||
// TODO - happinessPerUnique should be difficulty-dependent, 5 on Settler and Chieftian and 4 on other difficulties (should be parameter, not in code)
|
||||
var happinessPerUniqueLuxury = 4f + civInfo.getDifficulty().extraHappinessPerLuxury
|
||||
for(unique in civInfo.getMatchingUniques("+1 happiness from each type of luxury resource"))
|
||||
for (unique in civInfo.getMatchingUniques("+1 happiness from each type of luxury resource"))
|
||||
happinessPerUniqueLuxury += 1
|
||||
statMap["Luxury resources"]= civInfo.getCivResources().map { it.resource }
|
||||
statMap["Luxury resources"] = civInfo.getCivResources().map { it.resource }
|
||||
.count { it.resourceType === ResourceType.Luxury } * happinessPerUniqueLuxury
|
||||
|
||||
for(city in civInfo.cities) {
|
||||
for (city in civInfo.cities) {
|
||||
// There appears to be a concurrency problem? In concurrent thread in ConstructionsTable.getConstructionButtonDTOs
|
||||
// Literally no idea how, since happinessList is ONLY replaced, NEVER altered.
|
||||
// Oh well, toList() should solve the problem, wherever it may come from.
|
||||
// Literally no idea how, since happinessList is ONLY replaced, NEVER altered.
|
||||
// Oh well, toList() should solve the problem, wherever it may come from.
|
||||
for ((key, value) in city.cityStats.happinessList.toList()) {
|
||||
if (statMap.containsKey(key))
|
||||
statMap[key] = statMap[key]!! + value
|
||||
@ -150,7 +157,7 @@ class CivInfoStats(val civInfo: CivilizationInfo){
|
||||
}
|
||||
|
||||
if (civInfo.hasUnique("Provides 1 happiness per 2 additional social policies adopted")) {
|
||||
if(!statMap.containsKey("Policies")) statMap["Policies"]=0f
|
||||
if (!statMap.containsKey("Policies")) statMap["Policies"] = 0f
|
||||
statMap["Policies"] = statMap["Policies"]!! +
|
||||
civInfo.policies.getAdoptedPolicies().count { !it.endsWith("Complete") } / 2
|
||||
}
|
||||
@ -175,4 +182,4 @@ class CivInfoStats(val civInfo: CivilizationInfo){
|
||||
return statMap
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -113,8 +113,7 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap
|
||||
if (previousSelectedUnits.isNotEmpty() && previousSelectedUnits.any { it.getTile() != tileInfo }
|
||||
&& worldScreen.isPlayersTurn
|
||||
&& previousSelectedUnits.any { it.movement.canMoveTo(tileInfo) ||
|
||||
it.movement.isUnknownTileWeShouldAssumeToBePassable(tileInfo)
|
||||
}) {
|
||||
it.movement.isUnknownTileWeShouldAssumeToBePassable(tileInfo)}) {
|
||||
// this can take a long time, because of the unit-to-tile calculation needed, so we put it in a different thread
|
||||
addTileOverlaysWithUnitMovement(previousSelectedUnits, tileInfo)
|
||||
} else addTileOverlays(tileInfo) // no unit movement but display the units in the tile etc.
|
||||
|
Reference in New Issue
Block a user