forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
item_countdown_test.cpp
85 lines (66 loc) · 2.64 KB
/
item_countdown_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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "calendar.h"
#include "cata_catch.h"
#include "item.h"
#include "map.h"
TEST_CASE( "countdown_action_triggering", "[item]" )
{
item grenade( "grenade_act" );
grenade.active = true;
SECTION( "countdown_point is in future" ) {
grenade.countdown_point = calendar::turn + 10_seconds;
// Grenade does not explode
CHECK( grenade.process( get_map(), nullptr, tripoint_zero ) == false );
}
SECTION( "countdown_point is in past" ) {
grenade.countdown_point = calendar::turn - 10_seconds;
// Grenade explodes and is to be removed
CHECK( grenade.process( get_map(), nullptr, tripoint_zero ) == true );
}
SECTION( "countdown_point is now" ) {
grenade.countdown_point = calendar::turn;
// Grenade explodes and is to be removed
CHECK( grenade.process( get_map(), nullptr, tripoint_zero ) == true );
}
}
TEST_CASE( "countdown_action_revert_to", "[item]" )
{
SECTION( "revert to inert item" ) {
item test_item( "arrow_flamming" );
test_item.active = true;
test_item.countdown_point = calendar::turn;
// Is not deleted after coundown action
CHECK( test_item.process( get_map(), nullptr, tripoint_zero ) == false );
// Turns into normal arrow
CHECK( test_item.typeId().str() == "arrow_field_point_fletched" );
// Is not active anymore
CHECK_FALSE( test_item.active );
// Timer is gone
CHECK( test_item.countdown_point == calendar::turn_max );
}
SECTION( "revert to item with new timer" ) {
item test_item( "migo_plate_undergrown" );
test_item.active = true;
test_item.countdown_point = calendar::turn;
// Is not deleted after coundown action
CHECK( test_item.process( get_map(), nullptr, tripoint_zero ) == false );
// Turns into new armor type
CHECK( test_item.typeId().str() == "migo_plate" );
// Is still active
CHECK( test_item.active );
// Has new timer
CHECK( test_item.countdown_point == calendar::turn + 24_hours );
}
SECTION( "revert to item that requires processing" ) {
item test_item( "test_rock_cheese" );
test_item.active = true;
test_item.countdown_point = calendar::turn;
// Is not deleted after coundown action
CHECK( test_item.process( get_map(), nullptr, tripoint_zero ) == false );
// Turns into cheese
CHECK( test_item.typeId().str() == "cheese_hard" );
// Is still active
CHECK( test_item.active );
// Timer is gone
CHECK( test_item.countdown_point == calendar::turn_max );
}
}