-
Notifications
You must be signed in to change notification settings - Fork 280
/
magic_spell_effect_test.cpp
54 lines (44 loc) · 1.68 KB
/
magic_spell_effect_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
#include "catch/catch.hpp"
#include <sstream>
#include "json.h"
#include "magic.h"
#include "magic_spell_effect_helpers.h"
#include "npc.h"
#include "player_helpers.h"
#include "state_helpers.h"
TEST_CASE( "line_attack", "[magic]" )
{
clear_all_state();
// manually construct a testable spell
std::istringstream str(
" {\n"
" \"id\": \"test_line_spell\",\n"
" \"name\": { \"str\": \"Test Line Spell\" },\n"
" \"description\": \"Spews a line of magic\",\n"
" \"valid_targets\": [ \"ground\" ],\n"
" \"damage_type\": \"none\",\n"
" \"min_range\": 5,\n"
" \"max_range\": 5,\n"
" \"effect\": \"line_attack\",\n"
" \"min_aoe\": 0,\n"
" \"max_aoe\": 0,\n"
" \"flags\": [ \"VERBAL\", \"NO_HANDS\", \"NO_LEGS\" ]\n"
" }\n" );
JsonIn in( str );
JsonObject obj( in );
spell_type::load_spell( obj, "" );
spell sp( spell_id( "test_line_spell" ) );
// set up Character to test with, only need position
npc &c = spawn_npc( point_zero, "test_talker" );
clear_character( c );
c.setpos( tripoint_zero );
// target point 5 tiles east of zero
tripoint target = tripoint_east * 5;
// Ensure that AOE=0 spell covers the 5 tiles along vector towards target
SECTION( "aoe=0" ) {
const std::set<tripoint> reference( { tripoint_east * 1, tripoint_east * 2, tripoint_east * 3, tripoint_east * 4, tripoint_east * 5 } );
std::set<tripoint> targets = calculate_spell_effect_area( sp, target,
spell_effect::spell_effect_line, c, true );
CHECK( reference == targets );
}
}