Skip to content

Commit

Permalink
Test, Clang
Browse files Browse the repository at this point in the history
  • Loading branch information
Venera3 committed Jun 7, 2023
1 parent 0038d56 commit 1097f7a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
8 changes: 4 additions & 4 deletions tests/iteminfo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,18 +707,18 @@ TEST_CASE( "techniques when wielded", "[iteminfo][weapon][techniques]" )
"--\n"
"<color_c_white>Techniques when wielded</color>:"
" <color_c_light_blue>Brutal Strike</color>:"
" <color_c_cyan>Stun 1 turn, knockback 1 tile, crit only</color>,"
" <color_c_cyan>Stun 1 turn, knockback 1 tile, crit only</color> <color_c_cyan>* Only works on a <color_c_cyan>non-stunned mundane</color> target of <color_c_cyan>similar or smaller</color> size, may fail on enemies grabbing you</color>,"
" <color_c_light_blue>Sweep Attack</color>:"
" <color_c_cyan>Down 2 turns</color>, and"
" <color_c_cyan>Down 2 turns</color> <color_c_cyan>* Only works on a <color_c_cyan>non-downed humanoid</color> target of <color_c_cyan>similar or smaller</color> size incapable of flight</color>, and"
" <color_c_light_blue>Block</color>:"
" <color_c_cyan>Medium blocking ability</color>\n" );
" <color_c_cyan>Medium blocking ability</color> <color_c_cyan></color>\n" );

item plank( "test_2x4" );
CHECK( item_info_str( plank, { iteminfo_parts::DESCRIPTION_TECHNIQUES } ) ==
"--\n"
"<color_c_white>Techniques when wielded</color>:"
" <color_c_light_blue>Block</color>:"
" <color_c_cyan>Medium blocking ability</color>\n" );
" <color_c_cyan>Medium blocking ability</color> <color_c_cyan></color>\n" );
}

static std::vector<bodypart_id> bodyparts_to_check()
Expand Down
41 changes: 20 additions & 21 deletions tests/martial_art_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ static const efftype_id effect_grabbing( "grabbing" );
static const efftype_id effect_stunned( "stunned" );


static const itype_id itype_2_by_sword( "sword_wood" );
static const itype_id itype_club( "club_wooden" );
static const itype_id itype_sword_wood( "sword_wood" );
static const itype_id itype_club_wooden( "club_wooden" );
static const itype_id itype_test_weapon1( "test_weapon1" );
static const itype_id itype_test_weapon2( "test_weapon2" );

static const matec_id test_stun( "test_tech_condition_stun" );
static const matec_id test_sweep( "test_tech_condition_sweep" );
static const matec_id test_knockback( "test_tech_condition_knockback" );
static const matec_id test_tech( "test_technique" );
static const matec_id test_tech_condition_stun( "test_tech_condition_stun" );
static const matec_id test_tech_condition_sweep( "test_tech_condition_sweep" );
static const matec_id test_tech_condition_knockback( "test_tech_condition_knockback" );
static const matec_id test_technique( "test_technique" );
static const matype_id test_style_ma1( "test_style_ma1" );

static const species_id species_HUMAN( "HUMAN" );
static const species_id species_SLIME( "SLIME" );
static const species_id species_ZOMBIE( "ZOMBIE" );

Expand Down Expand Up @@ -66,7 +65,7 @@ TEST_CASE( "Martial art required weapon categories", "[martial_arts]" )

