More isAdopted to hasEffect conversions
This commit is contained in:
parent
d031b2855b
commit
381f61a441
3 changed files with 34 additions and 29 deletions
|
@ -67,11 +67,12 @@ object BattleDamage {
|
|||
if (civHappiness < 0)
|
||||
modifiers["Unhappiness"] = max(0.02f * civHappiness, -0.9f) // otherwise it could exceed -100% and start healing enemy units...
|
||||
|
||||
if (civInfo.policies.isAdopted("Populism") && combatant.getHealth() < 100) {
|
||||
if (civInfo.policies.hasEffect("Wounded military units deal +25% damage") && combatant.getHealth() < 100) {
|
||||
modifiers["Populism"] = 0.25f
|
||||
}
|
||||
|
||||
if (civInfo.policies.isAdopted("Discipline") && combatant.isMelee()
|
||||
if (civInfo.policies.hasEffect("+15% combat strength for melee units which have another military unit in an adjacent tile")
|
||||
&& combatant.isMelee()
|
||||
&& combatant.getTile().neighbors.flatMap { it.getUnits() }
|
||||
.any { it.civInfo == civInfo && !it.type.isCivilian() && !it.type.isAirUnit() })
|
||||
modifiers["Discipline"] = 0.15f
|
||||
|
@ -102,7 +103,7 @@ object BattleDamage {
|
|||
|
||||
if (enemy.getCivInfo().isBarbarian()) {
|
||||
modifiers["Difficulty"] = civInfo.gameInfo.getDifficulty().barbarianBonus
|
||||
if (civInfo.policies.isAdopted("Honor"))
|
||||
if (civInfo.policies.hasEffect("+25% bonus vs Barbarians; gain Culture when you kill a barbarian unit"))
|
||||
modifiers["vs Barbarians"] = 0.25f
|
||||
}
|
||||
|
||||
|
@ -138,7 +139,7 @@ object BattleDamage {
|
|||
modifiers["Flanking"] = 0.1f * (numberOfAttackersSurroundingDefender-1) //https://www.carlsguides.com/strategy/civilization5/war/combatbonuses.php
|
||||
}
|
||||
|
||||
if (policies.isAdopted("Autocracy Complete") && (policies.autocracyCompletedTurns > 0))
|
||||
if (policies.autocracyCompletedTurns > 0 && policies.hasEffect("+20% attack bonus to all Military Units for 30 turns"))
|
||||
modifiers["Autocracy Complete"] = 0.2f
|
||||
|
||||
if (defender is CityCombatant &&
|
||||
|
@ -147,7 +148,8 @@ object BattleDamage {
|
|||
}
|
||||
|
||||
else if (attacker is CityCombatant) {
|
||||
if (policies.isAdopted("Oligarchy") && attacker.city.getCenterTile().militaryUnit != null)
|
||||
if (policies.hasEffect("Units in cities cost no Maintenance, garrisoned city +50% attacking strength")
|
||||
&& attacker.city.getCenterTile().militaryUnit != null)
|
||||
modifiers["Oligarchy"] = 0.5f
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,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.nation.unique == UniqueAbility.TRADE_CARAVANS) goldFromTradeRoute += 1
|
||||
if (civInfo.policies.isAdopted("Trade Unions")) goldFromTradeRoute += 2
|
||||
if (civInfo.policies.hasEffect("Maintenance on roads & railroads reduced by 33%, +2 gold from all trade routes")) goldFromTradeRoute += 2
|
||||
if (civInfo.containsBuildingUnique("Gold from all trade routes +25%")) goldFromTradeRoute *= 1.25 // Machu Pichu speciality
|
||||
stats.gold += goldFromTradeRoute.toFloat()
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class CityStats {
|
|||
"Gold" -> stats.gold += production / 4
|
||||
"Science" -> {
|
||||
var scienceProduced = production / 4
|
||||
if (cityInfo.civInfo.policies.isAdopted("Rationalism")) scienceProduced *= 1.33f
|
||||
if (cityInfo.civInfo.policies.hasEffect("Production to science conversion in cities increased by 33%")) scienceProduced *= 1.33f
|
||||
stats.science += scienceProduced
|
||||
}
|
||||
}
|
||||
|
@ -162,9 +162,9 @@ class CityStats {
|
|||
|
||||
fun getGrowthBonusFromPolicies(): Float {
|
||||
var bonus = 0f
|
||||
if (cityInfo.civInfo.policies.isAdopted("Landed Elite") && cityInfo.isCapital())
|
||||
if (cityInfo.civInfo.policies.hasEffect("+10% food growth and +2 food in capital") && cityInfo.isCapital())
|
||||
bonus += 0.1f
|
||||
if (cityInfo.civInfo.policies.isAdopted("Tradition Complete"))
|
||||
if (cityInfo.civInfo.policies.hasEffect("+15% growth and +2 food in all cities"))
|
||||
bonus += 0.15f
|
||||
return bonus
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ class CityStats {
|
|||
newHappinessList["Cities"] = unhappinessFromCity * unhappinessModifier
|
||||
|
||||
var unhappinessFromCitizens = cityInfo.population.population.toFloat()
|
||||
if (civInfo.policies.isAdopted("Democracy"))
|
||||
if (civInfo.policies.hasEffect("Specialists produce half normal unhappiness"))
|
||||
unhappinessFromCitizens -= cityInfo.population.getNumberOfSpecialists() * 0.5f
|
||||
|
||||
if (cityInfo.isPuppet)
|
||||
|
@ -195,7 +195,7 @@ class CityStats {
|
|||
unhappinessFromCitizens *= 2f
|
||||
if (civInfo.containsBuildingUnique("Unhappiness from population decreased by 10%"))
|
||||
unhappinessFromCitizens *= 0.9f
|
||||
if (civInfo.policies.isAdopted("Meritocracy"))
|
||||
if (civInfo.policies.hasEffect("+1 happiness for every city connected to capital, -5% unhappiness from citizens"))
|
||||
unhappinessFromCitizens *= 0.95f
|
||||
if (civInfo.nation.unique == UniqueAbility.POPULATION_GROWTH)
|
||||
unhappinessFromCitizens *= 0.5f //halved for the Indian
|
||||
|
@ -203,13 +203,16 @@ class CityStats {
|
|||
newHappinessList["Population"] = -unhappinessFromCitizens * unhappinessModifier
|
||||
|
||||
var happinessFromPolicies = 0f
|
||||
if (civInfo.policies.isAdopted("Aristocracy"))
|
||||
if (civInfo.policies.hasEffect("+15% production when constructing wonders, +1 happiness for every 10 citizens in a city"))
|
||||
happinessFromPolicies += (cityInfo.population.population / 10).toFloat()
|
||||
if (civInfo.policies.isAdopted("Monarchy") && cityInfo.isCapital())
|
||||
if (civInfo.policies.hasEffect("+1 gold and -1 unhappiness for every 2 citizens in capital")
|
||||
&& cityInfo.isCapital())
|
||||
happinessFromPolicies += (cityInfo.population.population / 2).toFloat()
|
||||
if (civInfo.policies.isAdopted("Meritocracy") && cityInfo.isConnectedToCapital())
|
||||
if (civInfo.policies.hasEffect("+1 happiness for every city connected to capital, -5% unhappiness from citizens")
|
||||
&& cityInfo.isConnectedToCapital())
|
||||
happinessFromPolicies += 1f
|
||||
if (civInfo.policies.isAdopted("Military Caste") && cityInfo.getCenterTile().militaryUnit != null)
|
||||
if (civInfo.policies.hasEffect("Each city with a garrison increases happiness by 1 and culture by 2"
|
||||
) && cityInfo.getCenterTile().militaryUnit != null)
|
||||
happinessFromPolicies += 1
|
||||
|
||||
newHappinessList["Policies"] = happinessFromPolicies
|
||||
|
@ -257,23 +260,23 @@ class CityStats {
|
|||
|
||||
private fun getStatsFromPolicies(adoptedPolicies: PolicyManager): Stats {
|
||||
val stats = Stats()
|
||||
if (adoptedPolicies.isAdopted("Tradition") && cityInfo.isCapital())
|
||||
if (adoptedPolicies.hasEffect("+3 culture in capital and increased rate of border expansion") && cityInfo.isCapital())
|
||||
stats.culture += 3f
|
||||
if (adoptedPolicies.isAdopted("Landed Elite") && cityInfo.isCapital())
|
||||
if (adoptedPolicies.hasEffect("+10% food growth and +2 food in capital") && cityInfo.isCapital())
|
||||
stats.food += 2f
|
||||
if (adoptedPolicies.isAdopted("Tradition Complete"))
|
||||
if (adoptedPolicies.hasEffect("+15% growth and +2 food in all cities"))
|
||||
stats.food += 2f
|
||||
if (adoptedPolicies.isAdopted("Monarchy") && cityInfo.isCapital())
|
||||
if (adoptedPolicies.hasEffect("+1 gold and -1 unhappiness for every 2 citizens in capital") && cityInfo.isCapital())
|
||||
stats.gold += (cityInfo.population.population / 2).toFloat()
|
||||
if (adoptedPolicies.hasEffect("+1 culture in every city"))
|
||||
stats.culture += 1f
|
||||
if (adoptedPolicies.isAdopted("Republic"))
|
||||
if (adoptedPolicies.hasEffect("+1 production in every city, +5% production when constructing buildings"))
|
||||
stats.production += 1f
|
||||
if (adoptedPolicies.isAdopted("Military Caste") && cityInfo.getCenterTile().militaryUnit != null)
|
||||
if (adoptedPolicies.hasEffect("Each city with a garrison increases happiness by 1 and culture by 2") && cityInfo.getCenterTile().militaryUnit != null)
|
||||
stats.culture += 2
|
||||
if (adoptedPolicies.isAdopted("Universal Suffrage"))
|
||||
if (adoptedPolicies.hasEffect("+1 production per 5 population"))
|
||||
stats.production += (cityInfo.population.population / 5).toFloat()
|
||||
if (adoptedPolicies.isAdopted("Free Speech"))
|
||||
if (adoptedPolicies.hasEffect("+1 culture for every 2 citizens"))
|
||||
stats.culture += (cityInfo.population.population / 2).toFloat()
|
||||
|
||||
return stats
|
||||
|
@ -488,7 +491,7 @@ class CityStats {
|
|||
|
||||
private fun updateFoodEaten() {
|
||||
foodEaten = (cityInfo.population.population * 2).toFloat()
|
||||
if (cityInfo.civInfo.policies.isAdopted("Civil Society"))
|
||||
if (cityInfo.civInfo.policies.hasEffect("Specialists produce half normal unhappiness"))
|
||||
foodEaten -= cityInfo.population.getNumberOfSpecialists()
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class CivInfoStats(val civInfo: CivilizationInfo){
|
|||
val baseUnitCost = 0.5f
|
||||
val freeUnits = 3
|
||||
var unitsToPayFor = civInfo.getCivUnits()
|
||||
if(civInfo.policies.isAdopted("Oligarchy"))
|
||||
if(civInfo.policies.hasEffect("Units in cities cost no Maintenance, garrisoned city +50% attacking strength"))
|
||||
// Only land military units can truly "garrison"
|
||||
unitsToPayFor = unitsToPayFor.filterNot {
|
||||
it.getTile().isCityCenter()
|
||||
|
@ -39,7 +39,7 @@ class CivInfoStats(val civInfo: CivilizationInfo){
|
|||
cost = cost.pow(1+gameProgress/3) // Why 3? To spread 1 to 1.33
|
||||
if(!civInfo.isPlayerCivilization())
|
||||
cost *= civInfo.gameInfo.getDifficulty().aiUnitMaintenanceModifier
|
||||
if(civInfo.policies.isAdopted("Autocracy")) cost *= 0.66f
|
||||
if(civInfo.policies.hasEffect("-33% unit upkeep costs")) cost *= 0.66f
|
||||
return cost.toInt()
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ class CivInfoStats(val civInfo: CivilizationInfo){
|
|||
// Inca unique according to https://civilization.fandom.com/wiki/Incan_%28Civ5%29
|
||||
if (civInfo.nation.greatAndeanRoad)
|
||||
transportationUpkeep = (transportationUpkeep - hillsUpkeep) / 2
|
||||
if (civInfo.policies.isAdopted("Trade Unions"))
|
||||
if (civInfo.policies.hasEffect("Maintenance on roads & railroads reduced by 33%, +2 gold from all trade routes"))
|
||||
transportationUpkeep = (transportationUpkeep * 2 / 3f).toInt()
|
||||
return transportationUpkeep
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ class CivInfoStats(val civInfo: CivilizationInfo){
|
|||
statMap["Transportation upkeep"] = Stats().apply { gold=- getTransportationUpkeep().toFloat()}
|
||||
statMap["Unit upkeep"] = Stats().apply { gold=- getUnitUpkeep().toFloat()}
|
||||
|
||||
if (civInfo.policies.isAdopted("Mandate Of Heaven")) {
|
||||
if (civInfo.policies.hasEffect("50% of excess happiness added to culture towards policies")) {
|
||||
val happiness = statMap.values.map { it.happiness }.sum()
|
||||
if(happiness>0) statMap.add("Policies", Stats().apply { culture=happiness/2 })
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ class CivInfoStats(val civInfo: CivilizationInfo){
|
|||
|
||||
// TODO - happinessPerUnique should be difficulty-dependent, 5 on Settler and Chieftian and 4 on other difficulties (should be parameter, not in code)
|
||||
var happinessPerUniqueLuxury = 4f + civInfo.getDifficulty().extraHappinessPerLuxury
|
||||
if (civInfo.policies.isAdopted("Protectionism")) happinessPerUniqueLuxury += 1
|
||||
if (civInfo.policies.hasEffect("+1 happiness from each luxury resource")) happinessPerUniqueLuxury += 1
|
||||
statMap["Luxury resources"]= civInfo.getCivResources().map { it.resource }
|
||||
.count { it.resourceType === ResourceType.Luxury } * happinessPerUniqueLuxury
|
||||
|
||||
|
|
Loading…
Reference in a new issue