Files
Cataclysm-DDA/tests/creature_in_field_test.cpp
2026-06-22 15:07:51 -04:00

42 lines
1.5 KiB
C++

#include <string>
#include "cata_catch.h"
#include "coordinates.h"
#include "map.h"
#include "map_helpers.h"
#include "map_helpers_tests.h"
#include "monster.h"
#include "point.h"
#include "type_id.h"
#include "units.h"
static const vproto_id vehicle_prototype_handjack( "handjack" );
TEST_CASE( "creature_in_field", "[monster] [field]" )
{
static const tripoint_bub_ms target_location{ 5, 5, 0 };
clear_map_without_vision();
map &here = get_map();
GIVEN( "An acid field" ) {
here.add_field( target_location, field_type_id( "fd_acid" ) );
WHEN( "a monster stands on it" ) {
monster &test_monster = spawn_test_monster( "mon_zombie", target_location );
REQUIRE( test_monster.get_hp() == test_monster.get_hp_max() );
THEN( "the monster takes damage" ) {
here.creature_in_field( test_monster );
CHECK( test_monster.get_hp() < test_monster.get_hp_max() );
}
}
WHEN( "A monster in a vehicle stands in it" ) {
here.add_vehicle( vehicle_prototype_handjack, target_location, 0_degrees );
monster &test_monster = spawn_test_monster( "mon_zombie", target_location );
REQUIRE( test_monster.get_hp() == test_monster.get_hp_max() );
THEN( "the monster doesn't take damage" ) {
here.creature_in_field( test_monster );
CHECK( test_monster.get_hp() == test_monster.get_hp_max() );
}
}
}
}