Skip to content

Commit

Permalink
mongroup: documentation & tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dseguin committed Oct 14, 2022
1 parent 7b8ac53 commit 7d46750
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
5 changes: 5 additions & 0 deletions data/mods/TEST_DATA/monstergroups.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@
"type": "monstergroup",
"monsters": [ { "monster": "mon_test_shearable", "pack_size": [ 4, 6 ] } ]
},
{
"name": "test_upgrades_multi_null",
"type": "monstergroup",
"monsters": [ { "monster": "mon_null" }, { "monster": "mon_test_zombie_cop", "pack_size": [ 4, 6 ], "starts": "2 days" } ]
},
{
"name": "test_upgrades_multi_late",
"type": "monstergroup",
Expand Down
9 changes: 8 additions & 1 deletion data/mods/TEST_DATA/monsters.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,14 @@
"weight": "81500 g",
"hp": 100,
"speed": 50,
"flags": [ "SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "PET_WONT_FOLLOW" ]
"flags": [ "SEES", "HEARS", "SMELLS", "ANIMAL", "PATH_AVOID_DANGER_1", "WARM", "PET_WONT_FOLLOW" ],
"upgrades": {
"half_life": 0,
"into_group": "test_upgrades_multi_null",
"multiple_spawns": true,
"spawn_range": 5,
"despawn_when_null": true
}
},
{
"id": "dissect_mon_test_CBM",
Expand Down
1 change: 1 addition & 0 deletions doc/MONSTERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ The upgrades object may have the following members:
| `age_grow` | (int, optional) Number of days needed for monster to change into another monster. Does not scale with the evolution factor.
| `multiple_spawns` | (bool, optional) If using `into_group`, the selected entry spawns a number of monsters based on the entry's `pack_size`.
| `spawn_range` | (int, optional) Mandatory when `multiple_spawns` is true. Determines how far away from the original monster the upgraded monsters can spawn.
| `despawn_when_null` | (bool, optional) For `into_group`, when `mon_null` is selected as the group entry upgrade, the monster will despawn leaving no trace when this is true. Otherwise the monster "dies" naturally. Defaults to false.

## "reproduction"
(dictionary, optional)
Expand Down
19 changes: 19 additions & 0 deletions tests/mongroup_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,4 +391,23 @@ TEST_CASE( "mongroup_multi_spawn_restrictions", "[mongroup]" )
CHECK( counts.count( mon_test_shearable ) > 0 );
CHECK( counts.count( mon_test_zombie_cop ) > 0 );
}

SECTION( "no valid spawns, with mon_null" ) {
std::map<mtype_id, int> counts;

test_multi_spawn( mon_test_CBM, 5, 4, 6, calendar::turn_zero + 1_days,
{ mon_null, mon_test_CBM, mon_test_zombie_cop }, counts );

CHECK( counts.empty() );
}

SECTION( "1 valid spawn, with mon_null" ) {
std::map<mtype_id, int> counts;

test_multi_spawn( mon_test_CBM, 5, 4, 6, calendar::turn_zero + 4 * 3_days + 12_hours,
{ mon_null, mon_test_CBM, mon_test_zombie_cop }, counts );

CHECK( counts.size() == 1 );
CHECK( counts.count( mon_test_zombie_cop ) > 0 );
}
}

0 comments on commit 7d46750

Please sign in to comment.