From 84561e7ad438dee2be85688bece563e60020e799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B2=AD=ED=95=98=EB=8A=98?= <96629218+HaneulCheong@users.noreply.github.com> Date: Fri, 25 Mar 2022 03:33:42 -1100 Subject: [PATCH] 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) --- .../jsons/Civ V - Gods & Kings/Policies.json | 1130 ++++++++++------- .../jsons/Civ V - Vanilla/Policies.json | 1116 +++++++++------- .../logic/automation/NextTurnAutomation.kt | 104 +- .../unciv/logic/civilization/PolicyManager.kt | 135 +- .../com/unciv/models/ruleset/PolicyBranch.kt | 1 + core/src/com/unciv/models/ruleset/Ruleset.kt | 21 +- docs/Other/Civilization-related-JSON-files.md | 12 + 7 files changed, 1544 insertions(+), 975 deletions(-) diff --git a/android/assets/jsons/Civ V - Gods & Kings/Policies.json b/android/assets/jsons/Civ V - Gods & Kings/Policies.json index ed90c9e056..3aa3c928d1 100644 --- a/android/assets/jsons/Civ V - Gods & Kings/Policies.json +++ b/android/assets/jsons/Civ V - Gods & Kings/Policies.json @@ -1,463 +1,677 @@ [ - { - "name": "Tradition", - "era": "Ancient era", - "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]"], - "row": 1, - "column": 1 - }, - { - "name": "Legalism", - "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 "], - "row": 1, - "column": 5 - }, - { - "name": "Landed Elite", - "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]"], - "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"] - } - ] - }, - { - "name": "Liberty", - "era": "Ancient era", - "uniques": ["[+1 Culture] [in all cities]"], - "policies": [ - { - "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"], - "row": 1, - "column": 4 - }, - { - "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"], - "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]"], - "requires": ["Citizenship"], - "row": 2, - "column": 5 - }, - { - "name": "Liberty Complete", - "uniques": ["Free Great Person"] - } - ] - }, - { - "name": "Honor", - "era": "Ancient era", - "uniques": ["[+33]% Strength ", "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"], - "row": 1, - "column": 2 - }, - { - "name": "Discipline", - "uniques":["[+15]% Strength "], - "row": 1, - "column": 4 - }, - { - "name": "Military Tradition", - "uniques":["[+50]% XP gained from combat "], - "requires": ["Warrior Code"], - "row": 2, - "column": 2 - }, - { - "name": "Military Caste", - "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 ", "[+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, - "column": 4 - }, - { - "name": "Honor Complete", - "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 "], - "policies": [ - { - "name": "Organized Religion", - "uniques": ["[+1 Faith] from every [Shrine]","[+1 Faith] from every [Temple]"], - "row": 1, - "column": 2 - }, - { - "name": "Mandate Of Heaven", - "uniques": ["[50]% of excess happiness converted to [Culture]"], - "row": 1, - "column": 5 - }, - { - "name": "Theocracy", - "uniques": ["[+10]% [Gold] from every [Temple]"], - "requires": ["Organized Religion"], - "row": 2, - "column": 1 - }, - { - "name": "Reformation", - "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": ["[-10]% Culture cost of adopting new Policies"], - "requires": ["Mandate Of Heaven", "Reformation"], - "row": 3, - "column": 4 - }, - { - "name": "Piety Complete", - "uniques": ["[Faith] cost of purchasing items in cities [-20]% ", "[+3 Gold, +3 Culture] from every [Holy site]"] - } - ] - }, - { - "name": "Patronage", - "era": "Classical era", - "uniques": ["[-25]% City-State Influence degradation"], - "policies": [ - { - "name": "Philantropy", - "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]"], - "row": 1, - "column": 4 - }, - { - "name": "Scholasticism", - "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"], - "requires": ["Scholasticism"], - "row": 3, - "column": 2 - }, - { - "name": "Educated Elite", - "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!]"] - } - ] - }, - { - "name": "Commerce", - "uniques": ["[+25]% [Gold] [in capital]"], - "era": "Medieval era", - "policies": [ - { - "name": "Naval Tradition", - "uniques": ["[+1] Movement ", "[+1] Sight ", - "Free [Great General] appears" //, "[+2] Movement " - // 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]"], - "row": 1, - "column": 4 - }, - { - "name": "Merchant Navy", - "uniques": ["[+3 Production] [in all coastal cities]"], - "requires": ["Naval Tradition"], - "row": 2, - "column": 2 - }, - { - "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]"], - "requires": ["Trade Unions"], - "row": 2, - "column": 4 - }, - { - "name": "Protectionism", - "uniques": ["[+2] Happiness from each type of luxury resource"], - "requires": ["Mercantilism"], - "row": 3, - "column": 4 - }, - { - "name": "Commerce Complete", - "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]) " - ] - } - ] - }, - { - "name": "Rationalism", - "era": "Renaissance era", - "uniques": ["[+15]% [Science] ", "Only available "], - "policies": [ - { - "name": "Secularism", - "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]"], - "row": 1, - "column": 5 - }, - { - "name": "Free Thought", - "uniques": ["[+1 Science] from every [Trading post]", "[+17]% [Science] from every [University]"], - "requires": ["Secularism"], - "row": 2, - "column": 1 - }, - { - "name": "Sovereignty", - "uniques": ["[+1 Gold] from all [Science] buildings"], - "requires": ["Humanism"], - "row": 2, - "column": 5 - }, - { - "name": "Scientific Revolution", - "uniques": ["Science gained from research agreements [+50]%"], - "requires": ["Free Thought"], - "row": 3, - "column": 1 - }, - { - "name": "Rationalism Complete", - "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]) " - ] - } - ] - }, - { - "name": "Freedom", - "era": "Renaissance era", - "uniques": ["[+25]% Great Person generation [in all cities]", "Only available ", "Only available "], - "policies": [ - { - "name": "Constitution", - "uniques": ["[+2 Culture] from every [Wonder]"], - "row": 1, - "column": 1 - }, - { - "name": "Universal Suffrage", - "uniques": ["[+33]% Strength for cities "], - "row": 1, - "column": 3 - }, - { - "name": "Civil Society", - "uniques": ["[-50]% Food consumption by specialists [in all cities]"], - "row": 1, - "column": 5 - }, - { - "name": "Free Speech", - "uniques": ["[8] units cost no maintenance"], - "requires": ["Constitution"], - "row": 2, - "column": 1 - }, - { - "name": "Democracy", - "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", - "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]) " - ] - } - ] - }, - { - "name": "Autocracy", - "era": "Industrial era", - "uniques": ["[-33]% maintenance costs ", "Upon capturing a city, receive [10] times its [Culture] production as [Culture] immediately", - "Only available ", "Only available "], - "policies": [ - { - "name": "Populism", - "uniques": ["[+25]% Strength "], - "row": 1, - "column": 1 - }, - { - "name": "Militarism", - "uniques": ["[Gold] cost of purchasing [All] units [-33]%"], - "row": 1, - "column": 5 - }, - { - "name": "Fascism", - "uniques": ["Quantity of strategic resources produced by the empire +[100]%", "[+2] Movement "], - "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]"], - // 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": ["[+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 ", - "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]) ", - "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]) " - ] - } - ] - }, - { - "name": "Order", - "era": "Industrial era", - "uniques": ["[+1 Happiness] [in all cities]", "Only available ", "Only available "], - "policies": [ - { - "name": "United Front", - "uniques": ["Militaristic City-States grant units [2] times as fast when you are at war with a common nation"], - "row": 1, - "column": 1 + { + "name": "Tradition", + "era": "Ancient era", + "priorities": { + "Neutral": 30, + "Cultural": 30, + "Diplomatic": 0, + "Domination": 0, + "Scientific": 30 }, - { - "name": "Planned Economy", - "uniques": ["[+25]% [Science] from every [Factory]", "[+100]% Production when constructing [Factory] buildings [in all cities]"], - "row": 1, - "column": 3 - }, - { - "name": "Nationalism", - "uniques": ["[+15]% Strength "], - "row": 1, - "column": 5 - }, - { - "name": "Socialism", - "requires": ["Planned Economy"], - "uniques": ["[-15]% maintenance cost for buildings [in all cities]"], - "row": 2, - "column": 3 + "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]" + ], + "row": 1, + "column": 1 + }, + { + "name": "Legalism", + "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 " + ], + "row": 1, + "column": 5 + }, + { + "name": "Landed Elite", + "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]" + ], + "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" + ] + } + ] + }, + { + "name": "Liberty", + "era": "Ancient era", + "priorities": { + "Neutral": 30, + "Cultural": 0, + "Diplomatic": 30, + "Domination": 30, + "Scientific": 0 }, - { - "name": "Communism", - "requires": ["Socialism"], - "uniques": ["[+2 Production] [in all cities]", "[+1 Production] from every [Mine]", "[+1 Production] from every [Quarry]"], - "row": 3, - "column": 3 + "uniques": ["[+1 Culture] [in all cities]"], + "policies": [ + { + "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" + ], + "row": 1, + "column": 4 + }, + { + "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" + ], + "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]" + ], + "requires": ["Citizenship"], + "row": 2, + "column": 5 + }, + { + "name": "Liberty Complete", + "uniques": ["Free Great Person"] + } + ] + }, + { + "name": "Honor", + "era": "Ancient era", + "priorities": { + "Neutral": 0, + "Cultural": 0, + "Diplomatic": 10, + "Domination": 10, + "Scientific": 10 }, - { - "name": "Order Complete", - "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]) " - ] - } - ] -} + "uniques": [ + "[+33]% Strength ", + "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" + ], + "row": 1, + "column": 2 + }, + { + "name": "Discipline", + "uniques": [ + "[+15]% Strength " + ], + "row": 1, + "column": 4 + }, + { + "name": "Military Tradition", + "uniques": [ + "[+50]% XP gained from combat " + ], + "requires": ["Warrior Code"], + "row": 2, + "column": 2 + }, + { + "name": "Military Caste", + "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 ", + "[+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, + "column": 4 + }, + { + "name": "Honor Complete", + "uniques": [ + "Earn [10]% of killed [Military] unit's [Cost] as [Gold]" + ] + } + ] + }, + { + "name": "Piety", + "era": "Classical era", + "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 " + ], + "policies": [ + { + "name": "Organized Religion", + "uniques": [ + "[+1 Faith] from every [Shrine]", + "[+1 Faith] from every [Temple]" + ], + "row": 1, + "column": 2 + }, + { + "name": "Mandate Of Heaven", + "uniques": ["[50]% of excess happiness converted to [Culture]"], + "row": 1, + "column": 5 + }, + { + "name": "Theocracy", + "uniques": ["[+10]% [Gold] from every [Temple]"], + "requires": ["Organized Religion"], + "row": 2, + "column": 1 + }, + { + "name": "Reformation", + "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": ["[-10]% Culture cost of adopting new Policies"], + "requires": ["Mandate Of Heaven", "Reformation"], + "row": 3, + "column": 4 + }, + { + "name": "Piety Complete", + "uniques": [ + "[Faith] cost of purchasing items in cities [-20]% ", + "[+3 Gold, +3 Culture] from every [Holy site]" + ] + } + ] + }, + { + "name": "Patronage", + "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" + ], + "row": 1, + "column": 2 + }, + { + "name": "Aesthetics", + "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" + ], + "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" + ], + "requires": ["Scholasticism"], + "row": 3, + "column": 2 + }, + { + "name": "Educated Elite", + "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!]" + ] + } + ] + }, + { + "name": "Commerce", + "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 ", + "[+1] Sight ", + "Free [Great General] appears" + // "[+2] Movement " + // 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]" + ], + "row": 1, + "column": 4 + }, + { + "name": "Merchant Navy", + "uniques": ["[+3 Production] [in all coastal cities]"], + "requires": ["Naval Tradition"], + "row": 2, + "column": 2 + }, + { + "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]" + ], + "requires": ["Trade Unions"], + "row": 2, + "column": 4 + }, + { + "name": "Protectionism", + "uniques": ["[+2] Happiness from each type of luxury resource"], + "requires": ["Mercantilism"], + "row": 3, + "column": 4 + }, + { + "name": "Commerce Complete", + "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]) " + ] + } + ] + }, + { + "name": "Rationalism", + "era": "Renaissance era", + "priorities": { + "Neutral": 0, + "Cultural": 10, + "Diplomatic": 10, + "Domination": 10, + "Scientific": 20 + }, + "uniques": [ + "[+15]% [Science] ", + "Only available " + ], + "policies": [ + { + "name": "Secularism", + "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]" + ], + "row": 1, + "column": 5 + }, + { + "name": "Free Thought", + "uniques": [ + "[+1 Science] from every [Trading post]", + "[+17]% [Science] from every [University]" + ], + "requires": ["Secularism"], + "row": 2, + "column": 1 + }, + { + "name": "Sovereignty", + "uniques": ["[+1 Gold] from all [Science] buildings"], + "requires": ["Humanism"], + "row": 2, + "column": 5 + }, + { + "name": "Scientific Revolution", + "uniques": ["Science gained from research agreements [+50]%"], + "requires": ["Free Thought"], + "row": 3, + "column": 1 + }, + { + "name": "Rationalism Complete", + "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]) " + ] + } + ] + }, + { + "name": "Freedom", + "era": "Industrial era", + "priorities": { + "Neutral": 50, + "Cultural": 50, + "Diplomatic": 50, + "Domination": 40, + "Scientific": 50 + }, + "uniques": [ + "[+25]% Great Person generation [in all cities]", + "Only available ", + "Only available " + ], + "policies": [ + { + "name": "Constitution", + "uniques": ["[+2 Culture] from every [Wonder]"], + "row": 1, + "column": 1 + }, + { + "name": "Universal Suffrage", + "uniques": ["[+33]% Strength for cities "], + "row": 1, + "column": 3 + }, + { + "name": "Civil Society", + "uniques": [ + "[-50]% Food consumption by specialists [in all cities]" + ], + "row": 1, + "column": 5 + }, + { + "name": "Free Speech", + "uniques": ["[8] units cost no maintenance"], + "requires": ["Constitution"], + "row": 2, + "column": 1 + }, + { + "name": "Democracy", + "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", + "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]) " + ] + } + ] + }, + { + "name": "Autocracy", + "era": "Industrial era", + "priorities": { + "Neutral": 50, + "Cultural": 40, + "Diplomatic": 40, + "Domination": 50, + "Scientific": 40 + }, + "uniques": [ + "[-33]% maintenance costs ", + "Upon capturing a city, receive [10] times its [Culture] production as [Culture] immediately", + "Only available ", + "Only available " + ], + "policies": [ + { + "name": "Populism", + "uniques": ["[+25]% Strength "], + "row": 1, + "column": 1 + }, + { + "name": "Militarism", + "uniques": ["[Gold] cost of purchasing [All] units [-33]%"], + "row": 1, + "column": 5 + }, + { + "name": "Fascism", + "uniques": [ + "Quantity of strategic resources produced by the empire +[100]%", + "[+2] Movement " + ], + "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]" + ], + // 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": [ + "[+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 ", + "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]) ", + "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]) " + ] + } + ] + }, + { + "name": "Order", + "era": "Industrial era", + "priorities": { + "Neutral": 50, + "Cultural": 40, + "Diplomatic": 50, + "Domination": 40, + "Scientific": 50 + }, + "uniques": [ + "[+1 Happiness] [in all cities]", + "Only available ", + "Only available " + ], + "policies": [ + { + "name": "United Front", + "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]" + ], + "row": 1, + "column": 3 + }, + { + "name": "Nationalism", + "uniques": [ + "[+15]% Strength " + ], + "row": 1, + "column": 5 + }, + { + "name": "Socialism", + "requires": ["Planned Economy"], + "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]" + ], + "row": 3, + "column": 3 + }, + { + "name": "Order Complete", + "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]) " + ] + } + ] + } ] diff --git a/android/assets/jsons/Civ V - Vanilla/Policies.json b/android/assets/jsons/Civ V - Vanilla/Policies.json index 90e868e07f..f523cf1f51 100644 --- a/android/assets/jsons/Civ V - Vanilla/Policies.json +++ b/android/assets/jsons/Civ V - Vanilla/Policies.json @@ -1,449 +1,677 @@ [ - { - "name": "Tradition", - "era": "Ancient era", - "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]"], - "row": 1, - "column": 1 - }, - { - "name": "Legalism", - "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 "], - "row": 1, - "column": 5 - }, - { - "name": "Landed Elite", - "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]"], - "requires": ["Legalism"], - "row": 2, - "column": 4 - }, - { - "name": "Tradition Complete", - "uniques": ["[+15]% growth [in all cities]","[+2 Food] [in all cities]"] - } - ] - }, - { - "name": "Liberty", - "era": "Ancient era", - "uniques": ["[+1 Culture] [in all cities]"], - "policies": [ - - { - "name": "Collective Rule", - "uniques": ["[+50]% Production when constructing [Settler] units [in capital]", "Free [Settler] appears"], - "row": 1, - "column": 1 - }, - { - "name": "Citizenship", - "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"], - "row": 2, - "column": 1 - }, - { - "name": "Representation", - "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]"], - "requires": ["Citizenship"], - "row": 2, - "column": 5 - }, - { - "name": "Liberty Complete", - "uniques": ["Free Great Person"] - } - ] - }, - { - "name": "Honor", - "era": "Ancient era", - "uniques": ["[+25]% Strength ", "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"], - "row": 1, - "column": 2 - }, - { - "name": "Discipline", - "uniques":["[+10]% Strength "], - "row": 1, - "column": 4 - }, - { - "name": "Military Tradition", - "uniques":["[+50]% XP gained from combat "], - "requires": ["Warrior Code"], - "row": 2, - "column": 2 - }, - { - "name": "Military Caste", - "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 ", "[+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, - "column": 4 - }, - { - "name": "Honor Complete", - "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 "], - "policies": [ - { - "name": "Organized Religion", - "uniques": ["[+1 Happiness] from every [Monument]","[+1 Happiness] from every [Temple]","[+1 Happiness] from every [Monastery]"], - "row": 1, - "column": 2 - }, - { - "name": "Mandate Of Heaven", - "uniques": ["[50]% of excess happiness converted to [Culture]"], - "row": 1, - "column": 5 - }, - { - "name": "Theocracy", - "uniques": ["[+10]% [Gold] from every [Temple]"], - "requires": ["Organized Religion"], - "row": 2, - "column": 1 - }, - { - "name": "Reformation", - "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]"], - "requires": ["Mandate Of Heaven", "Reformation"], - "row": 3, - "column": 4 - }, - { - "name": "Piety Complete", - "uniques": ["[-10]% Culture cost of adopting new Policies"] - } - ] - }, - { - "name": "Patronage", - "era": "Classical era", - "uniques": ["[-25]% City-State Influence degradation"], - "policies": [ - { - "name": "Philantropy", - "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]"], - "row": 1, - "column": 4 - }, - { - "name": "Scholasticism", - "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"], - "requires": ["Scholasticism"], - "row": 3, - "column": 2 - }, - { - "name": "Educated Elite", - "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!]"] - } - ] - }, - { - "name": "Commerce", - "uniques": ["[+25]% [Gold] [in capital]"], - "era": "Medieval era", - "policies": [ - { - "name": "Naval Tradition", - "uniques": ["[+1] Movement ", "[+1] Sight ", - "Free [Great General] appears" //, "[+2] Movement ", "Free [Great Admiral] appears" - todo - ], - "row": 1, - "column": 2 - }, - { - "name": "Trade Unions", - "uniques": ["[-33]% maintenance on road & railroads", "[+1 Gold] from every [Harbor]", "[+1 Gold] from every [Seaport]"], - "row": 1, - "column": 4 - }, - { - "name": "Merchant Navy", - "uniques": ["[+3 Production] [in all coastal cities]"], - "requires": ["Naval Tradition"], - "row": 2, - "column": 2 - }, - { - "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]"], - "requires": ["Trade Unions"], - "row": 2, - "column": 4 - }, - { - "name": "Protectionism", - "uniques": ["[+1] 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]"] - } - ] - }, - { - "name": "Rationalism", - "era": "Renaissance era", - "uniques": ["Science gained from research agreements [+50]%", "Only available "], - "policies": [ - { - "name": "Secularism", - "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]"], - "row": 1, - "column": 5 - }, - { - "name": "Free Thought", - "uniques": ["[+1 Science] from every [Trading post]", "[+17]% [Science] from every [University]"], - "requires": ["Secularism"], - "row": 2, - "column": 1 - }, - { - "name": "Sovereignty", - "uniques": ["[+15]% [Science] "], - "requires": ["Humanism"], - "row": 2, - "column": 5 - }, - { - "name": "Scientific Revolution", - "uniques": ["[2] Free Technologies"], - "requires": ["Free Thought"], - "row": 3, - "column": 1 - }, - { - "name": "Rationalism Complete", - "uniques": ["[+1 Gold] from all [Science] buildings"] - } - ] - }, - { - "name": "Freedom", - "era": "Renaissance era", - "uniques": ["[+25]% Great Person generation [in all cities]", "Only available ", "Only available "], - "policies": [ - { - "name": "Constitution", - "uniques": ["[+2 Culture] from every [Wonder]"], - "row": 1, - "column": 1 - }, - { - "name": "Universal Suffrage", - "uniques": ["[+33]% Strength for cities "], - "row": 1, - "column": 3 - }, - { - "name": "Civil Society", - "uniques": ["[-50]% Food consumption by specialists [in all cities]"], - "row": 1, - "column": 5 - }, - { - "name": "Free Speech", - "uniques": ["[8] units cost no maintenance"], - "requires": ["Constitution"], - "row": 2, - "column": 1 - }, - { - "name": "Democracy", - "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"] - } - ] - }, - { - "name": "Autocracy", - "era": "Industrial era", - "uniques": ["[-33]% maintenance costs ", "Upon capturing a city, receive [10] times its [Culture] production as [Culture] immediately", - "Only available ", "Only available "], - "policies": [ - { - "name": "Populism", - "uniques": ["[+25]% Strength "], - "row": 1, - "column": 1 - }, - { - "name": "Militarism", - "uniques": ["[Gold] cost of purchasing [All] units [-33]%"], - "row": 1, - "column": 5 - }, - { - "name": "Fascism", - "uniques": ["Quantity of strategic resources produced by the empire +[100]%"], - "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]"], - "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"], - "row": 3, - "column": 4 - }, - { - "name": "Autocracy Complete", - "uniques": ["[+25]% Strength "] - } - ] - }, - { - "name": "Order", - "era": "Industrial era", - "uniques": ["[+1 Happiness] [in all cities]", "Only available ", "Only available "], - "policies": [ - { - "name": "United Front", - "uniques": ["Militaristic City-States grant units [2] times as fast when you are at war with a common nation"], - "row": 1, - "column": 1 + { + "name": "Tradition", + "era": "Ancient era", + "priorities": { + "Neutral": 40, + "Cultural": 40, + "Diplomatic": 0, + "Domination": 0, + "Scientific": 40 }, - { - "name": "Planned Economy", - "uniques": ["[+25]% [Science] from every [Factory]"], - "row": 1, - "column": 3 - }, - { - "name": "Nationalism", - "uniques": ["[+15]% Strength "], - "row": 1, - "column": 5 - }, - { - "name": "Socialism", - "requires": ["Planned Economy"], - "uniques": ["[-15]% maintenance cost for buildings [in all cities]"], - "row": 2, - "column": 3 + "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]" + ], + "row": 1, + "column": 1 + }, + { + "name": "Legalism", + "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 " + ], + "row": 1, + "column": 5 + }, + { + "name": "Landed Elite", + "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]" + ], + "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" + ] + } + ] + }, + { + "name": "Liberty", + "era": "Ancient era", + "priorities": { + "Neutral": 40, + "Cultural": 0, + "Diplomatic": 40, + "Domination": 40, + "Scientific": 0 }, - { - "name": "Communism", - "requires": ["Socialism"], - "uniques": ["[+2 Production] [in all cities]", "[+10]% Production when constructing [All] buildings [in all cities]"], - "row": 3, - "column": 3 + "uniques": ["[+1 Culture] [in all cities]"], + "policies": [ + { + "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" + ], + "row": 1, + "column": 4 + }, + { + "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" + ], + "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]" + ], + "requires": ["Citizenship"], + "row": 2, + "column": 5 + }, + { + "name": "Liberty Complete", + "uniques": ["Free Great Person"] + } + ] + }, + { + "name": "Honor", + "era": "Ancient era", + "priorities": { + "Neutral": 0, + "Cultural": 0, + "Diplomatic": 0, + "Domination": 10, + "Scientific": 0 }, - { - "name": "Order Complete", - "uniques": ["[+1 Food, +1 Production, +1 Science, +1 Gold, +1 Culture] [in all cities]"] - } - ] -} + "uniques": [ + "[+33]% Strength ", + "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" + ], + "row": 1, + "column": 2 + }, + { + "name": "Discipline", + "uniques": [ + "[+15]% Strength " + ], + "row": 1, + "column": 4 + }, + { + "name": "Military Tradition", + "uniques": [ + "[+50]% XP gained from combat " + ], + "requires": ["Warrior Code"], + "row": 2, + "column": 2 + }, + { + "name": "Military Caste", + "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 ", + "[+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, + "column": 4 + }, + { + "name": "Honor Complete", + "uniques": [ + "Earn [10]% of killed [Military] unit's [Cost] as [Gold]" + ] + } + ] + }, + { + "name": "Piety", + "era": "Classical era", + "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 " + ], + "policies": [ + { + "name": "Organized Religion", + "uniques": [ + "[+1 Faith] from every [Shrine]", + "[+1 Faith] from every [Temple]" + ], + "row": 1, + "column": 2 + }, + { + "name": "Mandate Of Heaven", + "uniques": ["[50]% of excess happiness converted to [Culture]"], + "row": 1, + "column": 5 + }, + { + "name": "Theocracy", + "uniques": ["[+10]% [Gold] from every [Temple]"], + "requires": ["Organized Religion"], + "row": 2, + "column": 1 + }, + { + "name": "Reformation", + "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": ["[-10]% Culture cost of adopting new Policies"], + "requires": ["Mandate Of Heaven", "Reformation"], + "row": 3, + "column": 4 + }, + { + "name": "Piety Complete", + "uniques": [ + "[Faith] cost of purchasing items in cities [-20]% ", + "[+3 Gold, +3 Culture] from every [Holy site]" + ] + } + ] + }, + { + "name": "Patronage", + "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" + ], + "row": 1, + "column": 2 + }, + { + "name": "Aesthetics", + "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" + ], + "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" + ], + "requires": ["Scholasticism"], + "row": 3, + "column": 2 + }, + { + "name": "Educated Elite", + "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!]" + ] + } + ] + }, + { + "name": "Commerce", + "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 ", + "[+1] Sight ", + "Free [Great General] appears" + // "[+2] Movement " + // 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]" + ], + "row": 1, + "column": 4 + }, + { + "name": "Merchant Navy", + "uniques": ["[+3 Production] [in all coastal cities]"], + "requires": ["Naval Tradition"], + "row": 2, + "column": 2 + }, + { + "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]" + ], + "requires": ["Trade Unions"], + "row": 2, + "column": 4 + }, + { + "name": "Protectionism", + "uniques": ["[+2] Happiness from each type of luxury resource"], + "requires": ["Mercantilism"], + "row": 3, + "column": 4 + }, + { + "name": "Commerce Complete", + "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]) " + ] + } + ] + }, + { + "name": "Rationalism", + "era": "Renaissance era", + "priorities": { + "Neutral": 0, + "Cultural": 10, + "Diplomatic": 0, + "Domination": 0, + "Scientific": 20 + }, + "uniques": [ + "[+15]% [Science] ", + "Only available " + ], + "policies": [ + { + "name": "Secularism", + "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]" + ], + "row": 1, + "column": 5 + }, + { + "name": "Free Thought", + "uniques": [ + "[+1 Science] from every [Trading post]", + "[+17]% [Science] from every [University]" + ], + "requires": ["Secularism"], + "row": 2, + "column": 1 + }, + { + "name": "Sovereignty", + "uniques": ["[+1 Gold] from all [Science] buildings"], + "requires": ["Humanism"], + "row": 2, + "column": 5 + }, + { + "name": "Scientific Revolution", + "uniques": ["Science gained from research agreements [+50]%"], + "requires": ["Free Thought"], + "row": 3, + "column": 1 + }, + { + "name": "Rationalism Complete", + "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]) " + ] + } + ] + }, + { + "name": "Freedom", + "era": "Renaissance era", + "priorities": { + "Neutral": 30, + "Cultural": 30, + "Diplomatic": 20, + "Domination": 0, + "Scientific": 20 + }, + "uniques": [ + "[+25]% Great Person generation [in all cities]", + "Only available ", + "Only available " + ], + "policies": [ + { + "name": "Constitution", + "uniques": ["[+2 Culture] from every [Wonder]"], + "row": 1, + "column": 1 + }, + { + "name": "Universal Suffrage", + "uniques": ["[+33]% Strength for cities "], + "row": 1, + "column": 3 + }, + { + "name": "Civil Society", + "uniques": [ + "[-50]% Food consumption by specialists [in all cities]" + ], + "row": 1, + "column": 5 + }, + { + "name": "Free Speech", + "uniques": ["[8] units cost no maintenance"], + "requires": ["Constitution"], + "row": 2, + "column": 1 + }, + { + "name": "Democracy", + "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", + "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]) " + ] + } + ] + }, + { + "name": "Autocracy", + "era": "Industrial era", + "priorities": { + "Neutral": 30, + "Cultural": 0, + "Diplomatic": 0, + "Domination": 30, + "Scientific": 0 + }, + "uniques": [ + "[-33]% maintenance costs ", + "Upon capturing a city, receive [10] times its [Culture] production as [Culture] immediately", + "Only available ", + "Only available " + ], + "policies": [ + { + "name": "Populism", + "uniques": ["[+25]% Strength "], + "row": 1, + "column": 1 + }, + { + "name": "Militarism", + "uniques": ["[Gold] cost of purchasing [All] units [-33]%"], + "row": 1, + "column": 5 + }, + { + "name": "Fascism", + "uniques": [ + "Quantity of strategic resources produced by the empire +[100]%", + "[+2] Movement " + ], + "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]" + ], + // 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": [ + "[+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 ", + "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]) ", + "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]) " + ] + } + ] + }, + { + "name": "Order", + "era": "Industrial era", + "priorities": { + "Neutral": 30, + "Cultural": 0, + "Diplomatic": 30, + "Domination": 0, + "Scientific": 20 + }, + "uniques": [ + "[+1 Happiness] [in all cities]", + "Only available ", + "Only available " + ], + "policies": [ + { + "name": "United Front", + "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]" + ], + "row": 1, + "column": 3 + }, + { + "name": "Nationalism", + "uniques": [ + "[+15]% Strength " + ], + "row": 1, + "column": 5 + }, + { + "name": "Socialism", + "requires": ["Planned Economy"], + "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]" + ], + "row": 3, + "column": 3 + }, + { + "name": "Order Complete", + "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]) " + ] + } + ] + } ] diff --git a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt index c9c8f72e5e..407150e981 100644 --- a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt +++ b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt @@ -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 @@ -74,7 +71,7 @@ object NextTurnAutomation { fun automateGoldToSciencePercentage(civInfo: CivilizationInfo) { // Don't let the AI run blindly with the default convert-gold-to-science ratio if that option is enabled val estimatedIncome = civInfo.statsForNextTurn.gold.toInt() - val projectedGold = civInfo.gold + estimatedIncome + val projectedGold = civInfo.gold + estimatedIncome // TODO: some cleverness, this is just wild guessing. val pissPoor = civInfo.tech.era.baseUnitBuyCost val stinkingRich = civInfo.tech.era.startingGold * 10 + civInfo.cities.size * 2 * pissPoor @@ -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 = civInfo.policies.incompleteBranches + val adoptableBranches: Set = 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 = 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 - val preferredPolicies = policiesByPreference.minByOrNull { it.key }!!.value + // Candidate branches to adopt + val candidates: Set = + // 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() + } + + // branchCompletionMap but keys are only candidates + val candidateCompletionMap: Map = + 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) @@ -485,7 +517,7 @@ object NextTurnAutomation { if (civInfo.religionManager.religionState != ReligionState.FoundingReligion) return val availableReligionIcons = civInfo.gameInfo.ruleSet.religions .filterNot { civInfo.gameInfo.religions.values.map { religion -> religion.name }.contains(it) } - val religionIcon = + val religionIcon = if (civInfo.nation.favoredReligion in availableReligionIcons) civInfo.nation.favoredReligion else availableReligionIcons.randomOrNull() ?: return // Wait what? How did we pass the checking when using a great prophet but not this? @@ -495,8 +527,8 @@ object NextTurnAutomation { private fun enhanceReligion(civInfo: CivilizationInfo) { civInfo.religionManager.chooseBeliefs( - null, - null, + null, + null, chooseBeliefs(civInfo, civInfo.religionManager.getBeliefsToChooseAtEnhancing()).toList() ) } @@ -519,11 +551,11 @@ object NextTurnAutomation { private fun chooseBeliefOfType(civInfo: CivilizationInfo, beliefType: BeliefType, additionalBeliefsToExclude: HashSet = hashSetOf()): Belief? { return civInfo.gameInfo.ruleSet.beliefs - .filter { - (it.value.type == beliefType || beliefType == BeliefType.Any) + .filter { + (it.value.type == beliefType || beliefType == BeliefType.Any) && !additionalBeliefsToExclude.contains(it.value) && !civInfo.gameInfo.religions.values - .flatMap { religion -> religion.getBeliefs(beliefType) }.contains(it.value) + .flatMap { religion -> religion.getBeliefs(beliefType) }.contains(it.value) } .map { it.value } .maxByOrNull { ChooseBeliefsAutomation.rateBelief(civInfo, it) } diff --git a/core/src/com/unciv/logic/civilization/PolicyManager.kt b/core/src/com/unciv/logic/civilization/PolicyManager.kt index 1e618c1edc..55eb202ae0 100644 --- a/core/src/com/unciv/logic/civilization/PolicyManager.kt +++ b/core/src/com/unciv/logic/civilization/PolicyManager.kt @@ -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 instead of HashSet? internal val adoptedPolicies = HashSet() var numberOfAdoptedPolicies = 0 var shouldOpenPolicyPicker = false get() = field && canAdoptPolicy() + /** A [Map] pairing each [PolicyBranch] to its priority ([Int]). */ + val priorityMap: Map + get() { + val value = HashMap() + 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 + get() = branches.filter { isAdopted(it.name) }.toSet() + /** A [Set] of newly adoptable [PolicyBranch]es. */ + val adoptableBranches: Set + get() = branches.filter { isAdoptable(it) }.toSet() + /** A [Set] of incomplete [PolicyBranch]es including newly adoptable ones. */ + val incompleteBranches: Set + get() { + val value = HashSet() + for (branch in branches) { + if (branch.policies.any { isAdoptable(it) }) value.add(branch) + } + return value + } + /** A [Set] of completed [PolicyBranch]es. */ + val completedBranches: Set + get() { + val value = HashSet() + 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 + get() { + val value = HashMap() + 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 + 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,24 +102,28 @@ 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) { @@ -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) @@ -109,14 +161,16 @@ class PolicyManager { * Note: branch completion policies are automatic and therefore not adoptable in this test. * @param policy The Policy to check * @param checkEra Include era test (with false the function returns whether the policy is adoptable now or in the future) - * @return `true` if the policy can be adopted, `false` if some rule prevents it (including when it's already adopted) + * @return `true` if the policy can be adopted, `false` if some rule prevents it (including when it's already adopted) */ fun isAdoptable(policy: Policy, checkEra: Boolean = true): Boolean { if (isAdopted(policy.name)) return false 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): 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)) { - "[${civInfo.civName}] has adopted the [${policy.name}] policy" - } else { - "An unknown civilization has adopted the [${policy.name}] policy" - } - civ.addNotification("${defaultNotificationText}${extraNotificationTextCopy}", NotificationIcon.Culture) + 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 + ) } } diff --git a/core/src/com/unciv/models/ruleset/PolicyBranch.kt b/core/src/com/unciv/models/ruleset/PolicyBranch.kt index eef0448dfa..5b6d657c3d 100644 --- a/core/src/com/unciv/models/ruleset/PolicyBranch.kt +++ b/core/src/com/unciv/models/ruleset/PolicyBranch.kt @@ -2,5 +2,6 @@ package com.unciv.models.ruleset class PolicyBranch : Policy() { var policies: ArrayList = arrayListOf() + var priorities: HashMap = HashMap() lateinit var era: String } diff --git a/core/src/com/unciv/models/ruleset/Ruleset.kt b/core/src/com/unciv/models/ruleset/Ruleset.kt index 7c3be3bf8f..2cc7f584e6 100644 --- a/core/src/com/unciv/models/ruleset/Ruleset.kt +++ b/core/src/com/unciv/models/ruleset/Ruleset.kt @@ -251,17 +251,32 @@ class Ruleset { val policiesFile = folderHandle.child("Policies.json") if (policiesFile.exists()) { - policyBranches += createHashmap(jsonParser.getFromJson(Array::class.java, policiesFile)) + policyBranches += createHashmap( + jsonParser.getFromJson(Array::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 } } diff --git a/docs/Other/Civilization-related-JSON-files.md b/docs/Other/Civilization-related-JSON-files.md index 16d52032ff..801ae14465 100644 --- a/docs/Other/Civilization-related-JSON-files.md +++ b/docs/Other/Civilization-related-JSON-files.md @@ -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)