From cd58f6ace8c8967c4f16b8ca6d5f08d5f4c5d598 Mon Sep 17 00:00:00 2001 From: Aron de Jong Date: Mon, 7 Jun 2021 21:04:33 +0200 Subject: [PATCH] Refund wasted production as gold (#4058) * Refund wasted production as gold Any wasted production, from for instance a partially completed wonder or obsolete units, will now be refunded as gold (in a 1:1 ratio). We update both at the start and end of the user turn. Updating at the start to account for wonders completed after our previous turn and updating at the end to account for obsolete buildings/units as a consequence of our own turn. When obsolete units get replaced by their upgraded version (as in civ 5) this code should probably be updated. * Implement wonder refund and obsolete unit upgrade If a wonder is built somewhere else but the user has production in this wonder, the production will be refunded as gold in a 1:1 ratio. A notification will be shown to indicate this. This reflects the behaviour in Civ 5. If a unit becomes obsolete and an upgrade is available, the production put into this unit will now be transferred to the upgraded version. If the unit is queued, the queued unit will also be changed to the new version and the user will be notified via notification. * Shorten notification messages * Update alerts: been obsolete -> become obsolete --- .../Brazilian_Portuguese.properties | 2 +- .../jsons/translations/Bulgarian.properties | 2 +- .../jsons/translations/Czech.properties | 2 +- .../jsons/translations/Dutch.properties | 6 ++- .../jsons/translations/English.properties | 2 +- .../jsons/translations/Finnish.properties | 2 +- .../jsons/translations/French.properties | 2 +- .../jsons/translations/German.properties | 2 +- .../jsons/translations/Hungarian.properties | 2 +- .../jsons/translations/Indonesian.properties | 2 +- .../jsons/translations/Italian.properties | 2 +- .../jsons/translations/Japanese.properties | 2 +- .../jsons/translations/Korean.properties | 2 +- .../jsons/translations/Lithuanian.properties | 2 +- .../jsons/translations/Malay.properties | 2 +- .../Persian_(Pinglish-DIN).properties | 2 +- .../Persian_(Pinglish-UN).properties | 2 +- .../jsons/translations/Polish.properties | 2 +- .../jsons/translations/Portuguese.properties | 2 +- .../jsons/translations/Romanian.properties | 2 +- .../jsons/translations/Russian.properties | 2 +- .../Simplified_Chinese.properties | 2 +- .../jsons/translations/Spanish.properties | 2 +- .../jsons/translations/Swedish.properties | 2 +- .../Traditional_Chinese.properties | 2 +- .../jsons/translations/Turkish.properties | 2 +- .../jsons/translations/Ukrainian.properties | 2 +- .../jsons/translations/Vietnamese.properties | 2 +- .../jsons/translations/template.properties | 6 ++- .../com/unciv/logic/city/CityConstructions.kt | 38 +++++++++++++++---- .../unciv/logic/civilization/TechManager.kt | 37 +++++++++++++++++- 31 files changed, 103 insertions(+), 38 deletions(-) diff --git a/android/assets/jsons/translations/Brazilian_Portuguese.properties b/android/assets/jsons/translations/Brazilian_Portuguese.properties index 3cd2bba16b..f28b4aa443 100644 --- a/android/assets/jsons/translations/Brazilian_Portuguese.properties +++ b/android/assets/jsons/translations/Brazilian_Portuguese.properties @@ -406,7 +406,7 @@ Locate mod errors = # Notifications Research of [technologyName] has completed! = A pesquisa de [technologyName] foi terminada! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = A [construction] está obsoleta e será removida da fila de construção em [cityName]! +[construction] has become obsolete and was removed from the queue in [cityName]! = A [construction] está obsoleta e será removida da fila de construção em [cityName]! You have entered a Golden Age! = Você entrou em uma idade de ouro! [resourceName] revealed near [cityName] = [resourceName] revelado perto de [cityName] # Requires translation! diff --git a/android/assets/jsons/translations/Bulgarian.properties b/android/assets/jsons/translations/Bulgarian.properties index dd819c94df..8ccb694d0e 100644 --- a/android/assets/jsons/translations/Bulgarian.properties +++ b/android/assets/jsons/translations/Bulgarian.properties @@ -398,7 +398,7 @@ Locate mod errors = Намиране на грешки в мод # Notifications Research of [technologyName] has completed! = Развитието на [technologyName] е готово! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = [construction] е твърде стара и ще бъде премахната от предстоящите разработки в [cityName]! +[construction] has become obsolete and was removed from the queue in [cityName]! = [construction] е твърде стара и ще бъде премахната от предстоящите разработки в [cityName]! You have entered a Golden Age! = Навлизате в Златна Ера! [resourceName] revealed near [cityName] = [resourceName] се разкри близо до [cityName] # Requires translation! diff --git a/android/assets/jsons/translations/Czech.properties b/android/assets/jsons/translations/Czech.properties index a0d58fdc5a..1f0f2bdbe5 100644 --- a/android/assets/jsons/translations/Czech.properties +++ b/android/assets/jsons/translations/Czech.properties @@ -395,7 +395,7 @@ Locate mod errors = Lokalizovat chyby modu # Notifications Research of [technologyName] has completed! = Výzkum technologie [technologyName] byl dokončen! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = Položka [construction] je zastaralá a bude odstraněna z fronty ve městě [cityName]! +[construction] has become obsolete and was removed from the queue in [cityName]! = Položka [construction] je zastaralá a bude odstraněna z fronty ve městě [cityName]! You have entered a Golden Age! = Započal Zlatý věk civilizace! [resourceName] revealed near [cityName] = Surovina [resourceName] objevena poblíž [cityName] # Requires translation! diff --git a/android/assets/jsons/translations/Dutch.properties b/android/assets/jsons/translations/Dutch.properties index a5398d65a0..d3db593621 100644 --- a/android/assets/jsons/translations/Dutch.properties +++ b/android/assets/jsons/translations/Dutch.properties @@ -395,7 +395,11 @@ Locate mod errors = Zoek fouten in mods # Notifications Research of [technologyName] has completed! = [technologyName] is onderzocht! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = [construction] werd overbodig en zal verwijderd worden van de bouwwerkwachtrij in [cityName]! +[construction] has become obsolete and was removed from the queue in [cityName]! = [construction] is overbodig geworden en in [cityName] van de wachtrij verwijderd! +[construction] has become obsolete and was removed from the queue in [amount] cities! = [construction] is overbodig geworden en in [amount] steden van de wachtrij verwijderd! +[cityName] changed production from [oldUnit] to [newUnit] = [cityName] heeft [oldUnit] productie omgezet in [newUnit] productie +[amount] cities changed production from [oldUnit] to [newUnit] = [amount] steden hebben productie van [oldUnit] in [newUnit] veranderdt +Excess production for [wonder] converted to [goldAmount] gold = Productie voor [wonder] omgezet naar [goldAmount] goud You have entered a Golden Age! = Een gouden eeuw is geariveerd! [resourceName] revealed near [cityName] = [resourceName] Ontdekt: in de buurt van [cityName] # Requires translation! diff --git a/android/assets/jsons/translations/English.properties b/android/assets/jsons/translations/English.properties index cb1e5c6071..8c971f4685 100644 --- a/android/assets/jsons/translations/English.properties +++ b/android/assets/jsons/translations/English.properties @@ -713,7 +713,7 @@ Locate mod errors = # Requires translation! Research of [technologyName] has completed! = # Requires translation! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = +[construction] has become obsolete and was removed from the queue in [cityName]! = # Requires translation! You have entered a Golden Age! = # Requires translation! diff --git a/android/assets/jsons/translations/Finnish.properties b/android/assets/jsons/translations/Finnish.properties index c2e0de18a2..7d62eb9f32 100644 --- a/android/assets/jsons/translations/Finnish.properties +++ b/android/assets/jsons/translations/Finnish.properties @@ -422,7 +422,7 @@ Locate mod errors = Research of [technologyName] has completed! = [technologyName] tutkittiin! # Requires translation! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = +[construction] has become obsolete and was removed from the queue in [cityName]! = You have entered a Golden Age! = Sinulla on alkanut Kultakausi! [resourceName] revealed near [cityName] = [resourceName] paljastui lähellä [cityName] # Requires translation! diff --git a/android/assets/jsons/translations/French.properties b/android/assets/jsons/translations/French.properties index eaa6ae1816..097573a1f1 100644 --- a/android/assets/jsons/translations/French.properties +++ b/android/assets/jsons/translations/French.properties @@ -397,7 +397,7 @@ Locate mod errors = Localise les erreurs dans les mods # Notifications Research of [technologyName] has completed! = Recherche de [technologyName] terminé ! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = [construction] est obsolete et va être retiré de la queue de construction de [cityName] ! +[construction] has become obsolete and was removed from the queue in [cityName]! = [construction] est obsolete et va être retiré de la queue de construction de [cityName] ! You have entered a Golden Age! = Vous êtes entré dans un Âge d'Or ! [resourceName] revealed near [cityName] = [resourceName] découvert près de [cityName] # Requires translation! diff --git a/android/assets/jsons/translations/German.properties b/android/assets/jsons/translations/German.properties index 2d2ef5b36b..c7ab973baf 100644 --- a/android/assets/jsons/translations/German.properties +++ b/android/assets/jsons/translations/German.properties @@ -387,7 +387,7 @@ Locate mod errors = Mod-Fehler lokalisieren # Notifications Research of [technologyName] has completed! = [technologyName] wurde erforscht! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = [construction] ist veraltet und wird aus der Bauwerke-Warteschlange in [cityName] gelöscht! +[construction] has become obsolete and was removed from the queue in [cityName]! = [construction] ist veraltet und wird aus der Bauwerke-Warteschlange in [cityName] gelöscht! You have entered a Golden Age! = Ein Goldenes Zeitalter hat begonnen! [resourceName] revealed near [cityName] = [resourceName] gefunden in der Nähe von [cityName] [n] sources of [resourceName] revealed, e.g. near [cityName] = [n] Vorkommen von [resourceName] aufgetaucht, z.B. nahe [cityName] diff --git a/android/assets/jsons/translations/Hungarian.properties b/android/assets/jsons/translations/Hungarian.properties index 2da0bbbe56..f3831072c1 100644 --- a/android/assets/jsons/translations/Hungarian.properties +++ b/android/assets/jsons/translations/Hungarian.properties @@ -404,7 +404,7 @@ Locate mod errors = # Notifications Research of [technologyName] has completed! = [technologyName] kutatása kész! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = [construction] termelése elavult és eltávolításra kerül [cityName] termelési sorából! +[construction] has become obsolete and was removed from the queue in [cityName]! = [construction] termelése elavult és eltávolításra kerül [cityName] termelési sorából! You have entered a Golden Age! = Aranykorba léptél! [resourceName] revealed near [cityName] = [resourceName] tűnt fel [cityName] mellett # Requires translation! diff --git a/android/assets/jsons/translations/Indonesian.properties b/android/assets/jsons/translations/Indonesian.properties index 9ae0380a5d..349f5bc055 100644 --- a/android/assets/jsons/translations/Indonesian.properties +++ b/android/assets/jsons/translations/Indonesian.properties @@ -383,7 +383,7 @@ Locate mod errors = Temukan eror mod # Notifications Research of [technologyName] has completed! = Riset untuk [technologyName] sudah selesai -[construction] has been obsolete and will be removed from construction queue in [cityName]! = [construction] sudah ketinggalan zaman dan akan dihapus dari antrean konstruksi di [cityName]! +[construction] has become obsolete and was removed from the queue in [cityName]! = [construction] sudah ketinggalan zaman dan akan dihapus dari antrean konstruksi di [cityName]! You have entered a Golden Age! = Kamu telah memasuki masa kejayaan! [resourceName] revealed near [cityName] = [resourceName] terlihat di dekat [cityName] [n] sources of [resourceName] revealed, e.g. near [cityName] = [n] sumber daya [resourceName] ditemukan, salah satunya di dekat [cityName] diff --git a/android/assets/jsons/translations/Italian.properties b/android/assets/jsons/translations/Italian.properties index 1384881ae8..08de2511e4 100644 --- a/android/assets/jsons/translations/Italian.properties +++ b/android/assets/jsons/translations/Italian.properties @@ -383,7 +383,7 @@ Locate mod errors = Trova errori di mod # Notifications Research of [technologyName] has completed! = Abbiamo scoperto la tecnologia [technologyName]! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = [cityName] non può più costruire [construction]! +[construction] has become obsolete and was removed from the queue in [cityName]! = [cityName] non può più costruire [construction]! You have entered a Golden Age! = È iniziata un'Età dell'Oro! [resourceName] revealed near [cityName] = Fonte di [resourceName] scoperta vicino a [cityName] [n] sources of [resourceName] revealed, e.g. near [cityName] = [n] fonti di [resourceName] scoperte nei pressi di [cityName] diff --git a/android/assets/jsons/translations/Japanese.properties b/android/assets/jsons/translations/Japanese.properties index e712ca5246..540a3f4072 100644 --- a/android/assets/jsons/translations/Japanese.properties +++ b/android/assets/jsons/translations/Japanese.properties @@ -395,7 +395,7 @@ Locate mod errors = modのエラーを検出 # Notifications Research of [technologyName] has completed! = [technologyName]の研究が完了 -[construction] has been obsolete and will be removed from construction queue in [cityName]! = [construction]は廃止され、[cityName]の建設キューから削除されます +[construction] has become obsolete and was removed from the queue in [cityName]! = [construction]は廃止され、[cityName]の建設キューから削除されます You have entered a Golden Age! = あなたは黄金時代に入りました [resourceName] revealed near [cityName] = [cityName]の近くに[resourceName]が表れました # Requires translation! diff --git a/android/assets/jsons/translations/Korean.properties b/android/assets/jsons/translations/Korean.properties index 6fbe11142a..28bf20eeba 100644 --- a/android/assets/jsons/translations/Korean.properties +++ b/android/assets/jsons/translations/Korean.properties @@ -406,7 +406,7 @@ Locate mod errors = # Notifications Research of [technologyName] has completed! = [technologyName]의 연구가 끝났습니다! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = [construction]이(가) 쇠퇴하여 [cityName]의 대기열에서 삭제되었습니다! +[construction] has become obsolete and was removed from the queue in [cityName]! = [construction]이(가) 쇠퇴하여 [cityName]의 대기열에서 삭제되었습니다! You have entered a Golden Age! = 황금기가 시작되었습니다! [resourceName] revealed near [cityName] = [cityName] 주변에서 [resourceName] 자원을 발견했습니다 # Requires translation! diff --git a/android/assets/jsons/translations/Lithuanian.properties b/android/assets/jsons/translations/Lithuanian.properties index 24addd8077..d35a4e9ea3 100644 --- a/android/assets/jsons/translations/Lithuanian.properties +++ b/android/assets/jsons/translations/Lithuanian.properties @@ -428,7 +428,7 @@ Locate mod errors = Research of [technologyName] has completed! = [technologyName] tyrimas baigtas! # Requires translation! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = +[construction] has become obsolete and was removed from the queue in [cityName]! = You have entered a Golden Age! = Jūs įžengėte į aukso amžių! [resourceName] revealed near [cityName] = [resourceName] parodytas šalia [cityName] # Requires translation! diff --git a/android/assets/jsons/translations/Malay.properties b/android/assets/jsons/translations/Malay.properties index 8b271fd3e9..4e1ec68116 100644 --- a/android/assets/jsons/translations/Malay.properties +++ b/android/assets/jsons/translations/Malay.properties @@ -484,7 +484,7 @@ Locate mod errors = # Requires translation! Research of [technologyName] has completed! = # Requires translation! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = +[construction] has become obsolete and was removed from the queue in [cityName]! = # Requires translation! You have entered a Golden Age! = # Requires translation! diff --git a/android/assets/jsons/translations/Persian_(Pinglish-DIN).properties b/android/assets/jsons/translations/Persian_(Pinglish-DIN).properties index e0a0cc2ce8..cbfb149cb7 100644 --- a/android/assets/jsons/translations/Persian_(Pinglish-DIN).properties +++ b/android/assets/jsons/translations/Persian_(Pinglish-DIN).properties @@ -419,7 +419,7 @@ Locate mod errors = Research of [technologyName] has completed! = Tahğig darbāre ye [technologyName] be natije resid! # Requires translation! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = +[construction] has become obsolete and was removed from the queue in [cityName]! = You have entered a Golden Age! = Šomā vāred e yek asr e talāi šodid! [resourceName] revealed near [cityName] = [resourceName] kenār e [cityName] peydā šode ast # Requires translation! diff --git a/android/assets/jsons/translations/Persian_(Pinglish-UN).properties b/android/assets/jsons/translations/Persian_(Pinglish-UN).properties index ed7c32750f..fa69b17ac8 100644 --- a/android/assets/jsons/translations/Persian_(Pinglish-UN).properties +++ b/android/assets/jsons/translations/Persian_(Pinglish-UN).properties @@ -416,7 +416,7 @@ Locate mod errors = Research of [technologyName] has completed! = Tahghig darbaare ye [technologyName] be natije resid! # Requires translation! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = +[construction] has become obsolete and was removed from the queue in [cityName]! = You have entered a Golden Age! = Shomaa vaared e yek asr e talaai shodid! [resourceName] revealed near [cityName] = [resourceName] kenaar e [cityName] peydaa shode ast # Requires translation! diff --git a/android/assets/jsons/translations/Polish.properties b/android/assets/jsons/translations/Polish.properties index 4cd40418ca..60bb2c4f99 100644 --- a/android/assets/jsons/translations/Polish.properties +++ b/android/assets/jsons/translations/Polish.properties @@ -397,7 +397,7 @@ Locate mod errors = Zlokalizuj błędy modyfikacji # Notifications Research of [technologyName] has completed! = Ukończono badania: [technologyName]! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = [construction] - jest teraz przestarzały i zostanie usunięty z kolejki produkcji w mieście [cityName]! +[construction] has become obsolete and was removed from the queue in [cityName]! = [construction] - jest teraz przestarzały i zostanie usunięty z kolejki produkcji w mieście [cityName]! You have entered a Golden Age! = Wkraczasz w Złotą Erę! [resourceName] revealed near [cityName] = Odkryto [resourceName] w pobliżu [cityName] # Requires translation! diff --git a/android/assets/jsons/translations/Portuguese.properties b/android/assets/jsons/translations/Portuguese.properties index c1348a6757..cf8292e8e8 100644 --- a/android/assets/jsons/translations/Portuguese.properties +++ b/android/assets/jsons/translations/Portuguese.properties @@ -400,7 +400,7 @@ Locate mod errors = # Notifications Research of [technologyName] has completed! = A pesquisa de [technologyName] foi terminada! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = [construction] está obsoleta e será removida da fila de construção em [cityName]! +[construction] has become obsolete and was removed from the queue in [cityName]! = [construction] está obsoleta e será removida da fila de construção em [cityName]! You have entered a Golden Age! = Você entrou em uma idade dourada! [resourceName] revealed near [cityName] = [resourceName] revelado perto de [cityName] # Requires translation! diff --git a/android/assets/jsons/translations/Romanian.properties b/android/assets/jsons/translations/Romanian.properties index 540b4bfe5e..64e941166c 100644 --- a/android/assets/jsons/translations/Romanian.properties +++ b/android/assets/jsons/translations/Romanian.properties @@ -427,7 +427,7 @@ Locate mod errors = Research of [technologyName] has completed! = Cercetarea pentru [technologyName] s-a încheiat! # Requires translation! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = +[construction] has become obsolete and was removed from the queue in [cityName]! = You have entered a Golden Age! = Ai intrat într-o epocă de aur! [resourceName] revealed near [cityName] = [resourceName] a fost dezvăluit lângă [cityName] # Requires translation! diff --git a/android/assets/jsons/translations/Russian.properties b/android/assets/jsons/translations/Russian.properties index bb2b297ec4..87adb6f79a 100644 --- a/android/assets/jsons/translations/Russian.properties +++ b/android/assets/jsons/translations/Russian.properties @@ -393,7 +393,7 @@ Locate mod errors = Ошибка в расположении мода # Notifications Research of [technologyName] has completed! = Исследование завершено: [technologyName] -[construction] has been obsolete and will be removed from construction queue in [cityName]! = Юнит [construction] устарел и был убран из очереди в городе [cityName]! +[construction] has become obsolete and was removed from the queue in [cityName]! = Юнит [construction] устарел и был убран из очереди в городе [cityName]! You have entered a Golden Age! = Вы вошли в золотой век! [resourceName] revealed near [cityName] = Ресурс [resourceName] обнаружен вблизи г. [cityName] # Requires translation! diff --git a/android/assets/jsons/translations/Simplified_Chinese.properties b/android/assets/jsons/translations/Simplified_Chinese.properties index 7fb14160c9..5ca8ec76f1 100644 --- a/android/assets/jsons/translations/Simplified_Chinese.properties +++ b/android/assets/jsons/translations/Simplified_Chinese.properties @@ -388,7 +388,7 @@ Locate mod errors = 定位模组错误 # Notifications Research of [technologyName] has completed! = [technologyName]的研究已完成! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = [construction]已经过时,将从[cityName]里的建设列队中移除! +[construction] has become obsolete and was removed from the queue in [cityName]! = [construction]已经过时,将从[cityName]里的建设列队中移除! You have entered a Golden Age! = 你开启了一个黄金时代! [resourceName] revealed near [cityName] = 我们在[cityName]附近发现了[resourceName] # Requires translation! diff --git a/android/assets/jsons/translations/Spanish.properties b/android/assets/jsons/translations/Spanish.properties index 83b656e674..4287293463 100644 --- a/android/assets/jsons/translations/Spanish.properties +++ b/android/assets/jsons/translations/Spanish.properties @@ -383,7 +383,7 @@ Locate mod errors = Encontrar errores en mods # Notifications Research of [technologyName] has completed! = ¡Investigación de [technologyName] completada! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = ¡[construction] ha quedado obsoleta y se eliminará de la cola de obras en [cityName] +[construction] has become obsolete and was removed from the queue in [cityName]! = ¡[construction] ha quedado obsoleta y se eliminará de la cola de obras en [cityName] You have entered a Golden Age! = ¡Has entrado en una edad dorada! [resourceName] revealed near [cityName] = [resourceName] descubierto cerca de [cityName] [n] sources of [resourceName] revealed, e.g. near [cityName] = [n] fuentes de [resourceName] reveladas, e.j. cerca de [cityName] diff --git a/android/assets/jsons/translations/Swedish.properties b/android/assets/jsons/translations/Swedish.properties index c502454972..68343496aa 100644 --- a/android/assets/jsons/translations/Swedish.properties +++ b/android/assets/jsons/translations/Swedish.properties @@ -388,7 +388,7 @@ Locate mod errors = Hitta modfel # Notifications Research of [technologyName] has completed! = Forskning i [technologyName] fullbordat! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = [construction] är föråldrad och kommer tas bort från byggnadskön i [cityName]! +[construction] has become obsolete and was removed from the queue in [cityName]! = [construction] är föråldrad och kommer tas bort från byggnadskön i [cityName]! You have entered a Golden Age! = Du har gått in i en Guldålder! [resourceName] revealed near [cityName] = [resourceName] upptäckt nära [cityName] [n] sources of [resourceName] revealed, e.g. near [cityName] = [n] källor till [resourceName] upptäckta, t ex nära [cityName] diff --git a/android/assets/jsons/translations/Traditional_Chinese.properties b/android/assets/jsons/translations/Traditional_Chinese.properties index df11093513..0d9fde6b0c 100644 --- a/android/assets/jsons/translations/Traditional_Chinese.properties +++ b/android/assets/jsons/translations/Traditional_Chinese.properties @@ -395,7 +395,7 @@ Locate mod errors = 定位模組錯誤 # Notifications Research of [technologyName] has completed! = [technologyName]的研究已完成! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = [construction]已經過時,將從[cityName]裡的建設列隊中移除! +[construction] has become obsolete and was removed from the queue in [cityName]! = [construction]已經過時,將從[cityName]裡的建設列隊中移除! You have entered a Golden Age! = 你開啟了一個黃金時代! [resourceName] revealed near [cityName] = 我們在[cityName]附近發現了[resourceName] # Requires translation! diff --git a/android/assets/jsons/translations/Turkish.properties b/android/assets/jsons/translations/Turkish.properties index bae899fdd0..4e490d14c7 100644 --- a/android/assets/jsons/translations/Turkish.properties +++ b/android/assets/jsons/translations/Turkish.properties @@ -392,7 +392,7 @@ Locate mod errors = Mod hatalarını bulun # Notifications Research of [technologyName] has completed! = [technologyName] araştırması tamamlandı! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = [construction] yapısı eskidi, [cityName] şehrindeki inşaat sırasından kaldırılacak! +[construction] has become obsolete and was removed from the queue in [cityName]! = [construction] yapısı eskidi, [cityName] şehrindeki inşaat sırasından kaldırılacak! You have entered a Golden Age! = Altın Çağ'a girdiniz! [resourceName] revealed near [cityName] = [resourceName], [cityName] yakınlarında görüldü # Requires translation! diff --git a/android/assets/jsons/translations/Ukrainian.properties b/android/assets/jsons/translations/Ukrainian.properties index 5d5246d028..ca772ced0f 100644 --- a/android/assets/jsons/translations/Ukrainian.properties +++ b/android/assets/jsons/translations/Ukrainian.properties @@ -397,7 +397,7 @@ Locate mod errors = Знайти помилки модифікації # Notifications Research of [technologyName] has completed! = [technologyName]: досліджено! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = Підрозділ «[construction]» застарів та був видалений з черги у місті [cityName]! +[construction] has become obsolete and was removed from the queue in [cityName]! = Підрозділ «[construction]» застарів та був видалений з черги у місті [cityName]! You have entered a Golden Age! = Розпочалась Золота доба! [resourceName] revealed near [cityName] = [resourceName] виявлено біля [cityName] # Requires translation! diff --git a/android/assets/jsons/translations/Vietnamese.properties b/android/assets/jsons/translations/Vietnamese.properties index 99b5cbed86..8a6e68f66b 100644 --- a/android/assets/jsons/translations/Vietnamese.properties +++ b/android/assets/jsons/translations/Vietnamese.properties @@ -418,7 +418,7 @@ Translation files are generated successfully. = Các tệp dịch thuật đã # Notifications Research of [technologyName] has completed! = [technologyName] đã được nguyên cứu thành công! -[construction] has been obsolete and will be removed from construction queue in [cityName]! = [construction] đã lỗi thời và sẽ được hủy bỏ trong hàng chờ thi công tại [cityName]! +[construction] has become obsolete and was removed from the queue in [cityName]! = [construction] đã lỗi thời và sẽ được hủy bỏ trong hàng chờ thi công tại [cityName]! You have entered a Golden Age! = Bạn đã bước vào Thời kì Hoàng kim! [resourceName] revealed near [cityName] = [resourceName] được hiện lên gần [cityName] A [greatPerson] has been born in [cityName]! = Một [greatPerson] đã được sinh ra ở [cityName]! diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index a202a4144f..92d302c092 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -384,7 +384,11 @@ Locate mod errors = # Notifications Research of [technologyName] has completed! = -[construction] has been obsolete and will be removed from construction queue in [cityName]! = +[construction] has become obsolete and was removed from the queue in [cityName]! = +[construction] has become obsolete and was removed from the queue in [amount] cities! = +[cityName] changed production from [oldUnit] to [newUnit] = +[amount] cities changed production from [oldUnit] to [newUnit] = +Excess production for [wonder] converted to [goldAmount] gold = You have entered a Golden Age! = [resourceName] revealed near [cityName] = [n] sources of [resourceName] revealed, e.g. near [cityName] = diff --git a/core/src/com/unciv/logic/city/CityConstructions.kt b/core/src/com/unciv/logic/city/CityConstructions.kt index 3f11dc9330..6d406b4a3d 100644 --- a/core/src/com/unciv/logic/city/CityConstructions.kt +++ b/core/src/com/unciv/logic/city/CityConstructions.kt @@ -272,6 +272,9 @@ class CityConstructions { fun constructIfEnough() { validateConstructionQueue() + // Update InProgressConstructions for any available refunds + validateInProgressConstructions() + val construction = getConstruction(currentConstructionFromQueue) if (construction is PerpetualConstruction) chooseNextConstruction() // check every turn if we could be doing something better, because this doesn't end by itself else { @@ -296,20 +299,21 @@ class CityConstructions { val queueSnapshot = constructionQueue.toMutableList() constructionQueue.clear() - for (construction in queueSnapshot) { - if (getConstruction(construction).isBuildable(this)) - constructionQueue.add(construction) + for (constructionName in queueSnapshot) { + if (getConstruction(constructionName).isBuildable(this)) + constructionQueue.add(constructionName) } } private fun validateInProgressConstructions() { // remove obsolete stuff from in progress constructions - happens often and leaves clutter in memory and save files - // should have NO visible consequences - any accumulated points that may be reused later should stay (nukes when manhattan project city lost, nat wonder when conquered an empty city...) - // Needs only be called once in a while - endTurn is enough + // should have little visible consequences - any accumulated points that may be reused later should stay (nukes when manhattan project city lost, nat wonder when conquered an empty city...), all other points should be refunded + // Should at least be called before each turn - if another civ completes a wonder after our previous turn, we should get the refund this turn val inProgressSnapshot = inProgressConstructions.keys.filter { it != currentConstructionFromQueue } for (constructionName in inProgressSnapshot) { + val construction = getConstruction(constructionName) val rejectionReason: String = - when (val construction = getConstruction(constructionName)) { + when (construction) { is Building -> construction.getRejectionReason(this) is BaseUnit -> construction.getRejectionReason(this) else -> "" @@ -319,7 +323,27 @@ class CityConstructions { || rejectionReason.startsWith("Cannot be built with") || rejectionReason.startsWith("Don't need to build any more") || rejectionReason.startsWith("Obsolete") - ) inProgressConstructions.remove(constructionName) + ) { + if (construction is Building) { + // Production put into wonders gets refunded + if (construction.isWonder && getWorkDone(constructionName) != 0) { + cityInfo.civInfo.gold += getWorkDone(constructionName) + val buildingIcon = "BuildingIcons/${constructionName}" + cityInfo.civInfo.addNotification("Excess production for [$constructionName] converted to [${getWorkDone(constructionName)}] gold", NotificationIcon.Gold, buildingIcon) + } + } else if (construction is BaseUnit) { + // Production put into upgradable units gets put into upgraded version + if (rejectionReason.startsWith("Obsolete") && construction.upgradesTo != null) { + // I'd love to use the '+=' operator but since 'inProgressConstructions[...]' can be null, kotlin doesn't allow me to + if (!inProgressConstructions.contains(construction.upgradesTo)) { + inProgressConstructions[construction.upgradesTo!!] = getWorkDone(constructionName) + } else { + inProgressConstructions[construction.upgradesTo!!] = inProgressConstructions[construction.upgradesTo!!]!! + getWorkDone(constructionName) + } + } + } + inProgressConstructions.remove(constructionName) + } } } diff --git a/core/src/com/unciv/logic/civilization/TechManager.kt b/core/src/com/unciv/logic/civilization/TechManager.kt index 50fbe33bc7..36ccb3c49c 100644 --- a/core/src/com/unciv/logic/civilization/TechManager.kt +++ b/core/src/com/unciv/logic/civilization/TechManager.kt @@ -1,11 +1,13 @@ package com.unciv.logic.civilization +import com.unciv.logic.civilization.LocationAction import com.unciv.logic.city.CityInfo import com.unciv.logic.map.MapSize import com.unciv.logic.map.RoadStatus import com.unciv.logic.map.TileInfo import com.unciv.models.ruleset.Unique import com.unciv.models.ruleset.UniqueTriggerActivation +import com.unciv.models.ruleset.unit.BaseUnit import com.unciv.models.ruleset.tech.Technology import com.unciv.ui.utils.withItem import java.util.* @@ -262,18 +264,49 @@ class TechManager { if (civInfo.playerType == PlayerType.Human) notifyRevealedResources(techName) val obsoleteUnits = getRuleset().units.values.filter { it.obsoleteTech == techName }.map { it.name } + val unitUpgrades = HashMap>() for (city in civInfo.cities) { // Do not use replaceAll - that's a Java 8 feature and will fail on older phones! val oldQueue = city.cityConstructions.constructionQueue.toList() // copy, since we're changing the queue city.cityConstructions.constructionQueue.clear() for (constructionName in oldQueue) { if (constructionName in obsoleteUnits) { - val text = "[$constructionName] has been obsolete and will be removed from construction queue in [${city.name}]!" - civInfo.addNotification(text, city.location, NotificationIcon.Construction) + if (constructionName !in unitUpgrades.keys) { + unitUpgrades[constructionName] = ArrayList() + } + unitUpgrades[constructionName]?.add(city) + val construction = city.cityConstructions.getConstruction(constructionName) + if (construction is BaseUnit && construction.upgradesTo != null) { + city.cityConstructions.constructionQueue.add(construction.upgradesTo!!) + } } else city.cityConstructions.constructionQueue.add(constructionName) } } + // Add notifications for obsolete units/constructions + for ((unit, cities) in unitUpgrades) { + val construction = cities[0].cityConstructions.getConstruction(unit) + if (cities.size == 1) { + val city = cities[0] + if (construction is BaseUnit && construction.upgradesTo != null) { + val text = "[${city.name}] changed production from [$unit] to [${construction.upgradesTo!!}]" + civInfo.addNotification(text, city.location, unit, NotificationIcon.Construction, construction.upgradesTo!!) + } else { + val text = "[$unit] has become obsolete and was removed from the queue in [${city.name}]!" + civInfo.addNotification(text, city.location, NotificationIcon.Construction) + } + } else { + val locationAction = LocationAction(cities.map { it.location }) + if (construction is BaseUnit && construction.upgradesTo != null) { + val text = "[${cities.size}] cities changed production from [$unit] to [${construction.upgradesTo!!}]" + civInfo.addNotification(text, locationAction, unit, NotificationIcon.Construction, construction.upgradesTo!!) + } else { + val text = "[$unit] has become osbolete and was removed from the queue in [${cities.size}] cities!" + civInfo.addNotification(text, locationAction, NotificationIcon.Construction) + } + } + } + for (unique in civInfo.getMatchingUniques("Receive free [] when you discover []")) { if (unique.params[1] != techName) continue civInfo.addUnit(unique.params[0])