forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enchantments_test.cpp
90 lines (65 loc) · 2.23 KB
/
enchantments_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
86
87
88
89
90
#include "avatar.h"
#include "cata_catch.h"
#include "field.h"
#include "item.h"
#include "item_location.h"
#include "map.h"
#include "map_helpers.h"
#include "monster.h"
#include "npc.h"
#include "player_helpers.h"
#include "point.h"
#include "type_id.h"
#include "units.h"
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 );
}