mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-26 13:27:22 -04:00
Bring allUnitActionsHaveTranslation
test up to date (#4688)
* Bring `allUnitActionsHaveTranslation` test up to date * Bring allUnitActionsHaveTranslation test up to date - revert enum prop
This commit is contained in:
parent
776be5a48a
commit
ee32392ecd
@ -61,6 +61,10 @@ data class UnitAction(
|
||||
* @param key keyboard binding - can be a [KeyCharAndCode], a [Char], or omitted.
|
||||
* @param uncivSound _default_ sound, can be overridden in UnitAction instantiation
|
||||
*/
|
||||
|
||||
// Note for Creators of new UnitActions: If your action uses a dynamic label overriding UnitActionType.value,
|
||||
// then you need to teach [com.unciv.testing.TranslationTests.allUnitActionsHaveTranslation] how to deal with it!
|
||||
|
||||
enum class UnitActionType(
|
||||
val value: String,
|
||||
val imageGetter: (()-> Actor)?,
|
||||
@ -79,6 +83,9 @@ enum class UnitActionType(
|
||||
{ ImageGetter.getImage("OtherIcons/Sleep") }, 'f'),
|
||||
SleepUntilHealed("Sleep until healed",
|
||||
{ ImageGetter.getImage("OtherIcons/Sleep") }, 'h'),
|
||||
// Note: Both Fortify actions are a special case. The button starting fortification uses the `value` here,
|
||||
// the button label as shown when the unit is already fortifying is "Fortification".tr() + " nn%".
|
||||
// For now we keep it simple, and the unit test `allUnitActionsHaveTranslation` does not know about the latter.
|
||||
Fortify("Fortify",
|
||||
null, 'f', UncivSound.Fortify),
|
||||
FortifyUntilHealed("Fortify until healed",
|
||||
|
@ -48,10 +48,12 @@ class TranslationTests {
|
||||
fun allUnitActionsHaveTranslation() {
|
||||
val actions: MutableSet<String> = HashSet()
|
||||
for (action in UnitActionType.values()) {
|
||||
if (action == UnitActionType.Upgrade)
|
||||
actions.add("Upgrade to [unitType] ([goldCost] gold)")
|
||||
else
|
||||
actions.add(action.value)
|
||||
actions.add( when(action) {
|
||||
UnitActionType.Upgrade -> "Upgrade to [unitType] ([goldCost] gold)"
|
||||
UnitActionType.Create -> "Create [improvement]"
|
||||
UnitActionType.SpreadReligion -> "Spread [religionName]"
|
||||
else -> action.value
|
||||
})
|
||||
}
|
||||
val allUnitActionsHaveTranslation = allStringAreTranslated(actions)
|
||||
Assert.assertTrue("This test will only pass when there is a translation for all unit actions",
|
||||
|
Loading…
x
Reference in New Issue
Block a user