@@ -40,13 +40,18 @@ static const efftype_id effect_infected( "infected" );
40
40
41
41
static const flag_id json_flag_SPLINT ( " SPLINT" );
42
42
43
+ static const itype_id itype_blindfold ( " blindfold" );
44
+ static const itype_id itype_ear_plugs ( " ear_plugs" );
43
45
static const itype_id itype_rad_badge ( " rad_badge" );
44
46
45
47
static const move_mode_id move_mode_crouch ( " crouch" );
46
48
static const move_mode_id move_mode_prone ( " prone" );
47
49
static const move_mode_id move_mode_run ( " run" );
48
50
static const move_mode_id move_mode_walk ( " walk" );
49
51
52
+ static const trait_id trait_GOODHEARING ( " GOODHEARING" );
53
+ static const trait_id trait_NIGHTVISION ( " NIGHTVISION" );
54
+
50
55
static const weather_type_id weather_acid_rain ( " acid_rain" );
51
56
static const weather_type_id weather_cloudy ( " cloudy" );
52
57
static const weather_type_id weather_drizzle ( " drizzle" );
@@ -85,6 +90,10 @@ static const widget_id widget_test_move_mode_text( "test_move_mode_text" );
85
90
static const widget_id widget_test_move_num ( " test_move_num" );
86
91
static const widget_id widget_test_overmap_3x3_text ( " test_overmap_3x3_text" );
87
92
static const widget_id widget_test_per_color_num ( " test_per_color_num" );
93
+ static const widget_id widget_test_phrase_legend ( " test_phrase_legend" );
94
+ static const widget_id widget_test_phrase_number ( " test_phrase_number" );
95
+ static const widget_id widget_test_phrase_sym ( " test_phrase_sym" );
96
+ static const widget_id widget_test_phrase_text ( " test_phrase_text" );
88
97
static const widget_id widget_test_pool_graph ( " test_pool_graph" );
89
98
static const widget_id widget_test_rad_badge_text ( " test_rad_badge_text" );
90
99
static const widget_id widget_test_speed_num ( " test_speed_num" );
@@ -1831,3 +1840,81 @@ TEST_CASE( "Widget alignment", "[widget]" )
1831
1840
" " + line3 + " " );
1832
1841
}
1833
1842
}
1843
+
1844
+ TEST_CASE ( " Phrase conditions - pure JSON widgets" , " [widget][phrase][condition]" )
1845
+ {
1846
+ const int sidebar_width = 20 ;
1847
+
1848
+ const time_point midnight = calendar::turn_zero + 0_hours;
1849
+ const time_point midday = calendar::turn_zero + 12_hours;
1850
+
1851
+ const item blindfold ( itype_blindfold );
1852
+ const item earplugs ( itype_ear_plugs );
1853
+
1854
+ widget w_num = widget_test_phrase_number.obj ();
1855
+ widget w_txt = widget_test_phrase_text.obj ();
1856
+ widget w_sym = widget_test_phrase_sym.obj ();
1857
+ widget w_lgd = widget_test_phrase_legend.obj ();
1858
+
1859
+ avatar &ava = get_avatar ();
1860
+ clear_avatar ();
1861
+ set_time ( midnight );
1862
+
1863
+ REQUIRE ( !ava.has_trait ( trait_GOODHEARING ) );
1864
+ REQUIRE ( !ava.has_trait ( trait_NIGHTVISION ) );
1865
+ REQUIRE ( !is_day ( calendar::turn ) );
1866
+ REQUIRE ( !ava.is_deaf () );
1867
+ REQUIRE ( !ava.is_blind () );
1868
+
1869
+ SECTION ( " Default values" ) {
1870
+ CHECK ( w_num.layout ( ava ) == " Num Values: <color_c_dark_gray>1</color>" );
1871
+ CHECK ( w_txt.layout ( ava ) == " Text Values: <color_c_dark_gray>None</color>" );
1872
+ CHECK ( w_sym.layout ( ava ) == " Symbol Values: <color_c_dark_gray>.</color>" );
1873
+ CHECK ( w_lgd.layout ( ava, sidebar_width ) == " <color_c_dark_gray>. None</color> " );
1874
+ }
1875
+
1876
+ SECTION ( " GOODHEARING" ) {
1877
+ ava.toggle_trait ( trait_GOODHEARING );
1878
+ CHECK ( w_num.layout ( ava ) == " Num Values: <color_c_white_green>10</color>" );
1879
+ CHECK ( w_txt.layout ( ava ) == " Text Values: <color_c_white_green>good hearing</color>" );
1880
+ CHECK ( w_sym.layout ( ava ) == " Symbol Values: <color_c_white_green>+</color>" );
1881
+ CHECK ( w_lgd.layout ( ava, sidebar_width ) == " <color_c_white_green>+</color> good hearing\n " );
1882
+ }
1883
+
1884
+ SECTION ( " Daylight" ) {
1885
+ set_time ( midday );
1886
+ CHECK ( w_num.layout ( ava ) == " Num Values: <color_c_yellow>0</color>" );
1887
+ CHECK ( w_txt.layout ( ava ) == " Text Values: <color_c_yellow>daylight</color>" );
1888
+ CHECK ( w_sym.layout ( ava ) == " Symbol Values: <color_c_yellow>=</color>" );
1889
+ CHECK ( w_lgd.layout ( ava, sidebar_width ) == " <color_c_yellow>=</color> daylight\n " );
1890
+ }
1891
+
1892
+ SECTION ( " Daylight / Blind" ) {
1893
+ set_time ( midday );
1894
+ ava.wear_item ( blindfold, false );
1895
+ CHECK ( w_num.layout ( ava ) ==
1896
+ " Num Values: <color_c_red_red>-20</color>, <color_c_yellow>0</color>" );
1897
+ CHECK ( w_txt.layout ( ava ) ==
1898
+ " Text Values: <color_c_red_red>blind</color>, <color_c_yellow>daylight</color>" );
1899
+ CHECK ( w_sym.layout ( ava ) ==
1900
+ " Symbol Values: <color_c_red_red><</color><color_c_yellow>=</color>" );
1901
+ CHECK ( w_lgd.layout ( ava, sidebar_width ) ==
1902
+ " <color_c_red_red><</color> blind <color_c_yellow>=</color> daylight\n " );
1903
+ }
1904
+
1905
+ SECTION ( " Daylight / Blind / Deaf / GOODHEARING / NIGHTVISION" ) {
1906
+ set_time ( midday );
1907
+ ava.wear_item ( blindfold, false );
1908
+ ava.wear_item ( earplugs, false );
1909
+ ava.toggle_trait ( trait_GOODHEARING );
1910
+ ava.toggle_trait ( trait_NIGHTVISION );
1911
+ CHECK ( w_num.layout ( ava ) ==
1912
+ " Num Values: <color_c_red_red>-20</color>, <color_i_yellow>-10</color>, <color_c_yellow>0</color>, <color_c_white_green>10</color>, <color_c_light_green>20</color>" );
1913
+ CHECK ( w_txt.layout ( ava ) ==
1914
+ " Text Values: <color_c_red_red>blind</color>, <color_i_yellow>deaf</color>, <color_c_yellow>daylight</color>, <color_c_white_green>good hearing</color>, <color_c_light_green>good vision</color>" );
1915
+ CHECK ( w_sym.layout ( ava ) ==
1916
+ " Symbol Values: <color_c_red_red><</color><color_i_yellow>-</color><color_c_yellow>=</color><color_c_white_green>+</color><color_c_light_green>></color>" );
1917
+ CHECK ( w_lgd.layout ( ava, sidebar_width ) ==
1918
+ " <color_c_red_red><</color> blind <color_i_yellow>-</color> deaf\n <color_c_yellow>=</color> daylight\n <color_c_white_green>+</color> good hearing\n <color_c_light_green>></color> good vision\n " );
1919
+ }
1920
+ }
0 commit comments