CleverRaven / CleverRaven/Cataclysm-DDA
Improving the Test suite for enchantments
- Dominant language
- C++
- Stars
- 13.1k
- Forks
- 4.6k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 200
Description
### Is your feature request related to a problem? Please describe.
We have a multitude of enchantments that can be applied in numerous parallel methods, many of these methods have different root structures and can fail or succeed depending on which method it is trying to use. These enchantments can then be applied in a number of different mathematic fashions, mutliplication, addition, subtraction and division. Despite all this variety we currently have four tests, one for invisibility and three for different methods of applying a strength addition. Over this experimental cycle we've had a number of regressions and fixes related to enchantments applying their effects. Some of this can be avoided in the future with more extensive test cases.
### Solution you would like.
I'd like to see testing for each enchantment type strength, skill, social, etc checking that they appropriately multiply, divide. subtract or add and give the intended effects. I believe it would be very helpful to have this in place before limbification really starts so that people doing limb work don't suddenly find during their tests that an enchantment doesn't work properly and then have to figure out if it's their changes or if they weren't working previously and no one knew.
### Describe alternatives you have considered.
_No response_
### Additional context
Current test suite for enchantments below
```
static const bionic_id test_bio_ench( "test_bio_ench" );
static const efftype_id effect_blind( "blind" );
static const efftype_id effect_invisibility( "invisibility" );
static const trait_id trait_TEST_ENCH_MUTATION( "TEST_ENCH_MUTATION" );
static void test_generic_ench( avatar &p, int str_before )
{
// wait a turn for the effect to kick in
p.process_turn();
CHECK( p.get_str() == str_before + p.get_str_base() * 2 + 25 );
CHECK( p.has_effect( effect_invisibility ) );
const field &fields_here = get_map().field_at( p.pos() );
CHECK( fields_here.find_field( field_type_id( "fd_shadow" ) ) != nullptr );
// place a zombie next to the avatar
const tripoint spot( 61, 60, 0 );
clear_map();
monster &zombie = spawn_test_monster( "mon_zombie", spot );
p.on_hit( &zombie, bodypart_id( "torso" ), 0.0, nullptr );
CHECK( zombie.has_effect( effect_blind ) );
}
TEST_CASE( "worn enchantments", "[enchantments][worn][items]" )
{
avatar p;
clear_character( p );
int str_before = p.get_str();
// put on the ring
item_location equipped_ring_strplus_one = p.i_add( item( "test_ring_strength_1" ) );
p.wear( equipped_ring_strplus_one, false );
// wait a turn for the effect to kick in
p.recalculate_enchantment_cache();
p.process_turn();
CHECK( p.get_str() == str_before + 1 );
}
TEST_CASE( "bionic enchantments", "[enchantments][bionics]" )
{
avatar p;
clear_character( p );
int str_before = p.get_str();
p.set_max_power_level( 100_kJ );
p.set_power_level( 100_kJ );
give_and_activate_bionic( p, test_bio_ench );
test_generic_ench( p, str_before );
}
TEST_CASE( "mutation enchantments", "[enchantments][mutations]" )
{
avatar p;
clear_character( p );
int str_before = p.get_str();
p.toggle_trait( trait_TEST_ENCH_MUTATION );
REQUIRE( p.has_trait( trait_TEST_ENCH_MUTATION ) );
p.recalculate_enchantment_cache();
test_generic_ench( p, str_before );
}
```
Contributor guide
Research direction
Start with the current enchantment tests shown in the issue, including the worn, bionic, and mutation cases and the test_generic_ench helper. Review how enchantment effects are represented and exercised, then expand coverage for the listed enchantment types and arithmetic operations. Done means tests verify the intended add, subtract, multiply, and divide behavior without regressions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- game-dev, testing-qa
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100