mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-15 10:18:26 +07:00
Added modoptions unique for disabling city-state spawning with only a settler (#4691)
This commit is contained in:
@ -9,6 +9,7 @@ import com.unciv.logic.map.TileMap
|
||||
import com.unciv.logic.map.mapgenerator.MapGenerator
|
||||
import com.unciv.models.metadata.GameParameters
|
||||
import com.unciv.models.ruleset.Era
|
||||
import com.unciv.models.ruleset.ModOptionsConstants
|
||||
import com.unciv.models.ruleset.Ruleset
|
||||
import com.unciv.models.ruleset.RulesetCache
|
||||
import com.unciv.models.ruleset.tile.ResourceType
|
||||
@ -235,6 +236,7 @@ object GameStarter {
|
||||
// An unusually bad spawning location
|
||||
addConsolationPrize(gameInfo, startingLocation, 45 - startingLocation.getTileStartScore().toInt())
|
||||
}
|
||||
|
||||
if(civ.isCityState())
|
||||
addCityStateLuxury(gameInfo, startingLocation)
|
||||
|
||||
@ -308,13 +310,21 @@ object GameStarter {
|
||||
return civ.getEquivalentUnit(unit).name
|
||||
}
|
||||
|
||||
// City states & one city challengers should spawn with one settler only regardless of era and difficulty
|
||||
if (civ.isCityState() || civ.playerType==PlayerType.Human && gameInfo.gameParameters.oneCityChallenge) {
|
||||
// City states should only spawn with one settler regardless of difficulty, but this may be disabled in mods
|
||||
if (civ.isCityState() && !ruleSet.modOptions.uniques.contains(ModOptionsConstants.allowCityStatesSpawnUnits)) {
|
||||
val startingSettlers = startingUnits.filter { settlerLikeUnits.contains(it) }
|
||||
|
||||
startingUnits.clear()
|
||||
startingUnits.add(startingSettlers.random())
|
||||
}
|
||||
|
||||
// One city challengers should spawn with one settler only regardless of era and difficulty
|
||||
if (civ.playerType == PlayerType.Human && gameInfo.gameParameters.oneCityChallenge) {
|
||||
val startingSettlers = startingUnits.filter { settlerLikeUnits.contains(it) }
|
||||
|
||||
startingUnits.removeAll(startingSettlers)
|
||||
startingUnits.add(startingSettlers.random())
|
||||
}
|
||||
|
||||
for (unit in startingUnits) {
|
||||
val unitToAdd = getEquivalentUnit(civ, unit)
|
||||
|
@ -6,6 +6,7 @@ import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
||||
import com.unciv.logic.map.RoadStatus
|
||||
import com.unciv.models.Counter
|
||||
import com.unciv.models.ruleset.Building
|
||||
import com.unciv.models.ruleset.ModOptionsConstants
|
||||
import com.unciv.models.ruleset.Unique
|
||||
import com.unciv.models.ruleset.unit.BaseUnit
|
||||
import com.unciv.models.stats.Stat
|
||||
@ -457,7 +458,7 @@ class CityStats {
|
||||
}
|
||||
|
||||
// AFTER we've gotten all the gold stats figured out, only THEN do we plonk that gold into Science
|
||||
if (cityInfo.getRuleset().modOptions.uniques.contains("Can convert gold to science with sliders")) {
|
||||
if (cityInfo.getRuleset().modOptions.uniques.contains(ModOptionsConstants.convertGoldToScience)) {
|
||||
val amountConverted = (newFinalStatList.values.sumByDouble { it.gold.toDouble() }
|
||||
* cityInfo.civInfo.tech.goldPercentConvertedToScience).toInt().toFloat()
|
||||
if (amountConverted > 0) // Don't want you converting negative gold to negative science yaknow
|
||||
|
@ -21,6 +21,8 @@ import kotlin.collections.set
|
||||
|
||||
object ModOptionsConstants {
|
||||
const val diplomaticRelationshipsCannotChange = "Diplomatic relationships cannot change"
|
||||
const val convertGoldToScience = "Can convert gold to science with sliders"
|
||||
const val allowCityStatesSpawnUnits = "Allow City States to spawn with additional units"
|
||||
}
|
||||
|
||||
class ModOptions {
|
||||
@ -29,13 +31,15 @@ class ModOptions {
|
||||
var buildingsToRemove = HashSet<String>()
|
||||
var unitsToRemove = HashSet<String>()
|
||||
var nationsToRemove = HashSet<String>()
|
||||
var uniques = HashSet<String>()
|
||||
val maxXPfromBarbarians = 30
|
||||
|
||||
|
||||
var lastUpdated = ""
|
||||
var modUrl = ""
|
||||
var author = ""
|
||||
var modSize = 0
|
||||
|
||||
val maxXPfromBarbarians = 30
|
||||
var uniques = HashSet<String>()
|
||||
}
|
||||
|
||||
class Ruleset {
|
||||
|
@ -5,6 +5,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Slider
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.civilization.GreatPersonManager
|
||||
import com.unciv.models.ruleset.ModOptionsConstants
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.utils.*
|
||||
import kotlin.math.roundToInt
|
||||
@ -62,7 +63,7 @@ class StatsOverviewTable (
|
||||
goldTable.add("Total".tr())
|
||||
goldTable.add(total.roundToInt().toString()).right()
|
||||
|
||||
if (viewingPlayer.gameInfo.ruleSet.modOptions.uniques.contains("Can convert gold to science with sliders")) {
|
||||
if (viewingPlayer.gameInfo.ruleSet.modOptions.uniques.contains(ModOptionsConstants.convertGoldToScience)) {
|
||||
goldTable.addSeparator()
|
||||
val sliderTable = Table()
|
||||
sliderTable.add("Convert gold to science".toLabel()).row()
|
||||
|
Reference in New Issue
Block a user