1010#include " bodypart.h"
1111#include " cata_catch.h"
1212#include " cata_utility.h"
13+ #include " character.h"
1314#include " character_id.h"
15+ #include " coordinates.h"
1416#include " debug_menu.h"
1517#include " event.h"
1618#include " event_bus.h"
1719#include " filesystem.h"
20+ #include " map_helpers.h"
1821#include " memorial_logger.h"
22+ #include " monster.h"
1923#include " mutation.h"
2024#include " player_helpers.h"
25+ #include " point.h"
2126#include " stats_tracker.h"
2227#include " type_id.h"
2328
@@ -33,13 +38,18 @@ static const spell_id spell_pain_damage( "pain_damage" );
3338
3439static const trap_str_id tr_pit ( " tr_pit" );
3540
36- template <event_type Type, typename ... Args>
37- void check_memorial ( memorial_logger &m, event_bus &b, const std::string &ref, Args... args )
41+ // Requires a custom sender for eg. using event types that need to be sent differently for EOCS to work
42+ template <event_type Type>
43+ void check_memorial_custom_sender (
44+ memorial_logger &m,
45+ const std::string &ref,
46+ std::function<void ()> &&sender
47+ )
3848{
3949 CAPTURE ( io::enum_to_string ( Type ) );
4050 CAPTURE ( ref );
4151 m.clear ();
42- b. send ( cata::event::make<Type>( args... ) );
52+ sender ( );
4353
4454 std::string result = m.dump ();
4555 CAPTURE ( result );
@@ -67,6 +77,21 @@ void check_memorial( memorial_logger &m, event_bus &b, const std::string &ref, A
6777 CHECK ( ref_lines.empty () );
6878}
6979
80+ // Send the event via event_bus::send as a sane default
81+ template <event_type Type, typename ... Args>
82+ void check_memorial (
83+ memorial_logger &m,
84+ const std::string &ref,
85+ Args... args
86+ )
87+ {
88+ check_memorial_custom_sender<Type>(
89+ m,
90+ ref,
91+ [&] { get_event_bus ().send ( cata::event::make<Type>( args... ) ); }
92+ );
93+ }
94+
7095TEST_CASE ( " memorials" , " [memorial]" )
7196{
7297 memorial_logger &m = get_memorial ();
@@ -75,15 +100,15 @@ TEST_CASE( "memorials", "[memorial]" )
75100 get_stats ().clear ();
76101 get_achievements ().clear ();
77102
78- event_bus &b = get_event_bus ();
79-
80103 avatar &player_character = get_avatar ();
81104 player_character.male = false ;
82105 character_id ch = player_character.getID ();
83106 std::string u_name = player_character.name ;
84107 character_id ch2 = character_id ( ch.get_value () + 1 );
85108 mutagen_technique mutagen = mutagen_technique::injected_purifier;
86109 mtype_id mon ( " mon_zombie_kevlar_2" );
110+ tripoint_bub_ms loc = get_avatar ().pos_bub () + tripoint::east;
111+ monster &dummy_monster = spawn_test_monster ( " mon_dragon_dummy" , loc );
87112 efftype_id eff ( " onfire" );
88113 itype_id it ( " marloss_seed" );
89114 trait_id mut ( " CARNIVORE" );
@@ -93,201 +118,205 @@ TEST_CASE( "memorials", "[memorial]" )
93118 proficiency_id prof ( " prof_wound_care" );
94119
95120 check_memorial<event_type::activates_artifact>(
96- m, b, " Activated the art_name." , ch, " art_name" );
121+ m, " Activated the art_name." , ch, " art_name" );
97122
98123 check_memorial<event_type::activates_mininuke>(
99- m, b, " Activated a mininuke." , ch );
124+ m, " Activated a mininuke." , ch );
100125
101126 check_memorial<event_type::administers_mutagen>(
102- m, b, " Injected purifier." , ch, mutagen );
127+ m, " Injected purifier." , ch, mutagen );
103128
104129 check_memorial<event_type::angers_amigara_horrors>(
105- m, b, " Angered a group of amigara horrors!" );
130+ m, " Angered a group of amigara horrors!" );
106131
107132 check_memorial<event_type::awakes_dark_wyrms>(
108- m, b, " Awoke a group of dark wyrms!" );
133+ m, " Awoke a group of dark wyrms!" );
109134
110135 check_memorial<event_type::becomes_wanted>(
111- m, b, " Became wanted by the police!" , ch );
136+ m, " Became wanted by the police!" , ch );
112137
113138 check_memorial<event_type::broken_bone>(
114- m, b, " Broke her right arm." , ch, bodypart_id ( " arm_r" ) );
139+ m, " Broke her right arm." , ch, bodypart_id ( " arm_r" ) );
115140
116141 check_memorial<event_type::broken_bone_mends>(
117- m, b, " Broken right arm began to mend." , ch, bodypart_id ( " arm_r" ) );
142+ m, " Broken right arm began to mend." , ch, bodypart_id ( " arm_r" ) );
118143
119144 check_memorial<event_type::buries_corpse>(
120- m, b, " You buried monster_name." , ch, mon, " monster_name" );
145+ m, " You buried monster_name." , ch, mon, " monster_name" );
121146
122147 check_memorial<event_type::causes_resonance_cascade>(
123- m, b, " Caused a resonance cascade." );
148+ m, " Caused a resonance cascade." );
124149
125150 check_memorial<event_type::character_gains_effect>(
126- m, b, " Caught on fire." , ch, bodypart_id ( " arm_r" ), eff, 1 );
151+ m, " Caught on fire." , ch, bodypart_id ( " arm_r" ), eff, 1 );
127152
128153 check_memorial<event_type::character_kills_character>(
129- m, b, " Killed an innocent person, victim_name, in cold blood and felt terrible "
154+ m, " Killed an innocent person, victim_name, in cold blood and felt terrible "
130155 " afterwards." , ch, ch2, " victim_name" );
131156
132- check_memorial<event_type::character_kills_monster>(
133- m, b, " Killed a Kevlar hulk." , ch, mon, 0 );
157+ check_memorial_custom_sender<event_type::character_kills_monster>(
158+ m, " Killed a Kevlar hulk." ,
159+ [&] {
160+ const cata::event e = cata::event::make<event_type::character_kills_monster>( ch, mon, 0 );
161+ get_event_bus ().send_with_talker ( player_character.as_character (), dummy_monster.as_monster (), e );
162+ } );
134163
135164 check_memorial<event_type::character_loses_effect>(
136- m, b, " Put out the fire." , ch, bodypart_id ( " arm_r" ), eff );
165+ m, " Put out the fire." , ch, bodypart_id ( " arm_r" ), eff );
137166
138167 check_memorial<event_type::character_triggers_trap>(
139- m, b, " Fell in a pit." , ch, tr_pit );
168+ m, " Fell in a pit." , ch, tr_pit );
140169
141170 check_memorial<event_type::consumes_marloss_item>(
142- m, b, " Consumed a Marloss seed." , ch, it );
171+ m, " Consumed a Marloss seed." , ch, it );
143172
144173 check_memorial<event_type::crosses_marloss_threshold>(
145- m, b, " Opened the Marloss Gateway." , ch );
174+ m, " Opened the Marloss Gateway." , ch );
146175
147176 check_memorial<event_type::crosses_mutation_threshold>(
148- m, b, " Became one with the bears." , ch, mutation_category_URSINE );
177+ m, " Became one with the bears." , ch, mutation_category_URSINE );
149178
150179 check_memorial<event_type::crosses_mycus_threshold>(
151- m, b, " Became one with the Mycus." , ch );
180+ m, " Became one with the Mycus." , ch );
152181
153182 check_memorial<event_type::dermatik_eggs_hatch>(
154- m, b, " Dermatik eggs hatched." , ch );
183+ m, " Dermatik eggs hatched." , ch );
155184
156185 check_memorial<event_type::dermatik_eggs_injected>(
157- m, b, " Injected with dermatik eggs." , ch );
186+ m, " Injected with dermatik eggs." , ch );
158187
159188 check_memorial<event_type::destroys_triffid_grove>(
160- m, b, " Destroyed a triffid grove." );
189+ m, " Destroyed a triffid grove." );
161190
162191 check_memorial<event_type::dies_from_asthma_attack>(
163- m, b, " Succumbed to an asthma attack." , ch );
192+ m, " Succumbed to an asthma attack." , ch );
164193
165194 check_memorial<event_type::dies_from_drug_overdose>(
166- m, b, " Died of a drug overdose." , ch, eff );
195+ m, " Died of a drug overdose." , ch, eff );
167196
168197 check_memorial<event_type::dies_from_bleeding>(
169- m, b, " Bled to death." , ch );
198+ m, " Bled to death." , ch );
170199
171200 check_memorial<event_type::dies_from_hypovolemia>(
172- m, b, " Died of hypovolemic shock." , ch );
201+ m, " Died of hypovolemic shock." , ch );
173202
174203 check_memorial<event_type::dies_from_redcells_loss>(
175- m, b, " Died from loss of red blood cells." , ch );
204+ m, " Died from loss of red blood cells." , ch );
176205
177206 check_memorial<event_type::dies_of_infection>(
178- m, b, " Succumbed to the infection." , ch );
207+ m, " Succumbed to the infection." , ch );
179208
180209 check_memorial<event_type::dies_of_starvation>(
181- m, b, " Died of starvation." , ch );
210+ m, " Died of starvation." , ch );
182211
183212 check_memorial<event_type::dies_of_thirst>(
184- m, b, " Died of thirst." , ch );
213+ m, " Died of thirst." , ch );
185214
186215 check_memorial<event_type::digs_into_lava>(
187- m, b, " Dug a shaft into lava." );
216+ m, " Dug a shaft into lava." );
188217
189218 check_memorial<event_type::disarms_nuke>(
190- m, b, " Disarmed a nuclear missile." );
219+ m, " Disarmed a nuclear missile." );
191220
192221 check_memorial<event_type::eats_sewage>(
193- m, b, " Ate a sewage sample." );
222+ m, " Ate a sewage sample." );
194223
195224 check_memorial<event_type::evolves_mutation>(
196- m, b, " 'Carnivore' mutation turned into 'Saprophage'" , ch, mut, mut2 );
225+ m, " 'Carnivore' mutation turned into 'Saprophage'" , ch, mut, mut2 );
197226
198227 check_memorial<event_type::exhumes_grave>(
199- m, b, " Exhumed a grave." , ch );
228+ m, " Exhumed a grave." , ch );
200229
201230 check_memorial<event_type::fails_to_install_cbm>(
202- m, b, " Failed install of bionic: Alarm System." , ch, cbm );
231+ m, " Failed install of bionic: Alarm System." , ch, cbm );
203232
204233 check_memorial<event_type::fails_to_remove_cbm>(
205- m, b, " Failed to remove bionic: Alarm System." , ch, cbm );
234+ m, " Failed to remove bionic: Alarm System." , ch, cbm );
206235
207236 check_memorial<event_type::falls_asleep_from_exhaustion>(
208- m, b, " Succumbed to lack of sleep." , ch );
237+ m, " Succumbed to lack of sleep." , ch );
209238
210239 check_memorial<event_type::fuel_tank_explodes>(
211- m, b, " The fuel tank of the vehicle_name exploded!" , " vehicle_name" );
240+ m, " The fuel tank of the vehicle_name exploded!" , " vehicle_name" );
212241
213242 check_memorial<event_type::gains_addiction>(
214- m, b, " Became addicted to alcohol." , ch, addiction_alcohol );
243+ m, " Became addicted to alcohol." , ch, addiction_alcohol );
215244
216245 check_memorial<event_type::gains_mutation>(
217- m, b, " Gained the mutation 'Carnivore'." , ch, mut );
246+ m, " Gained the mutation 'Carnivore'." , ch, mut );
218247
219248 check_memorial<event_type::gains_proficiency>(
220- m, b, " Gained the proficiency 'Wound Care'." , ch, prof );
249+ m, " Gained the proficiency 'Wound Care'." , ch, prof );
221250
222251 check_memorial<event_type::gains_skill_level>(
223- m, b, " Reached skill level 8 in vehicles." , ch, skill_driving, 8 );
252+ m, " Reached skill level 8 in vehicles." , ch, skill_driving, 8 );
224253
225254 check_memorial<event_type::game_avatar_death>(
226- m, b, u_name + " was killed.\n Last words: last_words" , ch, u_name, false , " last_words" );
255+ m, u_name + " was killed.\n Last words: last_words" , ch, u_name, false , " last_words" );
227256
228257 check_memorial<event_type::game_avatar_new>(
229- m, b, u_name + " began their journey into the Cataclysm." , true , false , ch, u_name,
258+ m, u_name + " began their journey into the Cataclysm." , true , false , ch, u_name,
230259 player_character.custom_profession );
231260
232261 check_memorial<event_type::installs_cbm>(
233- m, b, " Installed bionic: Alarm System." , ch, cbm );
262+ m, " Installed bionic: Alarm System." , ch, cbm );
234263
235264 check_memorial<event_type::installs_faulty_cbm>(
236- m, b, " Installed bad bionic: Alarm System." , ch, cbm );
265+ m, " Installed bad bionic: Alarm System." , ch, cbm );
237266
238267 check_memorial<event_type::learns_martial_art>(
239- m, b, " Learned Aikido." , ch, style_aikido );
268+ m, " Learned Aikido." , ch, style_aikido );
240269
241270 check_memorial<event_type::loses_addiction>(
242- m, b, " Overcame addiction to alcohol." , ch, addiction_alcohol );
271+ m, " Overcame addiction to alcohol." , ch, addiction_alcohol );
243272
244273 check_memorial<event_type::npc_becomes_hostile>(
245- m, b, " npc_name became hostile." , ch2, " npc_name" );
274+ m, " npc_name became hostile." , ch2, " npc_name" );
246275
247276 check_memorial<event_type::opens_portal>(
248- m, b, " Opened a portal." );
277+ m, " Opened a portal." );
249278
250279 check_memorial<event_type::opens_temple>(
251- m, b, " Opened a strange temple." );
280+ m, " Opened a strange temple." );
252281
253282 check_memorial<event_type::character_forgets_spell>(
254- m, b, " Forgot the spell Pain." , ch, spell_pain_damage );
283+ m, " Forgot the spell Pain." , ch, spell_pain_damage );
255284
256285 check_memorial<event_type::character_learns_spell>(
257- m, b, " Learned the spell Pain." , ch, spell_pain_damage );
286+ m, " Learned the spell Pain." , ch, spell_pain_damage );
258287
259288 check_memorial<event_type::player_levels_spell>(
260- m, b, " Gained a spell level on Pain." , ch, spell_pain_damage, 5 , mut3 );
289+ m, " Gained a spell level on Pain." , ch, spell_pain_damage, 5 , mut3 );
261290
262291 check_memorial<event_type::releases_subspace_specimens>(
263- m, b, " Released subspace specimens." );
292+ m, " Released subspace specimens." );
264293
265294 check_memorial<event_type::removes_cbm>(
266- m, b, " Removed bionic: Alarm System." , ch, cbm );
295+ m, " Removed bionic: Alarm System." , ch, cbm );
267296
268297 check_memorial<event_type::seals_hazardous_material_sarcophagus>(
269- m, b, " Sealed a Hazardous Material Sarcophagus." );
298+ m, " Sealed a Hazardous Material Sarcophagus." );
270299
271300 check_memorial<event_type::telefrags_creature>(
272- m, b, " Telefragged a telefragged_name." , ch, " telefragged_name" );
301+ m, " Telefragged a telefragged_name." , ch, " telefragged_name" );
273302
274303 check_memorial<event_type::teleglow_teleports>(
275- m, b, " Spontaneous teleport." , ch );
304+ m, " Spontaneous teleport." , ch );
276305
277306 check_memorial<event_type::teleports_into_wall>(
278- m, b, " Teleported into a obstacle_name." , ch, " obstacle_name" );
307+ m, " Teleported into a obstacle_name." , ch, " obstacle_name" );
279308
280309 check_memorial<event_type::terminates_subspace_specimens>(
281- m, b, " Terminated subspace specimens." );
310+ m, " Terminated subspace specimens." );
282311
283312 check_memorial<event_type::throws_up>(
284- m, b, " Threw up." , ch );
313+ m, " Threw up." , ch );
285314
286315 check_memorial<event_type::triggers_alarm>(
287- m, b, " Set off an alarm." , ch );
316+ m, " Set off an alarm." , ch );
288317
289318 check_memorial<event_type::uses_debug_menu>(
290- m, b, " Used the debug menu (WISH)." , debug_menu::debug_menu_index::WISH );
319+ m, " Used the debug menu (WISH)." , debug_menu::debug_menu_index::WISH );
291320}
292321
293322TEST_CASE ( " convert_legacy_memorial_log" , " [memorial]" )
0 commit comments