Dev: Techs are now recognized by their unique abilities, not by tech name

This commit is contained in:
Yair Morgenstern 2018-11-17 20:33:21 +02:00
parent ab255e5138
commit 69e30ce212
8 changed files with 28 additions and 20 deletions

View file

@ -93,6 +93,7 @@
cost:85,
row:1,
prerequisites:["Sailing"],
uniques:["Enables embarkation for land units"]
},
{
name:"Horseback Riding",
@ -161,7 +162,7 @@
name:"Guilds",
row:7,
prerequisites:["Currency"],
baseDescription:"Enables conversion of city production to gold"
uniques:["Enables conversion of city production to gold"]
},
{
name:"Metal Casting",
@ -186,7 +187,7 @@
name:"Education",
row:3,
prerequisites:["Theology","Civil Service"],
baseDescription:"Enables conversion of city production to science"
uniques:["Enables conversion of city production to science"]
},
{
name:"Chivalry",
@ -197,7 +198,7 @@
name:"Machinery",
row:8,
prerequisites:["Guilds","Engineering"],
baseDescription:"Improves movement speed on roads"
uniques:["Improves movement speed on roads"]
},
{
name:"Physics",
@ -221,7 +222,7 @@
{
name:"Astronomy",
row:2,
baseDescription:"Increases embarked movement +1",
uniques:["Increases embarked movement +1","Enables embarked units to enter ocean tiles"],
prerequisites:["Compass","Education"]
},
{
@ -339,7 +340,7 @@
{
name:"Steam Power",
row:7,
baseDescription:"Increases embarked movement +1",
uniques:["Increases embarked movement +1"],
prerequisites:["Industrialization","Scientific Theory","Rifling"]
},
{
@ -419,7 +420,7 @@
name:"Computers",
row:5,
prerequisites:["Mass Media"],
baseDescription:"+10% science and production in all cities"
uniques:["+10% science and production in all cities"]
},
{
name:"Nuclear Fission",
@ -486,7 +487,7 @@
name:"Future Tech",
row:5,
prerequisites:["Nanotechnology","Particle Physics","Satellites"],
baseDescription:"Who knows what the future holds?"
uniques:["Who knows what the future holds?"]
}
]
}

View file

@ -58,7 +58,10 @@ class CityStats {
private fun getStatPercentBonusesFromRailroad(): Stats {
val stats = Stats()
if (cityInfo.civInfo.tech.isResearched("Combustion")
val techEnablingRailroad = GameBasics.TileImprovements["Railroad"]!!.techRequired!!
// If we conquered enemy cities connected by railroad, but we don't yet have that tech,
// we shouldn't get bonuses, it's as if the tracks aare layed out but we can't operate them.
if (cityInfo.civInfo.tech.isResearched(techEnablingRailroad)
&& (cityInfo.isCapital() || isConnectedToCapital(RoadStatus.Railroad)))
stats.production += 25f
return stats
@ -79,7 +82,7 @@ class CityStats {
private fun getStatPercentBonusesFromComputers(): Stats {
val stats = Stats()
if (cityInfo.civInfo.tech.isResearched("Computers")) {
if (cityInfo.civInfo.tech.getUniques().contains("+10% science and production in all cities")) {
stats.production += 10f
stats.science += 10f
}

View file

@ -18,12 +18,12 @@ open class SpecialConstruction(override var name: String, override val descripti
fun getSpecialConstructions(): List<SpecialConstruction> {
val science = object:SpecialConstruction("Science", "Convert production to science at a rate of 4 to 1"){
override fun isBuildable(construction: CityConstructions): Boolean {
return construction.cityInfo.civInfo.tech.isResearched("Education")
return construction.cityInfo.civInfo.tech.getUniques().contains("Enables conversion of city production to science")
}
}
val gold = object:SpecialConstruction("Gold", "Convert production to gold at a rate of 4 to 1"){
override fun isBuildable(construction: CityConstructions): Boolean {
return construction.cityInfo.civInfo.tech.isResearched("Guilds")
return construction.cityInfo.civInfo.tech.getUniques().contains("Enables conversion of city production to gold")
}
}
val idle = object:SpecialConstruction("Nothing", "The city will not produce anything."){

View file

@ -48,7 +48,6 @@ class CivilizationInfo {
constructor(civName: String, gameInfo: GameInfo) {
this.civName = civName
// this.gameInfo = gameInfo // already happens in setTransients
tech.techsResearched.add("Agriculture")
}
@ -236,7 +235,7 @@ class CivilizationInfo {
fun isDefeated()= cities.isEmpty() && !getCivUnits().any{it.name=="Settler"}
fun getEra(): TechEra {
val maxEraOfTech = tech.techsResearched.map { GameBasics.Technologies[it]!! }
val maxEraOfTech = tech.getResearchedTechs()
.map { it.era() }
.max()
if(maxEraOfTech!=null) return maxEraOfTech

View file

@ -56,6 +56,11 @@ class TechManager {
fun canBeResearched(TechName: String): Boolean {
return GameBasics.Technologies[TechName]!!.prerequisites.all { isResearched(it) }
}
fun getResearchedTechs() = techsResearched.map { GameBasics.Technologies[it]!! }
fun getUniques() = getResearchedTechs().flatMap { it.uniques }
//endregion
fun nextTurn(scienceForNewTurn: Int) {

View file

@ -109,9 +109,10 @@ class MapUnit {
fun canPassThrough(tile: TileInfo):Boolean{
val tileOwner = tile.getOwner()
if(tile.isWater() && baseUnit.unitType.isLandUnit()){
if(!civInfo.tech.isResearched("Optics"))
val techUniques = civInfo.tech.getUniques()
if(!techUniques.contains("Enables embarkation for land units"))
return false
if(tile.baseTerrain == "Ocean" && !civInfo.tech.isResearched("Astronomy"))
if(tile.baseTerrain == "Ocean" && !techUniques.contains("Enables embarked units to enter ocean tiles"))
return false
}
if(tile.isLand() && baseUnit.unitType.isWaterUnit())
@ -167,8 +168,7 @@ class MapUnit {
fun getEmbarkedMovement(): Int {
var movement=2
movement += civInfo.tech.techsResearched.map { GameBasics.Technologies[it]!! }
.count { it.baseDescription!=null && it.baseDescription!! == "Increases embarked movement +1" }
movement += civInfo.tech.getUniques().count { it == "Increases embarked movement +1" }
return movement
}

View file

@ -16,7 +16,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
if (from.roadStatus !== RoadStatus.None && to.roadStatus !== RoadStatus.None) //Road
{
if (unit.civInfo.tech.isResearched("Machinery")) return 1 / 3f
if (unit.civInfo.tech.getUniques().contains("Improves movement speed on roads")) return 1 / 3f
else return 1 / 2f
}
if (unit.hasUnique("Ignores terrain cost")) return 1f

View file

@ -10,7 +10,7 @@ class Technology : ICivilopedia {
override val description: String
get(){
val SB=StringBuilder()
if(baseDescription!=null) SB.appendln(baseDescription!!.tr())
for(unique in uniques) SB.appendln(unique.tr())
val improvedImprovements = GameBasics.TileImprovements.values.filter { it.improvingTech==name }.groupBy { it.improvingTechStats.toString() }
for (improvement in improvedImprovements) {
@ -42,9 +42,9 @@ class Technology : ICivilopedia {
}
lateinit var name: String
var baseDescription: String? = null
var cost: Int = 0
var prerequisites = HashSet<String>()
var uniques = ArrayList<String>()
var column: TechColumn? = null // The column that this tech is in the tech tree
var row: Int = 0