|
18 | 18 | #include "player.h" |
19 | 19 | #include "state_helpers.h" |
20 | 20 | #include "test_statistics.h" |
| 21 | +#include "type_id.h" |
21 | 22 | #include "vehicle.h" |
22 | 23 | #include "vehicle_part.h" |
23 | 24 | #include "vpart_position.h" |
24 | 25 |
|
| 26 | +#include <algorithm> |
25 | 27 | #include <cmath> |
26 | 28 | #include <fstream> |
27 | 29 | #include <list> |
|
35 | 37 |
|
36 | 38 | using move_statistics = statistics<int>; |
37 | 39 |
|
| 40 | +namespace { |
| 41 | + |
| 42 | +auto count_items_at(const tripoint_bub_ms& pos, const itype_id& type) -> int { |
| 43 | + return std::ranges::count_if(get_map().i_at(pos), [&type](const auto* it) { |
| 44 | + return it->typeId() == type; |
| 45 | + }); |
| 46 | +} |
| 47 | + |
| 48 | +} // namespace |
| 49 | + |
| 50 | +TEST_CASE("extended monster death drops append to inherited drops", "[monster][death_drops]") { |
| 51 | + clear_all_state(); |
| 52 | + const auto global_spawn_rate = override_option("ITEM_SPAWNRATE", "1.0"); |
| 53 | + const auto rock_spawn_rate = override_option("SPAWN_RATE_rocks", "1.0"); |
| 54 | + const auto wood_spawn_rate = override_option("SPAWN_RATE_scrap_wood", "1.0"); |
| 55 | + static_cast<void>(global_spawn_rate); |
| 56 | + static_cast<void>(rock_spawn_rate); |
| 57 | + static_cast<void>(wood_spawn_rate); |
| 58 | + move_player_out_of_the_way(); |
| 59 | + |
| 60 | + auto& here = get_map(); |
| 61 | + build_test_map(ter_id("t_floor")); |
| 62 | + |
| 63 | + const auto monster_pos = tripoint_bub_ms(60, 60, 0); |
| 64 | + here.i_clear(monster_pos); |
| 65 | + |
| 66 | + auto& test_monster = spawn_test_monster("mon_test_death_drops_append", monster_pos); |
| 67 | + test_monster.drop_items_on_death(); |
| 68 | + |
| 69 | + CHECK(count_items_at(monster_pos, itype_id("rock")) == 1); |
| 70 | + CHECK(count_items_at(monster_pos, itype_id("stick")) == 1); |
| 71 | +} |
| 72 | + |
| 73 | +TEST_CASE("empty top-level monster death drops replace inherited drops", "[monster][death_drops]") { |
| 74 | + clear_all_state(); |
| 75 | + move_player_out_of_the_way(); |
| 76 | + |
| 77 | + auto& here = get_map(); |
| 78 | + build_test_map(ter_id("t_floor")); |
| 79 | + |
| 80 | + const auto monster_pos = tripoint_bub_ms(60, 60, 0); |
| 81 | + here.i_clear(monster_pos); |
| 82 | + |
| 83 | + auto& test_monster = spawn_test_monster("mon_test_death_drops_clear", monster_pos); |
| 84 | + test_monster.drop_items_on_death(); |
| 85 | + |
| 86 | + CHECK(here.i_at(monster_pos).empty()); |
| 87 | +} |
| 88 | + |
38 | 89 | TEST_CASE("hallucination_monsters_do_not_open_real_doors", "[monster][hallucination]") { |
39 | 90 | clear_all_state(); |
40 | 91 | move_player_out_of_the_way(); |
|
0 commit comments