@@ -57,29 +57,40 @@ static const vitamin_id vitamin_test_vitx( "test_vitx" );
57
57
// effect::get_start_time
58
58
//
59
59
// Create an `effect` object with given parameters, and check they were initialized correctly.
60
- static void check_effect_init ( const std::string &eff_name, const time_duration &dur,
61
- const std::string &bp_name, const bool permanent, const int intensity,
60
+ static void check_effect_init ( const std::string &eff_name,
61
+ const time_duration &requested_dur, const time_duration &expected_dur,
62
+ const std::string &bp_name, const bool permanent,
63
+ const int requested_int, const int expected_int,
62
64
const time_point &start_time )
63
65
{
64
66
const efftype_id eff_id ( eff_name );
65
67
const effect_type &type = eff_id.obj ();
66
68
const bodypart_str_id bp ( bp_name );
67
69
68
- effect effect_obj ( effect_source::empty (), &type, dur, bp, permanent, intensity, start_time );
70
+ effect effect_obj ( effect_source::empty (), &type, requested_dur, bp, permanent, requested_int,
71
+ start_time );
69
72
70
- CHECK ( dur == effect_obj.get_duration () );
73
+ CHECK ( expected_dur == effect_obj.get_duration () );
71
74
CHECK ( bp.id () == effect_obj.get_bp () );
72
75
CHECK ( permanent == effect_obj.is_permanent () );
73
- CHECK ( intensity == effect_obj.get_intensity () );
76
+ CHECK ( expected_int == effect_obj.get_intensity () );
74
77
CHECK ( start_time == effect_obj.get_start_time () );
75
78
}
76
79
77
80
TEST_CASE ( " effect_initialization_test" , " [effect][init]" )
78
81
{
79
82
// "debugged" effect is defined in data/mods/TEST_DATA/effects.json
80
- check_effect_init ( " debugged" , 1_days, " head" , false , 5 , calendar::turn_zero );
81
- check_effect_init ( " bite" , 1_minutes, " torso" , true , 2 , calendar::turn );
82
- check_effect_init ( " grabbed" , 1_turns, " arm_r" , false , 1 , calendar::turn + 1_hours );
83
+ // "debugged" effect has max_duration 1 hour, so 1 day gets clamped
84
+ check_effect_init ( " debugged" , 1_days, 1_hours, " head" , false , 5 , 5 , calendar::turn_zero );
85
+ check_effect_init ( " debugged" , 1_minutes, 1_minutes, " head" , false , 5 , 5 , calendar::turn_zero );
86
+ // "bite" effect has int_dur_factor, so intensity is calculated from duration regardless of requested intensity
87
+ check_effect_init ( " bite" , 60_minutes, 60_minutes, " torso" , true , 99 , 2 , calendar::turn );
88
+ check_effect_init ( " bite" , 30_minutes, 30_minutes, " torso" , true , 99 , 1 , calendar::turn );
89
+ check_effect_init ( " grabbed" , 1_turns, 1_turns, " arm_r" , false , 100 , 100 ,
90
+ calendar::turn + 1_hours );
91
+ check_effect_init ( " grabbed" , 100_turns, 100_turns, " arm_r" , false , 1 , 1 ,
92
+ calendar::turn + 1_hours );
93
+ check_effect_init ( " grabbed" , 1_turns, 1_turns, " arm_r" , false , 10 , 10 , calendar::turn + 1_hours );
83
94
}
84
95
85
96
// Effect duration
0 commit comments