RIP PolicyManager.PolicyEffects
This commit is contained in:
parent
97916e15a1
commit
1fb566ec30
6 changed files with 5 additions and 13 deletions
|
@ -22,7 +22,7 @@
|
|||
{
|
||||
"name": "Oligarchy",
|
||||
"effect": "Units in cities cost no Maintenance, garrisoned city +50% attacking strength",
|
||||
"uniques": ["Units in cities cost no Maintenance"]
|
||||
"uniques": ["Units in cities cost no Maintenance", "+50% attacking strength for cities with garrisoned units"]
|
||||
"row": 1,
|
||||
"column": 5
|
||||
},
|
||||
|
|
|
@ -112,7 +112,6 @@ object BattleDamage {
|
|||
|
||||
fun getAttackModifiers(attacker: ICombatant, tileToAttackFrom:TileInfo?, defender: ICombatant): HashMap<String, Float> {
|
||||
val modifiers = getGeneralModifiers(attacker, defender)
|
||||
val policies = attacker.getCivInfo().policies
|
||||
|
||||
if (attacker is MapUnitCombatant) {
|
||||
modifiers.putAll(getTileSpecificModifiers(attacker, defender.getTile()))
|
||||
|
@ -147,14 +146,14 @@ object BattleDamage {
|
|||
}
|
||||
}
|
||||
|
||||
if (policies.autocracyCompletedTurns > 0 && policies.hasEffect("+20% attack bonus to all Military Units for 30 turns"))
|
||||
if (attacker.getCivInfo().policies.autocracyCompletedTurns > 0)
|
||||
modifiers["Autocracy Complete"] = 0.2f
|
||||
|
||||
if (defender is CityCombatant &&
|
||||
attacker.getCivInfo().hasUnique("+15% Combat Strength for all units when attacking Cities"))
|
||||
modifiers["Statue of Zeus"] = 0.15f
|
||||
} else if (attacker is CityCombatant) {
|
||||
if (policies.hasEffect("Units in cities cost no Maintenance, garrisoned city +50% attacking strength")
|
||||
if (attacker.getCivInfo().hasUnique("+50% attacking strength for cities with garrisoned units")
|
||||
&& attacker.city.getCenterTile().militaryUnit != null)
|
||||
modifiers["Oligarchy"] = 0.5f
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ class CityStats {
|
|||
var happinessFromPolicies = 0f
|
||||
if (civInfo.hasUnique("+1 happiness for every 10 citizens in a city"))
|
||||
happinessFromPolicies += (cityInfo.population.population / 10).toFloat()
|
||||
if (civInfo.policies.hasEffect("+1 gold and -1 unhappiness for every 2 citizens in capital")
|
||||
if (civInfo.hasUnique("+1 gold and -1 unhappiness for every 2 citizens in capital")
|
||||
&& cityInfo.isCapital())
|
||||
happinessFromPolicies += (cityInfo.population.population / 2).toFloat()
|
||||
if (civInfo.hasUnique("+1 happiness for every city connected to capital")
|
||||
|
|
|
@ -63,7 +63,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.hasEffect("Maintenance on roads & railroads reduced by 33%, +2 gold from all trade routes"))
|
||||
if (civInfo.hasUnique("Maintenance on roads & railroads reduced by 33%, +2 gold from all trade routes"))
|
||||
transportationUpkeep = (transportationUpkeep * 2 / 3f).toInt()
|
||||
return transportationUpkeep
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@ import com.unciv.Constants
|
|||
import com.unciv.models.ruleset.Policy
|
||||
import com.unciv.models.ruleset.UniqueMap
|
||||
import com.unciv.models.ruleset.VictoryType
|
||||
import com.unciv.models.translations.getPlaceholderParameters
|
||||
import com.unciv.models.translations.getPlaceholderText
|
||||
import kotlin.math.min
|
||||
import kotlin.math.pow
|
||||
import kotlin.math.roundToInt
|
||||
|
@ -16,7 +14,6 @@ class PolicyManager {
|
|||
@Transient lateinit var civInfo: CivilizationInfo
|
||||
// Needs to be separate from the actual adopted policies, so that
|
||||
// in different game versions, policies can have different effects
|
||||
@Transient internal val policyEffects = HashSet<String>()
|
||||
@Transient internal val policyUniques = UniqueMap()
|
||||
|
||||
var freePolicies = 0
|
||||
|
@ -48,7 +45,6 @@ class PolicyManager {
|
|||
}
|
||||
|
||||
fun addPolicyToTransients(policy: Policy){
|
||||
policyEffects.addAll(policy.uniques)
|
||||
for(unique in policy.uniqueObjects)
|
||||
policyUniques.addUnique(unique)
|
||||
}
|
||||
|
@ -90,8 +86,6 @@ class PolicyManager {
|
|||
|
||||
fun isAdopted(policyName: String): Boolean = adoptedPolicies.contains(policyName)
|
||||
|
||||
fun hasEffect(effectName:String) = policyEffects.contains(effectName)
|
||||
|
||||
fun isAdoptable(policy: Policy): Boolean {
|
||||
if(isAdopted(policy.name)) return false
|
||||
if (policy.name.endsWith("Complete")) return false
|
||||
|
|
|
@ -6,7 +6,6 @@ open class Policy : INamed {
|
|||
lateinit var branch: PolicyBranch // not in json - added in gameBasics
|
||||
|
||||
override lateinit var name: String
|
||||
lateinit var effect: String
|
||||
var uniques: ArrayList<String> = ArrayList()
|
||||
val uniqueObjects:List<Unique> by lazy { uniques.map { Unique(it) } }
|
||||
var row: Int = 0
|
||||
|
|
Loading…
Reference in a new issue