diff --git a/android/assets/jsons/Civ V - Vanilla/Buildings.json b/android/assets/jsons/Civ V - Vanilla/Buildings.json index e927088e..4e7b2753 100644 --- a/android/assets/jsons/Civ V - Vanilla/Buildings.json +++ b/android/assets/jsons/Civ V - Vanilla/Buildings.json @@ -178,7 +178,7 @@ "hurryCostModifier": 25, "maintenance": 1, "resourceBonusStats": {"food": 1}, - "uniques": ["Can only be built in coastal cities","+1 food from Ocean and Coast tiles"], + "uniques": ["Can only be built in coastal cities", "[+1 Food] from [Ocean] tiles", "[+1 Food] from [Coast] tiles"] "requiredTech": "Optics" }, { diff --git a/android/assets/jsons/translations/Brazilian_Portuguese.properties b/android/assets/jsons/translations/Brazilian_Portuguese.properties index 82444b02..48fa824c 100644 --- a/android/assets/jsons/translations/Brazilian_Portuguese.properties +++ b/android/assets/jsons/translations/Brazilian_Portuguese.properties @@ -971,7 +971,8 @@ Provides a sum of gold each time you spend a Great Person = Proporciona um monta +2 Gold for each source of Marble and Stone = +2 de Ouro por cada recurso de Mármore e Pedra Mausoleum of Halicarnassus = Mausoléu de Halicarnasso -+1 food from Ocean and Coast tiles = +1 de comida de regiões costeiras e oceânicas + # Requires translation! +[stats] from [terrain] tiles = Lighthouse = Farol 'They that go down to the sea in ships, that do business in great waters; these see the works of the Lord, and his wonders in the deep.' - The Bible, Psalms 107:23-24 = 'Os navios que descem no mar, negociam em grandes águas; estes vêem as obras do Senhor, e suas maravilhas nas profundezas.' - A Bíblia, Salmos 107:23-24 diff --git a/android/assets/jsons/translations/Czech.properties b/android/assets/jsons/translations/Czech.properties index 0b101935..e4fa0eb7 100644 --- a/android/assets/jsons/translations/Czech.properties +++ b/android/assets/jsons/translations/Czech.properties @@ -1018,7 +1018,8 @@ Provides a sum of gold each time you spend a Great Person = Poskytne zlato při +2 Gold for each source of Marble and Stone = +2 zlata za každý Mramor a Kámen Mausoleum of Halicarnassus = Mauzoleum v Halikarnassu -+1 food from Ocean and Coast tiles = +1 jídlo z oceánu a pobřežních polí + # Requires translation! +[stats] from [terrain] tiles = Lighthouse = Maják 'They that go down to the sea in ships, that do business in great waters; these see the works of the Lord, and his wonders in the deep.' - The Bible, Psalms 107:23-24 = 'Ti, kteří se vydávají na lodích na moře, kdo konají dílo na nesmírných vodách, spatřili Hospodinovy skutky, jeho divy na hlubině.' - Bible, Žalm 107: 23-24 diff --git a/android/assets/jsons/translations/Dutch.properties b/android/assets/jsons/translations/Dutch.properties index 69b96934..5f4be846 100644 --- a/android/assets/jsons/translations/Dutch.properties +++ b/android/assets/jsons/translations/Dutch.properties @@ -1546,7 +1546,8 @@ Provides a sum of gold each time you spend a Great Person = # Requires translation! Mausoleum of Halicarnassus = -+1 food from Ocean and Coast tiles = +1 voedsel van Oceaan en Kust tegels + # Requires translation! +[stats] from [terrain] tiles = Lighthouse = Vuurtoren # Requires translation! diff --git a/android/assets/jsons/translations/English.properties b/android/assets/jsons/translations/English.properties index c5fe597f..2a3555db 100644 --- a/android/assets/jsons/translations/English.properties +++ b/android/assets/jsons/translations/English.properties @@ -1773,7 +1773,7 @@ Provides a sum of gold each time you spend a Great Person = Mausoleum of Halicarnassus = # Requires translation! -+1 food from Ocean and Coast tiles = +[stats] from [terrain] tiles = # Requires translation! Lighthouse = diff --git a/android/assets/jsons/translations/French.properties b/android/assets/jsons/translations/French.properties index f083f93c..3829ff2b 100644 --- a/android/assets/jsons/translations/French.properties +++ b/android/assets/jsons/translations/French.properties @@ -1002,7 +1002,8 @@ Provides a sum of gold each time you spend a Great Person = Donne de l'Or à cha +2 Gold for each source of Marble and Stone = +2 Or pour chaque ressource de Marbre et de Pierre Mausoleum of Halicarnassus = Mausolée d'Halicarnasse -+1 food from Ocean and Coast tiles = +1 nourriture des cases océans et côtes + # Requires translation! +[stats] from [terrain] tiles = Lighthouse = Phare 'They that go down to the sea in ships, that do business in great waters; these see the works of the Lord, and his wonders in the deep.' - The Bible, Psalms 107:23-24 = 'Ceux qui étaient descendus sur la mer dans des navires, et qui travaillaient sur les grandes eaux, Ceux-là virent les oeuvres de l'Eternel et ses merveilles au milieu de l'abîme.…' - La Bible, Psaumes 107:23-24 diff --git a/android/assets/jsons/translations/German.properties b/android/assets/jsons/translations/German.properties index 383d4d49..5786ad5c 100644 --- a/android/assets/jsons/translations/German.properties +++ b/android/assets/jsons/translations/German.properties @@ -969,7 +969,8 @@ Provides a sum of gold each time you spend a Great Person = Gibt Dir jedes mal b +2 Gold for each source of Marble and Stone = +2 Gold für jede Quelle von Marmor und Stein Mausoleum of Halicarnassus = Mausoleum von Halikarnassos -+1 food from Ocean and Coast tiles = +1 Nahrung von Ozean- und Küstenfeldern + # Requires translation! +[stats] from [terrain] tiles = Lighthouse = Leuchtturm 'They that go down to the sea in ships, that do business in great waters; these see the works of the Lord, and his wonders in the deep.' - The Bible, Psalms 107:23-24 = 'Die mit Schiffen auf dem Meere fuhren und trieben ihren Handel auf großen Wassern, die des HERRN Werke erfahren haben und seine Wunder im Meer.' - Die Bibel, Psalm 107,23-25 diff --git a/android/assets/jsons/translations/Indonesian.properties b/android/assets/jsons/translations/Indonesian.properties index 002f9972..7c0740c5 100644 --- a/android/assets/jsons/translations/Indonesian.properties +++ b/android/assets/jsons/translations/Indonesian.properties @@ -965,7 +965,8 @@ Provides a sum of gold each time you spend a Great Person = Menyediakan sejumlah +2 Gold for each source of Marble and Stone = +2 Emas untuk setiap sumber Marmer dan Batu Mausoleum of Halicarnassus = Makam Halikarnassus -+1 food from Ocean and Coast tiles = +1 makanan dari Samudera dan Pesisir + # Requires translation! +[stats] from [terrain] tiles = Lighthouse = Mercusuar 'They that go down to the sea in ships, that do business in great waters; these see the works of the Lord, and his wonders in the deep.' - The Bible, Psalms 107:23-24 = 'Ada orang-orang yang mengarungi laut dengan kapal-kapal, yang melakukan perdagangan di lautan luas; mereka melihat pekerjaan-pekerjaan Tuhan, dan perbuatan-perbuatan-Nya yang ajaib di tempat yang dalam.' - Alkitab, Mazmur 107:23-24 diff --git a/android/assets/jsons/translations/Italian.properties b/android/assets/jsons/translations/Italian.properties index 84ac2423..20193907 100644 --- a/android/assets/jsons/translations/Italian.properties +++ b/android/assets/jsons/translations/Italian.properties @@ -965,7 +965,8 @@ Provides a sum of gold each time you spend a Great Person = Concede una tantum d +2 Gold for each source of Marble and Stone = +2 Oro per ogni fonte di Marmo e Pietra Mausoleum of Halicarnassus = Mausoleo di Alicarnasso -+1 food from Ocean and Coast tiles = +1 Cibo da caselle Oceano e costiere + # Requires translation! +[stats] from [terrain] tiles = Lighthouse = Faro 'They that go down to the sea in ships, that do business in great waters; these see the works of the Lord, and his wonders in the deep.' - The Bible, Psalms 107:23-24 = 'Ecco quelli che scendon nel mare su navi, che trafficano sulle grandi acque; essi veggono le opere dell'Eterno e le sue meraviglie nell'abisso.' - Salmi 107:23-24 diff --git a/android/assets/jsons/translations/Japanese.properties b/android/assets/jsons/translations/Japanese.properties index 5fd1509c..0826c618 100644 --- a/android/assets/jsons/translations/Japanese.properties +++ b/android/assets/jsons/translations/Japanese.properties @@ -965,7 +965,8 @@ Provides a sum of gold each time you spend a Great Person = 偉人を消費す +2 Gold for each source of Marble and Stone = 大理石または石材1つにつきゴールド+2 Mausoleum of Halicarnassus = マウソロス霊廟 -+1 food from Ocean and Coast tiles = 海岸、海のタイルに食料+1 + # Requires translation! +[stats] from [terrain] tiles = Lighthouse = 灯台 'They that go down to the sea in ships, that do business in great waters; these see the works of the Lord, and his wonders in the deep.' - The Bible, Psalms 107:23-24 = 「彼らは船に乗り海に出て、大海原で事業をなす者となった。彼らは深き海で主の御業を見た。驚くべき主の美業を。」 - 旧約聖書詩編 107:23-24 diff --git a/android/assets/jsons/translations/Korean.properties b/android/assets/jsons/translations/Korean.properties index c03e02eb..c9b881d2 100644 --- a/android/assets/jsons/translations/Korean.properties +++ b/android/assets/jsons/translations/Korean.properties @@ -963,7 +963,8 @@ Provides a sum of gold each time you spend a Great Person = 위인 소모시 일 +2 Gold for each source of Marble and Stone = 대리석, 돌에서 금 +2 Mausoleum of Halicarnassus = 마우솔로스의 영묘 -+1 food from Ocean and Coast tiles = 연안, 대양에서 식량 +1 + # Requires translation! +[stats] from [terrain] tiles = Lighthouse = 등대 'They that go down to the sea in ships, that do business in great waters; these see the works of the Lord, and his wonders in the deep.' - The Bible, Psalms 107:23-24 = '배들을 바다에 띄우며 큰 물에서 일을 하는 자는 여호와께서 행하신 일들과 그의 기이한 일들을 깊은 바다에서 보나니.' - 성경, 시편 107:23-24 diff --git a/android/assets/jsons/translations/Lithuanian.properties b/android/assets/jsons/translations/Lithuanian.properties index 2c520f3c..27f2b1d1 100644 --- a/android/assets/jsons/translations/Lithuanian.properties +++ b/android/assets/jsons/translations/Lithuanian.properties @@ -1041,7 +1041,7 @@ Provides a sum of gold each time you spend a Great Person = Mausoleum of Halicarnassus = # Requires translation! -+1 food from Ocean and Coast tiles = +[stats] from [terrain] tiles = # Requires translation! Lighthouse = diff --git a/android/assets/jsons/translations/Malay.properties b/android/assets/jsons/translations/Malay.properties index 2208c31e..0962fe02 100644 --- a/android/assets/jsons/translations/Malay.properties +++ b/android/assets/jsons/translations/Malay.properties @@ -1719,7 +1719,7 @@ Provides a sum of gold each time you spend a Great Person = Mausoleum of Halicarnassus = # Requires translation! -+1 food from Ocean and Coast tiles = +[stats] from [terrain] tiles = Lighthouse = Rumah Api # Requires translation! diff --git a/android/assets/jsons/translations/Persian_(Pinglish-DIN).properties b/android/assets/jsons/translations/Persian_(Pinglish-DIN).properties index 0af632ea..79df5984 100644 --- a/android/assets/jsons/translations/Persian_(Pinglish-DIN).properties +++ b/android/assets/jsons/translations/Persian_(Pinglish-DIN).properties @@ -1003,7 +1003,7 @@ Provides a sum of gold each time you spend a Great Person = Mausoleum of Halicarnassus = # Requires translation! -+1 food from Ocean and Coast tiles = +[stats] from [terrain] tiles = # Requires translation! Lighthouse = diff --git a/android/assets/jsons/translations/Persian_(Pinglish-UN).properties b/android/assets/jsons/translations/Persian_(Pinglish-UN).properties index 62d5735d..8bbe2cf0 100644 --- a/android/assets/jsons/translations/Persian_(Pinglish-UN).properties +++ b/android/assets/jsons/translations/Persian_(Pinglish-UN).properties @@ -1004,7 +1004,7 @@ Provides a sum of gold each time you spend a Great Person = Mausoleum of Halicarnassus = # Requires translation! -+1 food from Ocean and Coast tiles = +[stats] from [terrain] tiles = # Requires translation! Lighthouse = diff --git a/android/assets/jsons/translations/Polish.properties b/android/assets/jsons/translations/Polish.properties index fb492c9a..e83042ed 100644 --- a/android/assets/jsons/translations/Polish.properties +++ b/android/assets/jsons/translations/Polish.properties @@ -998,7 +998,8 @@ Provides a sum of gold each time you spend a Great Person = Otrzymujesz sumę z +2 Gold for each source of Marble and Stone = +2 do Złota za każde źródło Marmuru i Kamienia Mausoleum of Halicarnassus = Mauzoleum z Halikarnasu -+1 food from Ocean and Coast tiles = +1 do żywności z pól wybrzeża i oceanicznych + # Requires translation! +[stats] from [terrain] tiles = Lighthouse = Latarnia morska 'They that go down to the sea in ships, that do business in great waters; these see the works of the Lord, and his wonders in the deep.' - The Bible, Psalms 107:23-24 = 'Ci, którzy na statkach ruszyli na morze, aby uprawiać handel na ogromnych wodach, ci widzieli dzieła Pana i jego cuda wśród głębiny.'– Biblia, Księga Psalmów 107,23-24 diff --git a/android/assets/jsons/translations/Portuguese.properties b/android/assets/jsons/translations/Portuguese.properties index 95f5a740..997dcbb7 100644 --- a/android/assets/jsons/translations/Portuguese.properties +++ b/android/assets/jsons/translations/Portuguese.properties @@ -1053,7 +1053,8 @@ Provides a sum of gold each time you spend a Great Person = # Requires translation! Mausoleum of Halicarnassus = -+1 food from Ocean and Coast tiles = +1 de comida de regiões costeiras e oceânicas + # Requires translation! +[stats] from [terrain] tiles = Lighthouse = Farol 'They that go down to the sea in ships, that do business in great waters; these see the works of the Lord, and his wonders in the deep.' - The Bible, Psalms 107:23-24 = 'Os navios que descem no mar, negociam em grandes águas; estes vêem as obras do Senhor, e suas maravilhas nas profundezas.' - A Bíblia, Salmos 107:23-24 diff --git a/android/assets/jsons/translations/Romanian.properties b/android/assets/jsons/translations/Romanian.properties index 06d7e753..2432c31e 100644 --- a/android/assets/jsons/translations/Romanian.properties +++ b/android/assets/jsons/translations/Romanian.properties @@ -1058,7 +1058,8 @@ Provides a sum of gold each time you spend a Great Person = Oferă o sumă de au # Requires translation! Mausoleum of Halicarnassus = -+1 food from Ocean and Coast tiles = +1 hrană din celule ocean și de țărm + # Requires translation! +[stats] from [terrain] tiles = Lighthouse = Far 'They that go down to the sea in ships, that do business in great waters; these see the works of the Lord, and his wonders in the deep.' - The Bible, Psalms 107:23-24 = 'Cei ce se coborâseră pe mare în corăbii și făceau negoț pe apele cele mari, aceia au văzut lucrările Domnului și minunile Lui în mijlocul adâncului.' - Biblia, Psalmul 107:23-24 diff --git a/android/assets/jsons/translations/Russian.properties b/android/assets/jsons/translations/Russian.properties index b60f2fe5..a28a7def 100644 --- a/android/assets/jsons/translations/Russian.properties +++ b/android/assets/jsons/translations/Russian.properties @@ -965,7 +965,8 @@ Provides a sum of gold each time you spend a Great Person = Дает золот +2 Gold for each source of Marble and Stone = Каждая обрабатываемая городом клетка с Мрамором или Камнем дает +2 Золота Mausoleum of Halicarnassus = Галикарнасский мавзолей -+1 food from Ocean and Coast tiles = +1 Еда от клеток океана и берега + # Requires translation! +[stats] from [terrain] tiles = Lighthouse = Маяк 'They that go down to the sea in ships, that do business in great waters; these see the works of the Lord, and his wonders in the deep.' - The Bible, Psalms 107:23-24 = 'Отправляющиеся на кораблях в море, производящие дела на больших водах, видят дела Господа и чудеса Его в пучине...' - Псалтирь, Псалом 106: 23-24 diff --git a/android/assets/jsons/translations/Simplified_Chinese.properties b/android/assets/jsons/translations/Simplified_Chinese.properties index 3e8d7a89..94069de0 100644 --- a/android/assets/jsons/translations/Simplified_Chinese.properties +++ b/android/assets/jsons/translations/Simplified_Chinese.properties @@ -969,7 +969,8 @@ Provides a sum of gold each time you spend a Great Person = 每次消耗掉一 +2 Gold for each source of Marble and Stone = 所在城市开发的每处大理石或花岗石资源额外产出2金钱 Mausoleum of Halicarnassus = 摩索拉斯陵墓 -+1 food from Ocean and Coast tiles = 每个海滨地块和海洋地块+1食物 + # Requires translation! +[stats] from [terrain] tiles = Lighthouse = 灯塔 'They that go down to the sea in ships, that do business in great waters; these see the works of the Lord, and his wonders in the deep.' - The Bible, Psalms 107:23-24 = “在大海上坐船,在大水里经理事务的;他们看到耶和华的作为,并他在深水中的奇事。”——圣经·诗篇 107:23-24 diff --git a/android/assets/jsons/translations/Spanish.properties b/android/assets/jsons/translations/Spanish.properties index 83905fc4..ee69274d 100644 --- a/android/assets/jsons/translations/Spanish.properties +++ b/android/assets/jsons/translations/Spanish.properties @@ -971,7 +971,8 @@ Provides a sum of gold each time you spend a Great Person = Proporciona una suma +2 Gold for each source of Marble and Stone = +2 de oro por cada fuente de Mármol y Piedra Mausoleum of Halicarnassus = Mausoleo de Halicarnaso -+1 food from Ocean and Coast tiles = +1 de comida en casillas costeras o de Océano + # Requires translation! +[stats] from [terrain] tiles = Lighthouse = Faro 'They that go down to the sea in ships, that do business in great waters; these see the works of the Lord, and his wonders in the deep.' - The Bible, Psalms 107:23-24 = 'Los que surcan el mar en las naves para hacer su negocio en la inmensidad de las aguas también ven la obra de Yavé y sus maravillas en el piélago.' - La Biblia, Salmos 107: 23-24 diff --git a/android/assets/jsons/translations/Traditional_Chinese.properties b/android/assets/jsons/translations/Traditional_Chinese.properties index 6bf735d7..1900f71a 100644 --- a/android/assets/jsons/translations/Traditional_Chinese.properties +++ b/android/assets/jsons/translations/Traditional_Chinese.properties @@ -990,7 +990,8 @@ Provides a sum of gold each time you spend a Great Person = 每次消耗掉一 +2 Gold for each source of Marble and Stone = 所在城市開發的每處大理石或花崗石資源額外產出2金錢 Mausoleum of Halicarnassus = 摩索拉斯陵墓 -+1 food from Ocean and Coast tiles = 每個海濱地區和海洋地區+1食物 + # Requires translation! +[stats] from [terrain] tiles = Lighthouse = 燈塔 'They that go down to the sea in ships, that do business in great waters; these see the works of the Lord, and his wonders in the deep.' - The Bible, Psalms 107:23-24 = “在大海上坐船,在大水裡處理事物的;他們看到耶和華的作為,並他在深水中的奇事。”——聖經·詩篇 107:23-24 diff --git a/android/assets/jsons/translations/Turkish.properties b/android/assets/jsons/translations/Turkish.properties index 4ea25039..324a0360 100644 --- a/android/assets/jsons/translations/Turkish.properties +++ b/android/assets/jsons/translations/Turkish.properties @@ -1021,7 +1021,8 @@ Provides a sum of gold each time you spend a Great Person = +2 Gold for each source of Marble and Stone = Her Mermer ve Taş kaynağı için +2 Altın Mausoleum of Halicarnassus = Halikarnas Mozolesi -+1 food from Ocean and Coast tiles = Okyanus ve Sahil çinilerinden +1 yiyecek + # Requires translation! +[stats] from [terrain] tiles = Lighthouse = Deniz feneri 'They that go down to the sea in ships, that do business in great waters; these see the works of the Lord, and his wonders in the deep.' - The Bible, Psalms 107:23-24 = 'Gemilerde denize inen, büyük sularda iş yapan onlar; bunlar Rabbin ve harikalarını derinlerde görür. ' - İncil, Mezmurlar 107: 23-24 diff --git a/android/assets/jsons/translations/Ukrainian.properties b/android/assets/jsons/translations/Ukrainian.properties index aa8676cf..f94ad929 100644 --- a/android/assets/jsons/translations/Ukrainian.properties +++ b/android/assets/jsons/translations/Ukrainian.properties @@ -969,7 +969,8 @@ Provides a sum of gold each time you spend a Great Person = Забезпечує +2 Gold for each source of Marble and Stone = +2 золота за кожен Мармур та Камінь Mausoleum of Halicarnassus = Галікарнаський мавзолей -+1 food from Ocean and Coast tiles = +1 їжа з кожної океанської і прибережної клітинки + # Requires translation! +[stats] from [terrain] tiles = Lighthouse = Маяк 'They that go down to the sea in ships, that do business in great waters; these see the works of the Lord, and his wonders in the deep.' - The Bible, Psalms 107:23-24 = «Ті, хто по морю пливе кораблями, хто чинить зайняття своє на великій воді; вони бачили чини Господні та чуда Його в глибині!» — Біблія, Псалом 107:23-34. diff --git a/android/assets/jsons/translations/completionPercentages.properties b/android/assets/jsons/translations/completionPercentages.properties index 811a3811..c34b62fd 100644 --- a/android/assets/jsons/translations/completionPercentages.properties +++ b/android/assets/jsons/translations/completionPercentages.properties @@ -2,7 +2,7 @@ Brazilian_Portuguese = 72 Persian_(Pinglish-UN) = 26 Traditional_Chinese = 63 Italian = 99 -Polish = 96 +Polish = 95 Russian = 99 Lithuanian = 26 Romanian = 46 diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index 63a7da8c..93d4a69a 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -10,6 +10,8 @@ import com.unciv.logic.civilization.CivilizationInfo import com.unciv.models.ruleset.Ruleset import com.unciv.models.ruleset.tile.* import com.unciv.models.stats.Stats +import com.unciv.models.translations.equalsPlaceholderText +import com.unciv.models.translations.getPlaceholderParameters import com.unciv.models.translations.tr import kotlin.math.abs @@ -170,9 +172,14 @@ open class TileInfo { fun getTileStats(city: CityInfo?, observingCiv: CivilizationInfo): Stats { var stats = getBaseTerrain().clone() - if ((baseTerrain == Constants.ocean || baseTerrain == Constants.coast) && city != null - && city.containsBuildingUnique("+1 food from Ocean and Coast tiles")) - stats.food += 1 + if(city!=null) for(unique in city.getBuildingUniques()) { + if (unique.equalsPlaceholderText("[] from [] tiles")) { + val placeholderParams = unique.getPlaceholderParameters() + val tileType = placeholderParams[1] + if (baseTerrain == tileType || terrainFeature == tileType) + stats.add(Stats.parse(placeholderParams[0])) + } + } if (terrainFeature != null) { val terrainFeatureBase = getTerrainFeature() diff --git a/core/src/com/unciv/models/stats/Stats.kt b/core/src/com/unciv/models/stats/Stats.kt index effabf11..23a3c364 100644 --- a/core/src/com/unciv/models/stats/Stats.kt +++ b/core/src/com/unciv/models/stats/Stats.kt @@ -4,13 +4,13 @@ import com.unciv.models.translations.tr open class Stats() { - var production: Float=0f - var food: Float=0f - var gold: Float=0f - var science: Float=0f - var culture: Float=0f - var happiness: Float=0f - var faith: Float=0f + var production: Float = 0f + var food: Float = 0f + var gold: Float = 0f + var science: Float = 0f + var culture: Float = 0f + var happiness: Float = 0f + var faith: Float = 0f constructor(hashMap: HashMap) : this() { setStats(hashMap) @@ -38,9 +38,9 @@ open class Stats() { } - fun add(stat:Stat, value:Float): Stats { + fun add(stat: Stat, value: Float): Stats { val hashMap = toHashMap() - hashMap[stat] = hashMap[stat]!!+value + hashMap[stat] = hashMap[stat]!! + value setStats(hashMap) return this } @@ -59,13 +59,13 @@ open class Stats() { operator fun times(number: Float): Stats { val hashMap = toHashMap() - for(stat in Stat.values()) hashMap[stat]= number * hashMap[stat]!! + for (stat in Stat.values()) hashMap[stat] = number * hashMap[stat]!! return Stats(hashMap) } override fun toString(): String { return toHashMap().filter { it.value != 0f } - .map { (if(it.value>0)"+" else "") + it.value.toInt()+" "+it.key.toString().tr() }.joinToString() + .map { (if (it.value > 0) "+" else "") + it.value.toInt() + " " + it.key.toString().tr() }.joinToString() } fun toHashMap(): HashMap { @@ -79,11 +79,11 @@ open class Stats() { ) } - fun get(stat:Stat):Float{ + fun get(stat: Stat): Float { return this.toHashMap()[stat]!! } - private fun setStats(hashMap:HashMap) { + private fun setStats(hashMap: HashMap) { culture = hashMap[Stat.Culture]!! gold = hashMap[Stat.Gold]!! production = hashMap[Stat.Production]!! @@ -93,7 +93,7 @@ open class Stats() { faith = hashMap[Stat.Faith]!! } - fun equals(otherStats: Stats):Boolean { + fun equals(otherStats: Stats): Boolean { return culture == otherStats.culture && gold == otherStats.gold && production == otherStats.production @@ -102,6 +102,25 @@ open class Stats() { && science == otherStats.science && faith == otherStats.faith } + + companion object { + private val allStatNames = Stat.values().joinToString("|") { it.name } + private val statRegexPattern = "([+-])(\\d+) ($allStatNames)" + private val statRegex = Regex(statRegexPattern) + private val entireStringRegexPattern = Regex("$statRegexPattern(, $statRegexPattern)*") + fun isStats(string:String): Boolean = entireStringRegexPattern.matches(string) + fun parse(string:String):Stats{ + val toReturn = Stats() + val statsWithBonuses = string.split(", ") + for(statWithBonuses in statsWithBonuses){ + val match = statRegex.matchEntire(statWithBonuses)!! + val statName = match.groupValues[3] + val statAmount = match.groupValues[2].toFloat() * (if(match.groupValues[1]=="-") -1 else 1) + toReturn.add(Stat.valueOf(statName), statAmount) + } + return toReturn + } + } } class StatMap:LinkedHashMap(){ diff --git a/core/src/com/unciv/models/translations/TranslationFileWriter.kt b/core/src/com/unciv/models/translations/TranslationFileWriter.kt index 35d17905..43cd92ae 100644 --- a/core/src/com/unciv/models/translations/TranslationFileWriter.kt +++ b/core/src/com/unciv/models/translations/TranslationFileWriter.kt @@ -14,6 +14,7 @@ import com.unciv.models.ruleset.tile.TileImprovement import com.unciv.models.ruleset.tile.TileResource import com.unciv.models.ruleset.unit.BaseUnit import com.unciv.models.ruleset.unit.Promotion +import com.unciv.models.stats.Stats import com.unciv.ui.worldscreen.unit.UnitActions import java.lang.reflect.Field @@ -198,13 +199,14 @@ object TranslationFileWriter { var stringToTranslate = string if (parameters.any()){ for(parameter in parameters) { - val parameterName = when{ + val parameterName = when { parameter.toIntOrNull() != null -> "amount" RulesetCache.getBaseRuleset().terrains.containsKey(parameter) -> "terrain" RulesetCache.getBaseRuleset().units.containsKey(parameter) -> "unit" + Stats.isStats(parameter) -> "stats" else -> "param" } - stringToTranslate = string.replace(parameters[0], parameterName) + stringToTranslate = stringToTranslate.replace(parameter, parameterName) } } diff --git a/core/src/com/unciv/models/translations/Translations.kt b/core/src/com/unciv/models/translations/Translations.kt index 1adc3c4d..556540c1 100644 --- a/core/src/com/unciv/models/translations/Translations.kt +++ b/core/src/com/unciv/models/translations/Translations.kt @@ -2,6 +2,7 @@ package com.unciv.models.translations import com.badlogic.gdx.Gdx import com.unciv.UncivGame +import com.unciv.models.stats.Stats import java.util.* import kotlin.collections.HashMap @@ -178,14 +179,14 @@ class Translations : LinkedHashMap(){ companion object { // Regex compilation is expensive, best to save it val bonusOrPenaltyRegex = Regex("""(Bonus|Penalty) vs (.*) (\d*)%""") - fun translateBonusOrPenalty(unique:String): String { + fun translateBonusOrPenalty(unique: String): String { val regexResult = bonusOrPenaltyRegex.matchEntire(unique) - if(regexResult==null) return unique.tr() - else{ + if (regexResult == null) return unique.tr() + else { var separatorCharacter = " " - if (UncivGame.Current.settings.language=="Simplified_Chinese") separatorCharacter = "" - val start = regexResult.groups[1]!!.value+" vs ["+regexResult.groups[2]!!.value+"]" - val translatedUnique = start.tr() + separatorCharacter + regexResult.groups[3]!!.value+"%" + if (UncivGame.Current.settings.language == "Simplified_Chinese") separatorCharacter = "" + val start = regexResult.groups[1]!!.value + " vs [" + regexResult.groups[2]!!.value + "]" + val translatedUnique = start.tr() + separatorCharacter + regexResult.groups[3]!!.value + "%" return translatedUnique } } @@ -269,6 +270,8 @@ fun String.tr(): String { return curlyBraceRegex.replace(this) { it.groups[1]!!.value.tr() } } + if (Stats.isStats(this)) return Stats.parse(this).toString() + return UncivGame.Current.translations.getText(this, UncivGame.Current.settings.language, activeMods) } diff --git a/tests/src/com/unciv/testing/BasicTests.kt b/tests/src/com/unciv/testing/BasicTests.kt index c157484d..15b85c1d 100644 --- a/tests/src/com/unciv/testing/BasicTests.kt +++ b/tests/src/com/unciv/testing/BasicTests.kt @@ -4,9 +4,13 @@ package com.unciv.testing import com.badlogic.gdx.Gdx import com.unciv.UncivGame import com.unciv.UncivGameParameters +import com.unciv.models.metadata.GameSettings import com.unciv.models.ruleset.Ruleset import com.unciv.models.ruleset.RulesetCache import com.unciv.models.ruleset.unit.BaseUnit +import com.unciv.models.stats.Stat +import com.unciv.models.stats.Stats +import com.unciv.models.translations.tr import org.junit.Assert import org.junit.Before import org.junit.Test @@ -60,4 +64,19 @@ class BasicTests { } Assert.assertTrue(allObsoletingUnitsHaveUpgrades) } + + @Test + fun statParserWorks(){ + Assert.assertTrue(Stats.isStats("+1 Production")) + Assert.assertTrue(Stats.isStats("+1 Gold, +2 Production")) + Assert.assertFalse(Stats.isStats("+1 Gold from tree")) + + val statsThatShouldBe = Stats().add(Stat.Gold,1f).add(Stat.Production, 2f) + Assert.assertTrue(Stats.parse("+1 Gold, +2 Production").equals(statsThatShouldBe)) + + UncivGame.Current = UncivGame("") + UncivGame.Current.settings = GameSettings().apply { language = "Italian" } + val x = "+1 Gold, +2 Production".tr() + print(x) + } } \ No newline at end of file