mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-21 13:18:56 +07:00
Added Medieval era units
Techs now display imformation baed on what's dependant on them Buildings uniques now in humanspeak
This commit is contained in:
@ -27,7 +27,7 @@ class CityConstructions {
|
||||
val stats = Stats()
|
||||
for (building in getBuiltBuildings())
|
||||
stats.add(building.getStats(cityInfo.civInfo.policies.adoptedPolicies))
|
||||
stats.science += (cityInfo.buildingUniques.count({ it == "SciencePer2Pop" }) * cityInfo.population.population / 2).toFloat()
|
||||
stats.science += (cityInfo.buildingUniques.count({ it == "Science Per 2 Population" }) * cityInfo.population.population / 2).toFloat()
|
||||
return stats
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ class CityExpansionManager {
|
||||
fun getCultureToNextTile(): Int {
|
||||
val numTilesClaimed = cityInfo.tiles.size - 7
|
||||
var cultureToNextTile = 6 * Math.pow(numTilesClaimed + 1.4813, 1.3)
|
||||
if (cityInfo.civInfo.buildingUniques.contains("NewTileCostReduction")) cultureToNextTile *= 0.75 //Speciality of Angkor Wat
|
||||
if (cityInfo.civInfo.buildingUniques.contains("Cost of acquiring new tiles reduced by 25%")) cultureToNextTile *= 0.75 //Speciality of Angkor Wat
|
||||
if (cityInfo.civInfo.policies.isAdopted("Tradition")) cultureToNextTile *= 0.75
|
||||
return Math.round(cultureToNextTile).toInt()
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ class CityInfo {
|
||||
if (building.greatPersonPoints != null)
|
||||
greatPersonPoints.add(building.greatPersonPoints!!)
|
||||
|
||||
if (civInfo.buildingUniques.contains("GreatPersonGenerationIncrease"))
|
||||
if (civInfo.buildingUniques.contains("+33% great person generation in all cities"))
|
||||
greatPersonPoints = greatPersonPoints.times(1.33f)
|
||||
if (civInfo.policies.isAdopted("Entrepreneurship"))
|
||||
greatPersonPoints.gold *= 1.25f
|
||||
|
@ -30,7 +30,7 @@ class CityStats {
|
||||
val civInfo = cityInfo.civInfo
|
||||
var goldFromTradeRoute = civInfo.getCapital().population.population * 0.15 + cityInfo.population.population * 1.1 - 1 // Calculated by http://civilization.wikia.com/wiki/Trade_route_(Civ5)
|
||||
if (civInfo.policies.isAdopted("Trade Unions")) goldFromTradeRoute += 2.0
|
||||
if (civInfo.buildingUniques.contains("TradeRouteGoldIncrease")) goldFromTradeRoute *= 1.25 // Machu Pichu speciality
|
||||
if (civInfo.buildingUniques.contains("Gold from all trade routes +25%")) goldFromTradeRoute *= 1.25 // Machu Pichu speciality
|
||||
stats.gold += goldFromTradeRoute.toFloat()
|
||||
}
|
||||
return stats
|
||||
@ -102,7 +102,7 @@ class CityStats {
|
||||
var unhappinessFromCitizens = cityInfo.population.population.toFloat()
|
||||
if (civInfo.policies.isAdopted("Democracy"))
|
||||
unhappinessFromCitizens -= cityInfo.population.getNumberOfSpecialists() * 0.5f
|
||||
if (civInfo.buildingUniques.contains("CitizenUnhappinessDecreased"))
|
||||
if (civInfo.buildingUniques.contains("Unhappiness from population decreased by 10%"))
|
||||
unhappinessFromCitizens *= 0.9f
|
||||
if (civInfo.policies.isAdopted("Aristocracy"))
|
||||
unhappinessFromCitizens *= 0.95f
|
||||
@ -163,6 +163,14 @@ class CityStats {
|
||||
return stats
|
||||
}
|
||||
|
||||
|
||||
private fun getStatPercentBonusesFromWonders(): Stats {
|
||||
val stats = Stats()
|
||||
val civUniques = cityInfo.civInfo.buildingUniques
|
||||
if (civUniques.contains("Culture in all cities increased by 25%")) stats.culture += 25f
|
||||
return stats
|
||||
}
|
||||
|
||||
private fun getStatPercentBonusesFromPolicies(policies: HashSet<String>, cityConstructions: CityConstructions): Stats {
|
||||
val stats = Stats()
|
||||
|
||||
@ -200,6 +208,8 @@ class CityStats {
|
||||
val statPercentBonuses = cityInfo.cityConstructions.getStatPercentBonuses()
|
||||
statPercentBonuses.add(getStatPercentBonusesFromGoldenAge(cityInfo.civInfo.goldenAges.isGoldenAge()))
|
||||
statPercentBonuses.add(getStatPercentBonusesFromPolicies(civInfo.policies.adoptedPolicies, cityInfo.cityConstructions))
|
||||
// from wonders - Culture in all cities increased by 25%
|
||||
statPercentBonuses.add(getStatPercentBonusesFromWonders())
|
||||
statPercentBonuses.add(getStatPercentBonusesFromRailroad())
|
||||
statPercentBonuses.add(getStatPercentBonusesFromMarble())
|
||||
statPercentBonuses.add(getStatPercentBonusesFromComputers())
|
||||
|
@ -56,7 +56,7 @@ class PopulationManager {
|
||||
// growth!
|
||||
{
|
||||
foodStored -= getFoodToNextPopulation()
|
||||
if (cityInfo.buildingUniques.contains("FoodCarriesOver")) foodStored += (0.4f * getFoodToNextPopulation()).toInt() // Aqueduct special
|
||||
if (cityInfo.buildingUniques.contains("40% of food is carried over after a new citizen is born")) foodStored += (0.4f * getFoodToNextPopulation()).toInt() // Aqueduct special
|
||||
population++
|
||||
autoAssignPopulation()
|
||||
cityInfo.civInfo.addNotification(cityInfo.name + " has grown!", cityInfo.location)
|
||||
|
@ -91,7 +91,7 @@ class CivilizationInfo {
|
||||
happiness += getCivResources().keys
|
||||
.count { it.resourceType === ResourceType.Luxury } * happinessPerUniqueLuxury
|
||||
happiness += cities.sumBy { it.cityStats.getCityHappiness().toInt() }
|
||||
if (buildingUniques.contains("HappinessPerSocialPolicy"))
|
||||
if (buildingUniques.contains("Provides 1 happiness per social policy"))
|
||||
happiness += policies.getAdoptedPolicies().count { !it.endsWith("Complete") }
|
||||
return happiness
|
||||
}
|
||||
@ -182,7 +182,7 @@ class CivilizationInfo {
|
||||
.flatMap { it.neighbors } // tiles adjacent to city tiles
|
||||
viewablePositions += gameInfo.tileMap.values
|
||||
.filter { it.unit != null && it.unit!!.owner == civName }
|
||||
.flatMap { it.getViewableTiles(2)} // Tiles within 2 tiles of units
|
||||
.flatMap { it.getViewableTiles(it.unit!!.getVisibilityRange())} // Tiles within 2 tiles of units
|
||||
viewablePositions.map { it.position }.filterNot { exploredTiles.contains(it) }.toCollection(exploredTiles)
|
||||
return viewablePositions
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ class GoldenAgeManager {
|
||||
|
||||
fun enterGoldenAge() {
|
||||
var turnsToGoldenAge = 10.0
|
||||
if (civInfo.buildingUniques.contains("GoldenAgeLengthIncrease")) turnsToGoldenAge *= 1.5
|
||||
if (civInfo.buildingUniques.contains("Golden Age length increases +50%")) turnsToGoldenAge *= 1.5
|
||||
if (civInfo.policies.isAdopted("Freedom Complete")) turnsToGoldenAge *= 1.5
|
||||
turnsLeftForCurrentGoldenAge += turnsToGoldenAge.toInt()
|
||||
civInfo.addNotification("You have entered a golden age!", null)
|
||||
|
@ -26,7 +26,7 @@ class PolicyManager {
|
||||
var cityModifier = 0.3 * (civInfo.cities.size - 1)
|
||||
if (isAdopted("Representation")) cityModifier *= (2 / 3f).toDouble()
|
||||
if (isAdopted("Piety Complete")) baseCost *= 0.9
|
||||
if (civInfo.buildingUniques.contains("PolicyCostReduction")) baseCost *= 0.9
|
||||
if (civInfo.buildingUniques.contains("Culture cost of adopting new Policies reduced by 10%")) baseCost *= 0.9
|
||||
val cost: Int = Math.round(baseCost * (1 + cityModifier)).toInt()
|
||||
return cost - (cost % 5)
|
||||
}
|
||||
|
@ -124,4 +124,10 @@ class MapUnit {
|
||||
override fun toString(): String {
|
||||
return name +" - "+owner
|
||||
}
|
||||
|
||||
fun getVisibilityRange(): Int {
|
||||
var visibilityRange = 2
|
||||
if(hasUnique("Limited Visibility")) visibilityRange-=1
|
||||
return visibilityRange
|
||||
}
|
||||
}
|
@ -111,7 +111,7 @@ class TileInfo {
|
||||
if (stats.production < 0) stats.production = 0f
|
||||
|
||||
if ("Jungle" == terrainFeature && city != null
|
||||
&& city.buildingUniques.contains("JunglesProvideScience"))
|
||||
&& city.buildingUniques.contains("Jungles provide +2 science"))
|
||||
stats.science += 2f
|
||||
if (stats.gold != 0f && observingCiv.goldenAges.isGoldenAge())
|
||||
stats.gold++
|
||||
|
@ -44,6 +44,12 @@ class Building : NamedStats(), IConstruction{
|
||||
|
||||
fun getRequiredTech(): Technology = GameBasics.Technologies[requiredTech]!!
|
||||
|
||||
fun getShortDescription(): String { // should fit in one line
|
||||
var str = getStats(hashSetOf()).toString()
|
||||
if(unique!=null) str += ", "+ unique!!
|
||||
return str
|
||||
}
|
||||
|
||||
fun getStats(adoptedPolicies: HashSet<String>): Stats {
|
||||
val stats = this.clone()
|
||||
if (adoptedPolicies.contains("Organized Religion") && hashSetOf("Monument", "Temple", "Monastery").contains(name))
|
||||
@ -141,7 +147,7 @@ class Building : NamedStats(), IConstruction{
|
||||
if (requiredBuildingInAllCities != null && civInfo.cities.any { !it.cityConstructions.isBuilt(requiredBuildingInAllCities!!) })
|
||||
return false
|
||||
if (cannotBeBuiltWith != null && construction.isBuilt(cannotBeBuiltWith!!)) return false
|
||||
if ("MustBeNextToDesert" == unique && !construction.cityInfo.getCenterTile().getTilesInDistance(1).any { it.baseTerrain == "Desert" })
|
||||
if ("Must be next to desert" == unique && !construction.cityInfo.getCenterTile().getTilesInDistance(1).any { it.baseTerrain == "Desert" })
|
||||
return false
|
||||
if (requiredResource != null && !civInfo.getCivResources().containsKey(GameBasics.TileResources[requiredResource!!]))
|
||||
return false
|
||||
@ -158,8 +164,8 @@ class Building : NamedStats(), IConstruction{
|
||||
if (!containsResourceWithImprovement) return false
|
||||
}
|
||||
|
||||
if ("SpaceshipPart" == unique) {
|
||||
if (!civInfo.buildingUniques.contains("ApolloProgram")) return false
|
||||
if ("Spaceship part" == unique) {
|
||||
if (!civInfo.buildingUniques.contains("Allows the building of spaceship parts")) return false
|
||||
if (civInfo.scienceVictory.unconstructedParts()[name] == 0) return false // Don't need to build any more of these!
|
||||
}
|
||||
return true
|
||||
@ -168,7 +174,7 @@ class Building : NamedStats(), IConstruction{
|
||||
override fun postBuildEvent(construction: CityConstructions) {
|
||||
val civInfo = construction.cityInfo.civInfo
|
||||
|
||||
if (unique == "SpaceshipPart") {
|
||||
if (unique == "Spaceship part") {
|
||||
civInfo.scienceVictory.currentParts.add(name, 1)
|
||||
UnCivGame.Current.screen = VictoryScreen()
|
||||
return
|
||||
@ -178,16 +184,16 @@ class Building : NamedStats(), IConstruction{
|
||||
if (providesFreeBuilding != null && !construction.builtBuildings.contains(providesFreeBuilding!!))
|
||||
construction.builtBuildings.add(providesFreeBuilding!!)
|
||||
when (unique) {
|
||||
"ApolloProgram" ->
|
||||
"Enables construction of Spaceship parts" ->
|
||||
if(construction.cityInfo.civInfo.isPlayerCivilization())
|
||||
UnCivGame.Current.screen = VictoryScreen()
|
||||
"EmpireEntersGoldenAge" -> civInfo.goldenAges.enterGoldenAge()
|
||||
"FreeGreatArtistAppears" -> civInfo.addGreatPerson("Great Artist")
|
||||
"WorkerConstruction" -> {
|
||||
"Empire enters golden age" -> civInfo.goldenAges.enterGoldenAge()
|
||||
"Free Great Artist Appears" -> civInfo.addGreatPerson("Great Artist")
|
||||
"Worker construction increased 25%, provides 2 free workers" -> {
|
||||
civInfo.placeUnitNearTile(construction.cityInfo.location, "Worker")
|
||||
civInfo.placeUnitNearTile(construction.cityInfo.location, "Worker")
|
||||
}
|
||||
"FreeSocialPolicy" -> {
|
||||
"Free Social Policy" -> {
|
||||
civInfo.policies.freePolicies++
|
||||
if(construction.cityInfo.civInfo.isPlayerCivilization())
|
||||
UnCivGame.Current.screen = PolicyPickerScreen(civInfo)
|
||||
|
@ -1,14 +1,47 @@
|
||||
package com.unciv.models.gamebasics
|
||||
|
||||
import java.util.HashSet
|
||||
import java.util.*
|
||||
|
||||
class Technology {
|
||||
class Technology : ICivilopedia {
|
||||
override val description: String
|
||||
get(){
|
||||
val SB=StringBuilder()
|
||||
if(baseDescription!=null) SB.appendln(baseDescription)
|
||||
|
||||
val enabledUnits = GameBasics.Units.values.filter { it.requiredTech==name }
|
||||
if(enabledUnits.isNotEmpty()) SB.appendln("Units enabled: "+enabledUnits.map { it.name }.joinToString())
|
||||
|
||||
val enabledBuildings = GameBasics.Buildings.values.filter { it.requiredTech==name }
|
||||
val regularBuildings = enabledBuildings.filter { !it.isWonder }
|
||||
if(regularBuildings.isNotEmpty())
|
||||
SB.appendln("Buildings enabled: "+regularBuildings.map { it.name + " ("+it.getShortDescription()+")" }.joinToString())
|
||||
val wonders = enabledBuildings.filter { it.isWonder }
|
||||
if(wonders.isNotEmpty()) SB.appendln("Wonders enabled: "+wonders.map { it.name }.joinToString())
|
||||
|
||||
val revealedResource = GameBasics.TileResources.values.filter { it.revealedBy==name }.firstOrNull() // can only be one
|
||||
if(revealedResource!=null) SB.appendln("Reveals $revealedResource on map")
|
||||
|
||||
val tileImprovements = GameBasics.TileImprovements.values.filter { it.techRequired==name }
|
||||
if(tileImprovements.isNotEmpty()) SB.appendln("Tile improvements enabled: "+tileImprovements.map { it.name }.joinToString())
|
||||
|
||||
val improvedImprovements = GameBasics.TileImprovements.values.filter { it.improvingTech==name }.groupBy { it.improvingTechStats.toString()!! }
|
||||
improvedImprovements.forEach{
|
||||
val impimpString = it.value.joinToString { it.name } +" provide" + (if(it.value.size==1) "s" else "") +" "+it.key
|
||||
SB.appendln(impimpString)
|
||||
}
|
||||
|
||||
return SB.toString().trim()
|
||||
}
|
||||
lateinit var name: String
|
||||
|
||||
var description: String? = null
|
||||
var baseDescription: String? = null
|
||||
var cost: Int = 0
|
||||
@JvmField var prerequisites = HashSet<String>()
|
||||
var prerequisites = HashSet<String>()
|
||||
|
||||
@JvmField var column: TechColumn? = null // The column that this tech is in the tech tree
|
||||
@JvmField var row: Int = 0
|
||||
var column: TechColumn? = null // The column that this tech is in the tech tree
|
||||
var row: Int = 0
|
||||
|
||||
override fun toString(): String {
|
||||
return name
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@ class TileImprovement : NamedStats(), ICivilopedia {
|
||||
private val turnsToBuild: Int = 0 // This is the base cost.
|
||||
fun getTurnsToBuild(civInfo: CivilizationInfo): Int {
|
||||
var realTurnsToBuild = turnsToBuild.toFloat()
|
||||
if (civInfo.buildingUniques.contains("WorkerConstruction"))
|
||||
if (civInfo.buildingUniques.contains("Worker construction increased 25%, provides 2 free workers"))
|
||||
realTurnsToBuild *= 0.75f
|
||||
if (civInfo.policies.isAdopted("Citizenship"))
|
||||
realTurnsToBuild *= 0.75f
|
||||
|
@ -39,6 +39,7 @@ class CivilopediaScreen : CameraStageBaseScreen() {
|
||||
map["Terrains"] = GameBasics.Terrains.values
|
||||
map["Tile Improvements"] = GameBasics.TileImprovements.values
|
||||
map["Units"] = GameBasics.Units.values
|
||||
map["Technologies"] = GameBasics.Technologies.values
|
||||
|
||||
val nameList = List<ICivilopedia>(CameraStageBaseScreen.skin)
|
||||
|
||||
|
@ -55,7 +55,7 @@ class VictoryScreen : PickerScreen() {
|
||||
fun scienceVictoryColumn():Table{
|
||||
val t = Table()
|
||||
t.defaults().pad(5f)
|
||||
t.add(getMilestone("Built Apollo Program",civInfo.buildingUniques.contains("ApolloProgram"))).row()
|
||||
t.add(getMilestone("Built Apollo Program",civInfo.buildingUniques.contains("Allows the building of spaceship parts"))).row()
|
||||
|
||||
val scienceVictory = civInfo.scienceVictory
|
||||
|
||||
|
Reference in New Issue
Block a user