Add Moddable Policy Priorities (#6390)

* Fixed G&K policy eras

Patronage should be Medieval and Freedom should be Industrial in G&K

* Added 'priorities' object to policy branch entries

* Fixed Vanilla policy eras

Also set testing priorities in advance

* Partial code formatting

* Reworked how the AI chooses a policy to newly adopt

* Removed debugging codes

* Update Civilization-related-JSON-files.md

Added Branch priorities

* Assigned actual priorities to each branch

Also fixed a debugging value in Ruleset.kt (-1 -> 0)
This commit is contained in:
청하늘
2022-03-25 03:33:42 -11:00
committed by GitHub
parent dd529db297
commit 84561e7ad4
7 changed files with 1544 additions and 975 deletions

View File

@ -2,80 +2,128 @@
{
"name": "Tradition",
"era": "Ancient era",
"uniques": ["[+3 Culture] [in capital]", "[-25]% Culture cost of natural border growth [in all cities]"],
"priorities": {
"Neutral": 30,
"Cultural": 30,
"Diplomatic": 0,
"Domination": 0,
"Scientific": 30
},
"uniques": [
"[+3 Culture] [in capital]",
"[-25]% Culture cost of natural border growth [in all cities]"
],
"policies": [
{
"name": "Aristocracy",
"uniques": ["[+15]% Production when constructing [All] wonders [in all cities]", "[+1 Happiness] per [10] population [in all cities]"],
"uniques": [
"[+15]% Production when constructing [All] wonders [in all cities]",
"[+1 Happiness] per [10] population [in all cities]"
],
"row": 1,
"column": 1
},
{
"name": "Legalism",
"uniques":["Provides the cheapest [Culture] building in your first [4] cities for free"],
"uniques": [
"Provides the cheapest [Culture] building in your first [4] cities for free"
],
"row": 1,
"column": 3
},
{
"name": "Oligarchy",
"uniques": ["Units in cities cost no Maintenance", "[+50]% Strength for cities <with a garrison> <when attacking>"],
"uniques": [
"Units in cities cost no Maintenance",
"[+50]% Strength for cities <with a garrison> <when attacking>"
],
"row": 1,
"column": 5
},
{
"name": "Landed Elite",
"uniques": ["[+10]% growth [in capital]", "[+2 Food] [in capital]"],
"uniques": [
"[+10]% growth [in capital]",
"[+2 Food] [in capital]"
],
"requires": ["Legalism"],
"row": 2,
"column": 2
},
{
"name": "Monarchy",
"uniques": ["[+1 Gold, +1 Happiness] per [2] population [in capital]"],
"uniques": [
"[+1 Gold, +1 Happiness] per [2] population [in capital]"
],
"requires": ["Legalism"],
"row": 2,
"column": 4
},
{
"name": "Tradition Complete",
"uniques": ["[+15]% growth [in all cities]","Provides a [Aqueduct] in your first [4] cities for free"]
"uniques": [
"[+15]% growth [in all cities]",
"Provides a [Aqueduct] in your first [4] cities for free"
]
}
]
},
{
"name": "Liberty",
"era": "Ancient era",
"priorities": {
"Neutral": 30,
"Cultural": 0,
"Diplomatic": 30,
"Domination": 30,
"Scientific": 0
},
"uniques": ["[+1 Culture] [in all cities]"],
"policies": [
{
"name": "Republic",
"uniques": ["[+1 Production] [in all cities]", "[+5]% Production when constructing [All] buildings [in all cities]"],
"uniques": [
"[+1 Production] [in all cities]",
"[+5]% Production when constructing [All] buildings [in all cities]"
],
"row": 1,
"column": 1
},
{
"name": "Citizenship",
"uniques": ["[-25]% tile improvement construction time", "Free [Worker] appears"],
"uniques": [
"[-25]% tile improvement construction time",
"Free [Worker] appears"
],
"row": 1,
"column": 4
},
{
"name": "Collective Rule",
"uniques": ["[+50]% Production when constructing [Settler] units [in capital]", "Free [Settler] appears"],
"uniques": [
"[+50]% Production when constructing [Settler] units [in capital]",
"Free [Settler] appears"
],
"requires": ["Republic"],
"row": 2,
"column": 1
},
{
"name": "Representation",
"uniques": ["Each city founded increases culture cost of policies [33]% less than normal", "Empire enters golden age"],
"uniques": [
"Each city founded increases culture cost of policies [33]% less than normal",
"Empire enters golden age"
],
"requires": ["Citizenship"],
"row": 2,
"column": 3
},
{
"name": "Meritocracy",
"uniques": ["[+1 Happiness] [in all cities connected to capital]", "[-5]% Unhappiness from [Population] [in all non-occupied cities]"],
"uniques": [
"[+1 Happiness] [in all cities connected to capital]",
"[-5]% Unhappiness from [Population] [in all non-occupied cities]"
],
"requires": ["Citizenship"],
"row": 2,
"column": 5
@ -89,39 +137,62 @@
{
"name": "Honor",
"era": "Ancient era",
"uniques": ["[+33]% Strength <vs [Barbarian] units>", "Earn [100]% of killed [Barbarian] unit's [Strength] as [Culture]",
"Notified of new Barbarian encampments"],
"priorities": {
"Neutral": 0,
"Cultural": 0,
"Diplomatic": 10,
"Domination": 10,
"Scientific": 10
},
"uniques": [
"[+33]% Strength <vs [Barbarian] units>",
"Earn [100]% of killed [Barbarian] unit's [Strength] as [Culture]",
"Notified of new Barbarian encampments"
],
"policies": [
{
"name": "Warrior Code",
"uniques":["[+15]% Production when constructing [Melee] units [in all cities]", "Free [Great General] appears"],
"uniques": [
"[+15]% Production when constructing [Melee] units [in all cities]",
"Free [Great General] appears"
],
"row": 1,
"column": 2
},
{
"name": "Discipline",
"uniques":["[+15]% Strength <for [Melee] units> <when adjacent to a [Melee] unit>"],
"uniques": [
"[+15]% Strength <for [Melee] units> <when adjacent to a [Melee] unit>"
],
"row": 1,
"column": 4
},
{
"name": "Military Tradition",
"uniques":["[+50]% XP gained from combat <for [Military] units>"],
"uniques": [
"[+50]% XP gained from combat <for [Military] units>"
],
"requires": ["Warrior Code"],
"row": 2,
"column": 2
},
{
"name": "Military Caste",
"uniques": ["[+1 Happiness, +2 Culture] [in all cities with a garrison]"],
"uniques": [
"[+1 Happiness, +2 Culture] [in all cities with a garrison]"
],
"requires": ["Discipline"],
"row": 2,
"column": 4
},
{
"name": "Professional Army",
"uniques": ["[-33]% Gold cost of upgrading <for [Military] units>", "[+1 Happiness] from every [Walls]",
"[+1 Happiness] from every [Castle]", "[+1 Happiness] from every [Arsenal]", "[+1 Happiness] from every [Military Base]"
"uniques": [
"[-33]% Gold cost of upgrading <for [Military] units>",
"[+1 Happiness] from every [Walls]",
"[+1 Happiness] from every [Castle]",
"[+1 Happiness] from every [Arsenal]",
"[+1 Happiness] from every [Military Base]"
],
"requires": ["Military Caste"],
"row": 3,
@ -129,18 +200,34 @@
},
{
"name": "Honor Complete",
"uniques": ["Earn [10]% of killed [Military] unit's [Cost] as [Gold]"]
"uniques": [
"Earn [10]% of killed [Military] unit's [Cost] as [Gold]"
]
}
]
},{
},
{
"name": "Piety",
"era": "Classical era",
"uniques": ["[+100]% Production when constructing [Shrine] buildings [in all cities]", "[+100]% Production when constructing [Temple] buildings [in all cities]",
"Only available <before adopting [Rationalism]>"],
"priorities": {
"Neutral": 0,
"Cultural": 10,
"Diplomatic": 10,
"Domination": 10,
"Scientific": 0
},
"uniques": [
"[+100]% Production when constructing [Shrine] buildings [in all cities]",
"[+100]% Production when constructing [Temple] buildings [in all cities]",
"Only available <before adopting [Rationalism]>"
],
"policies": [
{
"name": "Organized Religion",
"uniques": ["[+1 Faith] from every [Shrine]","[+1 Faith] from every [Temple]"],
"uniques": [
"[+1 Faith] from every [Shrine]",
"[+1 Faith] from every [Temple]"
],
"row": 1,
"column": 2
},
@ -159,7 +246,10 @@
},
{
"name": "Reformation",
"uniques": ["[+33]% [Culture] [in all cities with a world wonder]", "Empire enters golden age"],
"uniques": [
"[+33]% [Culture] [in all cities with a world wonder]",
"Empire enters golden age"
],
"requires": ["Organized Religion"],
"row": 2,
"column": 3
@ -173,65 +263,97 @@
},
{
"name": "Piety Complete",
"uniques": ["[Faith] cost of purchasing items in cities [-20]% ", "[+3 Gold, +3 Culture] from every [Holy site]"]
"uniques": [
"[Faith] cost of purchasing items in cities [-20]% ",
"[+3 Gold, +3 Culture] from every [Holy site]"
]
}
]
},
{
"name": "Patronage",
"era": "Classical era",
"era": "Medieval era",
"priorities": {
"Neutral": 0,
"Cultural": 10,
"Diplomatic": 20,
"Domination": 0,
"Scientific": 10
},
"uniques": ["[-25]% City-State Influence degradation"],
"policies": [
{
"name": "Philantropy",
"uniques":["Gifts of Gold to City-States generate [25]% more Influence"],
"uniques": [
"Gifts of Gold to City-States generate [25]% more Influence"
],
"row": 1,
"column": 2
},
{
"name": "Aesthetics",
"uniques":["Resting point for Influence with City-States is increased by [20]"],
"uniques": [
"Resting point for Influence with City-States is increased by [20]"
],
"row": 1,
"column": 4
},
{
"name": "Scholasticism",
"uniques":["Allied City-States provide [Science] equal to [25]% of what they produce for themselves"],
"uniques": [
"Allied City-States provide [Science] equal to [25]% of what they produce for themselves"
],
"requires": ["Philantropy"],
"row": 2,
"column": 2
},
{
"name": "Cultural Diplomacy",
"uniques": ["[+100]% resources gifted by City-States",
"[+50]% Happiness from luxury resources gifted by City-States"],
"uniques": [
"[+100]% resources gifted by City-States",
"[+50]% Happiness from luxury resources gifted by City-States"
],
"requires": ["Scholasticism"],
"row": 3,
"column": 2
},
{
"name": "Educated Elite",
"requires": ["Scholasticism","Aesthetics"],
"uniques": ["Allied City-States will occasionally gift Great People"],
"requires": ["Scholasticism", "Aesthetics"],
"uniques": [
"Allied City-States will occasionally gift Great People"
],
"row": 3,
"column": 4
},
{
"name": "Patronage Complete",
"uniques": ["Influence of all other civilizations with all city-states degrades [33]% faster",
"Triggers the following global alert: [Our influence with City-States has started dropping faster!]"]
"uniques": [
"Influence of all other civilizations with all city-states degrades [33]% faster",
"Triggers the following global alert: [Our influence with City-States has started dropping faster!]"
]
}
]
},
{
"name": "Commerce",
"uniques": ["[+25]% [Gold] [in capital]"],
"era": "Medieval era",
"priorities": {
"Neutral": 0,
"Cultural": 10,
"Diplomatic": 10,
"Domination": 10,
"Scientific": 10
},
"uniques": ["[+25]% [Gold] [in capital]"],
"policies": [
{
"name": "Naval Tradition",
"uniques": ["[+1] Movement <for [{Military} {Water}] units>", "[+1] Sight <for [{Military} {Water}] units>",
"Free [Great General] appears" //, "[+2] Movement <for [Great Admiral] units>"
"uniques": [
"[+1] Movement <for [{Military} {Water}] units>",
"[+1] Sight <for [{Military} {Water}] units>",
"Free [Great General] appears"
// "[+2] Movement <for [Great Admiral] units>"
// ToDo: Should be "Free [Great Admiral] appears"
],
"row": 1,
@ -239,7 +361,11 @@
},
{
"name": "Trade Unions",
"uniques": ["[-33]% maintenance on road & railroads", "[+1 Gold] from every [Harbor]", "[+1 Gold] from every [Seaport]"],
"uniques": [
"[-33]% maintenance on road & railroads",
"[+1 Gold] from every [Harbor]",
"[+1 Gold] from every [Seaport]"
],
"row": 1,
"column": 4
},
@ -252,8 +378,13 @@
},
{
"name": "Mercantilism",
"uniques": ["[Gold] cost of purchasing items in cities [-25]%", "[+1 Science] from every [Mint]", "[+1 Science] from every [Market]",
"[+1 Science] from every [Bank]", "[+1 Science] from every [Stock Exchange]"],
"uniques": [
"[Gold] cost of purchasing items in cities [-25]%",
"[+1 Science] from every [Mint]",
"[+1 Science] from every [Market]",
"[+1 Science] from every [Bank]",
"[+1 Science] from every [Stock Exchange]"
],
"requires": ["Trade Unions"],
"row": 2,
"column": 4
@ -267,7 +398,9 @@
},
{
"name": "Commerce Complete",
"uniques": ["[+1 Gold] from every [Trading post]", "[+100]% Gold from Great Merchant trade missions",
"uniques": [
"[+1 Gold] from every [Trading post]",
"[+100]% Gold from Great Merchant trade missions",
"May buy [Great Merchant] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>"
]
}
@ -276,24 +409,42 @@
{
"name": "Rationalism",
"era": "Renaissance era",
"uniques": ["[+15]% [Science] <while the empire is happy>", "Only available <before adopting [Piety]>"],
"priorities": {
"Neutral": 0,
"Cultural": 10,
"Diplomatic": 10,
"Domination": 10,
"Scientific": 20
},
"uniques": [
"[+15]% [Science] <while the empire is happy>",
"Only available <before adopting [Piety]>"
],
"policies": [
{
"name": "Secularism",
"uniques": ["[+2 Science] from every specialist [in all cities]"],
"uniques": [
"[+2 Science] from every specialist [in all cities]"
],
"row": 1,
"column": 2
},
{
"name": "Humanism",
"uniques": ["[+1 Happiness] from every [University]","[+1 Happiness] from every [Observatory]",
"[+1 Happiness] from every [Public School]"],
"uniques": [
"[+1 Happiness] from every [University]",
"[+1 Happiness] from every [Observatory]",
"[+1 Happiness] from every [Public School]"
],
"row": 1,
"column": 5
},
{
"name": "Free Thought",
"uniques": ["[+1 Science] from every [Trading post]", "[+17]% [Science] from every [University]"],
"uniques": [
"[+1 Science] from every [Trading post]",
"[+17]% [Science] from every [University]"
],
"requires": ["Secularism"],
"row": 2,
"column": 1
@ -314,7 +465,8 @@
},
{
"name": "Rationalism Complete",
"uniques": ["[2] Free Technologies",
"uniques": [
"[2] Free Technologies",
"May buy [Great Scientist] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>"
]
}
@ -322,8 +474,19 @@
},
{
"name": "Freedom",
"era": "Renaissance era",
"uniques": ["[+25]% Great Person generation [in all cities]", "Only available <before adopting [Autocracy]>", "Only available <before adopting [Order]>"],
"era": "Industrial era",
"priorities": {
"Neutral": 50,
"Cultural": 50,
"Diplomatic": 50,
"Domination": 40,
"Scientific": 50
},
"uniques": [
"[+25]% Great Person generation [in all cities]",
"Only available <before adopting [Autocracy]>",
"Only available <before adopting [Order]>"
],
"policies": [
{
"name": "Constitution",
@ -339,7 +502,9 @@
},
{
"name": "Civil Society",
"uniques": ["[-50]% Food consumption by specialists [in all cities]"],
"uniques": [
"[-50]% Food consumption by specialists [in all cities]"
],
"row": 1,
"column": 5
},
@ -352,14 +517,18 @@
},
{
"name": "Democracy",
"uniques": ["[-50]% Unhappiness from [Specialists] [in all cities]"],
"uniques": [
"[-50]% Unhappiness from [Specialists] [in all cities]"
],
"requires": ["Civil Society"],
"row": 2,
"column": 5
},
{
"name": "Freedom Complete",
"uniques": ["[+100]% Yield from every [Great Improvement]", "[+50]% Golden Age length",
"uniques": [
"[+100]% Yield from every [Great Improvement]",
"[+50]% Golden Age length",
"May buy [Great Artist] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>"
]
}
@ -368,8 +537,19 @@
{
"name": "Autocracy",
"era": "Industrial era",
"uniques": ["[-33]% maintenance costs <for [All] units>", "Upon capturing a city, receive [10] times its [Culture] production as [Culture] immediately",
"Only available <before adopting [Order]>", "Only available <before adopting [Freedom]>"],
"priorities": {
"Neutral": 50,
"Cultural": 40,
"Diplomatic": 40,
"Domination": 50,
"Scientific": 40
},
"uniques": [
"[-33]% maintenance costs <for [All] units>",
"Upon capturing a city, receive [10] times its [Culture] production as [Culture] immediately",
"Only available <before adopting [Order]>",
"Only available <before adopting [Freedom]>"
],
"policies": [
{
"name": "Populism",
@ -385,14 +565,20 @@
},
{
"name": "Fascism",
"uniques": ["Quantity of strategic resources produced by the empire +[100]%", "[+2] Movement <for [Great General] units>"],
"requires": ["Populism","Militarism"],
"uniques": [
"Quantity of strategic resources produced by the empire +[100]%",
"[+2] Movement <for [Great General] units>"
],
"requires": ["Populism", "Militarism"],
"row": 2,
"column": 3
},
{
"name": "Police State",
"uniques": ["[+3 Happiness] from every [Courthouse]", "[+100]% Production when constructing [Courthouse] buildings [in all cities]"],
"uniques": [
"[+3 Happiness] from every [Courthouse]",
"[+100]% Production when constructing [Courthouse] buildings [in all cities]"
],
// There are also some uniques regarding espoinage, which as of this writing is not yet implemented
"requires": ["Militarism"],
"row": 2,
@ -400,8 +586,11 @@
},
{
"name": "Total War",
"uniques": ["[+25]% Production when constructing [Military] units [in all cities]", "New [Military] units start with [15] Experience [in all cities]"],
"requires": ["Police State","Fascism"],
"uniques": [
"[+25]% Production when constructing [Military] units [in all cities]",
"New [Military] units start with [15] Experience [in all cities]"
],
"requires": ["Police State", "Fascism"],
"row": 3,
"column": 4
},
@ -418,46 +607,71 @@
{
"name": "Order",
"era": "Industrial era",
"uniques": ["[+1 Happiness] [in all cities]", "Only available <before adopting [Autocracy]>", "Only available <before adopting [Freedom]>"],
"priorities": {
"Neutral": 50,
"Cultural": 40,
"Diplomatic": 50,
"Domination": 40,
"Scientific": 50
},
"uniques": [
"[+1 Happiness] [in all cities]",
"Only available <before adopting [Autocracy]>",
"Only available <before adopting [Freedom]>"
],
"policies": [
{
"name": "United Front",
"uniques": ["Militaristic City-States grant units [2] times as fast when you are at war with a common nation"],
"uniques": [
"Militaristic City-States grant units [2] times as fast when you are at war with a common nation"
],
"row": 1,
"column": 1
},
{
"name": "Planned Economy",
"uniques": ["[+25]% [Science] from every [Factory]", "[+100]% Production when constructing [Factory] buildings [in all cities]"],
"uniques": [
"[+25]% [Science] from every [Factory]",
"[+100]% Production when constructing [Factory] buildings [in all cities]"
],
"row": 1,
"column": 3
},
{
"name": "Nationalism",
"uniques": ["[+15]% Strength <for [All] units> <when fighting in [Friendly Land] tiles>"],
"uniques": [
"[+15]% Strength <for [All] units> <when fighting in [Friendly Land] tiles>"
],
"row": 1,
"column": 5
},
{
"name": "Socialism",
"requires": ["Planned Economy"],
"uniques": ["[-15]% maintenance cost for buildings [in all cities]"],
"uniques": [
"[-15]% maintenance cost for buildings [in all cities]"
],
"row": 2,
"column": 3
},
{
"name": "Communism",
"requires": ["Socialism"],
"uniques": ["[+2 Production] [in all cities]", "[+1 Production] from every [Mine]", "[+1 Production] from every [Quarry]"],
"uniques": [
"[+2 Production] [in all cities]",
"[+1 Production] from every [Mine]",
"[+1 Production] from every [Quarry]"
],
"row": 3,
"column": 3
},
{
"name": "Order Complete",
"uniques": ["[+2 Food, +2 Production, +2 Science, +2 Gold, +2 Culture] [in all cities]",
"uniques": [
"[+2 Food, +2 Production, +2 Science, +2 Gold, +2 Culture] [in all cities]",
"May buy [Great Engineer] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>"
]
}
]
}
}
]

View File

@ -2,81 +2,128 @@
{
"name": "Tradition",
"era": "Ancient era",
"uniques": ["[+3 Culture] [in capital]", "[-25]% Culture cost of natural border growth [in all cities]"],
"priorities": {
"Neutral": 40,
"Cultural": 40,
"Diplomatic": 0,
"Domination": 0,
"Scientific": 40
},
"uniques": [
"[+3 Culture] [in capital]",
"[-25]% Culture cost of natural border growth [in all cities]"
],
"policies": [
{
"name": "Aristocracy",
"uniques": ["[+15]% Production when constructing [All] wonders [in all cities]", "[+1 Happiness] per [10] population [in all cities]"],
"uniques": [
"[+15]% Production when constructing [All] wonders [in all cities]",
"[+1 Happiness] per [10] population [in all cities]"
],
"row": 1,
"column": 1
},
{
"name": "Legalism",
"uniques":["Provides the cheapest [Culture] building in your first [4] cities for free"],
"uniques": [
"Provides the cheapest [Culture] building in your first [4] cities for free"
],
"row": 1,
"column": 3
},
{
"name": "Oligarchy",
"uniques": ["Units in cities cost no Maintenance", "[+100]% Strength for cities <with a garrison> <when attacking>"],
"uniques": [
"Units in cities cost no Maintenance",
"[+50]% Strength for cities <with a garrison> <when attacking>"
],
"row": 1,
"column": 5
},
{
"name": "Landed Elite",
"uniques": ["[+10]% growth [in capital]", "[+2 Food] [in capital]"],
"uniques": [
"[+10]% growth [in capital]",
"[+2 Food] [in capital]"
],
"requires": ["Legalism"],
"row": 2,
"column": 2
},
{
"name": "Monarchy",
"uniques": ["[+1 Gold, +1 Happiness] per [2] population [in capital]"],
"uniques": [
"[+1 Gold, +1 Happiness] per [2] population [in capital]"
],
"requires": ["Legalism"],
"row": 2,
"column": 4
},
{
"name": "Tradition Complete",
"uniques": ["[+15]% growth [in all cities]","[+2 Food] [in all cities]"]
"uniques": [
"[+15]% growth [in all cities]",
"Provides a [Aqueduct] in your first [4] cities for free"
]
}
]
},
{
"name": "Liberty",
"era": "Ancient era",
"priorities": {
"Neutral": 40,
"Cultural": 0,
"Diplomatic": 40,
"Domination": 40,
"Scientific": 0
},
"uniques": ["[+1 Culture] [in all cities]"],
"policies": [
{
"name": "Collective Rule",
"uniques": ["[+50]% Production when constructing [Settler] units [in capital]", "Free [Settler] appears"],
"name": "Republic",
"uniques": [
"[+1 Production] [in all cities]",
"[+5]% Production when constructing [All] buildings [in all cities]"
],
"row": 1,
"column": 1
},
{
"name": "Citizenship",
"uniques": ["[-25]% tile improvement construction time", "Free [Worker] appears"],
"uniques": [
"[-25]% tile improvement construction time",
"Free [Worker] appears"
],
"row": 1,
"column": 4
},
{
"name": "Republic",
"uniques": ["[+1 Production] [in all cities]", "[+5]% Production when constructing [All] buildings [in all cities]"],
"requires": ["Collective Rule"],
"name": "Collective Rule",
"uniques": [
"[+50]% Production when constructing [Settler] units [in capital]",
"Free [Settler] appears"
],
"requires": ["Republic"],
"row": 2,
"column": 1
},
{
"name": "Representation",
"uniques": ["Each city founded increases culture cost of policies [33]% less than normal", "Empire enters golden age"],
"uniques": [
"Each city founded increases culture cost of policies [33]% less than normal",
"Empire enters golden age"
],
"requires": ["Citizenship"],
"row": 2,
"column": 3
},
{
"name": "Meritocracy",
"uniques": ["[+1 Happiness] [in all cities connected to capital]", "[-5]% Unhappiness from [Population] [in all non-occupied cities]"],
"uniques": [
"[+1 Happiness] [in all cities connected to capital]",
"[-5]% Unhappiness from [Population] [in all non-occupied cities]"
],
"requires": ["Citizenship"],
"row": 2,
"column": 5
@ -90,39 +137,62 @@
{
"name": "Honor",
"era": "Ancient era",
"uniques": ["[+25]% Strength <vs [Barbarian] units>", "Earn [100]% of killed [Barbarian] unit's [Strength] as [Culture]",
"Notified of new Barbarian encampments"],
"priorities": {
"Neutral": 0,
"Cultural": 0,
"Diplomatic": 0,
"Domination": 10,
"Scientific": 0
},
"uniques": [
"[+33]% Strength <vs [Barbarian] units>",
"Earn [100]% of killed [Barbarian] unit's [Strength] as [Culture]",
"Notified of new Barbarian encampments"
],
"policies": [
{
"name": "Warrior Code",
"uniques":["[+15]% Production when constructing [Melee] units [in all cities]", "Free [Great General] appears"],
"uniques": [
"[+15]% Production when constructing [Melee] units [in all cities]",
"Free [Great General] appears"
],
"row": 1,
"column": 2
},
{
"name": "Discipline",
"uniques":["[+10]% Strength <for [Melee] units> <when adjacent to a [Military] unit>"],
"uniques": [
"[+15]% Strength <for [Melee] units> <when adjacent to a [Melee] unit>"
],
"row": 1,
"column": 4
},
{
"name": "Military Tradition",
"uniques":["[+50]% XP gained from combat <for [Military] units>"],
"uniques": [
"[+50]% XP gained from combat <for [Military] units>"
],
"requires": ["Warrior Code"],
"row": 2,
"column": 2
},
{
"name": "Military Caste",
"uniques": ["[+1 Happiness, +2 Culture] [in all cities with a garrison]"],
"uniques": [
"[+1 Happiness, +2 Culture] [in all cities with a garrison]"
],
"requires": ["Discipline"],
"row": 2,
"column": 4
},
{
"name": "Professional Army",
"uniques": ["[-33]% Gold cost of upgrading <for [Military] units>", "[+1 Happiness] from every [Walls]",
"[+1 Happiness] from every [Castle]", "[+1 Happiness] from every [Arsenal]", "[+1 Happiness] from every [Military Base]"
"uniques": [
"[-33]% Gold cost of upgrading <for [Military] units>",
"[+1 Happiness] from every [Walls]",
"[+1 Happiness] from every [Castle]",
"[+1 Happiness] from every [Arsenal]",
"[+1 Happiness] from every [Military Base]"
],
"requires": ["Military Caste"],
"row": 3,
@ -130,17 +200,34 @@
},
{
"name": "Honor Complete",
"uniques": ["Earn [10]% of killed [Military] unit's [Cost] as [Gold]"]
"uniques": [
"Earn [10]% of killed [Military] unit's [Cost] as [Gold]"
]
}
]
},{
},
{
"name": "Piety",
"era": "Classical era",
"uniques": ["[+15]% Production when constructing [Culture] buildings [in all cities]", "Only available <before adopting [Rationalism]>"],
"priorities": {
"Neutral": 0,
"Cultural": 10,
"Diplomatic": 0,
"Domination": 0,
"Scientific": 0
},
"uniques": [
"[+100]% Production when constructing [Shrine] buildings [in all cities]",
"[+100]% Production when constructing [Temple] buildings [in all cities]",
"Only available <before adopting [Rationalism]>"
],
"policies": [
{
"name": "Organized Religion",
"uniques": ["[+1 Happiness] from every [Monument]","[+1 Happiness] from every [Temple]","[+1 Happiness] from every [Monastery]"],
"uniques": [
"[+1 Faith] from every [Shrine]",
"[+1 Faith] from every [Temple]"
],
"row": 1,
"column": 2
},
@ -159,86 +246,126 @@
},
{
"name": "Reformation",
"uniques": ["[+33]% [Culture] [in all cities with a world wonder]", "Empire enters golden age"],
"uniques": [
"[+33]% [Culture] [in all cities with a world wonder]",
"Empire enters golden age"
],
"requires": ["Organized Religion"],
"row": 2,
"column": 3
},
{
"name": "Free Religion",
"uniques": ["Free Social Policy","[+1 Culture] from every [Monument]","[+1 Culture] from every [Temple]","[+1 Culture] from every [Monastery]"],
"uniques": ["[-10]% Culture cost of adopting new Policies"],
"requires": ["Mandate Of Heaven", "Reformation"],
"row": 3,
"column": 4
},
{
"name": "Piety Complete",
"uniques": ["[-10]% Culture cost of adopting new Policies"]
"uniques": [
"[Faith] cost of purchasing items in cities [-20]% ",
"[+3 Gold, +3 Culture] from every [Holy site]"
]
}
]
},
{
"name": "Patronage",
"era": "Classical era",
"era": "Medieval era",
"priorities": {
"Neutral": 0,
"Cultural": 0,
"Diplomatic": 20,
"Domination": 0,
"Scientific": 0
},
"uniques": ["[-25]% City-State Influence degradation"],
"policies": [
{
"name": "Philantropy",
"uniques":["Gifts of Gold to City-States generate [25]% more Influence"],
"uniques": [
"Gifts of Gold to City-States generate [25]% more Influence"
],
"row": 1,
"column": 2
},
{
"name": "Aesthetics",
"uniques":["Resting point for Influence with City-States is increased by [20]"],
"uniques": [
"Resting point for Influence with City-States is increased by [20]"
],
"row": 1,
"column": 4
},
{
"name": "Scholasticism",
"uniques":["Allied City-States provide [Science] equal to [25]% of what they produce for themselves"],
"uniques": [
"Allied City-States provide [Science] equal to [25]% of what they produce for themselves"
],
"requires": ["Philantropy"],
"row": 2,
"column": 2
},
{
"name": "Cultural Diplomacy",
"uniques": ["[+100]% resources gifted by City-States",
"[+50]% Happiness from luxury resources gifted by City-States"],
"uniques": [
"[+100]% resources gifted by City-States",
"[+50]% Happiness from luxury resources gifted by City-States"
],
"requires": ["Scholasticism"],
"row": 3,
"column": 2
},
{
"name": "Educated Elite",
"requires": ["Scholasticism","Aesthetics"],
"uniques": ["Allied City-States will occasionally gift Great People"],
"requires": ["Scholasticism", "Aesthetics"],
"uniques": [
"Allied City-States will occasionally gift Great People"
],
"row": 3,
"column": 4
},
{
"name": "Patronage Complete",
"uniques": ["Influence of all other civilizations with all city-states degrades [33]% faster",
"Triggers the following global alert: [Our influence with City-States has started dropping faster!]"]
"uniques": [
"Influence of all other civilizations with all city-states degrades [33]% faster",
"Triggers the following global alert: [Our influence with City-States has started dropping faster!]"
]
}
]
},
{
"name": "Commerce",
"uniques": ["[+25]% [Gold] [in capital]"],
"era": "Medieval era",
"priorities": {
"Neutral": 0,
"Cultural": 10,
"Diplomatic": 10,
"Domination": 20,
"Scientific": 10
},
"uniques": ["[+25]% [Gold] [in capital]"],
"policies": [
{
"name": "Naval Tradition",
"uniques": ["[+1] Movement <for [{Military} {Water}] units>", "[+1] Sight <for [{Military} {Water}] units>",
"Free [Great General] appears" //, "[+2] Movement <for [Great Admiral] units>", "Free [Great Admiral] appears" - todo
"uniques": [
"[+1] Movement <for [{Military} {Water}] units>",
"[+1] Sight <for [{Military} {Water}] units>",
"Free [Great General] appears"
// "[+2] Movement <for [Great Admiral] units>"
// ToDo: Should be "Free [Great Admiral] appears"
],
"row": 1,
"column": 2
},
{
"name": "Trade Unions",
"uniques": ["[-33]% maintenance on road & railroads", "[+1 Gold] from every [Harbor]", "[+1 Gold] from every [Seaport]"],
"uniques": [
"[-33]% maintenance on road & railroads",
"[+1 Gold] from every [Harbor]",
"[+1 Gold] from every [Seaport]"
],
"row": 1,
"column": 4
},
@ -251,74 +378,115 @@
},
{
"name": "Mercantilism",
"uniques": ["[Gold] cost of purchasing items in cities [-25]%", "[+1 Science] from every [Mint]", "[+1 Science] from every [Market]",
"[+1 Science] from every [Bank]", "[+1 Science] from every [Stock Exchange]"],
"uniques": [
"[Gold] cost of purchasing items in cities [-25]%",
"[+1 Science] from every [Mint]",
"[+1 Science] from every [Market]",
"[+1 Science] from every [Bank]",
"[+1 Science] from every [Stock Exchange]"
],
"requires": ["Trade Unions"],
"row": 2,
"column": 4
},
{
"name": "Protectionism",
"uniques": ["[+1] Happiness from each type of luxury resource"],
"uniques": ["[+2] Happiness from each type of luxury resource"],
"requires": ["Mercantilism"],
"row": 3,
"column": 4
},
{
"name": "Commerce Complete",
"uniques": ["[+1 Gold] from every specialist [in all cities]"]
"uniques": [
"[+1 Gold] from every [Trading post]",
"[+100]% Gold from Great Merchant trade missions",
"May buy [Great Merchant] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>"
]
}
]
},
{
"name": "Rationalism",
"era": "Renaissance era",
"uniques": ["Science gained from research agreements [+50]%", "Only available <before adopting [Piety]>"],
"priorities": {
"Neutral": 0,
"Cultural": 10,
"Diplomatic": 0,
"Domination": 0,
"Scientific": 20
},
"uniques": [
"[+15]% [Science] <while the empire is happy>",
"Only available <before adopting [Piety]>"
],
"policies": [
{
"name": "Secularism",
"uniques": ["[+2 Science] from every specialist [in all cities]"],
"uniques": [
"[+2 Science] from every specialist [in all cities]"
],
"row": 1,
"column": 2
},
{
"name": "Humanism",
"uniques": ["[+1 Happiness] from every [University]","[+1 Happiness] from every [Observatory]",
"[+1 Happiness] from every [Public School]"],
"uniques": [
"[+1 Happiness] from every [University]",
"[+1 Happiness] from every [Observatory]",
"[+1 Happiness] from every [Public School]"
],
"row": 1,
"column": 5
},
{
"name": "Free Thought",
"uniques": ["[+1 Science] from every [Trading post]", "[+17]% [Science] from every [University]"],
"uniques": [
"[+1 Science] from every [Trading post]",
"[+17]% [Science] from every [University]"
],
"requires": ["Secularism"],
"row": 2,
"column": 1
},
{
"name": "Sovereignty",
"uniques": ["[+15]% [Science] <while the empire is happy>"],
"uniques": ["[+1 Gold] from all [Science] buildings"],
"requires": ["Humanism"],
"row": 2,
"column": 5
},
{
"name": "Scientific Revolution",
"uniques": ["[2] Free Technologies"],
"uniques": ["Science gained from research agreements [+50]%"],
"requires": ["Free Thought"],
"row": 3,
"column": 1
},
{
"name": "Rationalism Complete",
"uniques": ["[+1 Gold] from all [Science] buildings"]
"uniques": [
"[2] Free Technologies",
"May buy [Great Scientist] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>"
]
}
]
},
{
"name": "Freedom",
"era": "Renaissance era",
"uniques": ["[+25]% Great Person generation [in all cities]", "Only available <before adopting [Autocracy]>", "Only available <before adopting [Order]>"],
"priorities": {
"Neutral": 30,
"Cultural": 30,
"Diplomatic": 20,
"Domination": 0,
"Scientific": 20
},
"uniques": [
"[+25]% Great Person generation [in all cities]",
"Only available <before adopting [Autocracy]>",
"Only available <before adopting [Order]>"
],
"policies": [
{
"name": "Constitution",
@ -334,7 +502,9 @@
},
{
"name": "Civil Society",
"uniques": ["[-50]% Food consumption by specialists [in all cities]"],
"uniques": [
"[-50]% Food consumption by specialists [in all cities]"
],
"row": 1,
"column": 5
},
@ -347,22 +517,39 @@
},
{
"name": "Democracy",
"uniques": ["[-50]% Unhappiness from [Specialists] [in all cities]"],
"uniques": [
"[-50]% Unhappiness from [Specialists] [in all cities]"
],
"requires": ["Civil Society"],
"row": 2,
"column": 5
},
{
"name": "Freedom Complete",
"uniques": ["[+100]% Yield from every [Great Improvement]", "[+50]% Golden Age length"]
"uniques": [
"[+100]% Yield from every [Great Improvement]",
"[+50]% Golden Age length",
"May buy [Great Artist] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>"
]
}
]
},
{
"name": "Autocracy",
"era": "Industrial era",
"uniques": ["[-33]% maintenance costs <for [All] units>", "Upon capturing a city, receive [10] times its [Culture] production as [Culture] immediately",
"Only available <before adopting [Order]>", "Only available <before adopting [Freedom]>"],
"priorities": {
"Neutral": 30,
"Cultural": 0,
"Diplomatic": 0,
"Domination": 30,
"Scientific": 0
},
"uniques": [
"[-33]% maintenance costs <for [All] units>",
"Upon capturing a city, receive [10] times its [Culture] production as [Culture] immediately",
"Only available <before adopting [Order]>",
"Only available <before adopting [Freedom]>"
],
"policies": [
{
"name": "Populism",
@ -378,72 +565,113 @@
},
{
"name": "Fascism",
"uniques": ["Quantity of strategic resources produced by the empire +[100]%"],
"requires": ["Populism","Militarism"],
"uniques": [
"Quantity of strategic resources produced by the empire +[100]%",
"[+2] Movement <for [Great General] units>"
],
"requires": ["Populism", "Militarism"],
"row": 2,
"column": 3
},
{
"name": "Police State",
"uniques": ["[+3 Happiness] from every [Courthouse]", "[+100]% Production when constructing [Courthouse] buildings [in all cities]"],
"uniques": [
"[+3 Happiness] from every [Courthouse]",
"[+100]% Production when constructing [Courthouse] buildings [in all cities]"
],
// There are also some uniques regarding espoinage, which as of this writing is not yet implemented
"requires": ["Militarism"],
"row": 2,
"column": 5
},
{
"name": "Total War",
"uniques": ["[+15]% Production when constructing [Military] units [in all cities]", "New [Military] units start with [15] Experience [in all cities]"],
"requires": ["Police State","Fascism"],
"uniques": [
"[+25]% Production when constructing [Military] units [in all cities]",
"New [Military] units start with [15] Experience [in all cities]"
],
"requires": ["Police State", "Fascism"],
"row": 3,
"column": 4
},
{
"name": "Autocracy Complete",
"uniques": ["[+25]% Strength <when attacking> <for [Military] units> <for [30] turns>"]
"uniques": [
"[+25]% Strength <when attacking> <for [Military] units> <for [50] turns>",
"May buy [Great General] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>",
"May buy [Great Admiral] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>"
]
}
]
},
{
"name": "Order",
"era": "Industrial era",
"uniques": ["[+1 Happiness] [in all cities]", "Only available <before adopting [Autocracy]>", "Only available <before adopting [Freedom]>"],
"priorities": {
"Neutral": 30,
"Cultural": 0,
"Diplomatic": 30,
"Domination": 0,
"Scientific": 20
},
"uniques": [
"[+1 Happiness] [in all cities]",
"Only available <before adopting [Autocracy]>",
"Only available <before adopting [Freedom]>"
],
"policies": [
{
"name": "United Front",
"uniques": ["Militaristic City-States grant units [2] times as fast when you are at war with a common nation"],
"uniques": [
"Militaristic City-States grant units [2] times as fast when you are at war with a common nation"
],
"row": 1,
"column": 1
},
{
"name": "Planned Economy",
"uniques": ["[+25]% [Science] from every [Factory]"],
"uniques": [
"[+25]% [Science] from every [Factory]",
"[+100]% Production when constructing [Factory] buildings [in all cities]"
],
"row": 1,
"column": 3
},
{
"name": "Nationalism",
"uniques": ["[+15]% Strength <for [All] units> <when fighting in [Friendly Land] tiles>"],
"uniques": [
"[+15]% Strength <for [All] units> <when fighting in [Friendly Land] tiles>"
],
"row": 1,
"column": 5
},
{
"name": "Socialism",
"requires": ["Planned Economy"],
"uniques": ["[-15]% maintenance cost for buildings [in all cities]"],
"uniques": [
"[-15]% maintenance cost for buildings [in all cities]"
],
"row": 2,
"column": 3
},
{
"name": "Communism",
"requires": ["Socialism"],
"uniques": ["[+2 Production] [in all cities]", "[+10]% Production when constructing [All] buildings [in all cities]"],
"uniques": [
"[+2 Production] [in all cities]",
"[+1 Production] from every [Mine]",
"[+1 Production] from every [Quarry]"
],
"row": 3,
"column": 3
},
{
"name": "Order Complete",
"uniques": ["[+1 Food, +1 Production, +1 Science, +1 Gold, +1 Culture] [in all cities]"]
"uniques": [
"[+2 Food, +2 Production, +2 Science, +2 Gold, +2 Culture] [in all cities]",
"May buy [Great Engineer] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>"
]
}
]
}
}
]

View File

@ -14,10 +14,7 @@ import com.unciv.logic.map.MapUnit
import com.unciv.logic.map.TileInfo
import com.unciv.logic.trade.*
import com.unciv.models.Counter
import com.unciv.models.ruleset.Belief
import com.unciv.models.ruleset.BeliefType
import com.unciv.models.ruleset.ModOptionsConstants
import com.unciv.models.ruleset.VictoryType
import com.unciv.models.ruleset.*
import com.unciv.models.ruleset.tech.Technology
import com.unciv.models.ruleset.tile.ResourceType
import com.unciv.models.ruleset.unique.UniqueType
@ -393,35 +390,72 @@ object NextTurnAutomation {
}
}
private object PolicyPriorityMap {
//todo This should be moddable, and needs an update to include new G&K Policies
/** Maps [VictoryType] to an ordered List of PolicyBranch names - the AI will prefer them in that order */
val priorities = mapOf(
VictoryType.Cultural to listOf("Piety", "Freedom", "Tradition", "Commerce", "Patronage"),
VictoryType.Scientific to listOf("Rationalism", "Commerce", "Liberty", "Order", "Patronage"),
VictoryType.Domination to listOf("Autocracy", "Honor", "Liberty", "Rationalism", "Commerce"),
VictoryType.Diplomatic to listOf("Patronage", "Commerce", "Rationalism", "Freedom", "Tradition")
)
}
private fun adoptPolicy(civInfo: CivilizationInfo) {
/*
# Branch-based policy-to-adopt decision
Basically the AI prioritizes finishing incomplete branches before moving on, \
unless a new branch with higher priority is adoptable.
- If incomplete branches have higher priorities than any newly adoptable branch,
- Candidates are the unfinished branches.
- Else if newly adoptable branches have higher priorities than any incomplete branch,
- Candidates are the new branches.
- Choose a random candidate closest to completion.
- Pick a random child policy of a chosen branch and adopt it.
*/
while (civInfo.policies.canAdoptPolicy()) {
val incompleteBranches: Set<PolicyBranch> = civInfo.policies.incompleteBranches
val adoptableBranches: Set<PolicyBranch> = civInfo.policies.adoptableBranches
val adoptablePolicies = civInfo.gameInfo.ruleSet.policies.values
.filter { civInfo.policies.isAdoptable(it) }
// Skip the whole thing if all branches are completed
if (incompleteBranches.isEmpty() && adoptableBranches.isEmpty()) return
// This can happen if the player is crazy enough to have the game continue forever and he disabled cultural victory
if (adoptablePolicies.isEmpty()) return
val priorityMap: Map<PolicyBranch, Int> = civInfo.policies.priorityMap
var maxIncompletePriority: Int? =
civInfo.policies.getMaxPriority(incompleteBranches)
var maxAdoptablePriority: Int? = civInfo.policies.getMaxPriority(adoptableBranches)
val policyBranchPriority = PolicyPriorityMap.priorities[civInfo.victoryType()]
?: emptyList()
val policiesByPreference = adoptablePolicies
.groupBy { policy ->
policyBranchPriority.indexOf(policy.branch.name).let { if (it == -1) 99 else it }
// This here is a (probably dirty) code to bypass NoSuchElementException error
// when one of the priority variables is null
if (maxIncompletePriority == null) maxIncompletePriority =
maxAdoptablePriority!! - 1
if (maxAdoptablePriority == null) maxAdoptablePriority =
maxIncompletePriority - 1
// Candidate branches to adopt
val candidates: Set<PolicyBranch> =
// If incomplete branches have higher priorities than any newly adoptable branch,
if (maxAdoptablePriority <= maxIncompletePriority) {
// Prioritize finishing one of the unfinished branches
incompleteBranches.filter {
priorityMap[it] == maxIncompletePriority
}.toSet()
}
// If newly adoptable branches have higher priorities than any incomplete branch,
else {
// Prioritize adopting one of the new branches
adoptableBranches.filter {
priorityMap[it] == maxAdoptablePriority
}.toSet()
}
val preferredPolicies = policiesByPreference.minByOrNull { it.key }!!.value
// branchCompletionMap but keys are only candidates
val candidateCompletionMap: Map<PolicyBranch, Int> =
civInfo.policies.branchCompletionMap.filterKeys { key ->
key in candidates
}
// The highest number of adopted child policies within a single candidate
val maxCompletion: Int =
candidateCompletionMap.maxOf { entry -> entry.value }
// The candidate closest to completion, hence the target branch
val targetBranch = candidateCompletionMap.filterValues { value ->
value == maxCompletion
}.keys.random()
val policyToAdopt: Policy =
if (civInfo.policies.isAdoptable(targetBranch)) targetBranch
else targetBranch.policies.filter { civInfo.policies.isAdoptable(it) }.random()
val policyToAdopt = preferredPolicies.random()
civInfo.policies.adopt(policyToAdopt)
}
}
@ -441,9 +475,7 @@ object NextTurnAutomation {
val unitToDisband = civInfo.getCivUnits()
.filter { it.baseUnit.requiresResource(resource) }
.minByOrNull { it.getForceEvaluation() }
if (unitToDisband != null) {
unitToDisband.disband()
}
unitToDisband?.disband()
for (city in civInfo.cities) {
if (city.hasSoldBuildingThisTurn)

View File

@ -3,7 +3,7 @@ package com.unciv.logic.civilization
import com.unciv.logic.map.MapSize
import com.unciv.models.ruleset.Policy
import com.unciv.models.ruleset.Policy.PolicyBranchType
import com.unciv.models.ruleset.unique.StateForConditionals
import com.unciv.models.ruleset.PolicyBranch
import com.unciv.models.ruleset.unique.UniqueMap
import com.unciv.models.ruleset.unique.UniqueTriggerActivation
import com.unciv.models.ruleset.unique.UniqueType
@ -26,11 +26,62 @@ class PolicyManager {
var freePolicies = 0
var storedCulture = 0
// TODO: 'adoptedPolicies' seems to be an internal API.
// Why is it HashSet<String> instead of HashSet<Policy>?
internal val adoptedPolicies = HashSet<String>()
var numberOfAdoptedPolicies = 0
var shouldOpenPolicyPicker = false
get() = field && canAdoptPolicy()
/** A [Map] pairing each [PolicyBranch] to its priority ([Int]). */
val priorityMap: Map<PolicyBranch, Int>
get() {
val value = HashMap<PolicyBranch, Int>()
for (branch in branches) {
value[branch] = branch.priorities[civInfo.victoryType().name] ?: 0
}
return value
}
/** A [Set] of adopted [PolicyBranch]es regardless of its completeness. */
val adoptedBranches: Set<PolicyBranch>
get() = branches.filter { isAdopted(it.name) }.toSet()
/** A [Set] of newly adoptable [PolicyBranch]es. */
val adoptableBranches: Set<PolicyBranch>
get() = branches.filter { isAdoptable(it) }.toSet()
/** A [Set] of incomplete [PolicyBranch]es including newly adoptable ones. */
val incompleteBranches: Set<PolicyBranch>
get() {
val value = HashSet<PolicyBranch>()
for (branch in branches) {
if (branch.policies.any { isAdoptable(it) }) value.add(branch)
}
return value
}
/** A [Set] of completed [PolicyBranch]es. */
val completedBranches: Set<PolicyBranch>
get() {
val value = HashSet<PolicyBranch>()
for (branch in branches) {
if (branch.policies.all { isAdopted(it.name) }) value.add(branch)
}
return value
}
/** A [Map] pairing each [PolicyBranch] to how many of its child branches are adopted ([Int]). */
val branchCompletionMap: Map<PolicyBranch, Int>
get() {
val value = HashMap<PolicyBranch, Int>()
for (branch in branches) {
value[branch] = adoptedPolicies.count {
branch.policies.contains(getPolicyByName(it))
}
}
return value
}
/** A [Set] of all [PolicyBranch]es. */
private val branches: Set<PolicyBranch>
get() = civInfo.gameInfo.ruleSet.policyBranches.values.toSet()
// Only instantiate a single value for all policy managers
companion object {
private val turnCountRegex by lazy { Regex("for \\[[0-9]*\\] turns") }
@ -51,25 +102,29 @@ class PolicyManager {
fun getPolicyByName(name: String): Policy = getRulesetPolicies()[name]!!
fun setTransients() {
for (policyName in adoptedPolicies)
addPolicyToTransients(getPolicyByName(policyName))
for (policyName in adoptedPolicies) addPolicyToTransients(
getPolicyByName(policyName)
)
}
fun addPolicyToTransients(policy: Policy) {
for (unique in policy.uniqueObjects) {
// Should be deprecated together with TimedAttackStrength so I'm putting this here so the compiler will complain if we don't
// Should be deprecated together with TimedAttackStrength so
// I'm putting this here so the compiler will complain if we don't
val rememberToDeprecate = UniqueType.TimedAttackStrength
if (!unique.text.contains(turnCountRegex) && unique.conditionals.none { it.type == UniqueType.ConditionalTimedUnique })
policyUniques.addUnique(unique)
if (!unique.text.contains(turnCountRegex) && unique.conditionals.none { it.type == UniqueType.ConditionalTimedUnique }) policyUniques.addUnique(
unique
)
}
}
fun addCulture(culture: Int) {
val couldAdoptPolicyBefore = canAdoptPolicy()
storedCulture += culture
if (!couldAdoptPolicyBefore && canAdoptPolicy())
if (!couldAdoptPolicyBefore && canAdoptPolicy()) {
shouldOpenPolicyPicker = true
}
}
fun endTurn(culture: Int) {
addCulture(culture)
@ -80,7 +135,7 @@ class PolicyManager {
fun getCultureNeededForNextPolicy(): Int {
var policyCultureCost = 25 + (numberOfAdoptedPolicies * 6).toDouble().pow(1.7)
// https://civilization.fandom.com/wiki/Map_(Civ5)
val worldSizeModifier = with (civInfo.gameInfo.tileMap.mapParameters.mapSize) {
val worldSizeModifier = with(civInfo.gameInfo.tileMap.mapParameters.mapSize) {
when {
radius >= MapSize.Huge.radius -> 0.05f
radius >= MapSize.Large.radius -> 0.075f
@ -89,12 +144,9 @@ class PolicyManager {
}
var cityModifier = worldSizeModifier * (civInfo.cities.count { !it.isPuppet } - 1)
for (unique in civInfo.getMatchingUniques(UniqueType.LessPolicyCostFromCities))
cityModifier *= 1 - unique.params[0].toFloat() / 100
for (unique in civInfo.getMatchingUniques(UniqueType.LessPolicyCost))
policyCultureCost *= unique.params[0].toPercent()
if (civInfo.isPlayerCivilization())
policyCultureCost *= civInfo.getDifficulty().policyCostModifier
for (unique in civInfo.getMatchingUniques(UniqueType.LessPolicyCostFromCities)) cityModifier *= 1 - unique.params[0].toFloat() / 100
for (unique in civInfo.getMatchingUniques(UniqueType.LessPolicyCost)) policyCultureCost *= unique.params[0].toPercent()
if (civInfo.isPlayerCivilization()) policyCultureCost *= civInfo.getDifficulty().policyCostModifier
policyCultureCost *= civInfo.gameInfo.gameParameters.gameSpeed.modifier
val cost: Int = (policyCultureCost * (1 + cityModifier)).roundToInt()
return cost - (cost % 5)
@ -116,7 +168,9 @@ class PolicyManager {
if (policy.policyBranchType == PolicyBranchType.BranchComplete) return false
if (!getAdoptedPolicies().containsAll(policy.requires!!)) return false
if (checkEra && civInfo.gameInfo.ruleSet.eras[policy.branch.era]!!.eraNumber > civInfo.getEraNumber()) return false
if (policy.getMatchingUniques(UniqueType.IncompatibleWith).any { adoptedPolicies.contains(it.params[0]) }) return false
if (policy.getMatchingUniques(UniqueType.IncompatibleWith)
.any { adoptedPolicies.contains(it.params[0]) }
) return false
if (policy.uniqueObjects.filter { it.type == UniqueType.OnlyAvailableWhen }
.any { !it.conditionalsApply(civInfo) }) return false
return true
@ -125,8 +179,7 @@ class PolicyManager {
fun canAdoptPolicy(): Boolean {
if (civInfo.cities.isEmpty()) return false
if (freePolicies == 0 && storedCulture < getCultureNeededForNextPolicy())
return false
if (freePolicies == 0 && storedCulture < getCultureNeededForNextPolicy()) return false
//Return true if there is a policy to adopt, else return false
return getRulesetPolicies().values.any { civInfo.policies.isAdoptable(it) }
@ -138,8 +191,9 @@ class PolicyManager {
if (freePolicies > 0) freePolicies--
else if (!civInfo.gameInfo.gameParameters.godMode) {
val cultureNeededForNextPolicy = getCultureNeededForNextPolicy()
if (cultureNeededForNextPolicy > storedCulture)
throw Exception("How is this possible??????")
if (cultureNeededForNextPolicy > storedCulture) throw Exception(
"How is this possible??????"
)
storedCulture -= cultureNeededForNextPolicy
numberOfAdoptedPolicies++
}
@ -156,34 +210,47 @@ class PolicyManager {
}
for (unique in policy.uniques) {
if (unique.equalsPlaceholderText("Triggers the following global alert: []"))
triggerGlobalAlerts(policy, unique.getPlaceholderParameters()[0])
if (unique.equalsPlaceholderText("Triggers the following global alert: []")) triggerGlobalAlerts(
policy, unique.getPlaceholderParameters()[0]
)
}
for (unique in policy.uniqueObjects)
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo)
for (unique in policy.uniqueObjects) UniqueTriggerActivation.triggerCivwideUnique(
unique, civInfo
)
// This ALSO has the side-effect of updating the CivInfo statForNextTurn so we don't need to call it explicitly
for (cityInfo in civInfo.cities)
cityInfo.cityStats.update()
for (cityInfo in civInfo.cities) cityInfo.cityStats.update()
if (!canAdoptPolicy()) shouldOpenPolicyPicker = false
}
private fun triggerGlobalAlerts(policy: Policy, extraNotificationText: String = "") {
/**
* Return the highest priority ([Int]) among the given [Set] of [PolicyBranch]es.
* Would return null if the given [Set] is empty.
*/
fun getMaxPriority(branchesToCompare: Set<PolicyBranch>): Int? {
val filteredMap = priorityMap.filterKeys { branch -> branch in branchesToCompare }
return filteredMap.values.maxOrNull()
}
private fun triggerGlobalAlerts(
policy: Policy, extraNotificationText: String = ""
) {
var extraNotificationTextCopy = extraNotificationText
if (extraNotificationText != "") {
extraNotificationTextCopy = "\n${extraNotificationText}"
}
for (civ in civInfo.gameInfo.civilizations.filter { it.isMajorCiv() }) {
if (civ == civInfo) continue
val defaultNotificationText =
if (civ.getKnownCivs().contains(civInfo)) {
val defaultNotificationText = if (civ.getKnownCivs().contains(civInfo)) {
"[${civInfo.civName}] has adopted the [${policy.name}] policy"
} else {
"An unknown civilization has adopted the [${policy.name}] policy"
}
civ.addNotification("${defaultNotificationText}${extraNotificationTextCopy}", NotificationIcon.Culture)
civ.addNotification(
"${defaultNotificationText}${extraNotificationTextCopy}", NotificationIcon.Culture
)
}
}

View File

@ -2,5 +2,6 @@ package com.unciv.models.ruleset
class PolicyBranch : Policy() {
var policies: ArrayList<Policy> = arrayListOf()
var priorities: HashMap<String, Int> = HashMap<String, Int>()
lateinit var era: String
}

View File

@ -251,17 +251,32 @@ class Ruleset {
val policiesFile = folderHandle.child("Policies.json")
if (policiesFile.exists()) {
policyBranches += createHashmap(jsonParser.getFromJson(Array<PolicyBranch>::class.java, policiesFile))
policyBranches += createHashmap(
jsonParser.getFromJson(Array<PolicyBranch>::class.java, policiesFile)
)
for (branch in policyBranches.values) {
// Setup this branch
branch.requires = ArrayList()
branch.branch = branch
for (victoryType in VictoryType.values()) {
if (victoryType.name !in branch.priorities.keys) {
branch.priorities[victoryType.name] = 0
}
}
policies[branch.name] = branch
// Append child policies of this branch
for (policy in branch.policies) {
policy.branch = branch
if (policy.requires == null) policy.requires = arrayListOf(branch.name)
if (policy.requires == null) {
policy.requires = arrayListOf(branch.name)
}
policies[policy.name] = policy
}
branch.policies.last().name = branch.name + Policy.branchCompleteSuffix
// Add a finisher
branch.policies.last().name =
branch.name + Policy.branchCompleteSuffix
}
}

View File

@ -2,6 +2,7 @@
- [Buildings.json](#buildingsjson)
- [Nations.json](#nationsjson)
- [Policies.json](#policiesjson)
- [Branch priorities](#branch-priorities)
- [Quests.json](#questsjson)
- [Religions.json](#religionsjson)
- [Specialists.json](#specialistsjson)
@ -109,6 +110,7 @@ Each policy branch can have the following properties:
|-----------|------|-----------|-------|
| name | String | Required | |
| era | String | Required | Unlocking era as defined in [Eras.json](Miscellaneous-JSON-files.md#erasjson) |
| priorities | Object | Default empty | Priorities for each victory type, [see here](#branch-priorities)
| uniques | List | Default empty | List of effects, [see here](../Modders/Unique-parameter-types.md#general-uniques) |
| policies | List | Default empty | List of member policies |
@ -121,6 +123,16 @@ Each member policy can have the following properties:
| requires | List | Default empty | List of prerequisite policy names |
| uniques | List | Default empty | List of effects, [see here](../Modders/Unique-parameter-types.md#general-uniques) |
#### Branch priorities
The "priorities" object lists its branch's priorities for each victory type. The AI refers to this when deciding which branch to prioritize, also taking its preferred victory type into consideration. If two or more candidate branches have the same priority, the AI chooses a random branch among the candidates. All values are set to 0 if the object itself is missing or empty.
| Attribute | Type | Optional? | Notes |
|-----------|------|-----------|-------|
| Neutral | Int | Default 0 | Priority value when the AI's preferred victory type is Neutral |
| Cultural | Int | Default 0 | Priority value when the AI's preferred victory type is Cultural |
| Diplomatic | Int | Default 0 | Priority value when the AI's preferred victory type is Diplomatic |
| Domination | Int | Default 0 | Priority value when the AI's preferred victory type is Domination|
| Scientific | Int | Default 0 | Priority value when the AI's preferred victory type is Scientific |
## Quests.json
[Link to original](/jsons/Civ%20V%20-%20Vanilla/Quests.json)