-
Notifications
You must be signed in to change notification settings - Fork 280
/
effects_test.cpp
71 lines (61 loc) · 2.86 KB
/
effects_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "catch/catch.hpp"
#include <cstdlib>
#include <map>
#include <sstream>
#include <utility>
#include "avatar.h"
#include "effect.h"
static const efftype_id effect_adrenaline( "adrenaline" );
static const efftype_id effect_adrenaline_comedown( "adrenaline_comedown" );
static const efftype_id effect_test_juggling_l1( "test_juggling_l1" );
static const efftype_id effect_test_juggling_l2( "test_juggling_l2" );
static const efftype_id effect_test_juggling_r1( "test_juggling_r1" );
static const efftype_id effect_test_juggling_r2( "test_juggling_r2" );
TEST_CASE( "Adrenaline decays into adrenaline comedown" )
{
REQUIRE( effect_adrenaline.is_valid() );
REQUIRE( effect_adrenaline->get_effects_on_remove().size() == 1 );
avatar dummy;
dummy.add_effect( effect_adrenaline, 0_turns );
REQUIRE( dummy.has_effect( effect_adrenaline ) );
dummy.process_effects();
CHECK( !dummy.has_effect( effect_adrenaline ) );
CHECK( dummy.has_effect( effect_adrenaline_comedown ) );
const effect &e = dummy.get_effect( effect_adrenaline_comedown );
auto on_remove = effect_adrenaline->get_effects_on_remove().front();
CHECK( to_turns<int>( e.get_duration() ) == to_turns<int>( on_remove.duration ) );
}
TEST_CASE( "Removed adrenaline still triggers adrenaline comedown" )
{
REQUIRE( effect_adrenaline.is_valid() );
REQUIRE( effect_adrenaline->get_effects_on_remove().size() == 1 );
avatar dummy;
dummy.add_effect( effect_adrenaline, 100_turns );
REQUIRE( dummy.has_effect( effect_adrenaline ) );
dummy.remove_effect( effect_adrenaline );
dummy.process_effects();
CHECK( !dummy.has_effect( effect_adrenaline ) );
REQUIRE( dummy.has_effect( effect_adrenaline_comedown ) );
const effect &e = dummy.get_effect( effect_adrenaline_comedown );
auto on_remove = effect_adrenaline->get_effects_on_remove().front();
CHECK( to_turns<int>( e.get_duration() ) == to_turns<int>( on_remove.duration ) );
}
TEST_CASE( "Effect body part switching and inheritance on decay works as expected" )
{
REQUIRE( effect_test_juggling_l1.is_valid() );
avatar dummy;
dummy.add_effect( effect_test_juggling_l1, 0_seconds, body_part_hand_l );
REQUIRE( dummy.has_effect( effect_test_juggling_l1 ) );
dummy.process_effects();
CHECK( !dummy.has_effect( effect_test_juggling_l1 ) );
CHECK( dummy.has_effect( effect_test_juggling_r1, body_part_hand_r ) );
dummy.process_effects();
CHECK( !dummy.has_effect( effect_test_juggling_r1 ) );
CHECK( dummy.has_effect( effect_test_juggling_r2, body_part_hand_r ) );
dummy.process_effects();
CHECK( !dummy.has_effect( effect_test_juggling_r2 ) );
CHECK( dummy.has_effect( effect_test_juggling_l2, body_part_hand_l ) );
dummy.process_effects();
CHECK( !dummy.has_effect( effect_test_juggling_l2 ) );
CHECK( dummy.has_effect( effect_test_juggling_l1, body_part_hand_l ) );
}