Skip to content

Commit

Permalink
Add mana and stamina tests; clean up
Browse files Browse the repository at this point in the history
All [widget] tests passing
  • Loading branch information
wapcaplet committed Oct 11, 2020
1 parent b6452f1 commit a810a5e
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 19 deletions.
17 changes: 17 additions & 0 deletions data/mods/TEST_DATA/widgets.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
"var": "focus",
"style": "number"
},
{
"id": "test_mana_num",
"type": "widget",
"label": "MANA",
"var": "mana",
"style": "number"
},
{
"id": "test_speed_num",
"type": "widget",
Expand All @@ -44,6 +51,16 @@
"var": "stamina",
"style": "number"
},
{
"id": "test_stamina_graph",
"type": "widget",
"label": "STAMINA",
"var": "stamina",
"style": "graph",
"fill": "pool",
"width": 10,
"symbols": "-=#"
},
{
"id": "test_sound_num",
"type": "widget",
Expand Down
68 changes: 49 additions & 19 deletions tests/widget_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,12 @@ TEST_CASE( "widgets showing avatar attributes", "[widget][avatar]" )
avatar &ava = get_avatar();
clear_avatar();

// Base stats
widget str_w = widget_id( "test_str_num" ).obj();
widget dex_w = widget_id( "test_dex_num" ).obj();
widget int_w = widget_id( "test_int_num" ).obj();
widget per_w = widget_id( "test_per_num" ).obj();
// Speed, move, focus, and others
widget speed_w = widget_id( "test_speed_num" ).obj();
widget move_w = widget_id( "test_move_num" ).obj();
widget focus_w = widget_id( "test_focus_num" ).obj();
widget sound_w = widget_id( "test_sound_num" ).obj();
widget stamina_w = widget_id( "test_stamina_num" ).obj();

bodypart_id head( "head" );
widget head_num_w = widget_id( "test_hp_head_num" ).obj();
widget head_graph_w = widget_id( "test_hp_head_graph" ).obj();

SECTION( "str, dex, int, per" ) {
SECTION( "base stats str / dex / int / per" ) {
widget str_w = widget_id( "test_str_num" ).obj();
widget dex_w = widget_id( "test_dex_num" ).obj();
widget int_w = widget_id( "test_int_num" ).obj();
widget per_w = widget_id( "test_per_num" ).obj();

ava.str_max = 8;
ava.dex_max = 10;
ava.int_max = 7;
Expand All @@ -128,30 +117,71 @@ TEST_CASE( "widgets showing avatar attributes", "[widget][avatar]" )
CHECK( per_w.show( ava ) == "PER: 13" );
}

SECTION( "stamina" ) {
widget stamina_num_w = widget_id( "test_stamina_num" ).obj();
widget stamina_graph_w = widget_id( "test_stamina_graph" ).obj();
REQUIRE( stamina_graph_w._fill == "pool" );
REQUIRE( stamina_graph_w._symbols == "-=#" );

ava.set_stamina( 0 );
CHECK( stamina_num_w.show( ava ) == "STAMINA: 0" );
CHECK( stamina_graph_w.show( ava ) == "STAMINA: ----------" );
ava.set_stamina( 2500 );
CHECK( stamina_num_w.show( ava ) == "STAMINA: 2500" );
CHECK( stamina_graph_w.show( ava ) == "STAMINA: =====-----" );
ava.set_stamina( 5000 );
CHECK( stamina_num_w.show( ava ) == "STAMINA: 5000" );
CHECK( stamina_graph_w.show( ava ) == "STAMINA: ==========" );
ava.set_stamina( 7500 );
CHECK( stamina_num_w.show( ava ) == "STAMINA: 7500" );
CHECK( stamina_graph_w.show( ava ) == "STAMINA: #####=====" );
ava.set_stamina( 10000 );
CHECK( stamina_num_w.show( ava ) == "STAMINA: 10000" );
CHECK( stamina_graph_w.show( ava ) == "STAMINA: ##########" );
}

SECTION( "speed pool" ) {
widget speed_w = widget_id( "test_speed_num" ).obj();

ava.set_speed_base( 90 );
CHECK( speed_w.show( ava ) == "SPEED: 90" );
ava.set_speed_base( 240 );
CHECK( speed_w.show( ava ) == "SPEED: 240" );
}

SECTION( "focus pool" ) {
widget focus_w = widget_id( "test_focus_num" ).obj();

ava.focus_pool = 75;
CHECK( focus_w.show( ava ) == "FOCUS: 75" );
ava.focus_pool = 120;
CHECK( focus_w.show( ava ) == "FOCUS: 120" );
}

SECTION( "mana pool" ) {
widget mana_w = widget_id( "test_mana_num" ).obj();

ava.magic->set_mana( 150 );
CHECK( mana_w.show( ava ) == "MANA: 150" );
ava.magic->set_mana( 450 );
CHECK( mana_w.show( ava ) == "MANA: 450" );
}

SECTION( "move counter" ) {
widget move_w = widget_id( "test_move_num" ).obj();

ava.movecounter = 80;
CHECK( move_w.show( ava ) == "MOVE: 80" );
ava.movecounter = 150;
CHECK( move_w.show( ava ) == "MOVE: 150" );
}

SECTION( "hit points" ) {
CHECK( ava.get_part_hp_max( head ) == 84 );
CHECK( ava.get_part_hp_cur( head ) == 84 );
bodypart_id head( "head" );
widget head_num_w = widget_id( "test_hp_head_num" ).obj();
widget head_graph_w = widget_id( "test_hp_head_graph" ).obj();
REQUIRE( ava.get_part_hp_max( head ) == 84 );
REQUIRE( ava.get_part_hp_cur( head ) == 84 );

ava.set_part_hp_cur( head, 84 );
CHECK( head_num_w.show( ava ) == "HEAD: 84" );
Expand Down

0 comments on commit a810a5e

Please sign in to comment.