mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-25 04:43:05 -04:00
Enable ModOptions uniques and ModConstants from non-base mods (#6345)
* Enable ModOptions uniques and ModConstants from non-base mods * Update ModConstants.merge for new ModConstants values
This commit is contained in:
parent
7f3b075ac4
commit
dd529db297
@ -2,6 +2,7 @@ package com.unciv.models
|
||||
|
||||
class ModConstants {
|
||||
// Max amount of experience that can be gained from combat with barbarians
|
||||
@Suppress("SpellCheckingInspection") // Pfrom is not a word ;)
|
||||
var maxXPfromBarbarians = 30
|
||||
|
||||
// Formula for city Strength:
|
||||
@ -11,12 +12,12 @@ class ModConstants {
|
||||
// defensiveBuildingStrength
|
||||
// where %techs is the percentage of techs in the tech tree that are complete
|
||||
// If no techs exist in this ruleset, %techs = 0.5 (=50%)
|
||||
val cityStrengthBase = 8.0
|
||||
val cityStrengthPerPop = 0.4
|
||||
val cityStrengthFromTechsMultiplier = 5.5
|
||||
val cityStrengthFromTechsExponent = 2.8
|
||||
val cityStrengthFromTechsFullMultiplier = 1.0
|
||||
val cityStrengthFromGarrison = 0.2
|
||||
var cityStrengthBase = 8.0
|
||||
var cityStrengthPerPop = 0.4
|
||||
var cityStrengthFromTechsMultiplier = 5.5
|
||||
var cityStrengthFromTechsExponent = 2.8
|
||||
var cityStrengthFromTechsFullMultiplier = 1.0
|
||||
var cityStrengthFromGarrison = 0.2
|
||||
|
||||
// Formula for Unit Supply:
|
||||
// Supply = unitSupplyBase (difficulties.json)
|
||||
@ -24,30 +25,54 @@ class ModConstants {
|
||||
// unitSupplyPerPopulation * amountOfPopulationInAllCities
|
||||
// unitSupplyBase and unitSupplyPerCity can be found in difficulties.json
|
||||
// unitSupplyBase, unitSupplyPerCity and unitSupplyPerPopulation can also be increased through uniques
|
||||
val unitSupplyPerPopulation = 0.5
|
||||
var unitSupplyPerPopulation = 0.5
|
||||
|
||||
// The minimal distance that must be between any two cities, not counting the tiles cities are on
|
||||
// The number is the amount of tiles between two cities, not counting the tiles the cities are on.
|
||||
// e.g. "C__C", where "C" is a tile with a city and "_" is a tile without a city, has a distance of 2.
|
||||
// First constant is for cities on the same landmass, the second is for cities on different continents.
|
||||
val minimalCityDistance = 3
|
||||
val minimalCityDistanceOnDifferentContinents = 2
|
||||
var minimalCityDistance = 3
|
||||
var minimalCityDistanceOnDifferentContinents = 2
|
||||
|
||||
// NaturalWonderGenerator uses these to determine the number of Natural Wonders to spawn for a given map size.
|
||||
// With these values, radius * mul + add gives a 1-2-3-4-5 progression for Unciv predefined map sizes and a 2-3-4-5-6-7 progression for the original Civ5 map sizes.
|
||||
// 0.124 = (Civ5.Huge.getHexagonalRadiusForArea(w*h) - Civ5.Duel.getHexagonalRadiusForArea(w*h)) / 5 (if you do not round in the radius function)
|
||||
// The other constant is empiric to avoid an ugly jump in the progression.
|
||||
val naturalWonderCountMultiplier = 0.124f
|
||||
val naturalWonderCountAddedConstant = 0.1f
|
||||
var naturalWonderCountMultiplier = 0.124f
|
||||
var naturalWonderCountAddedConstant = 0.1f
|
||||
|
||||
// MapGenerator.spreadAncientRuins: number of ruins = suitable tile count * this
|
||||
val ancientRuinCountMultiplier = 0.02f
|
||||
var ancientRuinCountMultiplier = 0.02f
|
||||
// MapGenerator.spawnIce: spawn Ice where T < this, with T calculated from temperatureExtremeness, latitude and perlin noise.
|
||||
val spawnIceBelowTemperature = -0.8f
|
||||
// MapGenerator.spawnLakesAndCoasts: Water bodies up to this tile count become Lakes
|
||||
val maxLakeSize = 10
|
||||
var maxLakeSize = 10
|
||||
// RiverGenerator: river frequency and length bounds
|
||||
val riverCountMultiplier = 0.01f
|
||||
val minRiverLength = 5
|
||||
val maxRiverLength = 666 // Do not set < max map radius
|
||||
var riverCountMultiplier = 0.01f
|
||||
var minRiverLength = 5
|
||||
var maxRiverLength = 666 // Do not set < max map radius
|
||||
|
||||
fun merge(other: ModConstants) {
|
||||
if (other.maxXPfromBarbarians != defaults.maxXPfromBarbarians) maxXPfromBarbarians = other.maxXPfromBarbarians
|
||||
if (other.cityStrengthBase != defaults.cityStrengthBase) cityStrengthBase = other.cityStrengthBase
|
||||
if (other.cityStrengthPerPop != defaults.cityStrengthPerPop) cityStrengthPerPop = other.cityStrengthPerPop
|
||||
if (other.cityStrengthFromTechsMultiplier != defaults.cityStrengthFromTechsMultiplier) cityStrengthFromTechsMultiplier = other.cityStrengthFromTechsMultiplier
|
||||
if (other.cityStrengthFromTechsExponent != defaults.cityStrengthFromTechsExponent) cityStrengthFromTechsExponent = other.cityStrengthFromTechsExponent
|
||||
if (other.cityStrengthFromTechsFullMultiplier != defaults.cityStrengthFromTechsFullMultiplier) cityStrengthFromTechsFullMultiplier = other.cityStrengthFromTechsFullMultiplier
|
||||
if (other.cityStrengthFromGarrison != defaults.cityStrengthFromGarrison) cityStrengthFromGarrison = other.cityStrengthFromGarrison
|
||||
if (other.unitSupplyPerPopulation != defaults.unitSupplyPerPopulation) unitSupplyPerPopulation = other.unitSupplyPerPopulation
|
||||
if (other.minimalCityDistance != defaults.minimalCityDistance) minimalCityDistance = other.minimalCityDistance
|
||||
if (other.minimalCityDistanceOnDifferentContinents != defaults.minimalCityDistanceOnDifferentContinents) minimalCityDistanceOnDifferentContinents = other.minimalCityDistanceOnDifferentContinents
|
||||
if (other.naturalWonderCountMultiplier != defaults.naturalWonderCountMultiplier) naturalWonderCountMultiplier = other.naturalWonderCountMultiplier
|
||||
if (other.naturalWonderCountAddedConstant != defaults.naturalWonderCountAddedConstant) naturalWonderCountAddedConstant = other.naturalWonderCountAddedConstant
|
||||
if (other.ancientRuinCountMultiplier != defaults.ancientRuinCountMultiplier) ancientRuinCountMultiplier = other.ancientRuinCountMultiplier
|
||||
if (other.maxLakeSize != defaults.maxLakeSize) maxLakeSize = other.maxLakeSize
|
||||
if (other.riverCountMultiplier != defaults.riverCountMultiplier) riverCountMultiplier = other.riverCountMultiplier
|
||||
if (other.minRiverLength != defaults.minRiverLength) minRiverLength = other.minRiverLength
|
||||
if (other.maxRiverLength != defaults.maxRiverLength) maxRiverLength = other.maxRiverLength
|
||||
}
|
||||
|
||||
companion object {
|
||||
val defaults = ModConstants()
|
||||
}
|
||||
}
|
||||
|
@ -133,6 +133,8 @@ class Ruleset {
|
||||
units.putAll(ruleset.units)
|
||||
unitTypes.putAll(ruleset.unitTypes)
|
||||
for (unitToRemove in ruleset.modOptions.unitsToRemove) units.remove(unitToRemove)
|
||||
modOptions.uniques.addAll(ruleset.modOptions.uniques)
|
||||
modOptions.constants.merge(ruleset.modOptions.constants)
|
||||
mods += ruleset.mods
|
||||
}
|
||||
|
||||
@ -864,11 +866,11 @@ object RulesetCache : HashMap<String,Ruleset>() {
|
||||
baseRuleset
|
||||
|
||||
for (mod in loadedMods.sortedByDescending { it.modOptions.isBaseRuleset }) {
|
||||
newRuleset.add(mod)
|
||||
newRuleset.mods += mod.name
|
||||
if (mod.modOptions.isBaseRuleset) {
|
||||
newRuleset.modOptions = mod.modOptions
|
||||
}
|
||||
newRuleset.add(mod)
|
||||
newRuleset.mods += mod.name
|
||||
}
|
||||
newRuleset.updateBuildingCosts() // only after we've added all the mods can we calculate the building costs
|
||||
|
||||
|
@ -22,7 +22,7 @@ import com.unciv.ui.utils.*
|
||||
class MapEditorScreen(): BaseScreen() {
|
||||
var mapName = ""
|
||||
var tileMap = TileMap()
|
||||
var ruleset = Ruleset().apply { add(RulesetCache.getVanillaRuleset()) }
|
||||
var ruleset = RulesetCache.getVanillaRuleset() // This will return a clone
|
||||
|
||||
var gameSetupInfo = GameSetupInfo()
|
||||
lateinit var mapHolder: EditorMapHolder
|
||||
|
Loading…
x
Reference in New Issue
Block a user