mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-10 04:43:29 +07:00
Added link checks when loading mods, so you'll know if you messed something up
This commit is contained in:
parent
9ca7e7ac5b
commit
4d6478cf05
@ -27,8 +27,10 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
|||||||
val militaryUnits = civUnits.filter { !it.type.isCivilian()}.count()
|
val militaryUnits = civUnits.filter { !it.type.isCivilian()}.count()
|
||||||
val workers = civUnits.filter { it.hasUnique(Constants.workerUnique) }.count().toFloat()
|
val workers = civUnits.filter { it.hasUnique(Constants.workerUnique) }.count().toFloat()
|
||||||
val cities = civInfo.cities.size
|
val cities = civInfo.cities.size
|
||||||
val canBuildWorkboat = cityInfo.cityConstructions.getConstructableUnits()
|
|
||||||
.any { it.uniques.contains("May create improvements on water resources") }
|
val buildableWorkboatUnits = cityInfo.cityConstructions.getConstructableUnits()
|
||||||
|
.filter { it.uniques.contains("May create improvements on water resources") }
|
||||||
|
val canBuildWorkboat = buildableWorkboatUnits.any()
|
||||||
&& !cityInfo.getTiles().any { it.civilianUnit?.hasUnique("May create improvements on water resources")==true }
|
&& !cityInfo.getTiles().any { it.civilianUnit?.hasUnique("May create improvements on water resources")==true }
|
||||||
val needWorkboat = canBuildWorkboat
|
val needWorkboat = canBuildWorkboat
|
||||||
&& cityInfo.getTiles().any { it.isWater && it.hasViewableResource(civInfo) && it.improvement == null }
|
&& cityInfo.getTiles().any { it.isWater && it.hasViewableResource(civInfo) && it.improvement == null }
|
||||||
@ -115,7 +117,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
|||||||
|
|
||||||
private fun addWorkBoatChoice() {
|
private fun addWorkBoatChoice() {
|
||||||
if (needWorkboat) {
|
if (needWorkboat) {
|
||||||
addChoice(relativeCostEffectiveness, "Work Boats", 0.6f)
|
addChoice(relativeCostEffectiveness, buildableWorkboatUnits.minBy { it.cost }!!.name, 0.6f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ object RulesetCache :HashMap<String,Ruleset>() {
|
|||||||
this[ruleset.fullName] = Ruleset().apply { load(fileHandle) }
|
this[ruleset.fullName] = Ruleset().apply { load(fileHandle) }
|
||||||
}
|
}
|
||||||
|
|
||||||
var modsHandles = if(consoleMode) FileHandle("mods").list()
|
val modsHandles = if(consoleMode) FileHandle("mods").list()
|
||||||
else Gdx.files.local("mods").list()
|
else Gdx.files.local("mods").list()
|
||||||
|
|
||||||
for (modFolder in modsHandles) {
|
for (modFolder in modsHandles) {
|
||||||
@ -203,6 +203,7 @@ object RulesetCache :HashMap<String,Ruleset>() {
|
|||||||
modRuleset.name = modFolder.name()
|
modRuleset.name = modFolder.name()
|
||||||
this[modRuleset.name] = modRuleset
|
this[modRuleset.name] = modRuleset
|
||||||
println("Mod loaded successfully: " + modRuleset.name)
|
println("Mod loaded successfully: " + modRuleset.name)
|
||||||
|
checkModLinks(modRuleset)
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
println("Exception loading mod '${modFolder.name()}':")
|
println("Exception loading mod '${modFolder.name()}':")
|
||||||
println(" ${ex.localizedMessage}")
|
println(" ${ex.localizedMessage}")
|
||||||
@ -211,6 +212,43 @@ object RulesetCache :HashMap<String,Ruleset>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun checkModLinks(modRuleset: Ruleset) {
|
||||||
|
for (unit in modRuleset.units.values) {
|
||||||
|
if (unit.requiredTech != null && !modRuleset.technologies.containsKey(unit.requiredTech!!))
|
||||||
|
println("${unit.name} requires tech ${unit.requiredTech} which does not exist!")
|
||||||
|
if (unit.obsoleteTech != null && !modRuleset.technologies.containsKey(unit.obsoleteTech!!))
|
||||||
|
println("${unit.name} obsoletes at tech ${unit.obsoleteTech} which does not exist!")
|
||||||
|
if (unit.requiredResource != null && !modRuleset.tileResources.containsKey(unit.requiredResource!!))
|
||||||
|
println("${unit.name} requires resource ${unit.requiredResource} which does not exist!")
|
||||||
|
if (unit.upgradesTo != null && !modRuleset.units.containsKey(unit.upgradesTo!!))
|
||||||
|
println("${unit.name} upgrades to unit ${unit.upgradesTo} which does not exist!")
|
||||||
|
if (unit.replaces != null && !modRuleset.units.containsKey(unit.replaces!!))
|
||||||
|
println("${unit.replaces} replaces ${unit.replaces} which does not exist!")
|
||||||
|
}
|
||||||
|
|
||||||
|
for (building in modRuleset.buildings.values) {
|
||||||
|
if (building.requiredTech != null && !modRuleset.technologies.containsKey(building.requiredTech!!))
|
||||||
|
println("${building.name} requires tech ${building.requiredTech} which does not exist!")
|
||||||
|
if (building.requiredResource != null && !modRuleset.tileResources.containsKey(building.requiredResource!!))
|
||||||
|
println("${building.name} requires resource ${building.requiredResource} which does not exist!")
|
||||||
|
if (building.replaces != null && !modRuleset.buildings.containsKey(building.replaces!!))
|
||||||
|
println("${building.name} replaces ${building.replaces} which does not exist!")
|
||||||
|
}
|
||||||
|
|
||||||
|
for (resource in modRuleset.tileResources.values) {
|
||||||
|
if (resource.revealedBy != null && !modRuleset.technologies.containsKey(resource.revealedBy!!))
|
||||||
|
println("${resource.name} revealed by tech ${resource.revealedBy} which does not exist!")
|
||||||
|
if (resource.improvement != null && !modRuleset.tileImprovements.containsKey(resource.improvement!!))
|
||||||
|
println("${resource.name} improved by improvement ${resource.improvement} which does not exist!")
|
||||||
|
}
|
||||||
|
|
||||||
|
for (improvement in modRuleset.tileImprovements.values) {
|
||||||
|
if (improvement.techRequired != null && !modRuleset.technologies.containsKey(improvement.techRequired!!))
|
||||||
|
println("${improvement.name} requires tech ${improvement.techRequired} which does not exist!")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
fun getBaseRuleset() = this[BaseRuleset.Civ_V_Vanilla.fullName]!!
|
fun getBaseRuleset() = this[BaseRuleset.Civ_V_Vanilla.fullName]!!
|
||||||
|
|
||||||
fun getComplexRuleset(gameParameters: GameParameters): Ruleset {
|
fun getComplexRuleset(gameParameters: GameParameters): Ruleset {
|
||||||
|
@ -447,13 +447,15 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
val turnsToTech = viewingCiv.tech.turnsToTech(currentTech)
|
val turnsToTech = viewingCiv.tech.turnsToTech(currentTech)
|
||||||
innerButton.text.setText(currentTech.tr() + "\r\n" + turnsToTech
|
innerButton.text.setText(currentTech.tr() + "\r\n" + turnsToTech
|
||||||
+ (if (turnsToTech > 1) " {turns}".tr() else " {turn}".tr()))
|
+ (if (turnsToTech > 1) " {turns}".tr() else " {turn}".tr()))
|
||||||
} else if (viewingCiv.tech.canResearchTech()) {
|
} else if (viewingCiv.tech.canResearchTech() || viewingCiv.tech.researchedTechnologies.any()) {
|
||||||
val buttonPic = Table()
|
val buttonPic = Table()
|
||||||
buttonPic.background = ImageGetter.getRoundedEdgeTableBackground(colorFromRGB(7, 46, 43))
|
buttonPic.background = ImageGetter.getRoundedEdgeTableBackground(colorFromRGB(7, 46, 43))
|
||||||
buttonPic.defaults().pad(20f)
|
buttonPic.defaults().pad(20f)
|
||||||
buttonPic.add("{Pick a tech}!".toLabel(Color.WHITE, 30))
|
val text = if(viewingCiv.tech.canResearchTech()) "{Pick a tech}!" else "Technologies"
|
||||||
|
buttonPic.add(text.toLabel(Color.WHITE, 30))
|
||||||
techButtonHolder.add(buttonPic)
|
techButtonHolder.add(buttonPic)
|
||||||
}
|
}
|
||||||
|
|
||||||
techButtonHolder.pack() //setSize(techButtonHolder.prefWidth, techButtonHolder.prefHeight)
|
techButtonHolder.pack() //setSize(techButtonHolder.prefWidth, techButtonHolder.prefHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user