mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 22:37:02 -04:00
Parametrized "Maintenance on roads & railroads reduced by []%"
This commit is contained in:
parent
8e8215b5c4
commit
9c725d74ae
@ -635,7 +635,8 @@
|
|||||||
"outerColor": [255,184,33],
|
"outerColor": [255,184,33],
|
||||||
"innerColor": [3,115,86],
|
"innerColor": [3,115,86],
|
||||||
"uniqueName": "Great Andean Road",
|
"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"],
|
"No Maintenance costs for improvements in Hills"],
|
||||||
"cities": ["Cuzco","Tiwanaku","Machu","Ollantaytambo","Corihuayrachina","Huamanga","Rumicucho","Vilcabamba","Vitcos",
|
"cities": ["Cuzco","Tiwanaku","Machu","Ollantaytambo","Corihuayrachina","Huamanga","Rumicucho","Vilcabamba","Vitcos",
|
||||||
"Andahuaylas","Ica","Arequipa","Nasca","Atico","Juli","Chuito","Chuquiapo","Huanuco Pampa","Tamboccocha",
|
"Andahuaylas","Ica","Arequipa","Nasca","Atico","Juli","Chuito","Chuquiapo","Huanuco Pampa","Tamboccocha",
|
||||||
|
@ -218,7 +218,7 @@
|
|||||||
"policies": [
|
"policies": [
|
||||||
{
|
{
|
||||||
"name": "Trade Unions",
|
"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,
|
"row": 1,
|
||||||
"column": 2
|
"column": 2
|
||||||
},
|
},
|
||||||
|
@ -12,7 +12,7 @@ import kotlin.math.min
|
|||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
|
|
||||||
/** CivInfo class was getting too crowded */
|
/** CivInfo class was getting too crowded */
|
||||||
class CivInfoStats(val civInfo: CivilizationInfo){
|
class CivInfoStats(val civInfo: CivilizationInfo) {
|
||||||
|
|
||||||
private fun getUnitMaintenance(): Int {
|
private fun getUnitMaintenance(): Int {
|
||||||
val baseUnitCost = 0.5f
|
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
|
// 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 []")
|
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.
|
// 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
|
// 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()) {
|
for (tile in city.getTiles()) {
|
||||||
if (tile.isCityCenter()) continue
|
if (tile.isCityCenter()) continue
|
||||||
if (ignoreHillTiles && tile.isHill()) continue
|
if (ignoreHillTiles && tile.isHill()) continue
|
||||||
@ -65,21 +65,28 @@ class CivInfoStats(val civInfo: CivilizationInfo){
|
|||||||
}
|
}
|
||||||
|
|
||||||
val tileUpkeep =
|
val tileUpkeep =
|
||||||
when (tile.roadStatus) {
|
when (tile.roadStatus) {
|
||||||
RoadStatus.Road -> 1
|
RoadStatus.Road -> 1
|
||||||
RoadStatus.Railroad -> 2
|
RoadStatus.Railroad -> 2
|
||||||
RoadStatus.None -> 0
|
RoadStatus.None -> 0
|
||||||
}
|
}
|
||||||
transportationUpkeep += tileUpkeep
|
transportationUpkeep += tileUpkeep
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Inca unique according to https://civilization.fandom.com/wiki/Incan_%28Civ5%29
|
// 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"))
|
if (civInfo.hasUnique("50% Maintenance costs reduction"))
|
||||||
transportationUpkeep /= 2
|
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%")
|
if (civInfo.hasUnique("Maintenance on roads & railroads reduced by 33%")
|
||||||
//presume we want to deprecate the old one at some point?
|
//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()
|
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
|
return transportationUpkeep
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,12 +110,12 @@ class CivInfoStats(val civInfo: CivilizationInfo){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
statMap["Transportation upkeep"] = Stats().apply { gold=- getTransportationUpkeep().toFloat()}
|
statMap["Transportation upkeep"] = Stats().apply { gold = -getTransportationUpkeep().toFloat() }
|
||||||
statMap["Unit upkeep"] = Stats().apply { gold=- getUnitMaintenance().toFloat()}
|
statMap["Unit upkeep"] = Stats().apply { gold = -getUnitMaintenance().toFloat() }
|
||||||
|
|
||||||
if (civInfo.hasUnique("50% of excess happiness added to culture towards policies")) {
|
if (civInfo.hasUnique("50% of excess happiness added to culture towards policies")) {
|
||||||
val happiness = civInfo.getHappiness()
|
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
|
// negative gold hurts science
|
||||||
@ -120,8 +127,8 @@ class CivInfoStats(val civInfo: CivilizationInfo){
|
|||||||
statMap["Treasury deficit"] = Stats().apply { science = scienceDeficit }
|
statMap["Treasury deficit"] = Stats().apply { science = scienceDeficit }
|
||||||
}
|
}
|
||||||
val goldDifferenceFromTrade = civInfo.diplomacy.values.sumBy { it.goldPerTurn() }
|
val goldDifferenceFromTrade = civInfo.diplomacy.values.sumBy { it.goldPerTurn() }
|
||||||
if(goldDifferenceFromTrade!=0)
|
if (goldDifferenceFromTrade != 0)
|
||||||
statMap["Trade"] = Stats().apply { gold= goldDifferenceFromTrade.toFloat() }
|
statMap["Trade"] = Stats().apply { gold = goldDifferenceFromTrade.toFloat() }
|
||||||
|
|
||||||
return statMap
|
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)
|
// 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
|
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
|
happinessPerUniqueLuxury += 1
|
||||||
statMap["Luxury resources"]= civInfo.getCivResources().map { it.resource }
|
statMap["Luxury resources"] = civInfo.getCivResources().map { it.resource }
|
||||||
.count { it.resourceType === ResourceType.Luxury } * happinessPerUniqueLuxury
|
.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
|
// There appears to be a concurrency problem? In concurrent thread in ConstructionsTable.getConstructionButtonDTOs
|
||||||
// Literally no idea how, since happinessList is ONLY replaced, NEVER altered.
|
// Literally no idea how, since happinessList is ONLY replaced, NEVER altered.
|
||||||
// Oh well, toList() should solve the problem, wherever it may come from.
|
// Oh well, toList() should solve the problem, wherever it may come from.
|
||||||
for ((key, value) in city.cityStats.happinessList.toList()) {
|
for ((key, value) in city.cityStats.happinessList.toList()) {
|
||||||
if (statMap.containsKey(key))
|
if (statMap.containsKey(key))
|
||||||
statMap[key] = statMap[key]!! + value
|
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 (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"]!! +
|
statMap["Policies"] = statMap["Policies"]!! +
|
||||||
civInfo.policies.getAdoptedPolicies().count { !it.endsWith("Complete") } / 2
|
civInfo.policies.getAdoptedPolicies().count { !it.endsWith("Complete") } / 2
|
||||||
}
|
}
|
||||||
|
@ -113,8 +113,7 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap
|
|||||||
if (previousSelectedUnits.isNotEmpty() && previousSelectedUnits.any { it.getTile() != tileInfo }
|
if (previousSelectedUnits.isNotEmpty() && previousSelectedUnits.any { it.getTile() != tileInfo }
|
||||||
&& worldScreen.isPlayersTurn
|
&& worldScreen.isPlayersTurn
|
||||||
&& previousSelectedUnits.any { it.movement.canMoveTo(tileInfo) ||
|
&& 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
|
// 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)
|
addTileOverlaysWithUnitMovement(previousSelectedUnits, tileInfo)
|
||||||
} else addTileOverlays(tileInfo) // no unit movement but display the units in the tile etc.
|
} else addTileOverlays(tileInfo) // no unit movement but display the units in the tile etc.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user