SECTION( "Weapon categories required for technique" ) {
REQUIRE( !test_style_ma1->techniques.empty() );
const matec_id &tec = *test_style_ma1->techniques.find( test_tech );
const matec_id &tec = *test_style_ma1->techniques.find( test_technique );

REQUIRE( tec->reqs.weapon_categories_allowed[0] == *test_style_ma1->weapon_category.begin() );
standard_npc dude( "TestCharacter", dude_pos, {}, 0, 8, 8, 8, 8 );
Expand All @@ -92,7 +91,7 @@ TEST_CASE( "Martial art technique conditionals", "[martial_arts]" )
dude.martial_arts_data->set_style( test_style_ma1, false );
REQUIRE( dude.get_size() == 3 );
SECTION( "Test sweep" ) {
const matec_id &tec = *test_style_ma1->techniques.find( test_sweep );
const matec_id &tec = *test_style_ma1->techniques.find( test_tech_condition_sweep );
monster &target_1 = spawn_test_monster( "mon_zombie_fat", target_1_pos );
monster &target_2 = spawn_test_monster( "mon_zombie_hulk", target_2_pos );
monster &target_3 = spawn_test_monster( "mon_blob", target_3_pos );
Expand All @@ -104,22 +103,22 @@ TEST_CASE( "Martial art technique conditionals", "[martial_arts]" )
CHECK( std::find( tech_1.begin(), tech_1.end(), tec ) != tech_1.end() );
// Being downed disables the attack
target_1.add_effect( effect_downed, 1_days );
CHECK( dude.evaluate_techniques( target_1, dude.used_weapon() ).size() == 0 );
CHECK( dude.evaluate_techniques( target_1, dude.used_weapon() ).empty() );
// test sweeping a big zomb (fail)
REQUIRE( target_2.get_size() == 5 );
CHECK( dude.evaluate_techniques( target_2, dude.used_weapon() ).size() == 0 );
CHECK( dude.evaluate_techniques( target_2, dude.used_weapon() ).empty() );
// test sweeping a slime (fail)
REQUIRE( target_3.get_size() == 3 );
REQUIRE( target_3.type->bodytype == "blob" );
CHECK( dude.evaluate_techniques( target_3, dude.used_weapon() ).size() == 0 );
CHECK( dude.evaluate_techniques( target_3, dude.used_weapon() ).empty() );
}

SECTION( "Test stun" ) {
const matec_id &tec = *test_style_ma1->techniques.find( test_stun );
const matec_id &tec = *test_style_ma1->techniques.find( test_tech_condition_stun );
monster &target_1 = spawn_test_monster( "mon_feral_human_pipe", target_1_pos );
monster &target_2 = spawn_test_monster( "mon_zombie_fat", target_2_pos );
monster &target_3 = spawn_test_monster( "mon_blob", target_3_pos );
item weap( itype_2_by_sword );
item weap( itype_sword_wood );
dude.wield( weap );
// test stunning a feral (succeed)
std::vector<matec_id> tech_1 = dude.evaluate_techniques( target_1, dude.used_weapon() );
Expand All @@ -128,33 +127,33 @@ TEST_CASE( "Martial art technique conditionals", "[martial_arts]" )
CHECK( std::find( tech_1.begin(), tech_1.end(), tec ) != tech_1.end() );
// Being downed disables the attack
target_1.add_effect( effect_stunned, 1_days );
CHECK( dude.evaluate_techniques( target_1, dude.used_weapon() ).size() == 0 );
CHECK( dude.evaluate_techniques( target_1, dude.used_weapon() ).empty() );
// test stunning a zombie (fail)
REQUIRE( target_2.get_size() == 3 );
REQUIRE( target_2.type->in_species( species_ZOMBIE ) );
CHECK( dude.evaluate_techniques( target_2, dude.used_weapon() ).size() == 0 );
CHECK( dude.evaluate_techniques( target_2, dude.used_weapon() ).empty() );
// test stunning a slime (fail)
REQUIRE( target_3.get_size() == 3 );
REQUIRE( target_3.type->in_species( species_SLIME ) );
CHECK( dude.evaluate_techniques( target_3, dude.used_weapon() ).size() == 0 );
CHECK( dude.evaluate_techniques( target_3, dude.used_weapon() ).empty() );
}
SECTION( "Test knockback" ) {
const matec_id &tec = *test_style_ma1->techniques.find( test_knockback );
const matec_id &tec = *test_style_ma1->techniques.find( test_tech_condition_knockback );
monster &target_1 = spawn_test_monster( "mon_feral_human_pipe", target_1_pos );
monster &target_2 = spawn_test_monster( "mon_zombie_hulk", target_2_pos );
monster &target_3 = spawn_test_monster( "mon_test_tech_grabber", target_3_pos );
item weap( itype_club );
item weap( itype_club_wooden );
dude.wield( weap );
// test throwing a feral (succeed)
std::vector<matec_id> tech_1 = dude.evaluate_techniques( target_1, dude.used_weapon() );
REQUIRE( target_1.get_size() == 3 );
CHECK( std::find( tech_1.begin(), tech_1.end(), tec ) != tech_1.end() );
// Being downed disables the attack
target_1.add_effect( effect_downed, 1_days );
CHECK( dude.evaluate_techniques( target_1, dude.used_weapon() ).size() == 0 );
CHECK( dude.evaluate_techniques( target_1, dude.used_weapon() ).empty() );
// test throwing a large target (fail)
REQUIRE( target_2.get_size() == 5 );
CHECK( dude.evaluate_techniques( target_2, dude.used_weapon() ).size() == 0 );
CHECK( dude.evaluate_techniques( target_2, dude.used_weapon() ).empty() );
// test throwing a monster grabbing you (succeed)
dude.add_effect( effect_grabbed, 1_days );
target_3.add_effect( effect_grabbing, 1_days );
Expand Down

0 comments on commit 1097f7a

Please sign in to comment.