From 234abfaaebedc3094ba97a698abcc1396b46c0c0 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Thu, 9 Jan 2025 17:32:26 +0000 Subject: [PATCH 01/14] Remove legacy raw string item constructor --- src/item.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/item.h b/src/item.h index 20650bfd25efb..eab1f670d893b 100644 --- a/src/item.h +++ b/src/item.h @@ -226,13 +226,6 @@ class item : public visitable /** For constructing in-progress disassemblies */ item( const recipe *rec, int qty, item &component ); - // Legacy constructor for constructing from string rather than itype_id - // TODO: remove this and migrate code using it. - template - explicit item( const std::string &itype, Args &&... args ) : - item( itype_id( itype ), std::forward( args )... ) - {} - ~item() override; /** Return a pointer-like type that's automatically invalidated if this From 1d66ebaf82545fd3f7364f5a9d798bef1e40f8b4 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Thu, 9 Jan 2025 19:11:12 +0000 Subject: [PATCH 02/14] Change /src remaining uses of raw string item initialisation to use itype_id s --- src/activity_handlers.cpp | 3 ++- src/avatar_action.cpp | 9 +++++--- src/ballistics.cpp | 2 +- src/bionics.cpp | 15 +++++++------ src/cata_tiles.cpp | 2 +- src/character.cpp | 28 ++++++++++++++---------- src/character_escape.cpp | 4 ++-- src/clzones.cpp | 3 +-- src/computer_session.cpp | 6 +++-- src/construction.cpp | 3 ++- src/crafting.cpp | 6 +++-- src/debug_menu.cpp | 7 ++++-- src/fungal_effects.cpp | 4 +++- src/game.cpp | 3 ++- src/gamemode_tutorial.cpp | 15 ++++++++----- src/iexamine.cpp | 30 ++++++++++++++----------- src/item.cpp | 12 +++++----- src/item.h | 1 + src/item_group.cpp | 12 +++++----- src/item_pocket.cpp | 4 +++- src/iuse.cpp | 45 ++++++++++++++++++++++++-------------- src/iuse_actor.cpp | 7 +++--- src/magic_spell_effect.cpp | 2 +- src/map.cpp | 32 +++++++++++++++++---------- src/map_field.cpp | 3 ++- src/mapgen.cpp | 3 ++- src/mattack_actors.cpp | 4 +++- src/mission.cpp | 5 ++--- src/mission_start.cpp | 3 ++- src/monattack.cpp | 8 ++++--- src/mondeath.cpp | 4 +++- src/monmove.cpp | 6 +++-- src/monster.cpp | 9 +++++--- src/npc.cpp | 9 +++++--- src/npctalk.cpp | 3 ++- src/npctalk_funcs.cpp | 10 ++++----- src/player_difficulty.cpp | 10 ++++++--- src/recipe.cpp | 3 +-- src/savegame_json.cpp | 21 ++++++++++++------ src/veh_appliance.cpp | 3 ++- src/veh_type.cpp | 4 +--- src/vehicle.cpp | 12 +++++----- src/vehicle_use.cpp | 9 ++++---- src/weather.cpp | 4 ++-- 44 files changed, 236 insertions(+), 152 deletions(-) diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index aff7b3e5999d2..ea5dfba75b2be 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -204,6 +204,7 @@ static const itype_id itype_battery( "battery" ); static const itype_id itype_burnt_out_bionic( "burnt_out_bionic" ); static const itype_id itype_muscle( "muscle" ); static const itype_id itype_pseudo_magazine( "pseudo_magazine" ); +static const itype_id itype_pseudo_magazine_mod( "pseudo_magazine_mod" ); static const json_character_flag json_flag_ASOCIAL1( "ASOCIAL1" ); static const json_character_flag json_flag_ASOCIAL2( "ASOCIAL2" ); @@ -2412,7 +2413,7 @@ struct weldrig_hack { return null_item_reference(); } pseudo.set_flag( STATIC( flag_id( "PSEUDO" ) ) ); - item mag_mod( "pseudo_magazine_mod" ); + item mag_mod( itype_pseudo_magazine_mod ); mag_mod.set_flag( STATIC( flag_id( "IRREMOVABLE" ) ) ); if( !pseudo.put_in( mag_mod, pocket_type::MOD ).success() ) { debugmsg( "tool %s has no space for a %s, this is likely a bug", diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index 1edb7a29662ce..5b62b52d7a2c8 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -77,7 +77,10 @@ static const efftype_id effect_winded( "winded" ); static const furn_str_id furn_f_safe_c( "f_safe_c" ); +static const itype_id itype_grass( "grass" ); +static const itype_id itype_small_plant( "small_plant" ); static const itype_id itype_swim_fins( "swim_fins" ); +static const itype_id itype_underbrush( "underbrush" ); static const json_character_flag json_flag_CANNOT_ATTACK( "CANNOT_ATTACK" ); static const json_character_flag json_flag_CANNOT_MOVE( "CANNOT_MOVE" ); @@ -879,7 +882,7 @@ bool avatar_action::eat_here( avatar &you ) return true; } else { here.ter_set( you.pos_bub(), ter_t_grass ); - item food( "underbrush", calendar::turn, 1 ); + item food( itype_underbrush, calendar::turn, 1 ); you.assign_activity( consume_activity_actor( food ) ); return true; } @@ -892,7 +895,7 @@ bool avatar_action::eat_here( avatar &you ) return true; } else { here.furn_set( you.pos_bub(), furn_str_id::NULL_ID() ); - item food( "small_plant", calendar::turn, 1 ); + item food( itype_small_plant, calendar::turn, 1 ); you.assign_activity( consume_activity_actor( food ) ); return true; } @@ -904,7 +907,7 @@ bool avatar_action::eat_here( avatar &you ) add_msg( _( "You're too full to graze." ) ); return true; } else { - item food( item( "grass", calendar::turn, 1 ) ); + item food( item( itype_grass, calendar::turn, 1 ) ); you.assign_activity( consume_activity_actor( food ) ); here.ter_set( you.pos_bub(), here.get_ter_transforms_into( you.pos_bub() ) ); return true; diff --git a/src/ballistics.cpp b/src/ballistics.cpp index 8a730ca923f84..4e23d4c4b8fa7 100644 --- a/src/ballistics.cpp +++ b/src/ballistics.cpp @@ -95,7 +95,7 @@ static void drop_or_embed_projectile( const dealt_projectile_attack &attack ) drop_item.tname(), nb_of_dropped_shard, max_nb_of_shards - 1, to_gram( drop_item.type->weight ) );*/ for( int i = 0; i < nb_of_dropped_shard; ++i ) { - item shard( "glass_shard" ); + item shard( itype_glass_shard ); //actual dropping of shards get_map().add_item_or_charges( pt, shard ); } diff --git a/src/bionics.cpp b/src/bionics.cpp index 35ffb41b560a4..e44d78a0b1144 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -137,6 +137,7 @@ static const efftype_id effect_under_operation( "under_operation" ); static const fault_id fault_bionic_salvaged( "fault_bionic_salvaged" ); static const itype_id itype_anesthetic( "anesthetic" ); +static const itype_id itype_burnt_out_bionic( "burnt_out_bionic" ); static const itype_id itype_radiocontrol( "radiocontrol" ); static const itype_id itype_remotevehcontrol( "remotevehcontrol" ); static const itype_id itype_water_clean( "water_clean" ); @@ -1095,9 +1096,9 @@ bool Character::activate_bionic( bionic &bio, bool eff_only, bool *close_bionics if( choice >= 0 && choice <= 1 ) { item ctr; if( choice == 0 ) { - ctr = item( "remotevehcontrol", calendar::turn_zero ); + ctr = item( itype_remotevehcontrol, calendar::turn_zero ); } else { - ctr = item( "radiocontrol", calendar::turn_zero ); + ctr = item( itype_radiocontrol, calendar::turn_zero ); } ctr.charges = units::to_kilojoule( get_power_level() ); int power_use = invoke_item( &ctr ); @@ -2198,9 +2199,9 @@ void Character::perform_uninstall( const bionic &bio, int difficulty, int succes } } - item cbm( "burnt_out_bionic" ); + item cbm( itype_burnt_out_bionic ); if( item::type_is_defined( bio_id->itype() ) ) { - cbm = item( bio_id.c_str() ); + cbm = item( bio_id->itype() ); } cbm.set_flag( flag_FILTHY ); cbm.set_flag( flag_NO_STERILE ); @@ -2228,7 +2229,7 @@ bool Character::uninstall_bionic( const bionic &bio, monster &installer, Charact return false; } - item bionic_to_uninstall = item( bio.id.str(), calendar::turn_zero ); + item bionic_to_uninstall = item( bio.info().itype(), calendar::turn_zero ); const itype *itemtype = bionic_to_uninstall.type; int difficulty = itemtype->bionic->difficulty; int chance_of_success = bionic_manip_cos( adjusted_skill, difficulty + 2 ); @@ -2272,7 +2273,7 @@ bool Character::uninstall_bionic( const bionic &bio, monster &installer, Charact add_msg( m_mixed, _( "Successfully removed %s." ), bio.info().name ); } - item cbm( "burnt_out_bionic" ); + item cbm( itype_burnt_out_bionic ); if( item::type_is_defined( bio.info().itype() ) ) { cbm = bionic_to_uninstall; } @@ -2620,7 +2621,7 @@ void Character::bionics_install_failure( const bionic_id &bid, const std::string } } if( drop_cbm ) { - item cbm( bid.c_str() ); + item cbm( bid->itype() ); cbm.set_flag( flag_NO_STERILE ); cbm.set_flag( flag_NO_PACKED ); cbm.faults.emplace( fault_bionic_salvaged ); diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index 59c7e9c1fd36f..18651dde5281b 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -2670,7 +2670,7 @@ bool cata_tiles::draw_from_id_string_internal( const std::string &id, TILE_CATEG if( string_starts_with( found_id, "corpse_" ) ) { tmp = item( itype_corpse, calendar::turn_zero ); } else { - tmp = item( found_id, calendar::turn_zero ); + tmp = item( itype_id( found_id ), calendar::turn_zero ); } if( !variant.empty() ) { tmp.set_itype_variant( variant ); diff --git a/src/character.cpp b/src/character.cpp index a49faafa7a15d..a44cbc112fbc9 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -284,12 +284,15 @@ static const itype_id fuel_type_muscle( "muscle" ); static const itype_id itype_UPS( "UPS" ); static const itype_id itype_apparatus( "apparatus" ); static const itype_id itype_battery( "battery" ); +static const itype_id itype_beartrap( "beartrap" ); static const itype_id itype_cookbook_human( "cookbook_human" ); static const itype_id itype_e_handcuffs( "e_handcuffs" ); static const itype_id itype_fire( "fire" ); static const itype_id itype_foodperson_mask( "foodperson_mask" ); static const itype_id itype_foodperson_mask_on( "foodperson_mask_on" ); -static const itype_id itype_null( "null" ); +static const itype_id itype_human_sample( "human_sample" ); +static const itype_id itype_rope_6( "rope_6" ); +static const itype_id itype_snare_trigger( "snare_trigger" ); static const itype_id itype_rm13_armor_on( "rm13_armor_on" ); static const json_character_flag json_flag_ACIDBLOOD( "ACIDBLOOD" ); @@ -611,7 +614,7 @@ Character::Character() : grab_point = tripoint_rel_ms::zero; hauling = false; set_focus( 100 ); - last_item = itype_null; + last_item = itype_id::NULL_ID(); sight_max = 9999; last_batch = 0; death_drops = true; @@ -2405,7 +2408,7 @@ void Character::process_turn() process_items(); leak_items(); // Didn't just pick something up - last_item = itype_null; + last_item = itype_id::NULL_ID(); cache_visit_items_with( "is_relic", &item::is_relic, [this]( item & it ) { it.process_relic( this, pos_bub() ); @@ -3652,7 +3655,7 @@ void Character::normalize() activity_history.weary_clear(); martial_arts_data->reset_style(); - weapon = item( "null", calendar::turn_zero ); + weapon = item( itype_id::NULL_ID(), calendar::turn_zero ); set_body(); recalc_hp(); @@ -3670,11 +3673,11 @@ void Character::die( Creature *nkiller ) set_time_died( calendar::turn ); if( has_effect( effect_heavysnare ) ) { - inv->add_item( item( "rope_6", calendar::turn_zero ) ); - inv->add_item( item( "snare_trigger", calendar::turn_zero ) ); + inv->add_item( item( itype_rope_6, calendar::turn_zero ) ); + inv->add_item( item( itype_snare_trigger, calendar::turn_zero ) ); } if( has_effect( effect_beartrap ) ) { - inv->add_item( item( "beartrap", calendar::turn_zero ) ); + inv->add_item( item( itype_beartrap, calendar::turn_zero ) ); } mission::on_creature_death( *this ); } @@ -10441,11 +10444,11 @@ void Character::place_corpse() body.force_insert_item( *itm, pocket_type::CONTAINER ); } // One sample, as you would get from dissecting any other human. - body.put_in( item( "human_sample" ), pocket_type::CORPSE ); + body.put_in( item( itype_human_sample ), pocket_type::CORPSE ); for( const bionic &bio : *my_bionics ) { if( item::type_is_defined( bio.info().itype() ) ) { - item cbm( bio.id.str(), calendar::turn ); + item cbm( bio.info().itype(), calendar::turn ); cbm.set_flag( flag_FILTHY ); cbm.set_flag( flag_NO_STERILE ); cbm.set_flag( flag_NO_PACKED ); @@ -10483,11 +10486,12 @@ void Character::place_corpse( const tripoint_abs_omt &om_target ) body.force_insert_item( *itm, pocket_type::CONTAINER ); } // One sample, as you would get from dissecting any other human. - body.put_in( item( "human_sample" ), pocket_type::CORPSE ); + body.put_in( item( itype_human_sample ), pocket_type::CORPSE ); for( const bionic &bio : *my_bionics ) { - if( item::type_is_defined( bio.info().itype() ) ) { - body.put_in( item( bio.id.str(), calendar::turn ), pocket_type::CORPSE ); + const itype_id &bio_itype = bio.info().itype(); + if( item::type_is_defined( bio_itype ) ) { + body.put_in( item( bio_itype, calendar::turn ), pocket_type::CORPSE ); } } diff --git a/src/character_escape.cpp b/src/character_escape.cpp index 5d16770b8f7fa..fa43ea7413fee 100644 --- a/src/character_escape.cpp +++ b/src/character_escape.cpp @@ -159,8 +159,8 @@ void Character::try_remove_heavysnare() remove_effect( effect_heavysnare ); add_msg_player_or_npc( m_good, _( "You free yourself from the heavy snare!" ), _( " frees themselves from the heavy snare!" ) ); - item rope( "rope_6", calendar::turn ); - item snare( "snare_trigger", calendar::turn ); + item rope( itype_rope_6, calendar::turn ); + item snare( itype_snare_trigger, calendar::turn ); here.add_item_or_charges( pos_bub(), rope ); here.add_item_or_charges( pos_bub(), snare ); } else { diff --git a/src/clzones.cpp b/src/clzones.cpp index fda442f6ad0dd..65a8c9f28d219 100644 --- a/src/clzones.cpp +++ b/src/clzones.cpp @@ -54,7 +54,6 @@ static const faction_id faction_your_followers( "your_followers" ); static const item_category_id item_category_food( "food" ); static const itype_id itype_disassembly( "disassembly" ); -static const itype_id itype_null( "null" ); static const zone_type_id zone_type_AUTO_DRINK( "AUTO_DRINK" ); static const zone_type_id zone_type_AUTO_EAT( "AUTO_EAT" ); @@ -319,7 +318,7 @@ plot_options::query_seed_result plot_options::query_seed() } } std::vector seed_entries = iexamine::get_seed_entries( seed_inv ); - seed_entries.emplace( seed_entries.begin(), itype_null, _( "No seed" ), 0 ); + seed_entries.emplace( seed_entries.begin(), itype_id::NULL_ID(), _( "No seed" ), 0 ); int seed_index = iexamine::query_seed( seed_entries ); diff --git a/src/computer_session.cpp b/src/computer_session.cpp index fc8122ec59061..4b53e56b4166a 100644 --- a/src/computer_session.cpp +++ b/src/computer_session.cpp @@ -74,6 +74,7 @@ static const furn_str_id furn_f_counter( "f_counter" ); static const furn_str_id furn_f_rubble_rock( "f_rubble_rock" ); static const itype_id itype_black_box( "black_box" ); +static const itype_id itype_black_box_transcript( "black_box_transcript" ); static const itype_id itype_blood( "blood" ); static const itype_id itype_blood_tainted( "blood_tainted" ); static const itype_id itype_c4( "c4" ); @@ -83,6 +84,7 @@ static const itype_id itype_mininuke_act( "mininuke_act" ); static const itype_id itype_radio_repeater_mod( "radio_repeater_mod" ); static const itype_id itype_sarcophagus_access_code( "sarcophagus_access_code" ); static const itype_id itype_sewage( "sewage" ); +static const itype_id itype_software_blood_data( "software_blood_data" ); static const itype_id itype_usb_drive( "usb_drive" ); static const itype_id itype_vacutainer( "vacutainer" ); @@ -1074,7 +1076,7 @@ void computer_session::action_blood_anal() print_line( _( "Pathogen bonded to erythrocytes and leukocytes." ) ); if( query_bool( _( "Download data?" ) ) ) { if( item *const usb = pick_usb() ) { - item software( "software_blood_data", calendar::turn_zero ); + item software( itype_software_blood_data, calendar::turn_zero ); usb->clear_items(); usb->put_in( software, pocket_type::SOFTWARE ); print_line( _( "Software downloaded." ) ); @@ -1113,7 +1115,7 @@ void computer_session::action_data_anal() } else { // Success! if( items.only_item().typeId() == itype_black_box ) { print_line( _( "Memory Bank: Military Hexron Encryption\nPrinting Transcript\n" ) ); - item transcript( "black_box_transcript", calendar::turn ); + item transcript( itype_black_box_transcript, calendar::turn ); here.add_item_or_charges( player_character.pos_bub(), transcript ); } else { print_line( _( "Memory Bank: Unencrypted\nNothing of interest.\n" ) ); diff --git a/src/construction.cpp b/src/construction.cpp index 8b9cbe94f2fbc..a44159943bbc3 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -103,6 +103,7 @@ static const item_group_id Item_spawn_data_jewelry_front( "jewelry_front" ); static const itype_id itype_2x4( "2x4" ); static const itype_id itype_bone_human( "bone_human" ); static const itype_id itype_nail( "nail" ); +static const itype_id itype_rope_30( "rope_30" ); static const itype_id itype_sheet( "sheet" ); static const itype_id itype_stick( "stick" ); static const itype_id itype_string_36( "string_36" ); @@ -1836,7 +1837,7 @@ void construct::done_deconstruct( const tripoint_bub_ms &p, Character &player_ch static void unroll_digging( const int numer_of_2x4s ) { // refund components! - item rope( "rope_30" ); + item rope( itype_rope_30 ); map &here = get_map(); tripoint_bub_ms avatar_pos = get_player_character().pos_bub(); here.add_item_or_charges( avatar_pos, rope ); diff --git a/src/crafting.cpp b/src/crafting.cpp index b8df78bf5efd2..e62c0cff3de45 100644 --- a/src/crafting.cpp +++ b/src/crafting.cpp @@ -96,7 +96,9 @@ static const furn_str_id furn_f_fake_bench_hands( "f_fake_bench_hands" ); static const furn_str_id furn_f_ground_crafting_spot( "f_ground_crafting_spot" ); static const itype_id itype_disassembly( "disassembly" ); +static const itype_id itype_pickaxe( "pickaxe" ); static const itype_id itype_plut_cell( "plut_cell" ); +static const itype_id itype_shovel( "shovel" ); static const json_character_flag json_flag_CRAFT_IN_DARKNESS( "CRAFT_IN_DARKNESS" ); static const json_character_flag json_flag_HYPEROPIC( "HYPEROPIC" ); @@ -682,8 +684,8 @@ const inventory &Character::crafting_inventory( const tripoint_bub_ms &src_pos, } if( has_trait( trait_BURROW ) || has_trait( trait_BURROWLARGE ) ) { - *crafting_cache.crafting_inventory += item( "pickaxe", calendar::turn ); - *crafting_cache.crafting_inventory += item( "shovel", calendar::turn ); + *crafting_cache.crafting_inventory += item( itype_pickaxe, calendar::turn ); + *crafting_cache.crafting_inventory += item( itype_shovel, calendar::turn ); } crafting_cache.valid = true; diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index 97b0d47c2042b..971f6059c1f8d 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -143,6 +143,9 @@ static const efftype_id effect_bleed( "bleed" ); static const faction_id faction_no_faction( "no_faction" ); static const faction_id faction_your_followers( "your_followers" ); +static const itype_id itype_architect_cube( "architect_cube" ); +static const itype_id itype_debug_backpack( "debug_backpack" ); + static const matype_id style_none( "style_none" ); static const mongroup_id GROUP_DEBUG_EXACTLY_ONE( "GROUP_DEBUG_EXACTLY_ONE" ); @@ -3833,7 +3836,7 @@ void do_debug_quick_setup() u.set_mutations( setup_traits ); u.remove_weapon(); u.clear_worn(); - item backpack( "debug_backpack" ); + item backpack( itype_debug_backpack ); u.wear_item( backpack ); for( const std::pair &pair : u.get_all_skills() ) { u.set_skill_level( pair.first, 10 ); @@ -4013,7 +4016,7 @@ void debug() break; case debug_menu_index::SPAWN_CLAIRVOYANCE: - player_character.i_add( item( "architect_cube", calendar::turn ) ); + player_character.i_add( item( itype_architect_cube, calendar::turn ) ); break; case debug_menu_index::MAP_EDITOR: diff --git a/src/fungal_effects.cpp b/src/fungal_effects.cpp index 9ca315662ff92..3968c957b270b 100644 --- a/src/fungal_effects.cpp +++ b/src/fungal_effects.cpp @@ -34,6 +34,8 @@ static const furn_str_id furn_f_flower_fungal( "f_flower_fungal" ); static const furn_str_id furn_f_fungal_clump( "f_fungal_clump" ); static const furn_str_id furn_f_fungal_mass( "f_fungal_mass" ); +static const itype_id itype_fungal_seeds( "fungal_seeds" ); + static const mtype_id mon_fungal_blossom( "mon_fungal_blossom" ); static const mtype_id mon_spore( "mon_spore" ); @@ -242,7 +244,7 @@ void fungal_effects::spread_fungus_one_tile( const tripoint_bub_ms &p, const int DebugLog( D_ERROR, DC_ALL ) << "No seed item in the PLANT terrain at position " << p.to_string_writable(); } else { - *seed = item( "fungal_seeds", calendar::turn ); + *seed = item( itype_fungal_seeds, calendar::turn ); } } } diff --git a/src/game.cpp b/src/game.cpp index afb97af555b68..458cef588ea9b 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -297,6 +297,7 @@ static const harvest_drop_type_id harvest_drop_offal( "offal" ); static const harvest_drop_type_id harvest_drop_skin( "skin" ); static const itype_id fuel_type_animal( "animal" ); +static const itype_id fuel_type_muscle( "muscle" ); static const itype_id itype_battery( "battery" ); static const itype_id itype_disassembly( "disassembly" ); static const itype_id itype_grapnel( "grapnel" ); @@ -11855,7 +11856,7 @@ void game::on_move_effects() { // TODO: Move this to a character method if( !u.is_mounted() ) { - const item muscle( "muscle" ); + const item muscle( fuel_type_muscle ); for( const bionic_id &bid : u.get_bionic_fueled_with_muscle() ) { if( u.has_active_bionic( bid ) ) {// active power gen u.mod_power_level( muscle.fuel_energy() * bid->fuel_efficiency ); diff --git a/src/gamemode_tutorial.cpp b/src/gamemode_tutorial.cpp index 148d7ed30c037..3b77f5d6f651a 100644 --- a/src/gamemode_tutorial.cpp +++ b/src/gamemode_tutorial.cpp @@ -29,11 +29,16 @@ static const furn_str_id furn_f_rack( "f_rack" ); +static const itype_id itype_boxer_shorts( "boxer_shorts" ); static const itype_id itype_cig( "cig" ); static const itype_id itype_codeine( "codeine" ); static const itype_id itype_flashlight( "flashlight" ); static const itype_id itype_flashlight_on( "flashlight_on" ); static const itype_id itype_grenade_act( "grenade_act" ); +static const itype_id itype_jeans( "jeans" ); +static const itype_id itype_longshirt( "longshirt" ); +static const itype_id itype_sneakers( "sneakers" ); +static const itype_id itype_socks( "socks" ); static const itype_id itype_water_clean( "water_clean" ); static const overmap_special_id overmap_special_tutorial( "tutorial" ); @@ -163,11 +168,11 @@ bool tutorial_game::init() starting_om.place_special_forced( overmap_special_tutorial, lp, om_direction::type::north ); starting_om.clear_mon_groups(); - player_character.wear_item( item( "boxer_shorts" ), false ); - player_character.wear_item( item( "jeans" ), false ); - player_character.wear_item( item( "longshirt" ), false ); - player_character.wear_item( item( "socks" ), false ); - player_character.wear_item( item( "sneakers" ), false ); + player_character.wear_item( item( itype_boxer_shorts ), false ); + player_character.wear_item( item( itype_jeans ), false ); + player_character.wear_item( item( itype_longshirt ), false ); + player_character.wear_item( item( itype_socks ), false ); + player_character.wear_item( item( itype_sneakers ), false ); player_character.set_skill_level( skill_gun, 5 ); player_character.set_skill_level( skill_melee, 5 ); diff --git a/src/iexamine.cpp b/src/iexamine.cpp index fd6f4c32c9441..e4b0d3b440d67 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -183,7 +183,9 @@ static const itype_id itype_marloss_seed( "marloss_seed" ); static const itype_id itype_mycus_fruit( "mycus_fruit" ); static const itype_id itype_nail( "nail" ); static const itype_id itype_nanomaterial( "nanomaterial" ); +static const itype_id itype_nectar( "nectar" ); static const itype_id itype_petrified_eye( "petrified_eye" ); +static const itype_id itype_poppy_nectar( "poppy_nectar" ); static const itype_id itype_sheet( "sheet" ); static const itype_id itype_stick( "stick" ); static const itype_id itype_string_36( "string_36" ); @@ -488,7 +490,8 @@ void iexamine::nanofab( Character &you, const tripoint_bub_ms &examp ) return; } - new_item = item( nanofab_template->get_var( "NANOFAB_ITEM_ID" ), calendar::turn ); + //TODO: Allow variables to be cata_variant ids + new_item = item( itype_id( nanofab_template->get_var( "NANOFAB_ITEM_ID" ) ), calendar::turn ); int qty = std::max( 1, new_item.volume() / 250_ml ); reqs = *nanofab_template->type->template_requirements * qty; } @@ -823,7 +826,7 @@ class atm_menu return false; } - item card( "cash_card", calendar::turn ); + item card( itype_cash_card, calendar::turn ); card.ammo_set( card.ammo_default(), 0 ); you.i_add( card ); you.cash -= 1000; @@ -1767,7 +1770,7 @@ void iexamine::pit_covered( Character &you, const tripoint_bub_ms &examp ) } map &here = get_map(); - item plank( "2x4", calendar::turn ); + item plank( itype_2x4, calendar::turn ); add_msg( _( "You remove the plank." ) ); here.add_item_or_charges( you.pos_bub(), plank ); const ter_id &ter_pit = here.ter( examp ); @@ -2249,7 +2252,7 @@ bool iexamine_helper::drink_nectar( Character &you ) { if( can_drink_nectar( you ) ) { add_msg( _( "You drink some nectar." ) ); - item nectar( "nectar", calendar::turn, 1 ); + item nectar( itype_nectar, calendar::turn, 1 ); you.assign_activity( consume_activity_actor( nectar ) ); return true; } @@ -2260,10 +2263,11 @@ bool iexamine_helper::drink_nectar( Character &you ) /** * Spawn an item after harvesting the plant */ +//BEFOREMERGE: Change to itype_id &itemid void iexamine_helper::handle_harvest( Character &you, const std::string &itemid, bool force_drop ) { - item harvest = item( itemid ); + item harvest = item( itype_id( itemid ) ); if( harvest.has_temperature() ) { harvest.set_item_temperature( get_weather().get_temperature( you.pos_bub() ) ); } @@ -2297,7 +2301,7 @@ void iexamine::flower_poppy( Character &you, const tripoint_bub_ms &examp ) return; } add_msg( _( "You slowly suck up the nectar." ) ); - item poppy( "poppy_nectar", calendar::turn, 1 ); + item poppy( itype_poppy_nectar, calendar::turn, 1 ); you.assign_activity( consume_activity_actor( poppy ) ); you.mod_sleepiness( 20 ); you.add_effect( effect_pkill2, 7_minutes ); @@ -3017,7 +3021,7 @@ void iexamine::kiln_empty( Character &you, const tripoint_bub_ms &examp ) you.use_charges( itype_fire, 1 ); here.i_clear( examp ); here.furn_set( examp, next_kiln_type ); - item result( "unfinished_charcoal", calendar::turn ); + item result( itype_unfinished_charcoal, calendar::turn ); result.charges = char_charges; here.add_item( examp, result ); @@ -3083,7 +3087,7 @@ void iexamine::kiln_full( Character &, const tripoint_bub_ms &examp ) } } - item result( "charcoal", calendar::turn ); + item result( itype_charcoal, calendar::turn ); result.charges = char_type->charges_per_volume( total_volume ); here.add_item( examp, result ); here.furn_set( examp, next_kiln_type ); @@ -3157,7 +3161,7 @@ void iexamine::arcfurnace_empty( Character &you, const tripoint_bub_ms &examp ) you.consume_ups( 1250_kJ ); here.i_clear( examp ); here.furn_set( examp, next_arcfurnace_type ); - item result( "unfinished_cac2", calendar::turn ); + item result( itype_unfinished_cac2, calendar::turn ); result.charges = char_charges; here.add_item( examp, result ); add_msg( _( "You turn on the furnace." ) ); @@ -3214,7 +3218,7 @@ void iexamine::arcfurnace_full( Character &, const tripoint_bub_ms &examp ) } } - item result( "chem_carbide", calendar::turn ); + item result( itype_chem_carbide, calendar::turn ); result.charges = char_type->charges_per_volume( total_volume ); here.add_item( examp, result ); here.furn_set( examp, next_arcfurnace_type ); @@ -4381,7 +4385,7 @@ void iexamine::tree_hickory( Character &you, const tripoint_bub_ms &examp ) static item_location maple_tree_sap_container() { - const item maple_sap = item( "maple_sap", calendar::turn_zero ); + const item maple_sap = item( itype_maple_sap, calendar::turn_zero ); return g->inv_map_splice( [&]( const item & it ) { return it.get_remaining_capacity_for_liquid( maple_sap, true ) > 0; }, _( "Use which container to collect sap?" ), PICKUP_RANGE, @@ -6294,7 +6298,7 @@ static void mill_activate( Character &you, const tripoint_bub_ms &examp ) } } here.furn_set( examp, next_mill_type ); - item result( "fake_milling_item", calendar::turn ); + item result( itype_fake_milling_item, calendar::turn ); result.item_counter = to_turns( milling_time ); result.activate(); here.add_item( examp, result ); @@ -6400,7 +6404,7 @@ static void smoker_activate( Character &you, const tripoint_bub_ms &examp ) } else { charcoal->charges -= char_charges; } - item result( "fake_smoke_plume", calendar::turn ); + item result( itype_fake_smoke_plume, calendar::turn ); result.item_counter = to_turns( 6_hours ); result.activate(); here.add_item( examp, result ); diff --git a/src/item.cpp b/src/item.cpp index 1add17d56ff70..a430e7a332446 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -173,10 +173,12 @@ static const itype_id itype_blood( "blood" ); static const itype_id itype_brass_catcher( "brass_catcher" ); static const itype_id itype_bullet_crossbow( "bullet_crossbow" ); static const itype_id itype_cash_card( "cash_card" ); +static const itype_id itype_corpse( "corpse" ); +static const itype_id itype_corpse_generic_human( "corpse_generic_human" ); +static const itype_id itype_craft( "craft" ); static const itype_id itype_disassembly( "disassembly" ); static const itype_id itype_hand_crossbow( "hand_crossbow" ); static const itype_id itype_joint_lit( "joint_lit" ); -static const itype_id itype_null( "null" ); static const itype_id itype_power_cord( "power_cord" ); static const itype_id itype_rad_badge( "rad_badge" ); static const itype_id itype_rm13_armor( "rm13_armor" ); @@ -539,7 +541,7 @@ static void inherit_rot_from_components( item &it ) } item::item( const recipe *rec, int qty, item_components items, std::vector selections ) - : item( "craft", calendar::turn ) + : item( itype_craft, calendar::turn ) { craft_data_ = cata::make_value(); craft_data_->making = rec; @@ -573,7 +575,7 @@ item::item( const recipe *rec, int qty, item_components items, std::vector(); craft_data_->making = rec; @@ -620,7 +622,7 @@ item item::make_corpse( const mtype_id &mt, time_point turn, const std::string & debugmsg( "tried to make a corpse with an invalid mtype id" ); } - std::string corpse_type = mt == mtype_id::NULL_ID() ? "corpse_generic_human" : "corpse"; + itype_id corpse_type = mt == mtype_id::NULL_ID() ? itype_corpse_generic_human : itype_corpse; item result( corpse_type, turn ); result.corpse = &mt.obj(); @@ -1248,7 +1250,7 @@ bool item::is_worn_by_player() const item item::in_its_container( int qty ) const { - return in_container( type->default_container.value_or( itype_null ), qty, + return in_container( type->default_container.value_or( itype_id::NULL_ID() ), qty, type->default_container_sealed, type->default_container_variant.value_or( "" ) ); } diff --git a/src/item.h b/src/item.h index eab1f670d893b..3e40022564143 100644 --- a/src/item.h +++ b/src/item.h @@ -1927,6 +1927,7 @@ class item : public visitable * */ /*@{*/ + //TODO: Add a set_var( const std::string &name, const cata_variant &id ) overload rather than using raw strings where appropriate void set_var( const std::string &name, int value ); void set_var( const std::string &name, long long value ); // Acceptable to use long as part of overload set diff --git a/src/item_group.cpp b/src/item_group.cpp index 8c886d8b0aa6e..f7d2129226d2c 100644 --- a/src/item_group.cpp +++ b/src/item_group.cpp @@ -30,8 +30,6 @@ #include "type_id.h" #include "units.h" -static const std::string null_item_id( "null" ); - std::size_t Item_spawn_data::create( ItemList &list, const time_point &birthday, spawn_flags flags ) const { @@ -190,20 +188,20 @@ item Single_item_creator::create_single_without_container( const time_point &bir { // Check direct return conditions first. if( type == S_NONE ) { - return item( null_item_id, birthday ); + return item( itype_id::NULL_ID(), birthday ); } Item_spawn_data *isd = nullptr; if( type == S_ITEM_GROUP ) { item_group_id group_id( id ); if( std::find( rec.begin(), rec.end(), group_id ) != rec.end() ) { debugmsg( "recursion in item spawn list %s", id.c_str() ); - return item( null_item_id, birthday ); + return item( itype_id::NULL_ID(), birthday ); } rec.push_back( group_id ); isd = item_controller->get_group( group_id ); if( isd == nullptr ) { debugmsg( "unknown item spawn list %s", id.c_str() ); - return item( null_item_id, birthday ); + return item( itype_id::NULL_ID(), birthday ); } } @@ -221,7 +219,7 @@ item Single_item_creator::create_single_without_container( const time_point &bir if( id == "corpse" ) { return item::make_corpse( mtype_id::NULL_ID(), birthday ); } else { - return item( id, birthday ); + return item( itype_id( id ), birthday ); } } } )(); @@ -863,7 +861,7 @@ item Item_group::create_single( const time_point &birthday, RecursionList &rec ) return elem->create_single( birthday, rec ); } } - return item( null_item_id, birthday ); + return item( itype_id::NULL_ID(), birthday ); } void Item_group::check_consistency( bool actually_spawn ) const diff --git a/src/item_pocket.cpp b/src/item_pocket.cpp index 646187ff322df..2b5524fe554fc 100644 --- a/src/item_pocket.cpp +++ b/src/item_pocket.cpp @@ -35,6 +35,8 @@ #include "units.h" #include "units_utility.h" +static const itype_id itype_water( "water" ); + namespace io { // *INDENT-OFF* @@ -452,7 +454,7 @@ bool item_pocket::is_funnel_container( units::volume &bigger_than ) const // should not be static, since after reloading some members of the item objects, // such as item types, may be invalidated. const std::vector allowed_liquids{ - item( "water", calendar::turn_zero, 1 ), + item( itype_water, calendar::turn_zero, 1 ), }; if( !data->watertight ) { return false; diff --git a/src/iuse.cpp b/src/iuse.cpp index 1f7ca2796a162..cf432c9d13da5 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -252,10 +252,14 @@ static const itype_id itype_arcade_machine( "arcade_machine" ); static const itype_id itype_atomic_coffeepot( "atomic_coffeepot" ); static const itype_id itype_barometer( "barometer" ); static const itype_id itype_battery( "battery" ); +static const itype_id itype_blood( "blood" ); +static const itype_id itype_blood_acid( "blood_acid" ); static const itype_id itype_c4armed( "c4armed" ); static const itype_id itype_canister_empty( "canister_empty" ); static const itype_id itype_cig( "cig" ); +static const itype_id itype_cig_lit( "cig_lit" ); static const itype_id itype_cigar( "cigar" ); +static const itype_id itype_cigar_lit( "cigar_lit" ); static const itype_id itype_cow_bell( "cow_bell" ); static const itype_id itype_detergent( "detergent" ); static const itype_id itype_ecig( "ecig" ); @@ -265,8 +269,10 @@ static const itype_id itype_firecracker_pack_act( "firecracker_pack_act" ); static const itype_id itype_geiger_on( "geiger_on" ); static const itype_id itype_handrolled_cig( "handrolled_cig" ); static const itype_id itype_heatpack_used( "heatpack_used" ); +static const itype_id itype_hotplate( "hotplate" ); static const itype_id itype_hygrometer( "hygrometer" ); static const itype_id itype_joint( "joint" ); +static const itype_id itype_joint_lit( "joint_lit" ); static const itype_id itype_liquid_soap( "liquid_soap" ); static const itype_id itype_log( "log" ); static const itype_id itype_mask_h20survivor_on( "mask_h20survivor_on" ); @@ -279,9 +285,11 @@ static const itype_id itype_multi_cooker( "multi_cooker" ); static const itype_id itype_multi_cooker_filled( "multi_cooker_filled" ); static const itype_id itype_nicotine_liquid( "nicotine_liquid" ); static const itype_id itype_paper( "paper" ); +static const itype_id itype_pot( "pot" ); static const itype_id itype_pur_tablets( "pur_tablets" ); static const itype_id itype_radio_car( "radio_car" ); static const itype_id itype_radio_car_on( "radio_car_on" ); +static const itype_id itype_radio_mod( "radio_mod" ); static const itype_id itype_radio_on( "radio_on" ); static const itype_id itype_rebreather_on( "rebreather_on" ); static const itype_id itype_rebreather_xl_on( "rebreather_xl_on" ); @@ -292,6 +300,10 @@ static const itype_id itype_smartphone_music( "smartphone_music" ); static const itype_id itype_soap( "soap" ); static const itype_id itype_soldering_iron( "soldering_iron" ); static const itype_id itype_spiral_stone( "spiral_stone" ); +static const itype_id itype_syringe( "syringe" ); +static const itype_id itype_tazer( "tazer" ); +static const itype_id itype_tongs( "tongs" ); +static const itype_id itype_toolset( "toolset" ); static const itype_id itype_towel( "towel" ); static const itype_id itype_towel_wet( "towel_wet" ); static const itype_id itype_water( "water" ); @@ -456,7 +468,7 @@ void remove_radio_mod( item &it, Character &p ) return; } p.add_msg_if_player( _( "You remove the radio modification from your %s." ), it.tname() ); - item mod( "radio_mod" ); + item mod( itype_radio_mod ); p.i_add_or_drop( mod, 1 ); it.unset_flag( flag_RADIO_ACTIVATION ); it.unset_flag( flag_RADIO_MOD ); @@ -570,17 +582,17 @@ std::optional iuse::smoking( Character *p, item *it, const tripoint_bub_ms item cig; if( it->typeId() == itype_cig || it->typeId() == itype_handrolled_cig ) { - cig = item( "cig_lit", calendar::turn ); + cig = item( itype_cig_lit, calendar::turn ); cig.item_counter = to_turns( 4_minutes ); p->mod_hunger( -3 ); p->mod_thirst( 2 ); } else if( it->typeId() == itype_cigar ) { - cig = item( "cigar_lit", calendar::turn ); + cig = item( itype_cigar_lit, calendar::turn ); cig.item_counter = to_turns( 12_minutes ); p->mod_thirst( 3 ); p->mod_hunger( -4 ); } else if( it->typeId() == itype_joint ) { - cig = item( "joint_lit", calendar::turn ); + cig = item( itype_joint_lit, calendar::turn ); cig.item_counter = to_turns( 4_minutes ); p->mod_hunger( 4 ); p->mod_thirst( 6 ); @@ -623,7 +635,7 @@ std::optional iuse::ecig( Character *p, item *it, const tripoint_bub_ms & ) p->add_msg_if_player( m_neutral, _( "You inhale some vapor from your advanced electronic cigarette." ) ); p->use_charges( itype_nicotine_liquid, 1 ); - item dummy_ecig = item( "ecig", calendar::turn ); + item dummy_ecig = item( itype_ecig, calendar::turn ); p->consume_effects( dummy_ecig ); } else { p->add_msg_if_player( m_info, _( "You don't have any nicotine liquid!" ) ); @@ -925,7 +937,7 @@ std::optional iuse::flu_vaccine( Character *p, item *it, const tripoint_bub _( "You notice the date on the packaging is pretty old. It may no longer be effective." ) ); } p->mod_pain( 3 ); - item syringe( "syringe", it->birthday() ); + item syringe( itype_syringe, it->birthday() ); p->i_add_or_drop( syringe ); return 1; } @@ -1233,7 +1245,7 @@ std::optional iuse::purify_smart( Character *p, item *it, const tripoint_bu p->mod_pain( 3 ); - item syringe( "syringe", it->birthday() ); + item syringe( itype_syringe, it->birthday() ); p->i_add( syringe ); p->vitamins_mod( default_character_compute_effective_nutrients( *it ).vitamins() ); get_event_bus().send( p->getID(), @@ -3738,7 +3750,7 @@ std::optional iuse::tazer2( Character *p, item *it, const tripoint_bub_ms & if( it->ammo_remaining( p, true ) >= 2 ) { // Instead of having a ctrl+c+v of the function above, spawn a fake tazer and use it // Ugly, but less so than copied blocks - item fake( "tazer", calendar::turn_zero ); + item fake( itype_tazer, calendar::turn_zero ); fake.charges = 2; return tazer( p, &fake, pos ); } else { @@ -4503,7 +4515,7 @@ std::optional iuse::blood_draw( Character *p, item *it, const tripoint_bub_ return std::nullopt; } - item blood( "blood", calendar::turn ); + item blood( itype_blood, calendar::turn ); bool drew_blood = false; bool acid_blood = false; bool vampire = false; @@ -4552,7 +4564,7 @@ std::optional iuse::blood_draw( Character *p, item *it, const tripoint_bub_ } if( acid_blood ) { - item acid( "blood_acid", calendar::turn ); + item acid( itype_blood_acid, calendar::turn ); acid.set_item_temperature( blood_temp ); it->put_in( acid, pocket_type::CONTAINER ); if( one_in( 3 ) ) { @@ -5143,7 +5155,7 @@ std::optional iuse::adrenaline_injector( Character *p, item *it, const trip p->add_msg_player_or_npc( _( "You inject yourself with adrenaline." ), _( " injects themselves with adrenaline." ) ); - item syringe( "syringe", it->birthday() ); + item syringe( itype_syringe, it->birthday() ); p->i_add( syringe ); if( p->has_effect( effect_adrenaline ) ) { p->add_msg_if_player( m_bad, _( "Your heart spasms!" ) ); @@ -7681,13 +7693,13 @@ std::optional iuse::multicooker( Character *p, item *it, const tripoint_bub // add some tools and qualities. we can't add this qualities to // json, because multicook must be used only by activating, not as // component other crafts. - crafting_inv.push_back( item( "hotplate", calendar::turn_zero ) ); //hotplate inside + crafting_inv.push_back( item( itype_hotplate, calendar::turn_zero ) ); //hotplate inside // some recipes requires tongs - crafting_inv.push_back( item( "tongs", calendar::turn_zero ) ); + crafting_inv.push_back( item( itype_tongs, calendar::turn_zero ) ); // toolset with CUT and other qualities inside - crafting_inv.push_back( item( "toolset", calendar::turn_zero ) ); + crafting_inv.push_back( item( itype_toolset, calendar::turn_zero ) ); // good COOK, BOIL, CONTAIN qualities inside - crafting_inv.push_back( item( "pot", calendar::turn_zero ) ); + crafting_inv.push_back( item( itype_pot, calendar::turn_zero ) ); int counter = 0; static const std::set multicooked_subcats = { "CSC_FOOD_MEAT", "CSC_FOOD_VEGGI", "CSC_FOOD_PASTA" }; @@ -7859,7 +7871,8 @@ std::optional iuse::multicooker_tick( Character *p, item *it, const tripoin } if( cooktime <= 0 ) { - item meal( it->get_var( "DISH" ), time_point( calendar::turn ), 1 ); + //TODO: Allow variables to be cata_variant ids + item meal( itype_id( it->get_var( "DISH" ) ), time_point( calendar::turn ), 1 ); if( ( *recipe_id( it->get_var( "RECIPE" ) ) ).hot_result() ) { meal.heat_up(); } else { diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 191cd31549d99..13e396b0a6888 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -882,8 +882,9 @@ std::optional consume_drug_iuse::use( Character *p, item &it, const tripoin } } + //BEFOREMERGE: Typify raw string consume_drug_iuse::used_up_item if( !used_up_item.empty() ) { - item used_up( used_up_item, it.birthday() ); + item used_up( itype_id( used_up_item ), it.birthday() ); p->i_add_or_drop( used_up ); } @@ -4121,7 +4122,7 @@ std::optional saw_barrel_actor::use( Character *p, item &it, const tripoint item &obj = *loc.obtain( *p ); p->add_msg_if_player( _( "You saw down the barrel of your %s." ), obj.tname() ); - obj.put_in( item( "barrel_small", calendar::turn ), pocket_type::MOD ); + obj.put_in( item( itype_barrel_small, calendar::turn ), pocket_type::MOD ); return 0; } @@ -4182,7 +4183,7 @@ std::optional saw_stock_actor::use( Character *p, item &it, const tripoint_ item &obj = *loc.obtain( *p ); p->add_msg_if_player( _( "You saw down the stock of your %s." ), obj.tname() ); - obj.put_in( item( "stock_none", calendar::turn ), pocket_type::MOD ); + obj.put_in( item( itype_stock_none, calendar::turn ), pocket_type::MOD ); return 0; } diff --git a/src/magic_spell_effect.cpp b/src/magic_spell_effect.cpp index 1a20bf806596d..6332dc84bc2b7 100644 --- a/src/magic_spell_effect.cpp +++ b/src/magic_spell_effect.cpp @@ -1179,7 +1179,7 @@ void spell_effect::spawn_ethereal_item( const spell &sp, Creature &caster, calendar::turn ); granted.insert( granted.end(), group_items.begin(), group_items.end() ); } else { - granted.emplace_back( sp.effect_data(), calendar::turn ); + granted.emplace_back( itype_id( sp.effect_data() ), calendar::turn ); } } diff --git a/src/map.cpp b/src/map.cpp index c0f62fbf3b485..6b744f6cf6095 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -151,7 +151,14 @@ static const item_group_id Item_spawn_data_default_zombie_clothes( "default_zomb static const item_group_id Item_spawn_data_default_zombie_items( "default_zombie_items" ); static const itype_id itype_battery( "battery" ); +static const itype_id itype_maple_sap( "maple_sap" ); static const itype_id itype_nail( "nail" ); +static const itype_id itype_pipe( "pipe" ); +static const itype_id itype_rock( "rock" ); +static const itype_id itype_scrap( "scrap" ); +static const itype_id itype_splinter( "splinter" ); +static const itype_id itype_steel_chunk( "steel_chunk" ); +static const itype_id itype_wire( "wire" ); static const json_character_flag json_flag_WALL_CLING( "WALL_CLING" ); @@ -2368,8 +2375,8 @@ bool map::ter_set( const tripoint_bub_ms &p, const ter_id &new_terrain, bool avo } if( !new_t.liquid_source_item_id.empty() && new_t.liquid_source_count != std::make_pair( 0, 0 ) ) { - - item water( new_t.liquid_source_item_id, calendar::start_of_cataclysm ); + //BEFOREMERGE: Typify raw string ter_t::liquid_source_item_id + item water( itype_id( new_t.liquid_source_item_id ), calendar::start_of_cataclysm ); water.charges = rng( new_t.liquid_source_count.first, new_t.liquid_source_count.second ); add_item( p, water ); } @@ -3534,24 +3541,24 @@ void map::make_rubble( const tripoint_bub_ms &p, const furn_id &rubble_type, con //Still hardcoded, but a step up from the old stuff due to being in only one place if( rubble_type == furn_f_wreckage ) { - item chunk( "steel_chunk", calendar::turn ); - item scrap( "scrap", calendar::turn ); + item chunk( itype_steel_chunk, calendar::turn ); + item scrap( itype_scrap, calendar::turn ); add_item_or_charges( p, chunk ); add_item_or_charges( p, scrap ); if( one_in( 5 ) ) { - item pipe( "pipe", calendar::turn ); - item wire( "wire", calendar::turn ); + item pipe( itype_pipe, calendar::turn ); + item wire( itype_wire, calendar::turn ); add_item_or_charges( p, pipe ); add_item_or_charges( p, wire ); } } else if( rubble_type == furn_f_rubble_rock ) { - item rock( "rock", calendar::turn ); + item rock( itype_rock, calendar::turn ); int rock_count = rng( 1, 3 ); for( int i = 0; i < rock_count; i++ ) { add_item_or_charges( p, rock ); } } else if( rubble_type == furn_f_rubble ) { - item splinter( "splinter", calendar::turn ); + item splinter( itype_splinter, calendar::turn ); int splinter_count = rng( 2, 8 ); for( int i = 0; i < splinter_count; i++ ) { add_item_or_charges( p, splinter ); @@ -5664,7 +5671,9 @@ item map::liquid_from( const tripoint_bub_ms &p ) const if( !source_terrain.liquid_source_item_id.empty() && source_terrain.liquid_source_count == std::make_pair( 0, 0 ) ) { - item ret( source_terrain.liquid_source_item_id, calendar::turn, item::INFINITE_CHARGES ); + //BEFOREMERGE: Typify raw string ter_t::liquid_source_item_id + item ret( itype_id( source_terrain.liquid_source_item_id ), calendar::turn, + item::INFINITE_CHARGES ); ret.set_item_temperature( std::max( weather.get_temperature( p ), units::from_celsius( source_terrain.liquid_source_min_temp ) ) ); return ret; @@ -8739,7 +8748,8 @@ void map::handle_decayed_corpse( const item &it, const tripoint_abs_ms &pnt ) bool anything_left = false; for( const harvest_entry &entry : *dead_monster->decay ) { - item harvest = item( entry.drop ); + //BEFOREMERGE: Typify raw string harvest_entry::drop + item harvest = item( itype_id( entry.drop ) ); const float random_decay_modifier = rng_float( 0.0f, static_cast( MAX_SKILL ) ); const float min_num = entry.scale_num.first * random_decay_modifier + entry.base_num.first; const float max_num = entry.scale_num.second * random_decay_modifier + entry.base_num.second; @@ -8974,7 +8984,7 @@ void map::produce_sap( const tripoint_bub_ms &p, const time_duration &time_since return; } - item sap( "maple_sap", calendar::turn ); + item sap( itype_maple_sap, calendar::turn ); sap.set_item_temperature( get_weather().get_temperature( p ) ); sap.charges = new_charges; diff --git a/src/map_field.cpp b/src/map_field.cpp index 0897adb0b44fb..de8138066582d 100644 --- a/src/map_field.cpp +++ b/src/map_field.cpp @@ -86,6 +86,7 @@ static const flag_id json_flag_NO_UNLOAD( "NO_UNLOAD" ); static const furn_str_id furn_f_ash( "f_ash" ); +static const itype_id itype_ash( "ash" ); static const itype_id itype_rm13_armor_on( "rm13_armor_on" ); static const itype_id itype_rock( "rock" ); @@ -1127,7 +1128,7 @@ void field_processor_fd_fire( const tripoint &p, field_entry &cur, field_proc_da if( cur.get_field_intensity() > 1 && one_in( 200 - cur.get_field_intensity() * 50 ) ) { here.furn_set( pos, furn_f_ash ); - here.add_item_or_charges( pos, item( "ash" ) ); + here.add_item_or_charges( pos, item( itype_ash ) ); } } else if( ter.has_flag( ter_furn_flag::TFLAG_NO_FLOOR ) && pos.z() > -OVERMAP_DEPTH ) { diff --git a/src/mapgen.cpp b/src/mapgen.cpp index ae5422419f814..52161d97b4204 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -121,6 +121,7 @@ static const itype_id itype_avgas( "avgas" ); static const itype_id itype_diesel( "diesel" ); static const itype_id itype_gasoline( "gasoline" ); static const itype_id itype_jp8( "jp8" ); +static const itype_id itype_water( "water" ); static const mongroup_id GROUP_BREATHER( "GROUP_BREATHER" ); static const mongroup_id GROUP_BREATHER_HUB( "GROUP_BREATHER_HUB" ); @@ -6631,7 +6632,7 @@ void map::place_gas_pump( const tripoint_bub_ms &p, int charges ) void map::place_toilet( const tripoint_bub_ms &p, int charges ) { - item water( "water", calendar::start_of_cataclysm ); + item water( itype_water, calendar::start_of_cataclysm ); water.charges = charges; add_item( p, water ); furn_set( p, furn_f_toilet ); diff --git a/src/mattack_actors.cpp b/src/mattack_actors.cpp index 5e4c01591c817..92b0a7e812c8c 100644 --- a/src/mattack_actors.cpp +++ b/src/mattack_actors.cpp @@ -64,6 +64,8 @@ static const flag_id json_flag_CANNOT_MOVE( "CANNOT_MOVE" ); static const flag_id json_flag_GRAB( "GRAB" ); static const flag_id json_flag_GRAB_FILTER( "GRAB_FILTER" ); +static const itype_id itype_backpack( "backpack" ); + static const json_character_flag json_flag_BIONIC_LIMB( "BIONIC_LIMB" ); static const skill_id skill_gun( "gun" ); @@ -1268,7 +1270,7 @@ bool gun_actor::shoot( monster &z, const tripoint_bub_ms &target, const gun_mode z.mod_moves( -move_cost ); standard_npc tmp( _( "The " ) + z.name(), z.pos_bub(), {}, 8, fake_str, fake_dex, fake_int, fake_per ); - tmp.worn.wear_item( tmp, item( "backpack" ), false, false, true, true ); + tmp.worn.wear_item( tmp, item( itype_backpack ), false, false, true, true ); tmp.set_fake( true ); tmp.set_attitude( z.friendly ? NPCATT_FOLLOW : NPCATT_KILL ); diff --git a/src/mission.cpp b/src/mission.cpp index e6c88923e5cf9..3af9382c660f3 100644 --- a/src/mission.cpp +++ b/src/mission.cpp @@ -42,7 +42,6 @@ static const efftype_id effect_pet( "pet" ); static const efftype_id effect_run( "run" ); -static const itype_id itype_null( "null" ); static const mission_type_id mission_NULL( "NULL" ); @@ -408,7 +407,7 @@ void mission::wrap_up() std::map matches = std::map(); get_all_item_group_matches( items, grp_type, matches, - container, itype_null, specific_container_required ); + container, itype_id::NULL_ID(), specific_container_required ); comps.reserve( matches.size() ); for( std::pair &cnt : matches ) { @@ -509,7 +508,7 @@ bool mission::is_complete( const character_id &_npc_id ) const std::map matches = std::map(); get_all_item_group_matches( items, grp_type, matches, - container, itype_null, specific_container_required ); + container, itype_id::NULL_ID(), specific_container_required ); int total_match = std::accumulate( matches.begin(), matches.end(), 0, []( const std::size_t previous, const std::pair &p ) { diff --git a/src/mission_start.cpp b/src/mission_start.cpp index e76b646d18877..7e83741b56ca7 100644 --- a/src/mission_start.cpp +++ b/src/mission_start.cpp @@ -36,6 +36,7 @@ static const furn_str_id furn_f_dresser( "f_dresser" ); static const itype_id itype_software_medical( "software_medical" ); static const itype_id itype_software_useless( "software_useless" ); +static const itype_id itype_usb_drive( "usb_drive" ); static const mission_type_id mission_MISSION_GET_ZOMBIE_BLOOD_ANAL( "MISSION_GET_ZOMBIE_BLOOD_ANAL" ); @@ -148,7 +149,7 @@ void mission_start::place_npc_software( mission *miss ) debugmsg( "Couldn't find NPC! %d", miss->npc_id.get_value() ); return; } - get_player_character().i_add( item( "usb_drive", calendar::turn_zero ) ); + get_player_character().i_add( item( itype_usb_drive, calendar::turn_zero ) ); add_msg( _( "%s gave you a USB drive." ), dev->get_name() ); std::string type = "house"; diff --git a/src/monattack.cpp b/src/monattack.cpp index 3dfc7a8978f6a..761b9714216c9 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -155,7 +155,9 @@ static const itype_id itype_bot_gasbomb_hack( "bot_gasbomb_hack" ); static const itype_id itype_bot_grenade_hack( "bot_grenade_hack" ); static const itype_id itype_bot_mininuke_hack( "bot_mininuke_hack" ); static const itype_id itype_bot_pacification_hack( "bot_pacification_hack" ); +static const itype_id itype_processor( "processor" ); static const itype_id itype_e_handcuffs( "e_handcuffs" ); +static const itype_id itype_sporeos( "sporeos" ); static const json_character_flag json_flag_BIONIC_LIMB( "BIONIC_LIMB" ); @@ -1684,7 +1686,7 @@ bool mattack::fungus_corporate( monster *z ) sounds::sound( z->pos_bub(), 10, sounds::sound_t::speech, _( "\"Buy SpOreos™ now!\"" ) ); if( get_player_view().sees( *z ) ) { add_msg( m_warning, _( "Delicious snacks are released from the %s!" ), z->name() ); - get_map().add_item( z->pos_bub(), item( "sporeos" ) ); + get_map().add_item( z->pos_bub(), item( itype_sporeos ) ); } // only spawns SpOreos if the player is near; can't have the COMMONERS stealing our product from good customers return true; } else { @@ -2854,7 +2856,7 @@ bool mattack::searchlight( monster *z ) creature_tracker &creatures = get_creature_tracker(); for( int i = 0; i < max_lamp_count; i++ ) { - item settings( "processor", calendar::turn_zero ); + item settings( itype_processor, calendar::turn_zero ); settings.set_var( "SL_PREFER_UP", "TRUE" ); settings.set_var( "SL_PREFER_DOWN", "TRUE" ); @@ -3676,7 +3678,7 @@ bool mattack::riotbot( monster *z ) if( choice == ur_arrest ) { z->anger = 0; - item handcuffs( "e_handcuffs", calendar::turn_zero ); + item handcuffs( itype_e_handcuffs, calendar::turn_zero ); handcuffs.charges = handcuffs.type->maximum_charges(); handcuffs.active = true; handcuffs.set_var( "HANDCUFFS_X", foe->posx() ); diff --git a/src/mondeath.cpp b/src/mondeath.cpp index 232dacf5e8140..d24ae9079c82c 100644 --- a/src/mondeath.cpp +++ b/src/mondeath.cpp @@ -222,13 +222,15 @@ void mdeath::broken( monster &z ) if( z.no_corpse_quiet ) { return; } + + //FIXME Remove hardcoded id manipulation std::string item_id = z.type->id.str(); if( item_id.compare( 0, 4, "mon_" ) == 0 ) { item_id.erase( 0, 4 ); } // make "broken_manhack", or "broken_eyebot", ... item_id.insert( 0, "broken_" ); - item broken_mon( item_id, calendar::turn ); + item broken_mon( itype_id( item_id ), calendar::turn ); const int max_hp = std::max( z.get_hp_max(), 1 ); const float overflow_damage = std::max( -z.get_hp(), 0 ); const float corpse_damage = 2.5 * overflow_damage / max_hp; diff --git a/src/monmove.cpp b/src/monmove.cpp index c52478b7ceb97..b7a6f5a379fef 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -82,6 +82,8 @@ static const flag_id json_flag_CANNOT_MOVE( "CANNOT_MOVE" ); static const flag_id json_flag_GRAB( "GRAB" ); static const flag_id json_flag_GRAB_FILTER( "GRAB_FILTER" ); +static const itype_id itype_gasoline( "gasoline" ); +static const itype_id itype_napalm( "napalm" ); static const itype_id itype_pressurized_tank( "pressurized_tank" ); static const material_id material_iflesh( "iflesh" ); @@ -2030,7 +2032,7 @@ bool monster::move_to( const tripoint_bub_ms &p, bool force, bool step_on_critte if( one_in( 10 ) ) { // if it has more napalm, drop some and reduce ammo in tank if( ammo[itype_pressurized_tank] > 0 ) { - here.add_item_or_charges( pos_bub(), item( "napalm", calendar::turn, 50 ) ); + here.add_item_or_charges( pos_bub(), item( itype_napalm, calendar::turn, 50 ) ); ammo[itype_pressurized_tank] -= 50; } else { // TODO: remove mon_flag_DRIPS_NAPALM flag since no more napalm in tank @@ -2041,7 +2043,7 @@ bool monster::move_to( const tripoint_bub_ms &p, bool force, bool step_on_critte if( has_flag( mon_flag_DRIPS_GASOLINE ) ) { if( one_in( 5 ) ) { // TODO: use same idea that limits napalm dripping - here.add_item_or_charges( pos_bub(), item( "gasoline" ) ); + here.add_item_or_charges( pos_bub(), item( itype_gasoline ) ); } } } diff --git a/src/monster.cpp b/src/monster.cpp index 78ac5154edd31..5cf0a830affdf 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -144,8 +144,11 @@ static const flag_id json_flag_DISABLE_FLIGHT( "DISABLE_FLIGHT" ); static const flag_id json_flag_GRAB( "GRAB" ); static const flag_id json_flag_GRAB_FILTER( "GRAB_FILTER" ); +static const itype_id itype_beartrap( "beartrap" ); static const itype_id itype_milk( "milk" ); static const itype_id itype_milk_raw( "milk_raw" ); +static const itype_id itype_rope_6( "rope_6" ); +static const itype_id itype_snare_trigger( "snare_trigger" ); static const json_character_flag json_flag_ANIMALDISCORD( "ANIMALDISCORD" ); static const json_character_flag json_flag_ANIMALDISCORD2( "ANIMALDISCORD2" ); @@ -3051,11 +3054,11 @@ void monster::die( Creature *nkiller ) move_special_item_to_inv( tied_item ); if( has_effect( effect_heavysnare ) ) { - add_item( item( "rope_6", calendar::turn_zero ) ); - add_item( item( "snare_trigger", calendar::turn_zero ) ); + add_item( item( itype_rope_6, calendar::turn_zero ) ); + add_item( item( itype_snare_trigger, calendar::turn_zero ) ); } if( has_effect( effect_beartrap ) ) { - add_item( item( "beartrap", calendar::turn_zero ) ); + add_item( item( itype_beartrap, calendar::turn_zero ) ); } } diff --git a/src/npc.cpp b/src/npc.cpp index dd57b0d87fb55..9071c193daf37 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -114,6 +114,8 @@ static const item_group_id Item_spawn_data_survivor_bashing( "survivor_bashing" static const item_group_id Item_spawn_data_survivor_cutting( "survivor_cutting" ); static const item_group_id Item_spawn_data_survivor_stabbing( "survivor_stabbing" ); +static const itype_id itype_molotov( "molotov" ); + static const json_character_flag json_flag_CANNIBAL( "CANNIBAL" ); static const json_character_flag json_flag_PSYCHOPATH( "PSYCHOPATH" ); static const json_character_flag json_flag_READ_IN_DARKNESS( "READ_IN_DARKNESS" ); @@ -293,8 +295,9 @@ standard_npc::standard_npc( const std::string &name, const tripoint_bub_ms &pos, set_skill_level( e.ident(), std::max( sk_lvl, 0 ) ); } + //BEFOREMERGE: Change to std::vector for( const std::string &e : clothing ) { - wear_item( item( e ), false ); + wear_item( item( itype_id( e ) ), false ); } worn.set_fitted(); @@ -575,7 +578,7 @@ void npc::randomize( const npc_class_id &type, const npc_template_id &tem_id ) return; } - set_wielded_item( item( "null", calendar::turn_zero ) ); + set_wielded_item( item( itype_id::NULL_ID(), calendar::turn_zero ) ); inv->clear(); randomize_personality(); moves = 100; @@ -930,7 +933,7 @@ void starting_inv( npc &who, const npc_class_id &type ) starting_inv_ammo( who, res, multiplier ); if( type == NC_ARSONIST ) { - res.emplace_back( "molotov" ); + res.emplace_back( itype_molotov ); } int qty = ( type == NC_EVAC_SHOPKEEP ) ? 5 : 2; diff --git a/src/npctalk.cpp b/src/npctalk.cpp index 421fa2b6beb65..59e014dbbaacf 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -3627,7 +3627,8 @@ void receive_item( itype_id &item_name, int count, std::string_view container_na } } } else { - item container( std::string( container_name ), calendar::turn ); + //BEFOREMERGE: See if this can be changed to pass an itype_id + item container( itype_id( container_name ), calendar::turn ); new_item.charges = count; container.put_in( new_item, pocket_type::CONTAINER ); diff --git a/src/npctalk_funcs.cpp b/src/npctalk_funcs.cpp index 4ef037f1b411a..c5257d368f201 100644 --- a/src/npctalk_funcs.cpp +++ b/src/npctalk_funcs.cpp @@ -581,11 +581,11 @@ static void bionic_remove_common( npc &p, Character &patient ) std::vector bionic_names; std::vector bionics; for( const bionic &bio : all_bio ) { - if( std::find( bionic_types.begin(), bionic_types.end(), - bio.info().itype() ) == bionic_types.end() ) { - bionic_types.push_back( bio.info().itype() ); - if( item::type_is_defined( bio.info().itype() ) ) { - item tmp = item( bio.id.str(), calendar::turn_zero ); + const itype_id &bio_itype = bio.info().itype(); + if( std::find( bionic_types.begin(), bionic_types.end(), bio_itype ) == bionic_types.end() ) { + bionic_types.push_back( bio_itype ); + if( item::type_is_defined( bio_itype ) ) { + item tmp = item( bio_itype, calendar::turn_zero ); bionic_names.push_back( tmp.tname() + " - " + format_money( 5000 + ( tmp.price( true ) / 4 ) ) ); } else { bionic_names.push_back( bio.id.str() + " - " + format_money( 5000 ) ); diff --git a/src/player_difficulty.cpp b/src/player_difficulty.cpp index 89a164c97bf7d..6b307495017eb 100644 --- a/src/player_difficulty.cpp +++ b/src/player_difficulty.cpp @@ -10,6 +10,10 @@ static const damage_type_id damage_bash( "bash" ); +static const itype_id itype_bat( "bat" ); +static const itype_id itype_knife_combat( "knife_combat" ); +static const itype_id itype_machete( "machete" ); + static const profession_id profession_unemployed( "unemployed" ); player_difficulty::player_difficulty() @@ -180,9 +184,9 @@ double player_difficulty::calc_dps_value( const Character &u ) { // check against the big three // efficient early weapons you can easily get access to - item early_piercing = item( "knife_combat" ); - item early_cutting = item( "machete" ); - item early_bashing = item( "bat" ); + item early_piercing = item( itype_knife_combat ); + item early_cutting = item( itype_machete ); + item early_bashing = item( itype_bat ); double baseline = std::max( u.weapon_value( early_piercing ), u.weapon_value( early_cutting ) ); diff --git a/src/recipe.cpp b/src/recipe.cpp index b902993479435..0a8a9b2074a05 100644 --- a/src/recipe.cpp +++ b/src/recipe.cpp @@ -43,7 +43,6 @@ static const itype_id itype_atomic_coffeepot( "atomic_coffeepot" ); static const itype_id itype_hotplate( "hotplate" ); -static const itype_id itype_null( "null" ); static const std::string flag_FULL_MAGAZINE( "FULL_MAGAZINE" ); @@ -600,7 +599,7 @@ void recipe::finalize() } if( contained && container.is_null() ) { - container = item::find_type( result_ )->default_container.value_or( itype_null ); + container = item::find_type( result_ )->default_container.value_or( itype_id::NULL_ID() ); if( item::find_type( result_ )->default_container_variant.has_value() ) { container_variant = item::find_type( result_ )->default_container_variant.value(); } diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index 584b640f0b5b9..d15271307e596 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -135,13 +135,20 @@ static const anatomy_id anatomy_human_anatomy( "human_anatomy" ); static const efftype_id effect_riding( "riding" ); +static const itype_id fuel_type_battery( "battery" ); +static const itype_id fuel_type_chem_ethanol( "chem_ethanol" ); +static const itype_id fuel_type_gasoline( "gasoline" ); +static const itype_id fuel_type_motor_oil( "motor_oil" ); static const itype_id itype_internal_battery_compartment( "internal_battery_compartment" ); static const itype_id itype_internal_ethanol_tank( "internal_ethanol_tank" ); static const itype_id itype_internal_gasoline_tank( "internal_gasoline_tank" ); static const itype_id itype_internal_oil_tank( "internal_oil_tank" ); +static const itype_id itype_medium_battery_cell( "medium_battery_cell" ); static const itype_id itype_rad_badge( "rad_badge" ); static const itype_id itype_radio( "radio" ); static const itype_id itype_radio_on( "radio_on" ); +static const itype_id itype_rock( "rock" ); +static const itype_id itype_steel_chunk( "steel_chunk" ); static const itype_id itype_usb_drive( "usb_drive" ); static const matype_id style_none( "style_none" ); @@ -1206,23 +1213,23 @@ void Character::load( const JsonObject &data ) // Migrate old fuels to new system. // Needed to be compatible with 0.F if( b_it == itype_internal_gasoline_tank && !get_value( "gasoline" ).empty() ) { - item gasoline( "gasoline" ); + item gasoline( fuel_type_gasoline ); gasoline.charges = std::stoi( get_value( "gasoline" ) ); remove_value( "gasoline" ); pseudo.put_in( gasoline, pocket_type::CONTAINER ); } else if( b_it == itype_internal_ethanol_tank && !get_value( "alcohol" ).empty() ) { - item ethanol( "chem_ethanol" ); + item ethanol( fuel_type_chem_ethanol ); ethanol.charges = std::stoi( get_value( "alcohol" ) ); remove_value( "alcohol" ); pseudo.put_in( ethanol, pocket_type::CONTAINER ); } else if( b_it == itype_internal_oil_tank && !get_value( "motor_oil" ).empty() ) { - item oil( "motor_oil" ); + item oil( fuel_type_motor_oil ); oil.charges = std::stoi( get_value( "motor_oil" ) ); remove_value( "motor_oil" ); pseudo.put_in( oil, pocket_type::CONTAINER ); } else if( b_it == itype_internal_battery_compartment && !get_value( "battery" ).empty() ) { - item battery( "medium_battery_cell" ); - item battery_charge( "battery" ); + item battery( itype_medium_battery_cell ); + item battery_charge( fuel_type_battery ); battery_charge.charges = std::min( 500, std::stoi( get_value( "battery" ) ) ); battery.put_in( battery_charge, pocket_type::MAGAZINE ); remove_value( "battery" ); @@ -4976,8 +4983,8 @@ void submap::load( const JsonValue &jv, const std::string &member_name, int vers JsonArray terrain_json = jv; // Small duplication here so that the update check is only performed once if( rubpow_update ) { - item rock = item( "rock", calendar::turn_zero ); - item chunk = item( "steel_chunk", calendar::turn_zero ); + item rock = item( itype_rock, calendar::turn_zero ); + item chunk = item( itype_steel_chunk, calendar::turn_zero ); for( int j = 0; j < SEEY; j++ ) { for( int i = 0; i < SEEX; i++ ) { const ter_str_id tid( terrain_json.next_string() ); diff --git a/src/veh_appliance.cpp b/src/veh_appliance.cpp index 672ba57e6e570..6b7904d4f2dfb 100644 --- a/src/veh_appliance.cpp +++ b/src/veh_appliance.cpp @@ -25,6 +25,7 @@ static const activity_id ACT_VEHICLE( "ACT_VEHICLE" ); static const itype_id fuel_type_battery( "battery" ); +static const itype_id itype_power_cord( "power_cord" ); static const itype_id itype_wall_wiring( "wall_wiring" ); static const quality_id qual_HOSE( "HOSE" ); @@ -530,7 +531,7 @@ void veh_app_interact::plug() { const int part = veh->part_at( veh->coord_translate( a_point ) ); const tripoint_bub_ms pos = veh->bub_part_pos( part ); - item cord( "power_cord" ); + item cord( itype_power_cord ); cord.link_to( *veh, a_point, link_state::automatic ); if( cord.get_use( "link_up" ) ) { cord.type->get_use( "link_up" )->call( &get_player_character(), cord, pos ); diff --git a/src/veh_type.cpp b/src/veh_type.cpp index beffc0c46c743..50121f18578c2 100644 --- a/src/veh_type.cpp +++ b/src/veh_type.cpp @@ -50,8 +50,6 @@ static const ammotype ammo_battery( "battery" ); static const itype_id fuel_type_animal( "animal" ); -static const itype_id itype_null( "null" ); - static const quality_id qual_JACK( "JACK" ); static const quality_id qual_LIFT( "LIFT" ); @@ -634,7 +632,7 @@ void vehicles::parts::finalize() void vpart_info::finalize() { - if( engine_info && engine_info->fuel_opts.empty() && fuel_type != itype_null ) { + if( engine_info && engine_info->fuel_opts.empty() && !fuel_type.is_null() ) { engine_info->fuel_opts.push_back( fuel_type ); } diff --git a/src/vehicle.cpp b/src/vehicle.cpp index f5684c6703a98..e14aff78b462b 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -109,7 +109,9 @@ static const itype_id fuel_type_muscle( "muscle" ); static const itype_id fuel_type_plutonium_cell( "plut_cell" ); static const itype_id fuel_type_wind( "wind" ); static const itype_id itype_battery( "battery" ); +static const itype_id itype_generic_folded_vehicle( "generic_folded_vehicle" ); static const itype_id itype_plut_cell( "plut_cell" ); +static const itype_id itype_plut_slurry_dense( "plut_slurry_dense" ); static const itype_id itype_wall_wiring( "wall_wiring" ); static const itype_id itype_water( "water" ); static const itype_id itype_water_clean( "water_clean" ); @@ -5118,7 +5120,7 @@ void vehicle::consume_fuel( int load, bool idling ) int base_burn = actual_staminaRegen - 3; base_burn = std::max( eff_load / 3, base_burn ); //charge bionics when using muscle engine - const item muscle( "muscle" ); + const item muscle( fuel_type_muscle ); for( const bionic_id &bid : driver->get_bionic_fueled_with_muscle() ) { if( driver->has_active_bionic( bid ) ) { // active power gen // more pedaling = more power @@ -6023,7 +6025,7 @@ void vehicle::slow_leak() p.ammo_consume( qty, bub_part_pos( p ) ); } else if( fuel == fuel_type_plutonium_cell ) { if( p.ammo_remaining() >= PLUTONIUM_CHARGES / 10 ) { - item leak( "plut_slurry_dense", calendar::turn, qty ); + item leak( itype_plut_slurry_dense, calendar::turn, qty ); here.add_item_or_charges( dest, leak ); p.ammo_consume( qty * PLUTONIUM_CHARGES / 10, bub_part_pos( p ) ); } else { @@ -7895,7 +7897,7 @@ time_duration vehicle::unfolding_time() const item vehicle::get_folded_item() const { - item folded( "generic_folded_vehicle", calendar::turn ); + item folded( itype_generic_folded_vehicle, calendar::turn ); const std::vector> &parts = real_parts(); try { std::ostringstream veh_data; @@ -8200,8 +8202,8 @@ void vehicle::update_time( const time_point &update_to ) const weather_sum accum_weather = sum_conditions( update_from, update_to, global_square_location() ); // make some reference objects to use to check for reload - const item water( "water" ); - const item water_clean( "water_clean" ); + const item water( itype_water ); + const item water_clean( itype_water_clean ); for( int idx : funnels ) { const vehicle_part &pt = parts[idx]; diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index 159ba1ca65ab2..9d9f909065523 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -85,8 +85,9 @@ static const itype_id itype_detergent( "detergent" ); static const itype_id itype_fungal_seeds( "fungal_seeds" ); static const itype_id itype_large_repairkit( "large_repairkit" ); static const itype_id itype_marloss_seed( "marloss_seed" ); -static const itype_id itype_null( "null" ); +static const itype_id itype_power_cord( "power_cord" ); static const itype_id itype_pseudo_magazine( "pseudo_magazine" ); +static const itype_id itype_pseudo_magazine_mod( "pseudo_magazine_mod" ); static const itype_id itype_small_repairkit( "small_repairkit" ); static const itype_id itype_soldering_iron( "soldering_iron" ); static const itype_id itype_water( "water" ); @@ -567,7 +568,7 @@ void vehicle::connect( const tripoint_bub_ms &source_pos, const tripoint_bub_ms return ; } - item cord( "power_cord" ); + item cord( itype_power_cord ); if( !cord.link_to( prev_vp, sel_vp, link_state::vehicle_port ).success() ) { debugmsg( "Failed to connect the %s, it tried to make an invalid connection!", cord.tname() ); } @@ -880,7 +881,7 @@ void vehicle::reload_seeds( const tripoint_bub_ms &pos ) std::vector seed_inv = player_character.cache_get_items_with( "is_seed", &item::is_seed ); auto seed_entries = iexamine::get_seed_entries( seed_inv ); - seed_entries.emplace( seed_entries.begin(), itype_null, _( "No seed" ), 0 ); + seed_entries.emplace( seed_entries.begin(), itype_id::NULL_ID(), _( "No seed" ), 0 ); int seed_index = iexamine::query_seed( seed_entries ); @@ -1746,7 +1747,7 @@ int vehicle::prepare_tool( item &tool ) const if( ammo_itype_id.is_null() ) { return 0; // likely tool needs no ammo } - item mag_mod( "pseudo_magazine_mod" ); + item mag_mod( itype_pseudo_magazine_mod ); mag_mod.set_flag( STATIC( flag_id( "IRREMOVABLE" ) ) ); if( !tool.put_in( mag_mod, pocket_type::MOD ).success() ) { debugmsg( "tool %s has no space for a %s, this is likely a bug", diff --git a/src/weather.cpp b/src/weather.cpp index 29fac6269dcb9..f1b3dca357ff3 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -241,7 +241,7 @@ void item::add_rain_to_container( int charges ) if( charges <= 0 ) { return; } - item ret( "water", calendar::turn ); + item ret( itype_water, calendar::turn ); const int capa = get_remaining_capacity_for_liquid( ret, true ); ret.charges = std::min( charges, capa ); if( contents.can_contain( ret ).success() ) { @@ -276,7 +276,7 @@ double funnel_charges_per_turn( const double surface_area_mm2, const double rain } // Calculate once, because that part is expensive - static const item water( "water", calendar::turn_zero ); + static const item water( itype_water, calendar::turn_zero ); // 250ml static const double charge_ml = static_cast( to_gram( water.weight() ) ) / water.charges; From 982df19d0f7d481efeaaeaa9c99f19583499d7ec Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Fri, 10 Jan 2025 03:07:32 +0000 Subject: [PATCH 03/14] Change /tests remaining uses of raw string item initialisation to use itype_id s "remaining uses" being somewhat of an understatement -_- --- tests/act_build_test.cpp | 19 +- tests/active_item_cache_test.cpp | 4 +- tests/active_item_test.cpp | 16 +- tests/activity_scheduling_helper.cpp | 7 +- tests/addiction_test.cpp | 6 +- tests/ammo_set_test.cpp | 40 +- tests/ammo_test.cpp | 190 ++++++---- tests/archery_damage_test.cpp | 36 +- tests/battery_mod_test.cpp | 20 +- tests/behavior_test.cpp | 20 +- tests/bionics_test.cpp | 27 +- tests/char_edible_rating_test.cpp | 75 ++-- tests/char_exposure_test.cpp | 14 +- tests/char_sight_test.cpp | 14 +- tests/char_stamina_test.cpp | 9 +- tests/char_suffer_test.cpp | 24 +- tests/character_modifier_test.cpp | 16 +- tests/clzones_test.cpp | 38 +- tests/comestible_test.cpp | 13 +- tests/consumption_time_test.cpp | 4 +- tests/coverage_test.cpp | 63 ++-- tests/crafting_test.cpp | 357 ++++++++++-------- tests/effect_test.cpp | 4 +- tests/effective_dps_test.cpp | 22 +- tests/enchantments_test.cpp | 49 ++- tests/encumbrance_test.cpp | 63 ++-- tests/eoc_test.cpp | 15 +- tests/explosion_balance_test.cpp | 22 +- tests/faction_camp_test.cpp | 12 +- tests/faction_price_rules_test.cpp | 35 +- tests/field_test.cpp | 14 +- tests/food_fun_for_test.cpp | 38 +- tests/fuel_test.cpp | 7 +- tests/invlet_test.cpp | 25 +- tests/item_contents_test.cpp | 14 +- tests/item_countdown_test.cpp | 22 +- tests/item_group_test.cpp | 31 +- tests/item_location_test.cpp | 19 +- tests/item_pocket_test.cpp | 263 +++++++------ tests/item_test.cpp | 199 ++++++---- tests/item_tick_action_test.cpp | 7 +- tests/item_tname_test.cpp | 86 +++-- tests/item_type_name_test.cpp | 9 +- tests/iteminfo_test.cpp | 278 ++++++++------ tests/itemname_test.cpp | 38 +- tests/iuse_actor_test.cpp | 122 +++--- tests/iuse_test.cpp | 31 +- tests/limb_test.cpp | 24 +- tests/map_bash_test.cpp | 28 +- tests/map_helpers.cpp | 10 +- tests/map_test.cpp | 18 +- tests/martial_art_test.cpp | 3 +- tests/materials_test.cpp | 19 +- tests/melee_dodge_hit_test.cpp | 10 +- tests/melee_test.cpp | 31 +- tests/modify_morale_test.cpp | 159 ++++---- tests/mondefense_test.cpp | 18 +- tests/morale_test.cpp | 27 +- tests/move_cost_test.cpp | 46 ++- tests/npc_attack_test.cpp | 22 +- tests/npc_blacklist_test.cpp | 6 +- tests/npc_shop_cons_rates_test.cpp | 27 +- tests/npc_shopkeeper_item_groups_test.cpp | 21 +- tests/npc_talk_test.cpp | 41 ++- tests/npc_test.cpp | 11 +- tests/player_activities_test.cpp | 7 +- tests/player_helpers.cpp | 37 +- tests/player_helpers.h | 14 +- tests/player_test.cpp | 92 +++-- tests/ranged_balance_test.cpp | 198 ++++++---- tests/reading_test.cpp | 74 ++-- tests/reload_magazine_test.cpp | 17 +- tests/reload_option_test.cpp | 50 ++- tests/reload_time_test.cpp | 46 ++- tests/reloading_test.cpp | 429 ++++++++++++---------- tests/rot_test.cpp | 13 +- tests/stomach_contents_test.cpp | 27 +- tests/temp_crafting_inv_test.cpp | 8 +- tests/temperature_test.cpp | 19 +- tests/throw_activation_test.cpp | 4 +- tests/throwing_test.cpp | 85 +++-- tests/tool_quality_test.cpp | 34 +- tests/unload_naked_test.cpp | 6 +- tests/vehicle_interact_test.cpp | 72 ++-- tests/vehicle_part_test.cpp | 5 +- tests/vehicle_power_test.cpp | 3 +- tests/vehicle_test.cpp | 13 +- tests/visitable_remove_test.cpp | 5 +- tests/visitable_test.cpp | 7 +- tests/water_movement_test.cpp | 11 +- tests/widget_test.cpp | 24 +- tests/wield_times_test.cpp | 17 +- tests/zones_custom_test.cpp | 21 +- 93 files changed, 2601 insertions(+), 1695 deletions(-) diff --git a/tests/act_build_test.cpp b/tests/act_build_test.cpp index fefcf046d5ab7..a72fd0d46676e 100644 --- a/tests/act_build_test.cpp +++ b/tests/act_build_test.cpp @@ -18,6 +18,13 @@ static const activity_id ACT_MULTIPLE_CONSTRUCTION( "ACT_MULTIPLE_CONSTRUCTION" static const faction_id faction_free_merchants( "free_merchants" ); +static const itype_id itype_bow_saw( "bow_saw" ); +static const itype_id itype_e_tool( "e_tool" ); +static const itype_id itype_hammer( "hammer" ); +static const itype_id itype_test_backpack( "test_backpack" ); +static const itype_id itype_test_multitool( "test_multitool" ); +static const itype_id itype_wearable_atomic_light( "wearable_atomic_light" ); + static const ter_str_id ter_t_dirt( "t_dirt" ); static const ter_str_id ter_t_metal_grate_window( "t_metal_grate_window" ); static const ter_str_id ter_t_railroad_rubble( "t_railroad_rubble" ); @@ -115,12 +122,12 @@ void run_test_case( Character &u ) map &here = get_map(); g->reset_light_level(); - u.wear_item( item( "test_backpack" ), false, false ); - u.wear_item( item( "wearable_atomic_light" ), false, true ); - u.i_add( item( "test_multitool" ) ); - u.i_add( item( "hammer" ) ); - u.i_add( item( "bow_saw" ) ); - u.i_add( item( "e_tool" ) ); + u.wear_item( item( itype_test_backpack ), false, false ); + u.wear_item( item( itype_wearable_atomic_light ), false, true ); + u.i_add( item( itype_test_multitool ) ); + u.i_add( item( itype_hammer ) ); + u.i_add( item( itype_bow_saw ) ); + u.i_add( item( itype_e_tool ) ); SECTION( "1-step construction activity with pre_terrain" ) { u.setpos( tripoint::zero ); diff --git a/tests/active_item_cache_test.cpp b/tests/active_item_cache_test.cpp index e7e4a3ead9c6a..3c69f051abcb2 100644 --- a/tests/active_item_cache_test.cpp +++ b/tests/active_item_cache_test.cpp @@ -8,13 +8,15 @@ #include "map_helpers.h" #include "point.h" +static const itype_id itype_firecracker_act( "firecracker_act" ); + TEST_CASE( "place_active_item_at_various_coordinates", "[item]" ) { clear_map( -OVERMAP_DEPTH, OVERMAP_HEIGHT ); map &here = get_map(); REQUIRE( here.get_submaps_with_active_items().empty() ); // An arbitrary active item. - item active( "firecracker_act", calendar::turn_zero, item::default_charges_tag() ); + item active( itype_firecracker_act, calendar::turn_zero, item::default_charges_tag() ); active.activate(); // For each space in a wide area place the item and check if the cache has been updated. diff --git a/tests/active_item_test.cpp b/tests/active_item_test.cpp index a9c0b9430fe94..d4783b28fd352 100644 --- a/tests/active_item_test.cpp +++ b/tests/active_item_test.cpp @@ -11,6 +11,12 @@ #include "map_helpers.h" #include "player_helpers.h" +static const itype_id itype_chainsaw_on( "chainsaw_on" ); +static const itype_id itype_debug_backpack( "debug_backpack" ); +static const itype_id itype_flashlight_on( "flashlight_on" ); +static const itype_id itype_gasoline_lantern_on( "gasoline_lantern_on" ); +static const itype_id itype_medium_battery_cell( "medium_battery_cell" ); + TEST_CASE( "active_items_processed_regularly", "[active_item]" ) { clear_avatar(); @@ -18,10 +24,10 @@ TEST_CASE( "active_items_processed_regularly", "[active_item]" ) avatar &player_character = get_avatar(); map &here = get_map(); // An arbitrary active item that ticks every turn. - item active_item( "chainsaw_on" ); + item active_item( itype_chainsaw_on ); active_item.active = true; - item storage( "debug_backpack", calendar::turn_zero ); + item storage( itype_debug_backpack, calendar::turn_zero ); std::optional::iterator> wear_success = player_character.wear_item( storage ); REQUIRE( wear_success ); @@ -47,7 +53,7 @@ TEST_CASE( "active_items_processed_regularly", "[active_item]" ) TEST_CASE( "non_energy_tool_power_consumption_rate", "[active_item]" ) { // Gasoline lantern without a battery, using gasoline instead - item test_lantern( "gasoline_lantern_on" ); + item test_lantern( itype_gasoline_lantern_on ); const itype_id &default_ammo = test_lantern.ammo_default(); const int ammo_capacity = test_lantern.ammo_capacity( default_ammo->ammo->type ); test_lantern.ammo_set( default_ammo, ammo_capacity ); @@ -75,11 +81,11 @@ TEST_CASE( "non_energy_tool_power_consumption_rate", "[active_item]" ) TEST_CASE( "tool_power_consumption_rate", "[active_item]" ) { // Give the flashlight a fully charged battery, 56 kJ - item test_battery( "medium_battery_cell" ); + item test_battery( itype_medium_battery_cell ); test_battery.ammo_set( test_battery.ammo_default(), 56 ); REQUIRE( test_battery.energy_remaining() == 56_kJ ); - item tool( "flashlight_on" ); + item tool( itype_flashlight_on ); tool.put_in( test_battery, pocket_type::MAGAZINE_WELL ); REQUIRE( tool.energy_remaining() == 56_kJ ); tool.active = true; diff --git a/tests/activity_scheduling_helper.cpp b/tests/activity_scheduling_helper.cpp index 94a687f538a20..d0826c217d840 100644 --- a/tests/activity_scheduling_helper.cpp +++ b/tests/activity_scheduling_helper.cpp @@ -15,6 +15,9 @@ #include "stomach.h" #include "string_formatter.h" +static const itype_id itype_atomic_lamp( "atomic_lamp" ); +static const itype_id itype_duffelbag( "duffelbag" ); + void activity_schedule::setup( avatar &guy ) const { // Start our task, for however long the schedule says. @@ -89,8 +92,8 @@ weariness_events do_activity( tasklist tasks, bool do_clear_avatar ) avatar &guy = get_avatar(); // Ensure we have enough light to see - item bag( "duffelbag" ); - item light( "atomic_lamp" ); + item bag( itype_duffelbag ); + item light( itype_atomic_lamp ); guy.worn.wear_item( guy, bag, false, false ); guy.i_add( light ); // How long we've been doing activities for diff --git a/tests/addiction_test.cpp b/tests/addiction_test.cpp index 15ffbbb03514d..a284621b69a9c 100644 --- a/tests/addiction_test.cpp +++ b/tests/addiction_test.cpp @@ -22,6 +22,8 @@ static const addiction_id addiction_test_nicotine( "test_nicotine" ); static const efftype_id effect_hallu( "hallu" ); static const efftype_id effect_shakes( "shakes" ); +static const itype_id itype_test_whiskey_caffenated( "test_whiskey_caffenated" ); + static const trait_id trait_MUT_JUNKIE( "MUT_JUNKIE" ); static constexpr int max_iters = 100000; @@ -720,7 +722,7 @@ TEST_CASE( "check_marloss_addiction_effects", "[addiction]" ) TEST_CASE( "check_that_items_can_inflict_multiple_addictions", "[addiction]" ) { - item addict_itm( "test_whiskey_caffenated" ); + item addict_itm( itype_test_whiskey_caffenated ); REQUIRE( addict_itm.is_comestible() ); REQUIRE( addict_itm.get_comestible()->addictions.size() == 2 ); CHECK( addict_itm.get_comestible()->addictions.at( addiction_alcohol ) == 101 ); @@ -731,7 +733,7 @@ TEST_CASE( "check_that_items_can_inflict_multiple_addictions", "[addiction]" ) REQUIRE( !victim.has_addiction( addiction_alcohol ) ); REQUIRE( !victim.has_addiction( addiction_caffeine ) ); for( int i = 0; i < MIN_ADDICTION_LEVEL; i++ ) { - item addict_itm = item( "test_whiskey_caffenated" ); + item addict_itm = item( itype_test_whiskey_caffenated ); REQUIRE( victim.consume( addict_itm, true ) != trinary::NONE ); } CHECK( victim.has_addiction( addiction_alcohol ) ); diff --git a/tests/ammo_set_test.cpp b/tests/ammo_set_test.cpp index e5113389a9856..2c5d3b19264c3 100644 --- a/tests/ammo_set_test.cpp +++ b/tests/ammo_set_test.cpp @@ -13,10 +13,17 @@ #include "type_id.h" #include "value_ptr.h" +static const itype_id itype_box_small( "box_small" ); +static const itype_id itype_cz75( "cz75" ); +static const itype_id itype_cz75mag_16rd( "cz75mag_16rd" ); +static const itype_id itype_cz75mag_20rd( "cz75mag_20rd" ); +static const itype_id itype_cz75mag_26rd( "cz75mag_26rd" ); +static const itype_id itype_M24( "M24" ); + TEST_CASE( "ammo_set_items_with_MAGAZINE_pockets", "[ammo_set][magazine][ammo]" ) { GIVEN( "empty 9mm CZ 75 20-round magazine" ) { - item cz75mag_20rd( "cz75mag_20rd" ); + item cz75mag_20rd( itype_cz75mag_20rd ); REQUIRE( cz75mag_20rd.is_magazine() ); REQUIRE( cz75mag_20rd.ammo_remaining() == 0 ); REQUIRE( cz75mag_20rd.ammo_default() ); @@ -97,7 +104,7 @@ TEST_CASE( "ammo_set_items_with_MAGAZINE_pockets", "[ammo_set][magazine][ammo]" } } GIVEN( "empty M24 gun with capacity of 5 .308 rounds" ) { - item m24( "M24" ); + item m24( itype_M24 ); REQUIRE( m24.is_gun() ); REQUIRE( m24.is_magazine() ); REQUIRE( m24.ammo_remaining() == 0 ); @@ -184,8 +191,8 @@ TEST_CASE( "ammo_set_items_with_MAGAZINE_WELL_pockets_with_magazine", "[ammo_set][magazine][ammo]" ) { GIVEN( "CZ 75 B 9mm gun with empty 9mm CZ 75 20-round magazine" ) { - item cz75( "cz75" ); - item cz75mag_20rd( "cz75mag_20rd" ); + item cz75( itype_cz75 ); + item cz75mag_20rd( itype_cz75mag_20rd ); REQUIRE( cz75.is_gun() ); REQUIRE_FALSE( cz75.is_magazine() ); REQUIRE( cz75.magazine_current() == nullptr ); @@ -199,7 +206,7 @@ TEST_CASE( "ammo_set_items_with_MAGAZINE_WELL_pockets_with_magazine", const ammotype &amtype = ammo9mm_id->ammo->type; REQUIRE( cz75mag_20rd.ammo_capacity( amtype ) == 20 ); cz75.put_in( cz75mag_20rd, pocket_type::MAGAZINE_WELL ); - REQUIRE( cz75.magazine_current()->typeId().str() == cz75mag_20rd.typeId().str() ); + REQUIRE( cz75.magazine_current()->typeId() == itype_cz75mag_20rd ); REQUIRE( cz75.ammo_capacity( amtype ) == 20 ); WHEN( "set 9mm ammo in the gun with magazine w/o quantity" ) { cz75.ammo_set( ammo9mm_id ); @@ -294,19 +301,16 @@ TEST_CASE( "ammo_set_items_with_MAGAZINE_WELL_pockets_without_magazine", "[ammo_set][magazine][ammo]" ) { GIVEN( "CZ 75 B 9mm gun w/o magazine" ) { - item cz75( "cz75" ); - itype_id cz75mag_16rd_id( "cz75mag_16rd" ); - itype_id cz75mag_20rd_id( "cz75mag_20rd" ); - itype_id cz75mag_26rd_id( "cz75mag_26rd" ); + item cz75( itype_cz75 ); itype_id ammo9mm_id( "9mm" ); REQUIRE( cz75.is_gun() ); REQUIRE_FALSE( cz75.is_magazine() ); REQUIRE( cz75.magazine_current() == nullptr ); REQUIRE( cz75.magazine_compatible().size() == 3 ); - REQUIRE( cz75.magazine_compatible().count( cz75mag_16rd_id ) == 1 ); - REQUIRE( cz75.magazine_compatible().count( cz75mag_20rd_id ) == 1 ); - REQUIRE( cz75.magazine_compatible().count( cz75mag_26rd_id ) == 1 ); - REQUIRE( cz75.magazine_default().str() == cz75mag_16rd_id.str() ); + REQUIRE( cz75.magazine_compatible().count( itype_cz75mag_16rd ) == 1 ); + REQUIRE( cz75.magazine_compatible().count( itype_cz75mag_20rd ) == 1 ); + REQUIRE( cz75.magazine_compatible().count( itype_cz75mag_26rd ) == 1 ); + REQUIRE( cz75.magazine_default() == itype_cz75mag_16rd ); const ammotype &amtype = ammo9mm_id->ammo->type; REQUIRE( cz75.ammo_capacity( amtype ) == 0 ); REQUIRE( !cz75.ammo_default().is_null() ); @@ -317,7 +321,7 @@ TEST_CASE( "ammo_set_items_with_MAGAZINE_WELL_pockets_without_magazine", CHECK( cz75.ammo_remaining() == 16 ); CHECK( cz75.ammo_current().str() == ammo9mm_id.str() ); REQUIRE( cz75.magazine_current() != nullptr ); - CHECK( cz75.magazine_current()->typeId().str() == cz75mag_16rd_id.str() ); + CHECK( cz75.magazine_current()->typeId() == itype_cz75mag_16rd ); CHECK( cz75.magazine_current()->ammo_remaining() == 16 ); CHECK( cz75.magazine_current()->ammo_current().str() == ammo9mm_id.str() ); } @@ -328,7 +332,7 @@ TEST_CASE( "ammo_set_items_with_MAGAZINE_WELL_pockets_without_magazine", CHECK( cz75.ammo_remaining() == 19 ); CHECK( cz75.ammo_current().str() == ammo9mm_id.str() ); REQUIRE( cz75.magazine_current() != nullptr ); - CHECK( cz75.magazine_current()->typeId().str() == cz75mag_20rd_id.str() ); + CHECK( cz75.magazine_current()->typeId() == itype_cz75mag_20rd ); CHECK( cz75.magazine_current()->ammo_remaining() == 19 ); CHECK( cz75.magazine_current()->ammo_current().str() == ammo9mm_id.str() ); } @@ -339,7 +343,7 @@ TEST_CASE( "ammo_set_items_with_MAGAZINE_WELL_pockets_without_magazine", CHECK( cz75.ammo_remaining() == 21 ); CHECK( cz75.ammo_current().str() == ammo9mm_id.str() ); REQUIRE( cz75.magazine_current() != nullptr ); - CHECK( cz75.magazine_current()->typeId().str() == cz75mag_26rd_id.str() ); + CHECK( cz75.magazine_current()->typeId() == itype_cz75mag_26rd ); CHECK( cz75.magazine_current()->ammo_remaining() == 21 ); CHECK( cz75.magazine_current()->ammo_current().str() == ammo9mm_id.str() ); } @@ -350,7 +354,7 @@ TEST_CASE( "ammo_set_items_with_MAGAZINE_WELL_pockets_without_magazine", CHECK( cz75.ammo_remaining() == 26 ); CHECK( cz75.ammo_current().str() == ammo9mm_id.str() ); REQUIRE( cz75.magazine_current() != nullptr ); - CHECK( cz75.magazine_current()->typeId().str() == cz75mag_26rd_id.str() ); + CHECK( cz75.magazine_current()->typeId() == itype_cz75mag_26rd ); CHECK( cz75.magazine_current()->ammo_remaining() == 26 ); CHECK( cz75.magazine_current()->ammo_current().str() == ammo9mm_id.str() ); } @@ -376,7 +380,7 @@ TEST_CASE( "ammo_set_items_with_MAGAZINE_WELL_pockets_without_magazine", TEST_CASE( "ammo_set_items_with_CONTAINER_pockets", "[ammo_set][magazine][ammo]" ) { GIVEN( "small box" ) { - item box( "box_small" ); + item box( itype_box_small ); REQUIRE_FALSE( box.is_gun() ); REQUIRE_FALSE( box.is_magazine() ); REQUIRE( box.is_container_empty() ); diff --git a/tests/ammo_test.cpp b/tests/ammo_test.cpp index aee7f29982716..316d57835f803 100644 --- a/tests/ammo_test.cpp +++ b/tests/ammo_test.cpp @@ -11,14 +11,58 @@ static const ammotype ammo_762( "762" ); static const ammotype ammo_9mm( "9mm" ); static const ammotype ammo_battery( "battery" ); +static const itype_id itype_38_special( "38_special" ); static const itype_id itype_44army( "44army" ); +static const itype_id itype_44magnum( "44magnum" ); static const itype_id itype_9mm( "9mm" ); +static const itype_id itype_ak47( "ak47" ); +static const itype_id itype_ak74_semi( "ak74_semi" ); +static const itype_id itype_akdrum75( "akdrum75" ); +static const itype_id itype_akmag10( "akmag10" ); +static const itype_id itype_barrel_glock_short( "barrel_glock_short" ); static const itype_id itype_battery( "battery" ); +static const itype_id itype_battery_car( "battery_car" ); +static const itype_id itype_battery_motorbike( "battery_motorbike" ); +static const itype_id itype_belt308( "belt308" ); +static const itype_id itype_belt40mm( "belt40mm" ); +static const itype_id itype_bp_9mm( "bp_9mm" ); +static const itype_id itype_colt_army( "colt_army" ); +static const itype_id itype_compositebow( "compositebow" ); +static const itype_id itype_cordless_drill( "cordless_drill" ); static const itype_id itype_fish_bait( "fish_bait" ); +static const itype_id itype_fish_trap( "fish_trap" ); +static const itype_id itype_flashlight( "flashlight" ); +static const itype_id itype_forge( "forge" ); +static const itype_id itype_glockmag( "glockmag" ); +static const itype_id itype_hand_crossbow( "hand_crossbow" ); +static const itype_id itype_heavy_battery_cell( "heavy_battery_cell" ); +static const itype_id itype_heavy_plus_battery_cell( "heavy_plus_battery_cell" ); +static const itype_id itype_hotplate( "hotplate" ); +static const itype_id itype_large_storage_battery( "large_storage_battery" ); +static const itype_id itype_light_battery_cell( "light_battery_cell" ); +static const itype_id itype_m1911( "m1911" ); +static const itype_id itype_magazine_battery_medium_mod( "magazine_battery_medium_mod" ); +static const itype_id itype_medium_battery_cell( "medium_battery_cell" ); +static const itype_id itype_nail( "nail" ); +static const itype_id itype_nailgun( "nailgun" ); +static const itype_id itype_needle_bone( "needle_bone" ); +static const itype_id itype_needle_wood( "needle_wood" ); static const itype_id itype_pebble( "pebble" ); +static const itype_id itype_reloaded_308( "reloaded_308" ); +static const itype_id itype_rock( "rock" ); +static const itype_id itype_sewing_kit( "sewing_kit" ); +static const itype_id itype_sinew( "sinew" ); +static const itype_id itype_sling( "sling" ); +static const itype_id itype_slingshot( "slingshot" ); +static const itype_id itype_solder_wire( "solder_wire" ); +static const itype_id itype_tailors_kit( "tailors_kit" ); static const itype_id itype_test_100mm_ammo( "test_100mm_ammo" ); static const itype_id itype_test_100mm_ammo_relative( "test_100mm_ammo_relative" ); +static const itype_id itype_test_glock_super_long( "test_glock_super_long" ); static const itype_id itype_thread( "thread" ); +static const itype_id itype_tommygun( "tommygun" ); +static const itype_id itype_usp_9mm( "usp_9mm" ); +static const itype_id itype_vac_sealer( "vac_sealer" ); // Functions: // - item::ammo_types @@ -49,110 +93,110 @@ TEST_CASE( "ammo_types", "[ammo][ammo_types]" ) SECTION( "items with MAGAZINE pockets have ammo_types" ) { // Batteries are magazines - REQUIRE( item( "light_battery_cell" ).is_magazine() ); - REQUIRE( item( "battery_car" ).is_magazine() ); + REQUIRE( item( itype_light_battery_cell ).is_magazine() ); + REQUIRE( item( itype_battery_car ).is_magazine() ); // Tool batteries - CHECK( has_ammo_types( item( "light_battery_cell" ) ) ); - CHECK( has_ammo_types( item( "medium_battery_cell" ) ) ); - CHECK( has_ammo_types( item( "heavy_battery_cell" ) ) ); - CHECK( has_ammo_types( item( "heavy_plus_battery_cell" ) ) ); + CHECK( has_ammo_types( item( itype_light_battery_cell ) ) ); + CHECK( has_ammo_types( item( itype_medium_battery_cell ) ) ); + CHECK( has_ammo_types( item( itype_heavy_battery_cell ) ) ); + CHECK( has_ammo_types( item( itype_heavy_plus_battery_cell ) ) ); // Vehicle batteries - CHECK( has_ammo_types( item( "battery_car" ) ) ); - CHECK( has_ammo_types( item( "battery_motorbike" ) ) ); - CHECK( has_ammo_types( item( "large_storage_battery" ) ) ); + CHECK( has_ammo_types( item( itype_battery_car ) ) ); + CHECK( has_ammo_types( item( itype_battery_motorbike ) ) ); + CHECK( has_ammo_types( item( itype_large_storage_battery ) ) ); SECTION( "battery magazines include 'battery' ammo type" ) { - CHECK( item( "light_battery_cell" ).ammo_types().count( ammo_battery ) == 1 ); - CHECK( item( "battery_car" ).ammo_types().count( ammo_battery ) == 1 ); + CHECK( item( itype_light_battery_cell ).ammo_types().count( ammo_battery ) == 1 ); + CHECK( item( itype_battery_car ).ammo_types().count( ammo_battery ) == 1 ); } // Gun magazines - REQUIRE( item( "belt40mm" ).is_magazine() ); - REQUIRE( item( "akmag10" ).is_magazine() ); + REQUIRE( item( itype_belt40mm ).is_magazine() ); + REQUIRE( item( itype_akmag10 ).is_magazine() ); - CHECK( has_ammo_types( item( "belt40mm" ) ) ); - CHECK( has_ammo_types( item( "belt308" ) ) ); - CHECK( has_ammo_types( item( "akmag10" ) ) ); - CHECK( has_ammo_types( item( "akdrum75" ) ) ); - CHECK( has_ammo_types( item( "glockmag" ) ) ); + CHECK( has_ammo_types( item( itype_belt40mm ) ) ); + CHECK( has_ammo_types( item( itype_belt308 ) ) ); + CHECK( has_ammo_types( item( itype_akmag10 ) ) ); + CHECK( has_ammo_types( item( itype_akdrum75 ) ) ); + CHECK( has_ammo_types( item( itype_glockmag ) ) ); SECTION( "gun magazines include ammo type for that magazine" ) { - CHECK( item( "glockmag" ).ammo_types().count( ammo_9mm ) == 1 ); - CHECK( item( "akmag10" ).ammo_types().count( ammo_762 ) == 1 ); + CHECK( item( itype_glockmag ).ammo_types().count( ammo_9mm ) == 1 ); + CHECK( item( itype_akmag10 ).ammo_types().count( ammo_762 ) == 1 ); } } SECTION( "GUN items with integral MAGAZINE pockets have ammo_types" ) { - REQUIRE( item( "nailgun" ).magazine_integral() ); - REQUIRE( item( "colt_army" ).magazine_integral() ); - - CHECK( has_ammo_types( item( "nailgun" ) ) ); - CHECK( has_ammo_types( item( "colt_army" ) ) ); - CHECK( has_ammo_types( item( "hand_crossbow" ) ) ); - CHECK( has_ammo_types( item( "compositebow" ) ) ); - CHECK( has_ammo_types( item( "sling" ) ) ); - CHECK( has_ammo_types( item( "slingshot" ) ) ); + REQUIRE( item( itype_nailgun ).magazine_integral() ); + REQUIRE( item( itype_colt_army ).magazine_integral() ); + + CHECK( has_ammo_types( item( itype_nailgun ) ) ); + CHECK( has_ammo_types( item( itype_colt_army ) ) ); + CHECK( has_ammo_types( item( itype_hand_crossbow ) ) ); + CHECK( has_ammo_types( item( itype_compositebow ) ) ); + CHECK( has_ammo_types( item( itype_sling ) ) ); + CHECK( has_ammo_types( item( itype_slingshot ) ) ); } SECTION( "TOOL items with integral MAGAZINE pockets have ammo_types" ) { - REQUIRE( item( "sewing_kit" ).magazine_integral() ); + REQUIRE( item( itype_sewing_kit ).magazine_integral() ); - CHECK( has_ammo_types( item( "needle_bone" ) ) ); - CHECK( has_ammo_types( item( "needle_wood" ) ) ); - CHECK( has_ammo_types( item( "sewing_kit" ) ) ); - CHECK( has_ammo_types( item( "tailors_kit" ) ) ); + CHECK( has_ammo_types( item( itype_needle_bone ) ) ); + CHECK( has_ammo_types( item( itype_needle_wood ) ) ); + CHECK( has_ammo_types( item( itype_sewing_kit ) ) ); + CHECK( has_ammo_types( item( itype_tailors_kit ) ) ); } SECTION( "TOOL items with NO pockets have ammo_types" ) { // NOTE: Fish trap is a TOOL with "ammo", but no "pocket_data", so an implicit MAGAZINE // pocket is added by Item_factory::check_and_create_magazine_pockets on JSON load. // This item would be considered needing data migration to an explicit MAGAZINE pocket. - REQUIRE( item( "fish_trap" ).magazine_integral() ); + REQUIRE( item( itype_fish_trap ).magazine_integral() ); - CHECK( has_ammo_types( item( "fish_trap" ) ) ); + CHECK( has_ammo_types( item( itype_fish_trap ) ) ); } // These items have NO ammo_types: SECTION( "GUN items with MAGAZINE_WELL pockets also have ammo_types" ) { - REQUIRE_FALSE( item( "m1911" ).magazine_integral() ); + REQUIRE_FALSE( item( itype_m1911 ).magazine_integral() ); - CHECK( has_ammo_types( item( "m1911" ) ) ); - CHECK( has_ammo_types( item( "usp_9mm" ) ) ); - CHECK( has_ammo_types( item( "tommygun" ) ) ); - CHECK( has_ammo_types( item( "ak74_semi" ) ) ); - CHECK( has_ammo_types( item( "ak47" ) ) ); + CHECK( has_ammo_types( item( itype_m1911 ) ) ); + CHECK( has_ammo_types( item( itype_usp_9mm ) ) ); + CHECK( has_ammo_types( item( itype_tommygun ) ) ); + CHECK( has_ammo_types( item( itype_ak74_semi ) ) ); + CHECK( has_ammo_types( item( itype_ak47 ) ) ); } SECTION( "TOOL items with MAGAZINE_WELL pockets do NOT have ammo_types" ) { - REQUIRE( item( "flashlight" ).is_tool() ); + REQUIRE( item( itype_flashlight ).is_tool() ); - CHECK_FALSE( has_ammo_types( item( "flashlight" ) ) ); - CHECK_FALSE( has_ammo_types( item( "hotplate" ) ) ); - CHECK_FALSE( has_ammo_types( item( "vac_sealer" ) ) ); - CHECK_FALSE( has_ammo_types( item( "forge" ) ) ); - CHECK_FALSE( has_ammo_types( item( "cordless_drill" ) ) ); + CHECK_FALSE( has_ammo_types( item( itype_flashlight ) ) ); + CHECK_FALSE( has_ammo_types( item( itype_hotplate ) ) ); + CHECK_FALSE( has_ammo_types( item( itype_vac_sealer ) ) ); + CHECK_FALSE( has_ammo_types( item( itype_forge ) ) ); + CHECK_FALSE( has_ammo_types( item( itype_cordless_drill ) ) ); } SECTION( "AMMO items themselves do NOT have ammo_types" ) { - REQUIRE( item( "38_special" ).is_ammo() ); - REQUIRE( item( "sinew" ).is_ammo() ); + REQUIRE( item( itype_38_special ).is_ammo() ); + REQUIRE( item( itype_sinew ).is_ammo() ); // Ammo for guns - CHECK_FALSE( has_ammo_types( item( "38_special" ) ) ); - CHECK_FALSE( has_ammo_types( item( "reloaded_308" ) ) ); - CHECK_FALSE( has_ammo_types( item( "bp_9mm" ) ) ); - CHECK_FALSE( has_ammo_types( item( "44magnum" ) ) ); + CHECK_FALSE( has_ammo_types( item( itype_38_special ) ) ); + CHECK_FALSE( has_ammo_types( item( itype_reloaded_308 ) ) ); + CHECK_FALSE( has_ammo_types( item( itype_bp_9mm ) ) ); + CHECK_FALSE( has_ammo_types( item( itype_44magnum ) ) ); // Not for guns but classified as ammo - CHECK_FALSE( has_ammo_types( item( "sinew" ) ) ); - CHECK_FALSE( has_ammo_types( item( "nail" ) ) ); - CHECK_FALSE( has_ammo_types( item( "rock" ) ) ); - CHECK_FALSE( has_ammo_types( item( "solder_wire" ) ) ); + CHECK_FALSE( has_ammo_types( item( itype_sinew ) ) ); + CHECK_FALSE( has_ammo_types( item( itype_nail ) ) ); + CHECK_FALSE( has_ammo_types( item( itype_rock ) ) ); + CHECK_FALSE( has_ammo_types( item( itype_solder_wire ) ) ); } SECTION( "TOOLMOD items do NOT have ammo_types" ) { - item med_mod( "magazine_battery_medium_mod" ); + item med_mod( itype_magazine_battery_medium_mod ); REQUIRE( med_mod.is_toolmod() ); CHECK_FALSE( has_ammo_types( med_mod ) ); @@ -164,8 +208,8 @@ TEST_CASE( "ammo_default", "[ammo][ammo_default]" ) { // TOOLMOD type, and TOOL type items with MAGAZINE_WELL pockets have no ammo_default SECTION( "items without ammo_default" ) { - item flashlight( "flashlight" ); - item med_mod( "magazine_battery_medium_mod" ); + item flashlight( itype_flashlight ); + item med_mod( itype_magazine_battery_medium_mod ); CHECK( flashlight.ammo_default().is_null() ); CHECK( med_mod.ammo_default().is_null() ); @@ -174,22 +218,22 @@ TEST_CASE( "ammo_default", "[ammo][ammo_default]" ) // MAGAZINE type, and TOOL/GUN items with integral MAGAZINE pockets do have ammo_default SECTION( "items with ammo_default" ) { // MAGAZINE type items - item battery( "light_battery_cell" ); - item glockmag( "glockmag" ); + item battery( itype_light_battery_cell ); + item glockmag( itype_glockmag ); CHECK( battery.ammo_default() == itype_battery ); CHECK( glockmag.ammo_default() == itype_9mm ); // TOOL type items with integral magazines - item sewing_kit( "sewing_kit" ); - item needle( "needle_bone" ); - item fishtrap( "fish_trap" ); + item sewing_kit( itype_sewing_kit ); + item needle( itype_needle_bone ); + item fishtrap( itype_fish_trap ); CHECK( sewing_kit.ammo_default() == itype_thread ); CHECK( needle.ammo_default() == itype_thread ); CHECK( fishtrap.ammo_default() == itype_fish_bait ); // GUN type items with integral magazine - item slingshot( "slingshot" ); - item colt( "colt_army" ); + item slingshot( itype_slingshot ); + item colt( itype_colt_army ); CHECK( slingshot.ammo_default() == itype_pebble ); // Revolver ammo is "44paper" but default ammunition type is "44army" CHECK( colt.ammo_default() == itype_44army ); @@ -199,27 +243,27 @@ TEST_CASE( "ammo_default", "[ammo][ammo_default]" ) TEST_CASE( "barrel_test", "[ammo][weapon]" ) { SECTION( "basic ammo and barrel length test" ) { - item base_gun( "test_glock_super_long" ); + item base_gun( itype_test_glock_super_long ); CHECK( base_gun.gun_damage( itype_test_100mm_ammo ).total_damage() == 65 ); } SECTION( "basic ammo and mod length test" ) { - item base_gun( "test_glock_super_long" ); - item gun_mod( "barrel_glock_short" ); + item base_gun( itype_test_glock_super_long ); + item gun_mod( itype_barrel_glock_short ); REQUIRE( base_gun.put_in( gun_mod, pocket_type::MOD ).success() ); REQUIRE( base_gun.barrel_length().value() == 100 ); CHECK( base_gun.gun_damage( itype_test_100mm_ammo ).total_damage() == 60 ); } SECTION( "inherited ammo and barrel length test" ) { - item base_gun( "test_glock_super_long" ); + item base_gun( itype_test_glock_super_long ); CHECK( base_gun.gun_damage( itype_test_100mm_ammo_relative ).total_damage() == 66 ); } } TEST_CASE( "battery_energy_test", "[ammo][energy][item]" ) { - item test_battery( "medium_battery_cell" ); + item test_battery( itype_medium_battery_cell ); test_battery.ammo_set( test_battery.ammo_default(), 56 ); SECTION( "Integer drain from battery" ) { diff --git a/tests/archery_damage_test.cpp b/tests/archery_damage_test.cpp index 1135fe3e8cbeb..b41bfbfbe1773 100644 --- a/tests/archery_damage_test.cpp +++ b/tests/archery_damage_test.cpp @@ -30,9 +30,19 @@ #include "type_id.h" #include "value_ptr.h" +static const itype_id itype_arrow_metal( "arrow_metal" ); +static const itype_id itype_bolt_steel( "bolt_steel" ); +static const itype_id itype_compbow( "compbow" ); +static const itype_id itype_compositecrossbow( "compositecrossbow" ); +static const itype_id itype_hand_crossbow( "hand_crossbow" ); +static const itype_id itype_recurbow( "recurbow" ); +static const itype_id itype_rep_crossbow( "rep_crossbow" ); +static const itype_id itype_selfbow( "selfbow" ); +static const itype_id itype_shortbow( "shortbow" ); + // In short, a bow should never destroy a wall, pretty simple. static void test_projectile_hitting_wall( const std::string &target_type, bool smashable, - dealt_projectile_attack &attack, const std::string &weapon_type ) + dealt_projectile_attack &attack, const itype_id &weapon_type ) { static const tripoint_bub_ms target_point{ 5, 5, 0 }; map &here = get_map(); @@ -42,7 +52,7 @@ static void test_projectile_hitting_wall( const std::string &target_type, bool s CAPTURE( projectile_copy.impact.total_damage() ); here.shoot( target_point, projectile_copy, false ); CAPTURE( target_type ); - CAPTURE( weapon_type ); + CAPTURE( weapon_type.c_str() ); CAPTURE( ter_id( target_type ).obj().name() ); CAPTURE( here.ter( target_point ).obj().name() ); if( smashable ) { @@ -54,7 +64,7 @@ static void test_projectile_hitting_wall( const std::string &target_type, bool s } static void test_projectile_attack( const std::string &target_type, bool killable, - dealt_projectile_attack &attack, const std::string &weapon_type ) + dealt_projectile_attack &attack, const itype_id &weapon_type ) { for( int i = 0; i < 10; ++i ) { monster target{ mtype_id( target_type ), tripoint_bub_ms::zero }; @@ -65,16 +75,16 @@ static void test_projectile_attack( const std::string &target_type, bool killabl CAPTURE( target.get_hp() ); CAPTURE( target.get_hp_max() ); CAPTURE( attack.proj.impact.total_damage() ); - CAPTURE( weapon_type ); + CAPTURE( weapon_type.c_str() ); CHECK( target.is_dead() == killable ); } } -static void test_archery_balance( const std::string &weapon_type, const std::string &ammo_type, +static void test_archery_balance( const itype_id &weapon_type, const itype_id &ammo_type, const std::string &killable, const std::string &unkillable ) { item weapon( weapon_type ); - weapon.ammo_set( itype_id( ammo_type ), 1 ); + weapon.ammo_set( ammo_type, 1 ); projectile test_projectile; test_projectile.speed = 1000; @@ -103,16 +113,16 @@ TEST_CASE( "archery_damage_thresholds", "[balance],[archery]" ) // undodgable bolt fired with a guaranteed crit 10 times // Selfbow can't kill a turkey - test_archery_balance( "selfbow", "arrow_metal", "", "mon_turkey" ); - test_archery_balance( "rep_crossbow", "bolt_steel", "", "mon_turkey" ); + test_archery_balance( itype_selfbow, itype_arrow_metal, "", "mon_turkey" ); + test_archery_balance( itype_rep_crossbow, itype_bolt_steel, "", "mon_turkey" ); // Shortbow can kill turkeys, but not deer - test_archery_balance( "shortbow", "arrow_metal", "mon_turkey", "mon_deer" ); - test_archery_balance( "hand_crossbow", "bolt_steel", "mon_turkey", "mon_deer" ); + test_archery_balance( itype_shortbow, itype_arrow_metal, "mon_turkey", "mon_deer" ); + test_archery_balance( itype_hand_crossbow, itype_bolt_steel, "mon_turkey", "mon_deer" ); // Fiberglass recurve can kill deer, but not bear - test_archery_balance( "recurbow", "arrow_metal", "mon_deer", "mon_bear" ); - test_archery_balance( "compositecrossbow", "bolt_steel", "mon_deer", "mon_bear" ); + test_archery_balance( itype_recurbow, itype_arrow_metal, "mon_deer", "mon_bear" ); + test_archery_balance( itype_compositecrossbow, itype_bolt_steel, "mon_deer", "mon_bear" ); // Medium setting compound bow can kill Bear - test_archery_balance( "compbow", "arrow_metal", "mon_bear", "" ); + test_archery_balance( itype_compbow, itype_arrow_metal, "mon_bear", "" ); // High setting modern compund bow can kill Moose // Currently disabled as it was not possible to make moose realistically tough while keeping the tests functional. Our bleeding isn't strong enough, and the tests are only hooked up to check instakills. Check the comments under PR #74554 for more detailed explanation. // test_archery_balance( "compcrossbow", "bolt_steel", "mon_moose", "" ); diff --git a/tests/battery_mod_test.cpp b/tests/battery_mod_test.cpp index dbdf4d343600e..8e18d03244b5d 100644 --- a/tests/battery_mod_test.cpp +++ b/tests/battery_mod_test.cpp @@ -23,8 +23,10 @@ // In JSON, "battery" is both an "ammunition_type" (ammo_types.json) and an "AMMO" (ammo.json) static const ammotype ammo_battery( "battery" ); static const itype_id itype_battery( "battery" ); +static const itype_id itype_diving_flashlight_small_hipower( "diving_flashlight_small_hipower" ); static const itype_id itype_heavy_plus_battery_cell( "heavy_plus_battery_cell" ); static const itype_id itype_light_battery_cell( "light_battery_cell" ); +static const itype_id itype_magazine_battery_medium_mod( "magazine_battery_medium_mod" ); static const itype_id itype_medium_battery_cell( "medium_battery_cell" ); // Includes functions: @@ -63,7 +65,7 @@ static const itype_id itype_medium_battery_cell( "medium_battery_cell" ); // TEST_CASE( "battery_tool_mod_test", "[battery][mod]" ) { - item med_mod( "magazine_battery_medium_mod" ); + item med_mod( itype_magazine_battery_medium_mod ); SECTION( "battery mod properties" ) { // Is a toolmod, and nothing else @@ -93,7 +95,7 @@ TEST_CASE( "battery_tool_mod_test", "[battery][mod]" ) } GIVEN( "tool compatible with light batteries" ) { - item flashlight( "diving_flashlight_small_hipower" ); + item flashlight( itype_diving_flashlight_small_hipower ); REQUIRE( flashlight.is_reloadable() ); REQUIRE( flashlight.can_reload_with( item( itype_light_battery_cell ), true ) ); @@ -139,7 +141,7 @@ TEST_CASE( "battery_tool_mod_test", "[battery][mod]" ) } WHEN( "medium battery is installed" ) { - item med_battery( "medium_battery_cell" ); + item med_battery( itype_medium_battery_cell ); ret_val result = flashlight.put_in( med_battery, pocket_type::MAGAZINE_WELL ); THEN( "battery installation succeeds" ) { @@ -156,7 +158,7 @@ TEST_CASE( "battery_tool_mod_test", "[battery][mod]" ) } WHEN( "charged medium battery is installed" ) { - item med_battery( "medium_battery_cell" ); + item med_battery( itype_medium_battery_cell ); const int bat_charges = med_battery.ammo_capacity( ammo_battery ); med_battery.ammo_set( med_battery.ammo_default(), bat_charges ); @@ -209,8 +211,8 @@ TEST_CASE( "battery_tool_mod_test", "[battery][mod]" ) // TEST_CASE( "battery_and_tool_properties", "[battery][tool][properties]" ) { - const item bat_cell( "light_battery_cell" ); - const item flashlight( "diving_flashlight_small_hipower" ); + const item bat_cell( itype_light_battery_cell ); + const item flashlight( itype_diving_flashlight_small_hipower ); SECTION( "battery cell" ) { SECTION( "is a magazine" ) { @@ -304,8 +306,8 @@ TEST_CASE( "battery_and_tool_properties", "[battery][tool][properties]" ) TEST_CASE( "installing_battery_in_tool", "[battery][tool][install]" ) { - item bat_cell( "light_battery_cell" ); - item flashlight( "diving_flashlight_small_hipower" ); + item bat_cell( itype_light_battery_cell ); + item flashlight( itype_diving_flashlight_small_hipower ); const int bat_charges = bat_cell.ammo_capacity( ammo_battery ); REQUIRE( bat_charges > 0 ); @@ -349,7 +351,7 @@ TEST_CASE( "installing_battery_in_tool", "[battery][tool][install]" ) } SECTION( "wrong size battery for flashlight" ) { - item med_bat_cell( "medium_battery_cell" ); + item med_bat_cell( itype_medium_battery_cell ); // Should fail to install the magazine REQUIRE( flashlight.has_pocket_type( pocket_type::MAGAZINE_WELL ) ); diff --git a/tests/behavior_test.cpp b/tests/behavior_test.cpp index a1471f6eb6efa..e249024ecb091 100644 --- a/tests/behavior_test.cpp +++ b/tests/behavior_test.cpp @@ -24,7 +24,11 @@ #include "weather.h" static const itype_id itype_2x4( "2x4" ); +static const itype_id itype_backpack( "backpack" ); +static const itype_id itype_corpse( "corpse" ); +static const itype_id itype_frame( "frame" ); static const itype_id itype_lighter( "lighter" ); +static const itype_id itype_pencil( "pencil" ); static const itype_id itype_sandwich_cheese_grilled( "sandwich_cheese_grilled" ); static const itype_id itype_sweater( "sweater" ); static const itype_id itype_water( "water" ); @@ -172,7 +176,7 @@ TEST_CASE( "check_npc_behavior_tree", "[npc][behavior]" ) test_npc.update_bodytemp(); REQUIRE( oracle.needs_warmth_badly( "" ) == behavior::status_t::running ); CHECK( npc_needs.tick( &oracle ) == "idle" ); - test_npc.worn.wear_item( test_npc, item( "backpack" ), false, false ); + test_npc.worn.wear_item( test_npc, item( itype_backpack ), false, false ); item_location sweater = test_npc.i_add( item( itype_sweater ) ); CHECK( oracle.can_wear_warmer_clothes( "" ) == behavior::status_t::running ); CHECK( npc_needs.tick( &oracle ) == "wear_warmer_clothes" ); @@ -271,7 +275,7 @@ TEST_CASE( "check_monster_behavior_tree_shoggoth", "[monster][behavior]" ) test_monster.set_special( "SPLIT", 0 ); test_monster.set_special( "ABSORB_ITEMS", 0 ); CHECK( monster_goals.tick( &oracle ) == "idle" ); - here.add_item( test_monster.pos_bub(), item( "frame" ) ); + here.add_item( test_monster.pos_bub(), item( itype_frame ) ); CHECK( monster_goals.tick( &oracle ) == "ABSORB_ITEMS" ); mattack::absorb_items( &test_monster ); @@ -290,7 +294,7 @@ TEST_CASE( "check_monster_behavior_tree_shoggoth", "[monster][behavior]" ) // also set proper conditions for ABSORB_ITEMS to make sure SPLIT takes priority test_monster.set_special( "ABSORB_ITEMS", 0 ); - here.add_item( test_monster.pos_bub(), item( "frame" ) ); + here.add_item( test_monster.pos_bub(), item( itype_frame ) ); CHECK( monster_goals.tick( &oracle ) == "SPLIT" ); @@ -326,8 +330,8 @@ TEST_CASE( "check_monster_behavior_tree_theoretical_corpse_eater", "[monster][be test_monster.set_special( "ABSORB_ITEMS", 0 ); CHECK( monster_goals.tick( &oracle ) == "idle" ); - item corpse = item( "corpse" ); - corpse.force_insert_item( item( "pencil" ), pocket_type::CONTAINER ); + item corpse( itype_corpse ); + corpse.force_insert_item( item( itype_pencil ), pocket_type::CONTAINER ); here.add_item( test_monster.pos_bub(), corpse ); CHECK( monster_goals.tick( &oracle ) == "ABSORB_ITEMS" ); @@ -346,7 +350,7 @@ TEST_CASE( "check_monster_behavior_tree_theoretical_corpse_eater", "[monster][be test_monster.set_hp( new_hp ); // also set proper conditions for ABSORB_ITEMS to make sure SPLIT takes priority - here.add_item( test_monster.pos_bub(), item( "corpse" ) ); + here.add_item( test_monster.pos_bub(), item( itype_corpse ) ); test_monster.set_special( "ABSORB_ITEMS", 0 ); CHECK( monster_goals.tick( &oracle ) == "SPLIT" ); @@ -384,8 +388,8 @@ TEST_CASE( "check_monster_behavior_tree_theoretical_absorb", "[monster][behavior test_monster.set_special( "ABSORB_ITEMS", 0 ); CHECK( monster_goals.tick( &oracle ) == "idle" ); - item corpse = item( "corpse" ); - corpse.force_insert_item( item( "pencil" ), pocket_type::CONTAINER ); + item corpse( itype_corpse ); + corpse.force_insert_item( item( itype_pencil ), pocket_type::CONTAINER ); here.add_item( test_monster.pos_bub(), corpse ); CHECK( monster_goals.tick( &oracle ) == "ABSORB_ITEMS" ); diff --git a/tests/bionics_test.cpp b/tests/bionics_test.cpp index 7372b2a4e2fad..8c5b03a08240c 100644 --- a/tests/bionics_test.cpp +++ b/tests/bionics_test.cpp @@ -32,9 +32,18 @@ static const bionic_id bio_power_storage( "bio_power_storage" ); // Change to some other weapon CBM if bio_surgical_razor is ever removed static const bionic_id bio_surgical_razor( "bio_surgical_razor" ); // Any item that can be wielded + static const flag_id json_flag_PSEUDO( "PSEUDO" ); + +static const itype_id fuel_type_gasoline( "gasoline" ); +static const itype_id itype_backpack( "backpack" ); +static const itype_id itype_light_battery_cell( "light_battery_cell" ); +static const itype_id itype_jumper_cable( "jumper_cable" ); +static const itype_id itype_pants_cargo( "pants_cargo" ); static const itype_id itype_solarpack_on( "solarpack_on" ); +static const itype_id itype_splinter( "splinter" ); static const itype_id itype_test_backpack( "test_backpack" ); +static const itype_id itype_UPS_ON( "UPS_ON" ); TEST_CASE( "Bionic_power_capacity", "[bionics] [power]" ) { @@ -392,7 +401,7 @@ TEST_CASE( "fueled_bionics", "[bionics] [item]" ) REQUIRE( !dummy.has_power() ); // Add fuel. Now it turns on and generates power. - item gasoline = item( "gasoline" ); + item gasoline = item( fuel_type_gasoline ); gasoline.charges = 2; CHECK( gasoline_tank->can_reload_with( gasoline, true ) ); gasoline_tank->put_in( gasoline, pocket_type::CONTAINER ); @@ -427,7 +436,7 @@ TEST_CASE( "fueled_bionics", "[bionics] [item]" ) REQUIRE( !dummy.has_power() ); // Add empty battery. Still won't work - item battery = item( "light_battery_cell" ); + item battery = item( itype_light_battery_cell ); CHECK( bat_compartment->can_reload_with( battery, true ) ); bat_compartment->put_in( battery, pocket_type::MAGAZINE_WELL ); REQUIRE( bat_compartment->ammo_remaining() == 0 ); @@ -470,9 +479,9 @@ TEST_CASE( "fueled_bionics", "[bionics] [item]" ) REQUIRE( !dummy.has_power() ); // Connect to empty ups. Bionic shouldn't work - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); - item_location ups = dummy.i_add( item( "UPS_ON" ) ); - item_location cable = dummy.i_add( item( "jumper_cable" ) ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); + item_location ups = dummy.i_add( item( itype_UPS_ON ) ); + item_location cable = dummy.i_add( item( itype_jumper_cable ) ); cable->link().source = link_state::ups; cable->link().target = link_state::bio_cable; ups->set_var( "cable", "plugged_in" ); @@ -525,12 +534,12 @@ TEST_CASE( "fueled_bionics", "[bionics] [item]" ) REQUIRE( g->is_in_sunlight( dummy.pos_bub() ) ); // Connect solar backpack - dummy.worn.wear_item( dummy, item( "pants_cargo" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_pants_cargo ), false, false ); dummy.worn.wear_item( dummy, item( itype_solarpack_on ), false, false ); // Unsafe way to get the worn solar backpack item_location solar_pack = dummy.top_items_loc()[1]; REQUIRE( solar_pack->typeId() == itype_solarpack_on ); - item_location cable = dummy.i_add( item( "jumper_cable" ) ); + item_location cable = dummy.i_add( item( itype_jumper_cable ) ); cable->link().source = link_state::solarpack; cable->link().target = link_state::bio_cable; solar_pack->set_var( "cable", "plugged_in" ); @@ -559,8 +568,8 @@ TEST_CASE( "fueled_bionics", "[bionics] [item]" ) REQUIRE( !dummy.has_power() ); // Add two splints. Now it turns on and generates power. - item wood = item( "splinter" ); - item wood_2 = item( "splinter" ); + item wood = item( itype_splinter ); + item wood_2 = item( itype_splinter ); REQUIRE_FALSE( wood.count_by_charges() ); woodshed->put_in( wood, pocket_type::CONTAINER ); woodshed->put_in( wood_2, pocket_type::CONTAINER ); diff --git a/tests/char_edible_rating_test.cpp b/tests/char_edible_rating_test.cpp index 56d9f3477deea..f28adc5bc8711 100644 --- a/tests/char_edible_rating_test.cpp +++ b/tests/char_edible_rating_test.cpp @@ -16,6 +16,27 @@ // Character "edible rating" tests, covering the `can_eat` and `will_eat` functions static const efftype_id effect_nausea( "nausea" ); +static const itype_id itype_apple( "apple" ); +static const itype_id itype_aspirin( "aspirin" ); +static const itype_id itype_birdfood( "birdfood" ); +static const itype_id itype_broth( "broth" ); +static const itype_id itype_cattlefodder( "cattlefodder" ); +static const itype_id itype_chocolate( "chocolate" ); +static const itype_id itype_human_cooked( "human_cooked" ); +static const itype_id itype_marloss_berry( "marloss_berry" ); +static const itype_id itype_meat_cooked( "meat_cooked" ); +static const itype_id itype_milkshake( "milkshake" ); +static const itype_id itype_neccowafers( "neccowafers" ); +static const itype_id itype_pine_nuts( "pine_nuts" ); +static const itype_id itype_scrambled_eggs( "scrambled_eggs" ); +static const itype_id itype_sheet_cotton( "sheet_cotton" ); +static const itype_id itype_soup_veggy( "soup_veggy" ); +static const itype_id itype_sourdough_bread( "sourdough_bread" ); +static const itype_id itype_sushi_fishroll( "sushi_fishroll" ); +static const itype_id itype_toastem( "toastem" ); +static const itype_id itype_veggy( "veggy" ); +static const itype_id itype_water_clean( "water_clean" ); + static const trait_id trait_ANTIFRUIT( "ANTIFRUIT" ); static const trait_id trait_CANNIBAL( "CANNIBAL" ); static const trait_id trait_CARNIVORE( "CARNIVORE" ); @@ -61,7 +82,7 @@ TEST_CASE( "cannot_eat_non-comestible", "[can_eat][will_eat][edible_rating][nonf { avatar dummy; GIVEN( "something not edible" ) { - item sheet_cotton( "sheet_cotton" ); + item sheet_cotton( itype_sheet_cotton ); THEN( "they cannot eat it" ) { expect_cannot_eat( dummy, sheet_cotton, "That doesn't look edible.", INEDIBLE ); @@ -74,7 +95,7 @@ TEST_CASE( "cannot_eat_dirty_food", "[can_eat][edible_rating][dirty]" ) avatar dummy; GIVEN( "food that is dirty" ) { - item chocolate( "chocolate" ); + item chocolate( itype_chocolate ); chocolate.set_flag( flag_DIRTY ); REQUIRE( chocolate.has_own_flag( flag_DIRTY ) ); @@ -88,8 +109,8 @@ TEST_CASE( "who_can_eat_while_underwater", "[can_eat][edible_rating][underwater] { avatar dummy; dummy.set_body(); - item sushi( "sushi_fishroll" ); - item water( "water_clean" ); + item sushi( itype_sushi_fishroll ); + item water( itype_water_clean ); GIVEN( "character is underwater" ) { dummy.set_underwater( true ); @@ -130,7 +151,7 @@ TEST_CASE( "when_frozen_food_can_be_eaten", "[can_eat][edible_rating][frozen]" ) avatar dummy; GIVEN( "food that is not edible when frozen" ) { - item apple( "apple" ); + item apple( itype_apple ); REQUIRE_FALSE( apple.has_flag( flag_EDIBLE_FROZEN ) ); REQUIRE_FALSE( apple.has_flag( flag_MELTS ) ); @@ -153,7 +174,7 @@ TEST_CASE( "when_frozen_food_can_be_eaten", "[can_eat][edible_rating][frozen]" ) } GIVEN( "drink that is not drinkable when frozen" ) { - item water( "water_clean" ); + item water( itype_water_clean ); REQUIRE_FALSE( water.has_flag( flag_EDIBLE_FROZEN ) ); REQUIRE_FALSE( water.has_flag( flag_MELTS ) ); @@ -176,7 +197,7 @@ TEST_CASE( "when_frozen_food_can_be_eaten", "[can_eat][edible_rating][frozen]" ) } GIVEN( "food that is edible when frozen" ) { - item necco( "neccowafers" ); + item necco( itype_neccowafers ); REQUIRE( necco.has_flag( flag_EDIBLE_FROZEN ) ); WHEN( "it is frozen" ) { @@ -190,7 +211,7 @@ TEST_CASE( "when_frozen_food_can_be_eaten", "[can_eat][edible_rating][frozen]" ) } GIVEN( "food that melts" ) { - item milkshake( "milkshake" ); + item milkshake( itype_milkshake ); // When food does not have EDIBLE_FROZEN, it will still be edible // frozen if it MELTS. Ice cream, milkshakes and such do not have @@ -216,8 +237,8 @@ TEST_CASE( "who_can_eat_inedible_animal_food", "[can_eat][edible_rating][inedibl // "birdfood" and "cattlefodder" are the only INEDIBLE items that exist in the game. GIVEN( "food for animals" ) { - item birdfood( "birdfood" ); - item cattlefodder( "cattlefodder" ); + item birdfood( itype_birdfood ); + item cattlefodder( itype_cattlefodder ); REQUIRE( birdfood.has_flag( flag_INEDIBLE ) ); REQUIRE( cattlefodder.has_flag( flag_INEDIBLE ) ); @@ -272,14 +293,14 @@ TEST_CASE( "what_herbivores_can_eat", "[can_eat][edible_rating][herbivore]" ) std::string expect_reason = "The thought of eating that makes you feel sick."; THEN( "they cannot eat meat" ) { - item meat( "meat_cooked" ); + item meat( itype_meat_cooked ); REQUIRE( meat.has_flag( flag_ALLERGEN_MEAT ) ); expect_cannot_eat( dummy, meat, expect_reason, INEDIBLE_MUTATION ); } THEN( "they cannot eat eggs" ) { - item eggs( "scrambled_eggs" ); + item eggs( itype_scrambled_eggs ); REQUIRE( eggs.has_flag( flag_ALLERGEN_EGG ) ); expect_cannot_eat( dummy, eggs, expect_reason, INEDIBLE_MUTATION ); @@ -299,35 +320,35 @@ TEST_CASE( "what_carnivores_can_eat", "[can_eat][edible_rating][carnivore]" ) std::string expect_reason = "Eww. Inedible plant stuff!"; THEN( "they cannot eat veggies" ) { - item veggy( "veggy" ); + item veggy( itype_veggy ); REQUIRE( veggy.has_flag( flag_ALLERGEN_VEGGY ) ); expect_cannot_eat( dummy, veggy, expect_reason, INEDIBLE_MUTATION ); } THEN( "they cannot eat fruit" ) { - item apple( "apple" ); + item apple( itype_apple ); REQUIRE( apple.has_flag( flag_ALLERGEN_FRUIT ) ); expect_cannot_eat( dummy, apple, expect_reason, INEDIBLE_MUTATION ); } THEN( "they cannot eat wheat" ) { - item bread( "sourdough_bread" ); + item bread( itype_sourdough_bread ); REQUIRE( bread.has_flag( flag_ALLERGEN_WHEAT ) ); expect_cannot_eat( dummy, bread, expect_reason, INEDIBLE_MUTATION ); } THEN( "they cannot eat nuts" ) { - item nuts( "pine_nuts" ); + item nuts( itype_pine_nuts ); REQUIRE( nuts.has_flag( flag_ALLERGEN_NUT ) ); expect_cannot_eat( dummy, nuts, expect_reason, INEDIBLE_MUTATION ); } THEN( "they can eat junk food, but are allergic to it" ) { - item chocolate( "chocolate" ); + item chocolate( itype_chocolate ); REQUIRE( chocolate.has_flag( flag_ALLERGEN_JUNK ) ); expect_can_eat( dummy, chocolate ); @@ -346,14 +367,14 @@ TEST_CASE( "what_you_can_eat_with_a_mycus_dependency", "[can_eat][edible_rating] REQUIRE( dummy.has_trait( trait_M_DEPENDENT ) ); THEN( "they cannot eat normal food" ) { - item nuts( "pine_nuts" ); + item nuts( itype_pine_nuts ); REQUIRE_FALSE( nuts.has_flag( flag_MYCUS_OK ) ); expect_cannot_eat( dummy, nuts, "We can't eat that. It's not right for us.", INEDIBLE_MUTATION ); } THEN( "they can eat mycus food" ) { - item berry( "marloss_berry" ); + item berry( itype_marloss_berry ); REQUIRE( berry.has_flag( flag_MYCUS_OK ) ); expect_can_eat( dummy, berry ); @@ -374,7 +395,7 @@ TEST_CASE( "what_you_can_drink_with_a_proboscis", "[can_eat][edible_rating][prob std::string expect_reason = "Ugh, you can't drink that!"; GIVEN( "a drink that is 'eaten' (USE_EAT_VERB)" ) { - item soup( "soup_veggy" ); + item soup( itype_soup_veggy ); REQUIRE( soup.has_flag( flag_USE_EAT_VERB ) ); THEN( "they cannot drink it" ) { @@ -383,7 +404,7 @@ TEST_CASE( "what_you_can_drink_with_a_proboscis", "[can_eat][edible_rating][prob } GIVEN( "food that must be chewed" ) { - item toastem( "toastem" ); + item toastem( itype_toastem ); REQUIRE( toastem.get_comestible()->comesttype == "FOOD" ); THEN( "they cannot drink it" ) { @@ -394,7 +415,7 @@ TEST_CASE( "what_you_can_drink_with_a_proboscis", "[can_eat][edible_rating][prob // Can drink GIVEN( "a drink that is not 'eaten'" ) { - item broth( "broth" ); + item broth( itype_broth ); REQUIRE_FALSE( broth.has_flag( flag_USE_EAT_VERB ) ); THEN( "they can drink it" ) { @@ -403,7 +424,7 @@ TEST_CASE( "what_you_can_drink_with_a_proboscis", "[can_eat][edible_rating][prob } GIVEN( "some medicine" ) { - item aspirin( "aspirin" ); + item aspirin( itype_aspirin ); REQUIRE( aspirin.is_medication() ); THEN( "they can consume it" ) { @@ -416,7 +437,7 @@ TEST_CASE( "what_you_can_drink_with_a_proboscis", "[can_eat][edible_rating][prob TEST_CASE( "can_eat_with_nausea", "[will_eat][edible_rating][nausea]" ) { avatar dummy; - item toastem( "toastem" ); + item toastem( itype_toastem ); GIVEN( "character has nausea" ) { dummy.add_effect( effect_nausea, 10_minutes ); @@ -434,7 +455,7 @@ TEST_CASE( "can_eat_with_allergies", "[will_eat][edible_rating][allergy]" ) { avatar dummy; dummy.set_body(); - item fruit( "apple" ); + item fruit( itype_apple ); REQUIRE( fruit.has_flag( flag_ALLERGEN_FRUIT ) ); GIVEN( "character hates fruit" ) { @@ -454,7 +475,7 @@ TEST_CASE( "who_will_eat_rotten_food", "[will_eat][edible_rating][rotten]" ) dummy.set_body(); GIVEN( "food just barely rotten" ) { - item toastem_rotten = item( "toastem" ); + item toastem_rotten = item( itype_toastem ); toastem_rotten.set_relative_rot( 1.01 ); REQUIRE( toastem_rotten.rotten() ); @@ -505,7 +526,7 @@ TEST_CASE( "who_will_eat_cooked_human_flesh", "[will_eat][edible_rating][canniba dummy.set_body(); GIVEN( "some cooked human flesh" ) { - item flesh( "human_cooked" ); + item flesh( itype_human_cooked ); REQUIRE( flesh.has_vitamin( vitamin_human_flesh_vitamin ) ); WHEN( "character is not a cannibal" ) { diff --git a/tests/char_exposure_test.cpp b/tests/char_exposure_test.cpp index 6fc8adda0d4b6..2535cba844072 100644 --- a/tests/char_exposure_test.cpp +++ b/tests/char_exposure_test.cpp @@ -8,6 +8,10 @@ #include "player_helpers.h" #include "type_id.h" +static const itype_id itype_test_croc_socks( "test_croc_socks" ); +static const itype_id itype_test_longshirt( "test_longshirt" ); +static const itype_id itype_test_socks( "test_socks" ); + // Tests for Character bodypart exposure // // Covers functions: @@ -31,7 +35,7 @@ TEST_CASE( "character_body_part_exposure", "[char][bodypart][exposure]" ) } WHEN( "wearing an item with 100% coverage on some parts" ) { - item socks( "test_socks" ); + item socks( itype_test_socks ); REQUIRE( socks.get_coverage( body_part_foot_l ) == 100 ); REQUIRE( socks.get_coverage( body_part_foot_r ) == 100 ); dummy.wear_item( socks, false ); @@ -50,7 +54,7 @@ TEST_CASE( "character_body_part_exposure", "[char][bodypart][exposure]" ) } WHEN( "wearing an item with 50% coverage on some parts" ) { - item croc_socks( "test_croc_socks" ); + item croc_socks( itype_test_croc_socks ); REQUIRE( croc_socks.get_coverage( body_part_foot_l ) == 50 ); REQUIRE( croc_socks.get_coverage( body_part_foot_r ) == 50 ); dummy.wear_item( croc_socks, false ); @@ -63,7 +67,7 @@ TEST_CASE( "character_body_part_exposure", "[char][bodypart][exposure]" ) } AND_WHEN( "wearing another item with 50% coverage on the same parts" ) { - item croc_socks2( "test_croc_socks" ); + item croc_socks2( itype_test_croc_socks ); dummy.wear_item( croc_socks2, false ); bp_exposure = dummy.bodypart_exposure(); @@ -76,7 +80,7 @@ TEST_CASE( "character_body_part_exposure", "[char][bodypart][exposure]" ) } WHEN( "wearing an item with 90% coverage on some parts" ) { - item shirt( "test_longshirt" ); + item shirt( itype_test_longshirt ); REQUIRE( shirt.get_coverage( body_part_torso ) == 90 ); REQUIRE( shirt.get_coverage( body_part_arm_l ) == 90 ); REQUIRE( shirt.get_coverage( body_part_arm_r ) == 90 ); @@ -100,7 +104,7 @@ TEST_CASE( "character_body_part_exposure", "[char][bodypart][exposure]" ) } AND_WHEN( "wearing another item with 90% coverage on the same parts" ) { - item shirt2( "test_longshirt" ); + item shirt2( itype_test_longshirt ); dummy.wear_item( shirt2, false ); bp_exposure = dummy.bodypart_exposure(); diff --git a/tests/char_sight_test.cpp b/tests/char_sight_test.cpp index 143f8061e3e0c..08a1a8f4dc767 100644 --- a/tests/char_sight_test.cpp +++ b/tests/char_sight_test.cpp @@ -18,6 +18,10 @@ static const efftype_id effect_boomered( "boomered" ); static const efftype_id effect_darkness( "darkness" ); +static const itype_id itype_atomic_lamp( "atomic_lamp" ); +static const itype_id itype_blindfold( "blindfold" ); +static const itype_id itype_glasses_eye( "glasses_eye" ); + static const trait_id trait_MYOPIC( "MYOPIC" ); static const trait_id trait_URSINE_EYE( "URSINE_EYE" ); @@ -73,7 +77,7 @@ TEST_CASE( "light_and_fine_detail_vision_mod", "[character][sight][light][vision } SECTION( "wielding a bright lamp" ) { - item lamp( "atomic_lamp" ); + item lamp( itype_atomic_lamp ); dummy.wield( lamp ); REQUIRE( dummy.active_light() == Approx( 15.0f ) ); @@ -102,7 +106,7 @@ TEST_CASE( "light_and_fine_detail_vision_mod", "[character][sight][light][vision } SECTION( "blindfolded" ) { - dummy.wear_item( item( "blindfold" ) ); + dummy.wear_item( item( itype_blindfold ) ); REQUIRE( dummy.worn_with_flag( flag_BLIND ) ); // 11.0 is zero light or blindness @@ -186,7 +190,7 @@ TEST_CASE( "character_sight_limits", "[character][sight][vision]" ) } WHEN( "blindfolded" ) { - dummy.wear_item( item( "blindfold" ) ); + dummy.wear_item( item( itype_blindfold ) ); REQUIRE( dummy.worn_with_flag( flag_BLIND ) ); THEN( "impaired sight, with 0 tiles of range" ) { @@ -223,7 +227,7 @@ TEST_CASE( "character_sight_limits", "[character][sight][vision]" ) } WHEN( "wearing glasses" ) { - dummy.wear_item( item( "glasses_eye" ) ); + dummy.wear_item( item( itype_glasses_eye ) ); REQUIRE( dummy.worn_with_flag( flag_FIX_NEARSIGHT ) ); THEN( "unimpaired sight, with " << MAX_VIEW_DISTANCE << " tiles of range" ) { @@ -337,7 +341,7 @@ TEST_CASE( "ursine_vision", "[character][ursine][vision]" ) // Glasses can correct Ursine Vision in bright light AND_WHEN( "wearing glasses" ) { - dummy.wear_item( item( "glasses_eye" ) ); + dummy.wear_item( item( itype_glasses_eye ) ); REQUIRE( dummy.worn_with_flag( flag_FIX_NEARSIGHT ) ); THEN( "unimpaired sight, with 87 tiles of range" ) { diff --git a/tests/char_stamina_test.cpp b/tests/char_stamina_test.cpp index f839ee0308b09..e1a63f4870c6b 100644 --- a/tests/char_stamina_test.cpp +++ b/tests/char_stamina_test.cpp @@ -21,6 +21,9 @@ character_modifier_stamina_recovery_breathing_mod( "stamina_recovery_breathing_m static const efftype_id effect_winded( "winded" ); +static const itype_id itype_scarf_fur( "scarf_fur" ); +static const itype_id itype_test_platinum_bit( "test_platinum_bit" ); + static const move_mode_id move_mode_crouch( "crouch" ); static const move_mode_id move_mode_run( "run" ); static const move_mode_id move_mode_walk( "walk" ); @@ -112,7 +115,7 @@ static void burden_player( Character &dummy, float burden_proportion ) // Add a pile of test platinum bits (1g/unit) to reach the desired weight capacity if( burden_proportion > 0.0 ) { - item pile( "test_platinum_bit", calendar::turn, units ); + item pile( itype_test_platinum_bit, calendar::turn, units ); dummy.i_add( pile ); } @@ -503,7 +506,7 @@ TEST_CASE( "stamina_regen_with_mouth_encumbrance", "[stamina][update][regen][enc } GIVEN( "character has mouth encumbrance" ) { - dummy.wear_item( item( "scarf_fur" ) ); + dummy.wear_item( item( itype_scarf_fur ) ); REQUIRE( dummy.encumb( bodypart_id( "mouth" ) ) == 10 ); THEN( "stamina regen is reduced" ) { @@ -514,7 +517,7 @@ TEST_CASE( "stamina_regen_with_mouth_encumbrance", "[stamina][update][regen][enc WHEN( "they have even more mouth encumbrance" ) { // Layering two scarves triples the encumbrance - dummy.wear_item( item( "scarf_fur" ) ); + dummy.wear_item( item( itype_scarf_fur ) ); REQUIRE( dummy.encumb( bodypart_id( "mouth" ) ) == 30 ); THEN( "stamina regen is reduced further" ) { diff --git a/tests/char_suffer_test.cpp b/tests/char_suffer_test.cpp index 489aa3a43586e..e67fe3870b73e 100644 --- a/tests/char_suffer_test.cpp +++ b/tests/char_suffer_test.cpp @@ -22,6 +22,12 @@ static const efftype_id effect_grabbed( "grabbed" ); +static const itype_id itype_test_hazmat_suit( "test_hazmat_suit" ); +static const itype_id itype_test_longshirt( "test_longshirt" ); +static const itype_id itype_test_sunglasses( "test_sunglasses" ); +static const itype_id itype_test_umbrella( "test_umbrella" ); +static const itype_id itype_test_zentai( "test_zentai" ); + static const ter_str_id ter_t_rock_wall( "t_rock_wall" ); static const trait_id trait_ALBINO( "ALBINO" ); @@ -115,16 +121,16 @@ TEST_CASE( "suffering_from_albinism", "[char][suffer][albino]" ) // The values should still be correct // Need sunglasses to protect the eyes, no matter how covered the rest of the body is - item shades( "test_sunglasses" ); + item shades( itype_test_sunglasses ); // Umbrella can protect completely - item umbrella( "test_umbrella" ); + item umbrella( itype_test_umbrella ); // hazmat suit has 100% coverage, but eyes and mouth are exposed - item hazmat( "test_hazmat_suit" ); + item hazmat( itype_test_hazmat_suit ); // zentai has 100% coverage over all body parts - item zentai( "test_zentai" ); + item zentai( itype_test_zentai ); // long-sleeve shirt has 90% coverage on torso and arms - item longshirt( "test_longshirt" ); + item longshirt( itype_test_longshirt ); GIVEN( "avatar is in sunlight with the albino trait" ) { REQUIRE( g->is_in_sunlight( dummy.pos_bub() ) ); @@ -219,10 +225,10 @@ TEST_CASE( "suffering_from_sunburn", "[char][suffer][sunburn]" ) int focus_lost = 0; int pain_felt = 0; - item shades( "test_sunglasses" ); - item umbrella( "test_umbrella" ); - item zentai( "test_zentai" ); - item longshirt( "test_longshirt" ); + item shades( itype_test_sunglasses ); + item umbrella( itype_test_umbrella ); + item zentai( itype_test_zentai ); + item longshirt( itype_test_longshirt ); GIVEN( "avatar is in sunlight with the solar sensitivity trait" ) { REQUIRE( g->is_in_sunlight( dummy.pos_bub() ) ); diff --git a/tests/character_modifier_test.cpp b/tests/character_modifier_test.cpp index 82d12ecf6ae0a..50a18debb2379 100644 --- a/tests/character_modifier_test.cpp +++ b/tests/character_modifier_test.cpp @@ -34,7 +34,11 @@ static const damage_type_id damage_cut( "cut" ); static const enchantment_id enchantment_ENCH_TEST_BIRD_PARTS( "ENCH_TEST_BIRD_PARTS" ); static const enchantment_id enchantment_ENCH_TEST_TAIL( "ENCH_TEST_TAIL" ); +static const itype_id itype_test_boxing_gloves( "test_boxing_gloves" ); +static const itype_id itype_test_goggles_welding( "test_goggles_welding" ); +static const itype_id itype_test_hazmat_suit( "test_hazmat_suit" ); static const itype_id itype_test_tail_encumber( "test_tail_encumber" ); +static const itype_id itype_test_winglets( "test_winglets" ); static const limb_score_id limb_score_test( "test" ); @@ -363,7 +367,7 @@ TEST_CASE( "Multi-limbscore_modifiers", "[character][limb]" ) } WHEN( "Character has high eye encumbrance" ) { - item eyecover( "test_goggles_welding" ); + item eyecover( itype_test_goggles_welding ); dude.wear_item( eyecover ); REQUIRE( dude.encumb( dude.get_all_body_parts_of_type( body_part_type::type::sensor, get_body_part_flags::primary_type ).front() ) == 60 ); @@ -386,7 +390,7 @@ TEST_CASE( "Multi-limbscore_modifiers", "[character][limb]" ) } WHEN( "Character has high eye encumbrance and broken arms" ) { - item eyecover( "test_goggles_welding" ); + item eyecover( itype_test_goggles_welding ); dude.wear_item( eyecover ); for( const bodypart_id &bid : dude.get_all_body_parts_of_type( body_part_type::type::arm, get_body_part_flags::primary_type ) ) { @@ -423,7 +427,7 @@ TEST_CASE( "Slip_prevention_modifier_/_weighted-list_multi-score_modifiers", "[c } WHEN( "Character is heavily encumbered" ) { - item hazmat_suit( "test_hazmat_suit" ); + item hazmat_suit( itype_test_hazmat_suit ); dude.wear_item( hazmat_suit ); REQUIRE( dude.encumb( dude.get_all_body_parts_of_type( body_part_type::type::foot, get_body_part_flags::primary_type ).front() ) == 37 ); @@ -434,7 +438,7 @@ TEST_CASE( "Slip_prevention_modifier_/_weighted-list_multi-score_modifiers", "[c } WHEN( "Character has broken arms and is heavily encumbered" ) { - item hazmat_suit( "test_hazmat_suit" ); + item hazmat_suit( itype_test_hazmat_suit ); dude.wear_item( hazmat_suit ); for( const bodypart_id &bid : dude.get_all_body_parts_of_type( body_part_type::type::arm, get_body_part_flags::primary_type ) ) { @@ -452,8 +456,8 @@ TEST_CASE( "Slip_prevention_modifier_/_weighted-list_multi-score_modifiers", "[c TEST_CASE( "Weighted_limb_types", "[character][limb]" ) { - item boxing_gloves( "test_boxing_gloves" ); - item wing_covers( "test_winglets" ); + item boxing_gloves( itype_test_boxing_gloves ); + item wing_covers( itype_test_winglets ); standard_npc dude( "Test NPC" ); clear_character( dude, true ); diff --git a/tests/clzones_test.cpp b/tests/clzones_test.cpp index f1f4b5e10b961..6d18152306a1e 100644 --- a/tests/clzones_test.cpp +++ b/tests/clzones_test.cpp @@ -20,6 +20,12 @@ static const faction_id faction_your_followers( "your_followers" ); static const itype_id itype_556( "556" ); static const itype_id itype_ammolink223( "ammolink223" ); static const itype_id itype_belt223( "belt223" ); +static const itype_id itype_test_bitter_almond( "test_bitter_almond" ); +static const itype_id itype_test_apple( "test_apple" ); +static const itype_id itype_test_milk( "test_milk" ); +static const itype_id +itype_test_watertight_open_sealed_container_250ml( "test_watertight_open_sealed_container_250ml" ); +static const itype_id itype_test_wine( "test_wine" ); static const vproto_id vehicle_prototype_shopping_cart( "shopping_cart" ); @@ -131,7 +137,7 @@ TEST_CASE( "zone_sorting_comestibles_", "[zones][items][food][activities]" ) SECTION( "without perishable zones" ) { GIVEN( "a non-perishable food" ) { - item nonperishable_food( "test_bitter_almond" ); + item nonperishable_food( itype_test_bitter_almond ); REQUIRE_FALSE( nonperishable_food.goes_bad() ); WHEN( "sorting without a container" ) { @@ -142,7 +148,7 @@ TEST_CASE( "zone_sorting_comestibles_", "[zones][items][food][activities]" ) } GIVEN( "a non-perishable drink" ) { - item nonperishable_drink( "test_wine" ); + item nonperishable_drink( itype_test_wine ); REQUIRE_FALSE( nonperishable_drink.goes_bad() ); WHEN( "sorting without a container" ) { @@ -153,7 +159,7 @@ TEST_CASE( "zone_sorting_comestibles_", "[zones][items][food][activities]" ) } GIVEN( "a perishable food" ) { - item perishable_food( "test_apple" ); + item perishable_food( itype_test_apple ); REQUIRE( perishable_food.goes_bad() ); WHEN( "sorting without a container" ) { @@ -164,7 +170,7 @@ TEST_CASE( "zone_sorting_comestibles_", "[zones][items][food][activities]" ) } GIVEN( "a perishable drink" ) { - item perishable_drink( "test_milk" ); + item perishable_drink( itype_test_milk ); REQUIRE( perishable_drink.goes_bad() ); WHEN( "sorting without a container" ) { @@ -180,7 +186,7 @@ TEST_CASE( "zone_sorting_comestibles_", "[zones][items][food][activities]" ) create_tile_zone( "PDrink", zone_type_LOOT_PDRINK, tripoint_abs_ms::zero + tripoint::south ); GIVEN( "a non-perishable food" ) { - item nonperishable_food( "test_bitter_almond" ); + item nonperishable_food( itype_test_bitter_almond ); REQUIRE_FALSE( nonperishable_food.goes_bad() ); WHEN( "sorting without a container" ) { @@ -190,7 +196,7 @@ TEST_CASE( "zone_sorting_comestibles_", "[zones][items][food][activities]" ) } WHEN( "sorting within an unsealed container" ) { - item container( "test_watertight_open_sealed_container_250ml" ); + item container( itype_test_watertight_open_sealed_container_250ml ); REQUIRE( container.put_in( nonperishable_food, pocket_type::CONTAINER ).success() ); REQUIRE( !container.any_pockets_sealed() ); @@ -200,7 +206,7 @@ TEST_CASE( "zone_sorting_comestibles_", "[zones][items][food][activities]" ) } WHEN( "sorting within a sealed container" ) { - item container( "test_watertight_open_sealed_container_250ml" ); + item container( itype_test_watertight_open_sealed_container_250ml ); REQUIRE( container.put_in( nonperishable_food, pocket_type::CONTAINER ).success() ); REQUIRE( container.seal() ); REQUIRE( container.get_all_contained_pockets().front()->spoil_multiplier() == @@ -214,7 +220,7 @@ TEST_CASE( "zone_sorting_comestibles_", "[zones][items][food][activities]" ) } GIVEN( "a non-perishable drink" ) { - item nonperishable_drink( "test_wine" ); + item nonperishable_drink( itype_test_wine ); REQUIRE_FALSE( nonperishable_drink.goes_bad() ); WHEN( "sorting without a container" ) { @@ -224,7 +230,7 @@ TEST_CASE( "zone_sorting_comestibles_", "[zones][items][food][activities]" ) } WHEN( "sorting within an unsealed container" ) { - item container( "test_watertight_open_sealed_container_250ml" ); + item container( itype_test_watertight_open_sealed_container_250ml ); REQUIRE( container.put_in( nonperishable_drink, pocket_type::CONTAINER ).success() ); REQUIRE( !container.any_pockets_sealed() ); @@ -234,7 +240,7 @@ TEST_CASE( "zone_sorting_comestibles_", "[zones][items][food][activities]" ) } WHEN( "sorting within a sealed container" ) { - item container( "test_watertight_open_sealed_container_250ml" ); + item container( itype_test_watertight_open_sealed_container_250ml ); REQUIRE( container.put_in( nonperishable_drink, pocket_type::CONTAINER ).success() ); REQUIRE( container.seal() ); REQUIRE( container.get_all_contained_pockets().front()->spoil_multiplier() == @@ -248,7 +254,7 @@ TEST_CASE( "zone_sorting_comestibles_", "[zones][items][food][activities]" ) } GIVEN( "a perishable food" ) { - item perishable_food( "test_apple" ); + item perishable_food( itype_test_apple ); REQUIRE( perishable_food.goes_bad() ); WHEN( "sorting without a container" ) { @@ -258,7 +264,7 @@ TEST_CASE( "zone_sorting_comestibles_", "[zones][items][food][activities]" ) } WHEN( "sorting within an unsealed container" ) { - item container( "test_watertight_open_sealed_container_250ml" ); + item container( itype_test_watertight_open_sealed_container_250ml ); REQUIRE( container.put_in( perishable_food, pocket_type::CONTAINER ).success() ); REQUIRE( !container.any_pockets_sealed() ); @@ -268,7 +274,7 @@ TEST_CASE( "zone_sorting_comestibles_", "[zones][items][food][activities]" ) } WHEN( "sorting within a sealed container" ) { - item container( "test_watertight_open_sealed_container_250ml" ); + item container( itype_test_watertight_open_sealed_container_250ml ); REQUIRE( container.put_in( perishable_food, pocket_type::CONTAINER ).success() ); REQUIRE( container.seal() ); REQUIRE( container.get_all_contained_pockets().front()->spoil_multiplier() == @@ -282,7 +288,7 @@ TEST_CASE( "zone_sorting_comestibles_", "[zones][items][food][activities]" ) } GIVEN( "a perishable drink" ) { - item perishable_drink( "test_milk" ); + item perishable_drink( itype_test_milk ); REQUIRE( perishable_drink.goes_bad() ); WHEN( "sorting without a container" ) { @@ -292,7 +298,7 @@ TEST_CASE( "zone_sorting_comestibles_", "[zones][items][food][activities]" ) } WHEN( "sorting within an unsealed container" ) { - item container( "test_watertight_open_sealed_container_250ml" ); + item container( itype_test_watertight_open_sealed_container_250ml ); REQUIRE( container.put_in( perishable_drink, pocket_type::CONTAINER ).success() ); REQUIRE( !container.any_pockets_sealed() ); @@ -302,7 +308,7 @@ TEST_CASE( "zone_sorting_comestibles_", "[zones][items][food][activities]" ) } WHEN( "sorting within a sealed container" ) { - item container( "test_watertight_open_sealed_container_250ml" ); + item container( itype_test_watertight_open_sealed_container_250ml ); REQUIRE( container.put_in( perishable_drink, pocket_type::CONTAINER ).success() ); REQUIRE( container.seal() ); REQUIRE( container.get_all_contained_pockets().front()->spoil_multiplier() == diff --git a/tests/comestible_test.cpp b/tests/comestible_test.cpp index af3df5cebb99d..72adc75d644c7 100644 --- a/tests/comestible_test.cpp +++ b/tests/comestible_test.cpp @@ -26,9 +26,14 @@ static const item_category_id item_category_drugs( "drugs" ); static const item_category_id item_category_mutagen( "mutagen" ); + static const itype_id itype_marloss_berry( "marloss_berry" ); static const itype_id itype_marloss_gel( "marloss_gel" ); static const itype_id itype_marloss_seed( "marloss_seed" ); +static const itype_id itype_test_apple( "test_apple" ); +static const itype_id itype_test_egg( "test_egg" ); +static const itype_id itype_test_pine_nuts( "test_pine_nuts" ); +static const itype_id itype_veggy_wild_cooked( "veggy_wild_cooked" ); static const recipe_id recipe_veggy_wild_cooked( "veggy_wild_cooked" ); @@ -248,7 +253,7 @@ TEST_CASE( "cooked_veggies_get_correct_calorie_prediction", "[recipe]" ) { // This test verifies that predicted calorie ranges properly take into // account the "RAW"/"COOKED" flags. - const item veggy_wild_cooked( "veggy_wild_cooked" ); + const item veggy_wild_cooked( itype_veggy_wild_cooked ); const Character &u = get_player_character(); @@ -281,7 +286,7 @@ TEST_CASE( "effective_food_volume_and_satiety", "[character][food][satiety]" ) double expect_ratio; // Apple: 95 kcal / 200 g (1 serving) - const item apple( "test_apple" ); + const item apple( itype_test_apple ); const nutrients apple_nutr = u.compute_effective_nutrients( apple ); REQUIRE( apple.count() == 1 ); REQUIRE( apple.weight() == 200_gram ); @@ -294,7 +299,7 @@ TEST_CASE( "effective_food_volume_and_satiety", "[character][food][satiety]" ) CHECK( satiety_bar( 502 ) == "||\\.." ); // Egg: 80 kcal / 40 g (1 serving) - const item egg( "test_egg" ); + const item egg( itype_test_egg ); const nutrients egg_nutr = u.compute_effective_nutrients( egg ); REQUIRE( egg.count() == 1 ); REQUIRE( egg.weight() == 40_gram ); @@ -307,7 +312,7 @@ TEST_CASE( "effective_food_volume_and_satiety", "[character][food][satiety]" ) CHECK( satiety_bar( 1777 ) == "||||\\" ); // Pine nuts: 202 kcal / 30 g (4 servings) - const item nuts( "test_pine_nuts" ); + const item nuts( itype_test_pine_nuts ); const nutrients nuts_nutr = u.compute_effective_nutrients( nuts ); // If food count > 1, total weight is divided by count before computing kcal/gram REQUIRE( nuts.count() == 4 ); diff --git a/tests/consumption_time_test.cpp b/tests/consumption_time_test.cpp index b11b722255d02..934b3c8366f87 100644 --- a/tests/consumption_time_test.cpp +++ b/tests/consumption_time_test.cpp @@ -2,6 +2,8 @@ #include "item.h" #include "cata_catch.h" +static const itype_id itype_mustard( "mustard" ); + TEST_CASE( "characters_with_no_mutations_take_at_least_1_second_to_consume_comestibles", "[character][item][food][time]" ) { @@ -9,7 +11,7 @@ TEST_CASE( "characters_with_no_mutations_take_at_least_1_second_to_consume_comes avatar character; REQUIRE( character.cached_mutations.empty() ); - item mustard( "mustard" ); + item mustard( itype_mustard ); REQUIRE( mustard.is_comestible() ); WHEN( "character wants to consume it" ) { diff --git a/tests/coverage_test.cpp b/tests/coverage_test.cpp index 3c76aac13f63a..efdced810edf2 100644 --- a/tests/coverage_test.cpp +++ b/tests/coverage_test.cpp @@ -20,6 +20,23 @@ static const efftype_id effect_sleep( "sleep" ); static const flag_id json_flag_FILTHY( "FILTHY" ); +static const itype_id itype_ballistic_vest_esapi( "ballistic_vest_esapi" ); +static const itype_id itype_face_shield( "face_shield" ); +static const itype_id itype_hat_hard( "hat_hard" ); +static const itype_id itype_test_ghost_vest( "test_ghost_vest" ); +static const itype_id itype_test_hazmat_suit( "test_hazmat_suit" ); +static const itype_id itype_test_hazmat_suit_nomelee( "test_hazmat_suit_nomelee" ); +static const itype_id itype_test_hazmat_suit_noranged( "test_hazmat_suit_noranged" ); +static const itype_id +itype_test_multi_portion_segmented_armor( "test_multi_portion_segmented_armor" ); +static const itype_id itype_test_plate( "test_plate" ); +static const itype_id itype_test_plate_skirt_super( "test_plate_skirt_super" ); +static const itype_id itype_test_portion_segmented_armor( "test_portion_segmented_armor" ); +static const itype_id itype_test_swat_mostly_cotton( "test_swat_mostly_cotton" ); +static const itype_id itype_test_swat_mostly_steel( "test_swat_mostly_steel" ); +static const itype_id itype_test_zentai( "test_zentai" ); +static const itype_id itype_test_zentai_nomelee( "test_zentai_nomelee" ); + static const mtype_id mon_manhack( "mon_manhack" ); static const sub_bodypart_str_id sub_body_part_eyes_right( "eyes_right" ); @@ -47,7 +64,7 @@ static void check_not_near( const std::string &subject, float actual, const floa } } -static float get_avg_melee_dmg( const std::string &clothing_id, bool infect_risk = false ) +static float get_avg_melee_dmg( const itype_id &clothing_id, bool infect_risk = false ) { monster zed( mon_manhack, mon_pos ); standard_npc dude( "TestCharacter", dude_pos, {}, 0, 8, 8, 8, 8 ); @@ -118,7 +135,7 @@ static float get_avg_melee_dmg( item cloth, bool infect_risk = false ) return static_cast( dam_acc ) / num_hits; } -static float get_avg_bullet_dmg( const std::string &clothing_id ) +static float get_avg_bullet_dmg( const itype_id &clothing_id ) { clear_map(); std::unique_ptr badguy = std::make_unique( "TestBaddie", @@ -162,12 +179,12 @@ static float get_avg_bullet_dmg( const std::string &clothing_id ) TEST_CASE( "Infections_from_filthy_clothing", "[coverage]" ) { SECTION( "Full melee and ranged coverage vs. melee attack" ) { - const float chance = get_avg_melee_dmg( "test_zentai", true ); + const float chance = get_avg_melee_dmg( itype_test_zentai, true ); check_near( "Infection chance", chance, 0.48f, 0.05f ); } SECTION( "No melee coverage vs. melee attack" ) { - const float chance = get_avg_melee_dmg( "test_zentai_nomelee", true ); + const float chance = get_avg_melee_dmg( itype_test_zentai_nomelee, true ); check_near( "Infection chance", chance, 0.0f, 0.0001f ); } } @@ -175,12 +192,12 @@ TEST_CASE( "Infections_from_filthy_clothing", "[coverage]" ) TEST_CASE( "Melee_coverage_vs_melee_damage", "[coverage] [melee] [damage]" ) { SECTION( "Full melee and ranged coverage vs. melee attack" ) { - const float dmg = get_avg_melee_dmg( "test_hazmat_suit" ); + const float dmg = get_avg_melee_dmg( itype_test_hazmat_suit ); check_near( "Average damage", dmg, 9.2f, 0.2f ); } SECTION( "No melee coverage vs. melee attack" ) { - const float dmg = get_avg_melee_dmg( "test_hazmat_suit_nomelee" ); + const float dmg = get_avg_melee_dmg( itype_test_hazmat_suit_nomelee ); check_near( "Average damage", dmg, 17.0f, 0.2f ); } } @@ -188,12 +205,12 @@ TEST_CASE( "Melee_coverage_vs_melee_damage", "[coverage] [melee] [damage]" ) TEST_CASE( "Ranged_coverage_vs_bullet", "[coverage] [ranged]" ) { SECTION( "Full melee and ranged coverage vs. ranged attack" ) { - const float dmg = get_avg_bullet_dmg( "test_hazmat_suit" ); + const float dmg = get_avg_bullet_dmg( itype_test_hazmat_suit ); check_near( "Average damage", dmg, 15.4f, 0.2f ); } SECTION( "No ranged coverage vs. ranged attack" ) { - const float dmg = get_avg_bullet_dmg( "test_hazmat_suit_noranged" ); + const float dmg = get_avg_bullet_dmg( itype_test_hazmat_suit_noranged ); check_near( "Average damage", dmg, 17.2f, 0.2f ); } } @@ -201,20 +218,20 @@ TEST_CASE( "Ranged_coverage_vs_bullet", "[coverage] [ranged]" ) TEST_CASE( "Proportional_armor_material_resistances", "[material]" ) { SECTION( "Mostly steel armor vs. melee" ) { - const float dmg = get_avg_melee_dmg( "test_swat_mostly_steel" ); + const float dmg = get_avg_melee_dmg( itype_test_swat_mostly_steel ); check_near( "Average damage", dmg, 4.0f, 0.2f ); } SECTION( "Mostly cotton armor vs. melee" ) { - const float dmg = get_avg_melee_dmg( "test_swat_mostly_cotton" ); + const float dmg = get_avg_melee_dmg( itype_test_swat_mostly_cotton ); // more variance on this test since it has a 5% chance of blocking with // high protection steel check_near( "Average damage", dmg, 14.4f, 0.4f ); } SECTION( "Multi material segmented armor vs. melee" ) { - const float dmg = get_avg_melee_dmg( "test_multi_portion_segmented_armor" ); - const float base_line = get_avg_melee_dmg( "test_portion_segmented_armor" ); + const float dmg = get_avg_melee_dmg( itype_test_multi_portion_segmented_armor ); + const float base_line = get_avg_melee_dmg( itype_test_portion_segmented_armor ); // our armor should NOT be near 1 mm cloth + 80% of 1mm of steel // and should be higher (so lower damage) since they can overlap check_not_near( "Average damage", dmg, base_line, 0.05f ); @@ -224,10 +241,10 @@ TEST_CASE( "Proportional_armor_material_resistances", "[material]" ) TEST_CASE( "Ghost_ablative_vest", "[coverage]" ) { SECTION( "Ablative not covered same limb" ) { - item full = item( "test_ghost_vest" ); - full.force_insert_item( item( "test_plate" ), pocket_type::CONTAINER ); - full.force_insert_item( item( "test_plate" ), pocket_type::CONTAINER ); - item empty = item( "test_ghost_vest" ); + item full = item( itype_test_ghost_vest ); + full.force_insert_item( item( itype_test_plate ), pocket_type::CONTAINER ); + full.force_insert_item( item( itype_test_plate ), pocket_type::CONTAINER ); + item empty = item( itype_test_ghost_vest ); // make sure vest only covers torso_upper when it has armor in it REQUIRE( full.covers( sub_bodypart_id( "torso_upper" ) ) ); @@ -244,11 +261,11 @@ TEST_CASE( "helmet_with_face_shield_coverage", "[coverage]" ) Character &dummy = get_player_character(); clear_avatar(); - item hat_hard( "hat_hard" ); + item hat_hard( itype_hat_hard ); CHECK( hat_hard.get_coverage( body_part_eyes ) == 0 ); WHEN( "wearing helmet with face shield should cover eyes and mouth" ) { - item face_shield( "face_shield" ); + item face_shield( itype_face_shield ); REQUIRE( hat_hard.put_in( face_shield, pocket_type::CONTAINER ).success() ); dummy.wear_item( hat_hard ); @@ -262,14 +279,14 @@ TEST_CASE( "helmet_with_face_shield_coverage", "[coverage]" ) TEST_CASE( "vest_with_plate_coverage", "[coverage]" ) { //Vest covers torso_upper and torso_lower - item vest = item( "ballistic_vest_esapi" ); + item vest = item( itype_ballistic_vest_esapi ); //100 (torso_upper coverage) * 0.6 (torso_upper max_coverage) + 80 (torso_lower coverage) * 0.4 CHECK( vest.get_coverage( body_part_torso ) == 92 ); WHEN( "inserting 2 plates" ) { //Each plate covers torso_upper with coverage 45 - CHECK( vest.put_in( item( "test_plate" ), pocket_type::CONTAINER ).success() ); - CHECK( vest.put_in( item( "test_plate" ), pocket_type::CONTAINER ).success() ); + CHECK( vest.put_in( item( itype_test_plate ), pocket_type::CONTAINER ).success() ); + CHECK( vest.put_in( item( itype_test_plate ), pocket_type::CONTAINER ).success() ); THEN( "vest with plates should retain the same coverage" ) { CHECK( vest.get_coverage( body_part_torso ) == 92 ); @@ -281,8 +298,8 @@ TEST_CASE( "vest_with_plate_coverage", "[coverage]" ) TEST_CASE( "Off_Limb_Ghost_ablative_vest", "[coverage]" ) { SECTION( "Ablative not covered seperate limb" ) { - item full = item( "test_ghost_vest" ); - full.force_insert_item( item( "test_plate_skirt_super" ), pocket_type::CONTAINER ); + item full = item( itype_test_ghost_vest ); + full.force_insert_item( item( itype_test_plate_skirt_super ), pocket_type::CONTAINER ); standard_npc dude( "TestCharacter", dude_pos, {}, 0, 8, 8, 8, 8 ); dude.wear_item( full, false ); diff --git a/tests/crafting_test.cpp b/tests/crafting_test.cpp index de598b0f437fa..c390b0f8b931b 100644 --- a/tests/crafting_test.cpp +++ b/tests/crafting_test.cpp @@ -51,21 +51,66 @@ static const flag_id json_flag_USE_UPS( "USE_UPS" ); static const furn_str_id furn_f_smoking_rack( "f_smoking_rack" ); +static const itype_id itype_2x4( "2x4" ); +static const itype_id itype_amplifier( "amplifier" ); static const itype_id itype_awl_bone( "awl_bone" ); +static const itype_id itype_backpack( "backpack" ); +static const itype_id itype_battery_ups( "battery_ups" ); +static const itype_id itype_blade( "blade" ); +static const itype_id itype_bottle_glass( "bottle_glass" ); +static const itype_id itype_bottle_plastic( "bottle_plastic" ); +static const itype_id itype_brewing_cookbook( "brewing_cookbook" ); +static const itype_id itype_cable( "cable" ); static const itype_id itype_candle( "candle" ); static const itype_id itype_cash_card( "cash_card" ); static const itype_id itype_charcoal( "charcoal" ); +static const itype_id itype_cheese( "cheese" ); static const itype_id itype_chisel( "chisel" ); +static const itype_id itype_craft( "craft" ); +static const itype_id itype_debug_backpack( "debug_backpack" ); +static const itype_id itype_dehydrator( "dehydrator" ); +static const itype_id itype_eink_tablet_pc( "eink_tablet_pc" ); static const itype_id itype_fake_anvil( "fake_anvil" ); static const itype_id itype_hacksaw( "hacksaw" ); static const itype_id itype_hammer( "hammer" ); +static const itype_id itype_heavy_atomic_battery_cell( "heavy_atomic_battery_cell" ); +static const itype_id itype_hotplate( "hotplate" ); +static const itype_id itype_jar_glass_sealed( "jar_glass_sealed" ); static const itype_id itype_kevlar_shears( "kevlar_shears" ); +static const itype_id itype_knife_huge( "knife_huge" ); +static const itype_id itype_knife_small( "knife_small" ); +static const itype_id itype_light_bulb( "light_bulb" ); +static const itype_id itype_macaroni_raw( "macaroni_raw" ); +static const itype_id itype_manual_electronics( "manual_electronics" ); +static const itype_id itype_manual_tailor( "manual_tailor" ); +static const itype_id itype_meat( "meat" ); +static const itype_id itype_motor_micro( "motor_micro" ); +static const itype_id itype_plastic_chunk( "plastic_chunk" ); static const itype_id itype_pockknife( "pockknife" ); +static const itype_id itype_polycarbonate_sheet( "polycarbonate_sheet" ); +static const itype_id itype_popcan_stove( "popcan_stove" ); +static const itype_id itype_pot( "pot" ); +static const itype_id itype_pot_canning( "pot_canning" ); +static const itype_id itype_power_supply( "power_supply" ); +static const itype_id itype_razor_blade( "razor_blade" ); +static const itype_id itype_razor_shaving( "razor_shaving" ); +static const itype_id itype_scissors( "scissors" ); +static const itype_id itype_scrap( "scrap" ); +static const itype_id itype_screwdriver( "screwdriver" ); static const itype_id itype_sewing_kit( "sewing_kit" ); static const itype_id itype_sheet_cotton( "sheet_cotton" ); +static const itype_id itype_solder_wire( "solder_wire" ); +static const itype_id itype_soldering_iron( "soldering_iron" ); +static const itype_id itype_soldering_iron_portable( "soldering_iron_portable" ); +static const itype_id itype_survivor_mess_kit( "survivor_mess_kit" ); static const itype_id itype_test_cracklins( "test_cracklins" ); static const itype_id itype_test_gum( "test_gum" ); +static const itype_id itype_test_storage_battery( "test_storage_battery" ); +static const itype_id itype_test_ups( "test_ups" ); static const itype_id itype_thread( "thread" ); +static const itype_id itype_UPS_ON( "UPS_ON" ); +static const itype_id itype_UPS_off( "UPS_off" ); +static const itype_id itype_vac_mold( "vac_mold" ); static const itype_id itype_water( "water" ); static const itype_id itype_water_clean( "water_clean" ); static const itype_id itype_water_faucet( "water_faucet" ); @@ -256,8 +301,8 @@ TEST_CASE( "available_recipes", "[recipes]" ) } GIVEN( "an appropriate book" ) { - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); - item_location craftbook = dummy.i_add( item( "manual_electronics" ) ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); + item_location craftbook = dummy.i_add( item( itype_manual_electronics ) ); REQUIRE( craftbook->is_book() ); REQUIRE_FALSE( craftbook->type->book->recipes.empty() ); REQUIRE_FALSE( dummy.knows_recipe( r ) ); @@ -297,8 +342,8 @@ TEST_CASE( "available_recipes", "[recipes]" ) GIVEN( "an eink pc with a sushi recipe" ) { const recipe *r2 = &recipe_id( recipe_sushi_rice ).obj(); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); - item_location eink = dummy.i_add( item( "eink_tablet_pc" ) ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); + item_location eink = dummy.i_add( item( itype_eink_tablet_pc ) ); eink->set_var( "EIPC_RECIPES", ",sushi_rice," ); REQUIRE_FALSE( dummy.knows_recipe( r2 ) ); @@ -365,7 +410,7 @@ TEST_CASE( "crafting_with_a_companion", "[.]" ) } } AND_WHEN( "he has the cookbook in his inventory" ) { - item_location cookbook = who.i_add( item( "brewing_cookbook" ) ); + item_location cookbook = who.i_add( item( itype_brewing_cookbook ) ); REQUIRE( cookbook->is_book() ); REQUIRE_FALSE( cookbook->type->book->recipes.empty() ); @@ -386,7 +431,7 @@ static void give_tools( const std::vector &tools, const bool plug_in ) player_character.calc_encumbrance(); player_character.inv->clear(); player_character.remove_weapon(); - const item backpack( "debug_backpack" ); + const item backpack( itype_debug_backpack ); player_character.worn.wear_item( player_character, backpack, false, false ); std::vector boil; @@ -452,7 +497,7 @@ static void prep_craft( const recipe_id &rid, const std::vector &tools, } const tripoint_bub_ms battery_pos = test_origin + tripoint::north; - std::optional battery_item( "test_storage_battery" ); + std::optional battery_item( itype_test_storage_battery ); place_appliance( battery_pos, vpart_ap_test_storage_battery, player_character, battery_item ); give_tools( tools, plug_in_tools ); @@ -545,7 +590,7 @@ static int test_craft_for_prof( const recipe_id &rid, const proficiency_id &prof // Test gaining proficiency by repeatedly crafting short recipe TEST_CASE( "proficiency_gain_short_crafts", "[crafting][proficiency]" ) { - std::vector tools = { item( "2x4" ) }; + std::vector tools = { item( itype_2x4 ) }; const recipe_id &rec = recipe_cudgel_simple; prep_craft( rec, tools, true ); @@ -580,7 +625,7 @@ TEST_CASE( "proficiency_gain_short_crafts", "[crafting][proficiency]" ) // Test gaining proficiency all at once after finishing 5% of a very long recipe TEST_CASE( "proficiency_gain_long_craft", "[crafting][proficiency]" ) { - std::vector tools = { item( "2x4" ) }; + std::vector tools = { item( itype_2x4 ) }; const recipe_id &rec = recipe_cudgel_slow; prep_craft( rec, tools, true ); avatar &ch = get_avatar(); @@ -765,8 +810,8 @@ TEST_CASE( "UPS_shows_as_a_crafting_component", "[crafting][ups]" ) { avatar dummy; clear_character( dummy ); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); - item_location ups = dummy.i_add( item( "UPS_ON" ) ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); + item_location ups = dummy.i_add( item( itype_UPS_ON ) ); item ups_mag( ups->magazine_default() ); ups_mag.ammo_set( ups_mag.ammo_default(), 259 ); ret_val result = ups->put_in( ups_mag, pocket_type::MAGAZINE_WELL ); @@ -786,9 +831,9 @@ TEST_CASE( "UPS_modded_tools", "[crafting][ups]" ) clear_map(); clear_character( dummy ); tripoint_bub_ms const test_loc = dummy.pos_bub(); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); - item ups = GENERATE( item( "UPS_ON" ), item( "test_ups" ) ); + item ups = GENERATE( item( itype_UPS_ON ), item( itype_test_ups ) ); CAPTURE( ups.typeId() ); item_location ups_loc; if( ups_on_ground ) { @@ -805,8 +850,8 @@ TEST_CASE( "UPS_modded_tools", "[crafting][ups]" ) ret_val result = ups_loc->put_in( ups_mag, pocket_type::MAGAZINE_WELL ); REQUIRE( result.success() ); - item_location soldering_iron = dummy.i_add( item( "soldering_iron" ) ); - item battery_ups( "battery_ups" ); + item_location soldering_iron = dummy.i_add( item( itype_soldering_iron ) ); + item battery_ups( itype_battery_ups ); ret_val ret_solder = soldering_iron->put_in( battery_ups, pocket_type::MOD ); REQUIRE( ret_solder.success() ); REQUIRE( soldering_iron->has_flag( json_flag_USE_UPS ) ); @@ -836,29 +881,29 @@ TEST_CASE( "tools_use_charge_to_craft", "[crafting][charge]" ) // Learned from advanced_electronics or textbook_electronics // Tools needed: - tools.emplace_back( "screwdriver" ); - tools.emplace_back( "vac_mold" ); + tools.emplace_back( itype_screwdriver ); + tools.emplace_back( itype_vac_mold ); // Materials needed - tools.insert( tools.end(), 10, item( "solder_wire" ) ); - tools.insert( tools.end(), 6, item( "plastic_chunk" ) ); - tools.insert( tools.end(), 2, item( "blade" ) ); - tools.insert( tools.end(), 5, item( "cable" ) ); - tools.insert( tools.end(), 4, item( "polycarbonate_sheet" ) ); - tools.insert( tools.end(), 1, item( "knife_small" ) ); - tools.emplace_back( "motor_micro" ); - tools.emplace_back( "power_supply" ); - tools.emplace_back( "scrap" ); + tools.insert( tools.end(), 10, item( itype_solder_wire ) ); + tools.insert( tools.end(), 6, item( itype_plastic_chunk ) ); + tools.insert( tools.end(), 2, item( itype_blade ) ); + tools.insert( tools.end(), 5, item( itype_cable ) ); + tools.insert( tools.end(), 4, item( itype_polycarbonate_sheet ) ); + tools.insert( tools.end(), 1, item( itype_knife_small ) ); + tools.emplace_back( itype_motor_micro ); + tools.emplace_back( itype_power_supply ); + tools.emplace_back( itype_scrap ); // Charges needed to craft: // - 10 charges of soldering iron // - 20 charges of surface heat WHEN( "each tool has enough charges" ) { - item popcan_stove = tool_with_ammo( "popcan_stove", 60 ); + item popcan_stove = tool_with_ammo( itype_popcan_stove, 60 ); REQUIRE( popcan_stove.ammo_remaining() == 60 ); tools.push_back( popcan_stove ); - item soldering = tool_with_ammo( "soldering_iron_portable", 16 ); + item soldering = tool_with_ammo( itype_soldering_iron_portable, 16 ); REQUIRE( soldering.ammo_remaining() == 16 ); tools.push_back( soldering ); @@ -866,36 +911,36 @@ TEST_CASE( "tools_use_charge_to_craft", "[crafting][charge]" ) prep_craft( recipe_carver_off, tools, true, 0, false, true ); int turns = actually_test_craft( recipe_carver_off, INT_MAX ); CAPTURE( turns ); - CHECK( get_remaining_charges( "popcan_stove" ) == 0 ); - CHECK( get_remaining_charges( "soldering_iron_portable" ) == 6 ); + CHECK( get_remaining_charges( itype_popcan_stove ) == 0 ); + CHECK( get_remaining_charges( itype_soldering_iron_portable ) == 6 ); } } WHEN( "multiple tools have enough combined charges" ) { - tools.insert( tools.end(), 2, tool_with_ammo( "popcan_stove", 30 ) ); - tools.insert( tools.end(), 2, tool_with_ammo( "soldering_iron_portable", 5 ) ); + tools.insert( tools.end(), 2, tool_with_ammo( itype_popcan_stove, 30 ) ); + tools.insert( tools.end(), 2, tool_with_ammo( itype_soldering_iron_portable, 5 ) ); THEN( "crafting succeeds, and uses charges from multiple tools" ) { prep_craft( recipe_carver_off, tools, true, 0, false, true ); actually_test_craft( recipe_carver_off, INT_MAX ); - CHECK( get_remaining_charges( "popcan_stove" ) == 0 ); - CHECK( get_remaining_charges( "soldering_iron_portable" ) == 0 ); + CHECK( get_remaining_charges( itype_popcan_stove ) == 0 ); + CHECK( get_remaining_charges( itype_soldering_iron_portable ) == 0 ); } } WHEN( "UPS-modded tools have enough charges" ) { - item hotplate( "hotplate" ); - hotplate.put_in( item( "battery_ups" ), pocket_type::MOD ); + item hotplate( itype_hotplate ); + hotplate.put_in( item( itype_battery_ups ), pocket_type::MOD ); tools.push_back( hotplate ); - item soldering_iron_portable( "soldering_iron_portable" ); - soldering_iron_portable.put_in( item( "battery_ups" ), pocket_type::MOD ); + item soldering_iron_portable( itype_soldering_iron_portable ); + soldering_iron_portable.put_in( item( itype_battery_ups ), pocket_type::MOD ); tools.push_back( soldering_iron_portable ); - item plastic_molding = item( "vac_mold" ); - plastic_molding.put_in( item( "battery_ups" ), pocket_type::MOD ); + item plastic_molding = item( itype_vac_mold ); + plastic_molding.put_in( item( itype_battery_ups ), pocket_type::MOD ); tools.push_back( plastic_molding ); - item UPS( "UPS_off" ); - item UPS_mag( "heavy_atomic_battery_cell" ); + item UPS( itype_UPS_off ); + item UPS_mag( itype_heavy_atomic_battery_cell ); UPS_mag.ammo_set( UPS_mag.ammo_default(), 1000 ); UPS.put_in( UPS_mag, pocket_type::MAGAZINE_WELL ); tools.emplace_back( UPS ); @@ -904,25 +949,25 @@ TEST_CASE( "tools_use_charge_to_craft", "[crafting][charge]" ) prep_craft( recipe_carver_off, tools, true, 0, false, false ); // this recipe should be replaced with a test recipe that isn't impacted by changes in game recipes actually_test_craft( recipe_carver_off, INT_MAX ); - CHECK( get_remaining_charges( "hotplate" ) == 0 ); - CHECK( get_remaining_charges( "soldering_iron_portable" ) == 0 ); + CHECK( get_remaining_charges( itype_hotplate ) == 0 ); + CHECK( get_remaining_charges( itype_soldering_iron_portable ) == 0 ); // vacuum molding takes 4 charges - CHECK( get_remaining_charges( "UPS_off" ) == 282 ); + CHECK( get_remaining_charges( itype_UPS_off ) == 282 ); } } WHEN( "UPS-modded tools do not have enough charges" ) { - item hotplate( "hotplate" ); - hotplate.put_in( item( "battery_ups" ), pocket_type::MOD ); + item hotplate( itype_hotplate ); + hotplate.put_in( item( itype_battery_ups ), pocket_type::MOD ); tools.push_back( hotplate ); - item soldering_iron_portable( "soldering_iron_portable" ); - soldering_iron_portable.put_in( item( "battery_ups" ), pocket_type::MOD ); + item soldering_iron_portable( itype_soldering_iron_portable ); + soldering_iron_portable.put_in( item( itype_battery_ups ), pocket_type::MOD ); tools.push_back( soldering_iron_portable ); - item plastic_molding = item( "vac_mold" ); - plastic_molding.put_in( item( "battery_ups" ), pocket_type::MOD ); + item plastic_molding = item( itype_vac_mold ); + plastic_molding.put_in( item( itype_battery_ups ), pocket_type::MOD ); tools.push_back( plastic_molding ); - item ups( "UPS_off" ); + item ups( itype_UPS_off ); item ups_mag( ups.magazine_default() ); ups_mag.ammo_set( ups_mag.ammo_default(), 10 ); ups.put_in( ups_mag, pocket_type::MAGAZINE_WELL ); @@ -930,7 +975,7 @@ TEST_CASE( "tools_use_charge_to_craft", "[crafting][charge]" ) THEN( "crafting fails, and no charges are used" ) { prep_craft( recipe_carver_off, tools, false, 0, false, false ); - CHECK( get_remaining_charges( "UPS_off" ) == 10 ); + CHECK( get_remaining_charges( itype_UPS_off ) == 10 ); } } } @@ -940,51 +985,51 @@ TEST_CASE( "tool_use", "[crafting][tool]" ) { SECTION( "clean_water" ) { std::vector tools; - tools.push_back( tool_with_ammo( "popcan_stove", 500 ) ); - item plastic_bottle( "bottle_plastic" ); + tools.push_back( tool_with_ammo( itype_popcan_stove, 500 ) ); + item plastic_bottle( itype_bottle_plastic ); plastic_bottle.put_in( - item( "water", calendar::turn_zero, 2 ), pocket_type::CONTAINER ); + item( itype_water, calendar::turn_zero, 2 ), pocket_type::CONTAINER ); tools.push_back( plastic_bottle ); - tools.emplace_back( "pot" ); + tools.emplace_back( itype_pot ); // Can't actually test crafting here since crafting a liquid currently causes a ui prompt prep_craft( recipe_water_clean, tools, true ); } SECTION( "clean_water_in_loaded_survivor_mess_kit" ) { std::vector tools; - tools.push_back( tool_with_ammo( "popcan_stove", 500 ) ); - item plastic_bottle( "bottle_plastic" ); + tools.push_back( tool_with_ammo( itype_popcan_stove, 500 ) ); + item plastic_bottle( itype_bottle_plastic ); plastic_bottle.put_in( - item( "water", calendar::turn_zero, 2 ), pocket_type::CONTAINER ); + item( itype_water, calendar::turn_zero, 2 ), pocket_type::CONTAINER ); tools.push_back( plastic_bottle ); - tools.push_back( tool_with_ammo( "survivor_mess_kit", 500 ) ); + tools.push_back( tool_with_ammo( itype_survivor_mess_kit, 500 ) ); // Can't actually test crafting here since crafting a liquid currently causes a ui prompt prep_craft( recipe_water_clean, tools, true ); } SECTION( "clean_water_in_occupied_cooking_vessel" ) { std::vector tools; - tools.push_back( tool_with_ammo( "popcan_stove", 500 ) ); - item plastic_bottle( "bottle_plastic" ); + tools.push_back( tool_with_ammo( itype_popcan_stove, 500 ) ); + item plastic_bottle( itype_bottle_plastic ); plastic_bottle.put_in( - item( "water", calendar::turn_zero, 2 ), pocket_type::CONTAINER ); + item( itype_water, calendar::turn_zero, 2 ), pocket_type::CONTAINER ); tools.push_back( plastic_bottle ); - item jar( "jar_glass_sealed" ); + item jar( itype_jar_glass_sealed ); // If it's not watertight the water will spill. REQUIRE( jar.is_watertight_container() ); - jar.put_in( item( "water", calendar::turn_zero, 2 ), pocket_type::CONTAINER ); + jar.put_in( item( itype_water, calendar::turn_zero, 2 ), pocket_type::CONTAINER ); tools.push_back( jar ); prep_craft( recipe_water_clean, tools, false ); } SECTION( "clean_water with broken tool" ) { std::vector tools; - tools.push_back( tool_with_ammo( "popcan_stove", 500 ) ); - item plastic_bottle( "bottle_plastic" ); + tools.push_back( tool_with_ammo( itype_popcan_stove, 500 ) ); + item plastic_bottle( itype_bottle_plastic ); plastic_bottle.put_in( - item( "water", calendar::turn_zero, 2 ), pocket_type::CONTAINER ); + item( itype_water, calendar::turn_zero, 2 ), pocket_type::CONTAINER ); tools.push_back( plastic_bottle ); - tools.emplace_back( "pot" ); + tools.emplace_back( itype_pot ); tools.front().set_flag( json_flag_ITEM_BROKEN ); REQUIRE( tools.front().is_broken() ); @@ -999,10 +1044,10 @@ TEST_CASE( "broken_component", "[crafting][component]" ) recipe_id test_recipe( "flashlight" ); std::vector tools; - tools.emplace_back( "amplifier" ); - tools.emplace_back( "bottle_glass" ); - tools.emplace_back( "light_bulb" ); - tools.insert( tools.end(), 10, item( "cable" ) ); + tools.emplace_back( itype_amplifier ); + tools.emplace_back( itype_bottle_glass ); + tools.emplace_back( itype_light_bulb ); + tools.insert( tools.end(), 10, item( itype_cable ) ); WHEN( "one of its components is broken" ) { tools.front().set_flag( json_flag_ITEM_BROKEN ); @@ -1043,8 +1088,8 @@ static int resume_craft() return turns; } -static void verify_inventory( const std::vector &has, - const std::vector &hasnt ) +static void verify_inventory( const std::vector &has, + const std::vector &hasnt ) { std::ostringstream os; os << "Inventory:\n"; @@ -1054,18 +1099,18 @@ static void verify_inventory( const std::vector &has, } os << "Wielded:\n" << player_character.get_wielded_item()->tname() << "\n"; INFO( os.str() ); - for( const std::string &i : has ) { - INFO( "expecting " << i ); + for( const itype_id &i : has ) { + INFO( "expecting " << i.c_str() ); const bool has_item = player_has_item_of_type( i ) || - player_character.get_wielded_item()->type->get_id() == itype_id( i ); + player_character.get_wielded_item()->typeId() == i; REQUIRE( has_item ); } - for( const std::string &i : hasnt ) { - INFO( "not expecting " << i ); + for( const itype_id &i : hasnt ) { + INFO( "not expecting " << i.c_str() ); const bool hasnt_item = !player_has_item_of_type( i ) && - !( player_character.get_wielded_item()->type->get_id() == itype_id( i ) ); + !( player_character.get_wielded_item()->typeId() == i ); REQUIRE( hasnt_item ); } } @@ -1078,15 +1123,15 @@ TEST_CASE( "total_crafting_time_with_or_without_interruption", "[crafting][time] int expected_turns_taken = divide_round_up( expected_time_taken, 100 ); std::vector tools; - tools.emplace_back( "pockknife" ); + tools.emplace_back( itype_pockknife ); // Will interrupt after 2 turns, so craft needs to take at least that long REQUIRE( expected_turns_taken > 2 ); int actual_turns_taken; WHEN( "crafting begins, and continues until the craft is completed" ) { - tools.emplace_back( "razor_blade", calendar::turn_zero, 1 ); - tools.emplace_back( "plastic_chunk", calendar::turn_zero, 1 ); + tools.emplace_back( itype_razor_blade, calendar::turn_zero, 1 ); + tools.emplace_back( itype_plastic_chunk, calendar::turn_zero, 1 ); prep_craft( test_recipe, tools, true ); actual_turns_taken = actually_test_craft( test_recipe, INT_MAX ); @@ -1094,20 +1139,20 @@ TEST_CASE( "total_crafting_time_with_or_without_interruption", "[crafting][time] CHECK( actual_turns_taken == expected_turns_taken ); AND_THEN( "the finished item should be in the inventory" ) { - verify_inventory( { "razor_shaving" }, { "razor_blade" } ); + verify_inventory( { itype_razor_shaving }, { itype_razor_blade } ); } } } WHEN( "crafting begins, but is interrupted after 2 turns" ) { - tools.emplace_back( "razor_blade", calendar::turn_zero, 1 ); - tools.emplace_back( "plastic_chunk", calendar::turn_zero, 1 ); + tools.emplace_back( itype_razor_blade, calendar::turn_zero, 1 ); + tools.emplace_back( itype_plastic_chunk, calendar::turn_zero, 1 ); prep_craft( test_recipe, tools, true ); actual_turns_taken = actually_test_craft( test_recipe, 2 ); REQUIRE( actual_turns_taken == 3 ); THEN( "the in-progress craft should be in the inventory" ) { - verify_inventory( { "craft" }, { "razor_shaving" } ); + verify_inventory( { itype_craft }, { itype_razor_shaving } ); AND_WHEN( "crafting resumes until the craft is finished" ) { actual_turns_taken = resume_craft(); @@ -1116,7 +1161,7 @@ TEST_CASE( "total_crafting_time_with_or_without_interruption", "[crafting][time] CHECK( actual_turns_taken == expected_turns_taken - 2 ); AND_THEN( "the finished item should be in the inventory" ) { - verify_inventory( { "razor_shaving" }, { "craft" } ); + verify_inventory( { itype_razor_shaving }, { itype_craft } ); } } } @@ -1158,7 +1203,7 @@ static void test_skill_progression( const recipe_id &test_recipe, int expected_t const requirement_data &req = r.simple_requirements(); for( const std::vector &tool_list : req.get_tools() ) { for( const tool_comp &tool : tool_list ) { - tools.push_back( tool_with_ammo( tool.type.str(), tool.count ) ); + tools.push_back( tool_with_ammo( tool.type, tool.count ) ); break; } } @@ -1365,7 +1410,7 @@ TEST_CASE( "book_proficiency_mitigation", "[crafting][proficiency]" ) WHEN( "player has a book mitigating lack of proficiency" ) { std::vector books; - books.emplace_back( "manual_tailor" ); + books.emplace_back( itype_manual_tailor ); give_tools( books, true ); get_player_character().invalidate_crafting_inventory(); int mitigated_time_taken = test_recipe.batch_time( get_player_character(), 1, 1, 0 ); @@ -1426,11 +1471,11 @@ TEST_CASE( "prompt_for_liquid_containers_-_crafting_1_makeshift_funnel", "[craft { map &m = get_map(); item pocketknife( itype_pockknife ); - const item backpack( "debug_backpack" ); + const item backpack( itype_debug_backpack ); GIVEN( "crafting 1 makeshift funnel" ) { WHEN( "3 empty plastic bottles on the ground" ) { - item plastic_bottle( "bottle_plastic" ); + item plastic_bottle( itype_bottle_plastic ); REQUIRE( plastic_bottle.is_watertight_container() ); REQUIRE( plastic_bottle.empty_container() ); Character &c = get_player_character(); @@ -1454,7 +1499,7 @@ TEST_CASE( "prompt_for_liquid_containers_-_crafting_1_makeshift_funnel", "[craft } WHEN( "3 empty plastic bottles in inventory" ) { - item plastic_bottle( "bottle_plastic" ); + item plastic_bottle( itype_bottle_plastic ); REQUIRE( plastic_bottle.is_watertight_container() ); REQUIRE( plastic_bottle.empty_container() ); Character &c = get_player_character(); @@ -1475,8 +1520,8 @@ TEST_CASE( "prompt_for_liquid_containers_-_crafting_1_makeshift_funnel", "[craft } WHEN( "3 full plastic bottles on the ground" ) { - item plastic_bottle( "bottle_plastic" ); - plastic_bottle.put_in( item( "water", calendar::turn_zero, 2 ), + item plastic_bottle( itype_bottle_plastic ); + plastic_bottle.put_in( item( itype_water, calendar::turn_zero, 2 ), pocket_type::CONTAINER ); REQUIRE( plastic_bottle.is_watertight_container() ); REQUIRE( !plastic_bottle.empty_container() ); @@ -1503,8 +1548,8 @@ TEST_CASE( "prompt_for_liquid_containers_-_crafting_1_makeshift_funnel", "[craft } WHEN( "3 full plastic bottles in inventory" ) { - item plastic_bottle( "bottle_plastic" ); - plastic_bottle.put_in( item( "water", calendar::turn_zero, 2 ), + item plastic_bottle( itype_bottle_plastic ); + plastic_bottle.put_in( item( itype_water, calendar::turn_zero, 2 ), pocket_type::CONTAINER ); REQUIRE( plastic_bottle.is_watertight_container() ); REQUIRE( !plastic_bottle.empty_container() ); @@ -1527,9 +1572,9 @@ TEST_CASE( "prompt_for_liquid_containers_-_crafting_1_makeshift_funnel", "[craft } WHEN( "3 empty and 3 full plastic bottles on the ground" ) { - item empty_plastic_bottle( "bottle_plastic" ); - item full_plastic_bottle( "bottle_plastic" ); - full_plastic_bottle.put_in( item( "water", calendar::turn_zero, 2 ), + item empty_plastic_bottle( itype_bottle_plastic ); + item full_plastic_bottle( itype_bottle_plastic ); + full_plastic_bottle.put_in( item( itype_water, calendar::turn_zero, 2 ), pocket_type::CONTAINER ); REQUIRE( empty_plastic_bottle.is_watertight_container() ); REQUIRE( empty_plastic_bottle.empty_container() ); @@ -1551,9 +1596,9 @@ TEST_CASE( "prompt_for_liquid_containers_-_crafting_1_makeshift_funnel", "[craft } WHEN( "3 empty and 3 full plastic bottles in inventory" ) { - item empty_plastic_bottle( "bottle_plastic" ); - item full_plastic_bottle( "bottle_plastic" ); - full_plastic_bottle.put_in( item( "water", calendar::turn_zero, 2 ), + item empty_plastic_bottle( itype_bottle_plastic ); + item full_plastic_bottle( itype_bottle_plastic ); + full_plastic_bottle.put_in( item( itype_water, calendar::turn_zero, 2 ), pocket_type::CONTAINER ); REQUIRE( empty_plastic_bottle.is_watertight_container() ); REQUIRE( empty_plastic_bottle.empty_container() ); @@ -1582,9 +1627,9 @@ TEST_CASE( "prompt_for_liquid_containers_-_crafting_1_makeshift_funnel", "[craft } WHEN( "2 empty and 3 full plastic bottles on the ground" ) { - item empty_plastic_bottle( "bottle_plastic" ); - item full_plastic_bottle( "bottle_plastic" ); - full_plastic_bottle.put_in( item( "water", calendar::turn_zero, 2 ), + item empty_plastic_bottle( itype_bottle_plastic ); + item full_plastic_bottle( itype_bottle_plastic ); + full_plastic_bottle.put_in( item( itype_water, calendar::turn_zero, 2 ), pocket_type::CONTAINER ); REQUIRE( empty_plastic_bottle.is_watertight_container() ); REQUIRE( empty_plastic_bottle.empty_container() ); @@ -1606,9 +1651,9 @@ TEST_CASE( "prompt_for_liquid_containers_-_crafting_1_makeshift_funnel", "[craft } WHEN( "2 empty and 3 full plastic bottles in inventory" ) { - item empty_plastic_bottle( "bottle_plastic" ); - item full_plastic_bottle( "bottle_plastic" ); - full_plastic_bottle.put_in( item( "water", calendar::turn_zero, 2 ), + item empty_plastic_bottle( itype_bottle_plastic ); + item full_plastic_bottle( itype_bottle_plastic ); + full_plastic_bottle.put_in( item( itype_water, calendar::turn_zero, 2 ), pocket_type::CONTAINER ); REQUIRE( empty_plastic_bottle.is_watertight_container() ); REQUIRE( empty_plastic_bottle.empty_container() ); @@ -1641,11 +1686,11 @@ TEST_CASE( "prompt_for_liquid_containers_-_batch_crafting_3_makeshift_funnels", { map &m = get_map(); item pocketknife( itype_pockknife ); - const item backpack( "debug_backpack" ); + const item backpack( itype_debug_backpack ); GIVEN( "crafting batch of 3 makeshift funnels" ) { WHEN( "10 empty plastic bottles on the ground" ) { - item plastic_bottle( "bottle_plastic" ); + item plastic_bottle( itype_bottle_plastic ); REQUIRE( plastic_bottle.is_watertight_container() ); REQUIRE( plastic_bottle.empty_container() ); Character &c = get_player_character(); @@ -1662,7 +1707,7 @@ TEST_CASE( "prompt_for_liquid_containers_-_batch_crafting_3_makeshift_funnels", } WHEN( "10 empty plastic bottles in inventory" ) { - item plastic_bottle( "bottle_plastic" ); + item plastic_bottle( itype_bottle_plastic ); REQUIRE( plastic_bottle.is_watertight_container() ); REQUIRE( plastic_bottle.empty_container() ); Character &c = get_player_character(); @@ -1690,8 +1735,8 @@ TEST_CASE( "prompt_for_liquid_containers_-_batch_crafting_3_makeshift_funnels", } WHEN( "10 full plastic bottles on the ground" ) { - item plastic_bottle( "bottle_plastic" ); - plastic_bottle.put_in( item( "water", calendar::turn_zero, 2 ), + item plastic_bottle( itype_bottle_plastic ); + plastic_bottle.put_in( item( itype_water, calendar::turn_zero, 2 ), pocket_type::CONTAINER ); REQUIRE( plastic_bottle.is_watertight_container() ); REQUIRE( !plastic_bottle.empty_container() ); @@ -1711,8 +1756,8 @@ TEST_CASE( "prompt_for_liquid_containers_-_batch_crafting_3_makeshift_funnels", } WHEN( "10 full plastic bottles in inventory" ) { - item plastic_bottle( "bottle_plastic" ); - plastic_bottle.put_in( item( "water", calendar::turn_zero, 2 ), + item plastic_bottle( itype_bottle_plastic ); + plastic_bottle.put_in( item( itype_water, calendar::turn_zero, 2 ), pocket_type::CONTAINER ); REQUIRE( plastic_bottle.is_watertight_container() ); REQUIRE( !plastic_bottle.empty_container() ); @@ -1742,9 +1787,9 @@ TEST_CASE( "prompt_for_liquid_containers_-_batch_crafting_3_makeshift_funnels", } WHEN( "10 empty and 3 full plastic bottles on the ground" ) { - item empty_plastic_bottle( "bottle_plastic" ); - item full_plastic_bottle( "bottle_plastic" ); - full_plastic_bottle.put_in( item( "water", calendar::turn_zero, 2 ), + item empty_plastic_bottle( itype_bottle_plastic ); + item full_plastic_bottle( itype_bottle_plastic ); + full_plastic_bottle.put_in( item( itype_water, calendar::turn_zero, 2 ), pocket_type::CONTAINER ); REQUIRE( empty_plastic_bottle.is_watertight_container() ); REQUIRE( empty_plastic_bottle.empty_container() ); @@ -1766,9 +1811,9 @@ TEST_CASE( "prompt_for_liquid_containers_-_batch_crafting_3_makeshift_funnels", } WHEN( "10 empty and 3 full plastic bottles in inventory" ) { - item empty_plastic_bottle( "bottle_plastic" ); - item full_plastic_bottle( "bottle_plastic" ); - full_plastic_bottle.put_in( item( "water", calendar::turn_zero, 2 ), + item empty_plastic_bottle( itype_bottle_plastic ); + item full_plastic_bottle( itype_bottle_plastic ); + full_plastic_bottle.put_in( item( itype_water, calendar::turn_zero, 2 ), pocket_type::CONTAINER ); REQUIRE( empty_plastic_bottle.is_watertight_container() ); REQUIRE( empty_plastic_bottle.empty_container() ); @@ -1804,9 +1849,9 @@ TEST_CASE( "prompt_for_liquid_containers_-_batch_crafting_3_makeshift_funnels", } WHEN( "7 empty and 3 full plastic bottles on the ground" ) { - item empty_plastic_bottle( "bottle_plastic" ); - item full_plastic_bottle( "bottle_plastic" ); - full_plastic_bottle.put_in( item( "water", calendar::turn_zero, 2 ), + item empty_plastic_bottle( itype_bottle_plastic ); + item full_plastic_bottle( itype_bottle_plastic ); + full_plastic_bottle.put_in( item( itype_water, calendar::turn_zero, 2 ), pocket_type::CONTAINER ); REQUIRE( empty_plastic_bottle.is_watertight_container() ); REQUIRE( empty_plastic_bottle.empty_container() ); @@ -1828,9 +1873,9 @@ TEST_CASE( "prompt_for_liquid_containers_-_batch_crafting_3_makeshift_funnels", } WHEN( "7 empty and 3 full plastic bottles in inventory" ) { - item empty_plastic_bottle( "bottle_plastic" ); - item full_plastic_bottle( "bottle_plastic" ); - full_plastic_bottle.put_in( item( "water", calendar::turn_zero, 2 ), + item empty_plastic_bottle( itype_bottle_plastic ); + item full_plastic_bottle( itype_bottle_plastic ); + full_plastic_bottle.put_in( item( itype_water, calendar::turn_zero, 2 ), pocket_type::CONTAINER ); REQUIRE( empty_plastic_bottle.is_watertight_container() ); REQUIRE( empty_plastic_bottle.empty_container() ); @@ -1892,7 +1937,7 @@ TEST_CASE( "Warn_when_using_favorited_component", "[crafting]" ) GIVEN( "crafting 1 makeshift funnel" ) { WHEN( "no favorited components" ) { - item plastic_bottle( "bottle_plastic" ); + item plastic_bottle( itype_bottle_plastic ); Character &c = get_player_character(); clear_and_setup( c, m, pocketknife ); REQUIRE( m.i_at( c.pos_bub() ).empty() ); @@ -1906,7 +1951,7 @@ TEST_CASE( "Warn_when_using_favorited_component", "[crafting]" ) } } WHEN( "all favorited components" ) { - item plastic_bottle( "bottle_plastic" ); + item plastic_bottle( itype_bottle_plastic ); plastic_bottle.is_favorite = true; Character &c = get_player_character(); clear_and_setup( c, m, pocketknife ); @@ -1921,7 +1966,7 @@ TEST_CASE( "Warn_when_using_favorited_component", "[crafting]" ) } } WHEN( "1 favorited component" ) { - item plastic_bottle( "bottle_plastic" ); + item plastic_bottle( itype_bottle_plastic ); Character &c = get_player_character(); clear_and_setup( c, m, pocketknife ); REQUIRE( m.i_at( c.pos_bub() ).empty() ); @@ -1936,7 +1981,7 @@ TEST_CASE( "Warn_when_using_favorited_component", "[crafting]" ) } } WHEN( "1 favorited component, extra non-favorited components" ) { - item plastic_bottle( "bottle_plastic" ); + item plastic_bottle( itype_bottle_plastic ); Character &c = get_player_character(); clear_and_setup( c, m, pocketknife ); REQUIRE( m.i_at( c.pos_bub() ).empty() ); @@ -2064,8 +2109,8 @@ TEST_CASE( "tools_with_charges_as_components", "[crafting]" ) Character &c = get_player_character(); item pocketknife( itype_pockknife ); item sew_kit( itype_sewing_kit ); - item thread( "thread" ); - item sheet_cotton( "sheet_cotton" ); + item thread( itype_thread ); + item sheet_cotton( itype_sheet_cotton ); thread.charges = 100; sew_kit.put_in( thread, pocket_type::MAGAZINE ); REQUIRE( sew_kit.ammo_remaining() == 100 ); @@ -2108,7 +2153,7 @@ TEST_CASE( "tools_with_charges_as_components", "[crafting]" ) } GIVEN( "sewing kit with thread in inventory" ) { - const item backpack( "debug_backpack" ); + const item backpack( itype_debug_backpack ); item_location pack_loc( c, & **c.wear_item( backpack, false ) ); REQUIRE( !!pack_loc.get_item() ); REQUIRE( pack_loc->is_container_empty() ); @@ -2154,23 +2199,23 @@ TEST_CASE( "recipes_inherit_rot_of_components_properly", "[crafting][rot]" ) { Character &player_character = get_player_character(); std::vector tools; - tools.insert( tools.end(), 10, tool_with_ammo( "popcan_stove", 500 ) ); - tools.insert( tools.end(), 10, tool_with_ammo( "dehydrator", 500 ) ); - tools.emplace_back( "pot_canning" ); - tools.emplace_back( "knife_huge" ); + tools.insert( tools.end(), 10, tool_with_ammo( itype_popcan_stove, 500 ) ); + tools.insert( tools.end(), 10, tool_with_ammo( itype_dehydrator, 500 ) ); + tools.emplace_back( itype_pot_canning ); + tools.emplace_back( itype_knife_huge ); GIVEN( "1 hour until rotten macaroni and fresh cheese" ) { - item macaroni( "macaroni_raw" ); - item cheese( "cheese" ); - item water_clean( "water_clean" ); + item macaroni( itype_macaroni_raw ); + item cheese( itype_cheese ); + item water_clean( itype_water_clean ); macaroni.set_rot( macaroni.get_shelf_life() - 1_hours ); REQUIRE( cheese.get_shelf_life() - cheese.get_rot() > 1_hours ); tools.insert( tools.end(), 1, macaroni ); tools.insert( tools.end(), 1, cheese ); - item &bottle = tools.emplace_back( "bottle_plastic" ); // water container + item &bottle = tools.emplace_back( itype_bottle_plastic ); // water container bottle.get_contents().insert_item( item( itype_water_clean ), pocket_type::CONTAINER ); WHEN( "crafting the mac and cheese" ) { @@ -2188,16 +2233,16 @@ TEST_CASE( "recipes_inherit_rot_of_components_properly", "[crafting][rot]" ) } GIVEN( "fresh macaroni and fresh cheese" ) { - item macaroni( "macaroni_raw" ); - item cheese( "cheese" ); - item water_clean( "water_clean" ); + item macaroni( itype_macaroni_raw ); + item cheese( itype_cheese ); + item water_clean( itype_water_clean ); REQUIRE( macaroni.get_rot() == 0_turns ); REQUIRE( cheese.get_rot() == 0_turns ); tools.insert( tools.end(), 1, macaroni ); tools.insert( tools.end(), 1, cheese ); - item &bottle = tools.emplace_back( "bottle_plastic" ); // water container + item &bottle = tools.emplace_back( itype_bottle_plastic ); // water container bottle.get_contents().insert_item( item( itype_water_clean ), pocket_type::CONTAINER ); WHEN( "crafting the mac and cheese" ) { @@ -2215,7 +2260,7 @@ TEST_CASE( "recipes_inherit_rot_of_components_properly", "[crafting][rot]" ) } GIVEN( "meat with 1 percent of its shelf life left" ) { - item meat( "meat" ); + item meat( itype_meat ); meat.set_relative_rot( 0.01 ); @@ -2246,9 +2291,9 @@ TEST_CASE( "variant_crafting_recipes", "[crafting][slow]" ) for( int i = 0; i < max_iters; i++ ) { std::vector tools; tools.emplace_back( itype_sewing_kit ); - tools.emplace_back( "scissors" ); - tools.insert( tools.end(), 10, item( "sheet_cotton" ) ); - tools.insert( tools.end(), 10, item( "thread" ) ); + tools.emplace_back( itype_scissors ); + tools.insert( tools.end(), 10, item( itype_sheet_cotton ) ); + tools.insert( tools.end(), 10, item( itype_thread ) ); const recipe_id apron_recipe = recipe_test_waist_apron_long; prep_craft( apron_recipe, tools, true ); actually_test_craft( apron_recipe, INT_MAX, 10 ); @@ -2275,9 +2320,9 @@ TEST_CASE( "variant_crafting_recipes", "[crafting][slow]" ) for( int i = 0; i < max_iters; i++ ) { std::vector tools; tools.emplace_back( itype_sewing_kit ); - tools.emplace_back( "scissors" ); - tools.insert( tools.end(), 10, item( "sheet_cotton" ) ); - tools.insert( tools.end(), 10, item( "thread" ) ); + tools.emplace_back( itype_scissors ); + tools.insert( tools.end(), 10, item( itype_sheet_cotton ) ); + tools.insert( tools.end(), 10, item( itype_thread ) ); const recipe_id apron_recipe = recipe_test_xl_waist_apron_long_pink_apron_cotton; prep_craft( apron_recipe, tools, true ); actually_test_craft( apron_recipe, INT_MAX, 10 ); diff --git a/tests/effect_test.cpp b/tests/effect_test.cpp index 656fcc6b1ede2..0987d6b7c844d 100644 --- a/tests/effect_test.cpp +++ b/tests/effect_test.cpp @@ -34,6 +34,8 @@ static const efftype_id effect_test_fatalism( "test_fatalism" ); static const efftype_id effect_test_int_remove( "test_int_remove" ); static const efftype_id effect_test_vitamineff( "test_vitamineff" ); +static const itype_id itype_test_vitfood( "test_vitfood" ); + static const mtype_id pseudo_debug_mon( "pseudo_debug_mon" ); static const vitamin_id vitamin_test_vitv( "test_vitv" ); @@ -692,7 +694,7 @@ TEST_CASE( "Vitamin_Effects", "[effect][vitamins]" ) subject.add_effect( vitamin_effect ); // A food rich in in vitamin x - we need 2 of them, for with/without the effect - item food1( "test_vitfood" ); + item food1( itype_test_vitfood ); item food2( food1 ); // Make sure they have none of these vitamins at the start diff --git a/tests/effective_dps_test.cpp b/tests/effective_dps_test.cpp index 924835bf5d19e..5e112bb343dbd 100644 --- a/tests/effective_dps_test.cpp +++ b/tests/effective_dps_test.cpp @@ -15,6 +15,10 @@ #include "test_data.h" #include "type_id.h" +static const itype_id itype_test_balanced_sword( "test_balanced_sword" ); +static const itype_id itype_test_clumsy_sword( "test_clumsy_sword" ); +static const itype_id itype_test_normal_sword( "test_normal_sword" ); + static const mtype_id mon_zombie_smoker( "mon_zombie_smoker" ); static const mtype_id mon_zombie_soldier_no_weakpoints( "mon_zombie_soldier_no_weakpoints" ); static const mtype_id mon_zombie_survivor_no_weakpoints( "mon_zombie_survivor_no_weakpoints" ); @@ -118,9 +122,9 @@ TEST_CASE( "effective_damage_per_second", "[effective][dps]" ) avatar &dummy = get_avatar(); clear_character( dummy ); - item clumsy_sword( "test_clumsy_sword" ); - item normal_sword( "test_normal_sword" ); - item good_sword( "test_balanced_sword" ); + item clumsy_sword( itype_test_clumsy_sword ); + item normal_sword( itype_test_normal_sword ); + item good_sword( itype_test_balanced_sword ); SECTION( "against a debug monster with no armor or dodge" ) { monster mummy( pseudo_debug_mon ); @@ -185,9 +189,9 @@ TEST_CASE( "effective_vs_actual_damage_per_second", "[actual][dps][!mayfail]" ) monster smoker( mon_zombie_smoker ); monster survivor( mon_zombie_survivor_no_weakpoints ); - item clumsy_sword( "test_clumsy_sword" ); - item normal_sword( "test_normal_sword" ); - item good_sword( "test_balanced_sword" ); + item clumsy_sword( itype_test_clumsy_sword ); + item normal_sword( itype_test_normal_sword ); + item good_sword( itype_test_balanced_sword ); SECTION( "soldier zombie" ) { check_actual_dps( dummy, soldier, clumsy_sword ); @@ -217,9 +221,9 @@ TEST_CASE( "accuracy_increases_success", "[accuracy][dps]" ) monster smoker( mon_zombie_smoker ); monster survivor( mon_zombie_survivor_no_weakpoints ); - item clumsy_sword( "test_clumsy_sword" ); - item normal_sword( "test_normal_sword" ); - item good_sword( "test_balanced_sword" ); + item clumsy_sword( itype_test_clumsy_sword ); + item normal_sword( itype_test_normal_sword ); + item good_sword( itype_test_balanced_sword ); SECTION( "soldier zombie" ) { check_accuracy_dps( dummy, soldier, clumsy_sword, normal_sword, good_sword ); diff --git a/tests/enchantments_test.cpp b/tests/enchantments_test.cpp index 2e74b1a2af9b9..4017065e73d78 100644 --- a/tests/enchantments_test.cpp +++ b/tests/enchantments_test.cpp @@ -22,6 +22,25 @@ static const efftype_id effect_blind( "blind" ); static const efftype_id effect_debug_no_staggered( "debug_no_staggered" ); static const efftype_id effect_invisibility( "invisibility" ); +static const itype_id itype_debug_backpack( "debug_backpack" ); +static const itype_id itype_test_ATTACK_SPEED_ench_item( "test_ATTACK_SPEED_ench_item" ); +static const itype_id itype_test_ATTACK_SPEED_ench_item_2( "test_ATTACK_SPEED_ench_item_2" ); +static const itype_id itype_test_BONUS_DODGE_ench_item_1( "test_BONUS_DODGE_ench_item_1" ); +static const itype_id itype_test_BONUS_DODGE_ench_item_2( "test_BONUS_DODGE_ench_item_2" ); +static const itype_id +itype_test_MELEE_STAMINA_CONSUMPTION_ench_item_0( "test_MELEE_STAMINA_CONSUMPTION_ench_item_0" ); +static const itype_id +itype_test_MELEE_STAMINA_CONSUMPTION_ench_item_1( "test_MELEE_STAMINA_CONSUMPTION_ench_item_1" ); +static const itype_id +itype_test_MELEE_STAMINA_CONSUMPTION_ench_item_2( "test_MELEE_STAMINA_CONSUMPTION_ench_item_2" ); +static const itype_id itype_test_MELEE_TO_HIT_ench_item_1( "test_MELEE_TO_HIT_ench_item_1" ); +static const itype_id itype_test_MELEE_TO_HIT_ench_item_2( "test_MELEE_TO_HIT_ench_item_2" ); +static const itype_id +itype_test_PAIN_PENALTY_MOD_ench_item_1( "test_PAIN_PENALTY_MOD_ench_item_1" ); +static const itype_id itype_test_SPEED_ench_item( "test_SPEED_ench_item" ); +static const itype_id itype_test_STAT_ench_item_1( "test_STAT_ench_item_1" ); +static const itype_id itype_test_ring_strength_1( "test_ring_strength_1" ); + static const mtype_id pseudo_debug_mon( "pseudo_debug_mon" ); static const skill_id skill_melee( "melee" ); @@ -89,7 +108,7 @@ TEST_CASE( "worn_enchantments", "[enchantments][worn][items]" ) int str_before = p.get_str(); // put on the ring - item_location equipped_ring_strplus_one = p.i_add( item( "test_ring_strength_1" ) ); + item_location equipped_ring_strplus_one = p.i_add( item( itype_test_ring_strength_1 ) ); p.wear( equipped_ring_strplus_one, false ); // wait a turn for the effect to kick in @@ -136,7 +155,7 @@ TEST_CASE( "Enchantments_change_stats", "[magic][enchantments]" ) clear_avatar(); INFO( "Default character with 8 8 8 8 stats" ); INFO( "When obtain item with stat enchantments" ); - guy.i_add( item( "test_STAT_ench_item_1" ) ); + guy.i_add( item( itype_test_STAT_ench_item_1 ) ); guy.recalculate_enchantment_cache(); advance_turn( guy ); INFO( "Stats change accordingly" ); @@ -156,9 +175,9 @@ TEST_CASE( "Enchantments_change_stats", "[magic][enchantments]" ) INFO( "Default character with 8 8 8 8 stats" ); INFO( "When obtain two items with stat enchantments" ); - item backpack( "debug_backpack" ); + item backpack( itype_debug_backpack ); guy.wear_item( backpack ); - item enchantment_item( "test_STAT_ench_item_1" ); + item enchantment_item( itype_test_STAT_ench_item_1 ); guy.i_add( enchantment_item ); guy.i_add( enchantment_item ); guy.recalculate_enchantment_cache(); @@ -184,7 +203,7 @@ TEST_CASE( "Enchantment_SPEED_test", "[magic][enchantments]" ) INFO( "Character obtain speed enchantment" ); - guy.i_add( item( "test_SPEED_ench_item" ) ); + guy.i_add( item( itype_test_SPEED_ench_item ) ); guy.recalculate_enchantment_cache(); guy.set_moves( 0 ); advance_turn( guy ); @@ -247,7 +266,7 @@ TEST_CASE( "Enchantment_ATTACK_SPEED_test", "[magic][enchantments]" ) INFO( "Character, melee skill lvl 10, attacks with enchantment, that halves attack speed cost" ); - guy.i_add( item( "test_ATTACK_SPEED_ench_item" ) ); + guy.i_add( item( itype_test_ATTACK_SPEED_ench_item ) ); // 25 moves per attack INFO( "10 attacks cost only 250 moves" ); moves_spent_on_attacks = test_melee_attack_attack_speed( guy, mon ); @@ -256,7 +275,7 @@ TEST_CASE( "Enchantment_ATTACK_SPEED_test", "[magic][enchantments]" ) INFO( "Character attacks with enchantment, that adds 62 moves to each attack" ); - guy.i_add( item( "test_ATTACK_SPEED_ench_item_2" ) ); + guy.i_add( item( itype_test_ATTACK_SPEED_ench_item_2 ) ); // 100 moves per attack INFO( "10 attacks cost 1000 moves" ); moves_spent_on_attacks = test_melee_attack_attack_speed( guy, mon ); @@ -301,7 +320,7 @@ TEST_CASE( "Enchantment_MELEE_STAMINA_CONSUMPTION_test", "[magic][enchantments]" INFO( "Character attacks with no enchantment" ); // item weight 2 kilo and has 2 L of volume - guy.i_add( item( "test_MELEE_STAMINA_CONSUMPTION_ench_item_0" ) ); + guy.i_add( item( itype_test_MELEE_STAMINA_CONSUMPTION_ench_item_0 ) ); // 165 stamina per attack INFO( "10 attacks cost 1650 stamina" ); stamina_init = guy.get_stamina(); @@ -312,7 +331,7 @@ TEST_CASE( "Enchantment_MELEE_STAMINA_CONSUMPTION_test", "[magic][enchantments]" INFO( "Character attacks with enchantment, that decreases stamina cost for 100" ); - guy.i_add( item( "test_MELEE_STAMINA_CONSUMPTION_ench_item_1" ) ); + guy.i_add( item( itype_test_MELEE_STAMINA_CONSUMPTION_ench_item_1 ) ); // 65 stamina per attack INFO( "10 attacks cost 650 stamina" ); stamina_init = guy.get_stamina(); @@ -323,7 +342,7 @@ TEST_CASE( "Enchantment_MELEE_STAMINA_CONSUMPTION_test", "[magic][enchantments]" INFO( "Character attacks with enchantment, that double stamina cost" ); - guy.i_add( item( "test_MELEE_STAMINA_CONSUMPTION_ench_item_2" ) ); + guy.i_add( item( itype_test_MELEE_STAMINA_CONSUMPTION_ench_item_2 ) ); // 330 stamina per attack INFO( "10 attacks cost 3300 stamina" ); stamina_init = guy.get_stamina(); @@ -367,14 +386,14 @@ TEST_CASE( "Enchantment_MELEE_TO_HIT_test", "[magic][enchantments]" ) double hit_rate = 0; INFO( "Character attacks with +100 to hit enchantment" ); - guy.i_add( item( "test_MELEE_TO_HIT_ench_item_1" ) ); + guy.i_add( item( itype_test_MELEE_TO_HIT_ench_item_1 ) ); hit_rate = test_melee_attack_hit_rate( guy, mon ); REQUIRE( hit_rate >= 0.8 ); clear_avatar(); INFO( "Character attacks with -100 to hit enchantment" ); - guy.i_add( item( "test_MELEE_TO_HIT_ench_item_2" ) ); + guy.i_add( item( itype_test_MELEE_TO_HIT_ench_item_2 ) ); hit_rate = test_melee_attack_hit_rate( guy, mon ); REQUIRE( hit_rate <= 0.2 ); clear_avatar(); @@ -392,7 +411,7 @@ TEST_CASE( "Enchantment_BONUS_DODGE_test", "[magic][enchantments]" ) INFO( "Character has enchantment that gives +3 dodges" ); - guy.i_add( item( "test_BONUS_DODGE_ench_item_1" ) ); + guy.i_add( item( itype_test_BONUS_DODGE_ench_item_1 ) ); guy.recalculate_enchantment_cache(); advance_turn( guy ); INFO( "4 dodges" ); @@ -401,7 +420,7 @@ TEST_CASE( "Enchantment_BONUS_DODGE_test", "[magic][enchantments]" ) clear_avatar(); INFO( "Character has enchantment that gives +4 dodges, and then halves amount of dodges" ); - guy.i_add( item( "test_BONUS_DODGE_ench_item_2" ) ); + guy.i_add( item( itype_test_BONUS_DODGE_ench_item_2 ) ); guy.recalculate_enchantment_cache(); advance_turn( guy ); INFO( "2.5 dodges, rounded down to 2" ); @@ -425,7 +444,7 @@ TEST_CASE( "Enchantment_PAIN_PENALTY_MOD_test", "[magic][enchantments]" ) INFO( "Character has 50 pain, obtain enchantment" ); - guy.i_add( item( "test_PAIN_PENALTY_MOD_ench_item_1" ) ); + guy.i_add( item( itype_test_PAIN_PENALTY_MOD_ench_item_1 ) ); guy.recalculate_enchantment_cache(); advance_turn( guy ); INFO( "Stats are: 4 str, 7 dex, 7 int, 1 per, 89 speed" ); diff --git a/tests/encumbrance_test.cpp b/tests/encumbrance_test.cpp index 0cf3a9c110ba5..046e21706e748 100644 --- a/tests/encumbrance_test.cpp +++ b/tests/encumbrance_test.cpp @@ -13,6 +13,17 @@ static const flag_id json_flag_UNDERSIZE( "UNDERSIZE" ); +static const itype_id itype_test_ballistic_vest( "test_ballistic_vest" ); +static const itype_id itype_test_complex_phase( "test_complex_phase" ); +static const itype_id itype_test_ghost_vest( "test_ghost_vest" ); +static const itype_id itype_holster( "holster" ); +static const itype_id itype_test_jacket_jean( "test_jacket_jean" ); +static const itype_id itype_test_load_bearing_vest( "test_load_bearing_vest" ); +static const itype_id itype_test_longshirt( "test_longshirt" ); +static const itype_id itype_test_plate( "test_plate" ); +static const itype_id itype_test_plate_skirt( "test_plate_skirt" ); +static const itype_id itype_test_postman_shirt( "test_postman_shirt" ); + static void test_encumbrance_on( Character &p, const std::vector &clothing, @@ -58,7 +69,7 @@ static void test_encumbrance_items( } static void test_encumbrance( - const std::vector &clothing_types, + const std::vector &clothing_types, const std::string &body_part, const int expected_encumbrance ) @@ -66,7 +77,7 @@ static void test_encumbrance( CAPTURE( clothing_types ); std::vector clothing; clothing.reserve( clothing_types.size() ); - for( const std::string &type : clothing_types ) { + for( const itype_id &type : clothing_types ) { clothing.emplace_back( type ); } test_encumbrance_items( clothing, body_part, expected_encumbrance ); @@ -93,54 +104,56 @@ static constexpr int complex_phase = 10; TEST_CASE( "regular_clothing_encumbrance", "[encumbrance]" ) { - test_encumbrance( { "test_postman_shirt" }, "torso", postman_shirt_e ); - test_encumbrance( { "test_longshirt" }, "torso", longshirt_e ); - test_encumbrance( { "test_jacket_jean" }, "torso", jacket_jean_e ); - test_encumbrance( { "test_ballistic_vest" }, "torso", ballistic ); - test_encumbrance( { "test_load_bearing_vest" }, "torso", load_bearing ); + test_encumbrance( { itype_test_postman_shirt }, "torso", postman_shirt_e ); + test_encumbrance( { itype_test_longshirt }, "torso", longshirt_e ); + test_encumbrance( { itype_test_jacket_jean }, "torso", jacket_jean_e ); + test_encumbrance( { itype_test_ballistic_vest }, "torso", ballistic ); + test_encumbrance( { itype_test_load_bearing_vest }, "torso", load_bearing ); } TEST_CASE( "plate_encumbrance", "[encumbrance]" ) { - item with_plates( "test_ballistic_vest" ); - with_plates.force_insert_item( item( "test_plate" ), pocket_type::CONTAINER ); + item with_plates( itype_test_ballistic_vest ); + with_plates.force_insert_item( item( itype_test_plate ), pocket_type::CONTAINER ); test_encumbrance_items( { with_plates }, "torso", ballistic + plate ); } TEST_CASE( "off_limb_ablative_encumbrance", "[encumbrance]" ) { - item with_plates( "test_ghost_vest" ); - with_plates.force_insert_item( item( "test_plate_skirt" ), pocket_type::CONTAINER ); + item with_plates( itype_test_ghost_vest ); + with_plates.force_insert_item( item( itype_test_plate_skirt ), pocket_type::CONTAINER ); test_encumbrance_items( { with_plates }, "leg_l", plate ); } TEST_CASE( "separate_layer_encumbrance", "[encumbrance]" ) { - test_encumbrance( { "test_longshirt", "test_jacket_jean" }, "torso", longshirt_e + jacket_jean_e ); - test_encumbrance( { "test_longshirt", "test_ballistic_vest" }, "torso", longshirt_e + ballistic ); - test_encumbrance( { "test_longshirt", "test_load_bearing_vest" }, "torso", + test_encumbrance( { itype_test_longshirt, itype_test_jacket_jean }, "torso", + longshirt_e + jacket_jean_e ); + test_encumbrance( { itype_test_longshirt, itype_test_ballistic_vest }, "torso", + longshirt_e + ballistic ); + test_encumbrance( { itype_test_longshirt, itype_test_load_bearing_vest }, "torso", longshirt_e + load_bearing ); } TEST_CASE( "Complicated_with_split_layers_no_conflict", "[encumbrance]" ) { - test_encumbrance( { "test_complex_phase", "test_ballistic_vest" }, "torso", + test_encumbrance( { itype_test_complex_phase, itype_test_ballistic_vest }, "torso", ballistic + complex_phase ); } // make sure ordering still works with pockets TEST_CASE( "additional_pockets_encumbrance", "[encumbrance]" ) { - item addition_vest( "test_load_bearing_vest" ); - item undershirt( "test_longshirt" ); - addition_vest.get_contents().add_pocket( item( "holster" ) ); + item addition_vest( itype_test_load_bearing_vest ); + item undershirt( itype_test_longshirt ); + addition_vest.get_contents().add_pocket( item( itype_holster ) ); test_encumbrance_items( { undershirt, addition_vest }, "torso", longshirt_e + load_bearing ); } TEST_CASE( "out_of_order_encumbrance", "[encumbrance]" ) { - test_encumbrance( { "test_jacket_jean", "test_longshirt" }, "torso", + test_encumbrance( { itype_test_jacket_jean, itype_test_longshirt }, "torso", longshirt_e * 2 + jacket_jean_e ); } @@ -148,24 +161,26 @@ TEST_CASE( "same_layer_encumbrance", "[encumbrance]" ) { // When stacking within a layer, encumbrance for additional items is // counted twice - test_encumbrance( { "test_longshirt", "test_longshirt" }, "torso", longshirt_e * 2 + longshirt_e ); + test_encumbrance( { itype_test_longshirt, itype_test_longshirt }, "torso", + longshirt_e * 2 + longshirt_e ); // ... with a minimum of 2 - test_encumbrance( { "test_postman_shirt", "test_postman_shirt" }, "torso", + test_encumbrance( { itype_test_postman_shirt, itype_test_postman_shirt }, "torso", postman_shirt_e * 2 + 2 ); // ... and a maximum of 10 - test_encumbrance( { "test_jacket_jean", "test_jacket_jean" }, "torso", jacket_jean_e * 2 + 10 ); + test_encumbrance( { itype_test_jacket_jean, itype_test_jacket_jean }, "torso", + jacket_jean_e * 2 + 10 ); } TEST_CASE( "tiny_clothing", "[encumbrance]" ) { - item i( "test_longshirt" ); + item i( itype_test_longshirt ); i.set_flag( json_flag_UNDERSIZE ); test_encumbrance_items( { i }, "torso", longshirt_e * 3 ); } TEST_CASE( "tiny_character", "[encumbrance]" ) { - item i( "test_longshirt" ); + item i( itype_test_longshirt ); SECTION( "regular shirt" ) { test_encumbrance_items( { i }, "torso", longshirt_e * 2, add_trait( "SMALL2" ) ); } diff --git a/tests/eoc_test.cpp b/tests/eoc_test.cpp index de792544c5468..d89bce8877599 100644 --- a/tests/eoc_test.cpp +++ b/tests/eoc_test.cpp @@ -142,7 +142,10 @@ static const furn_str_id furn_f_cardboard_box( "f_cardboard_box" ); static const furn_str_id furn_test_f_eoc( "test_f_eoc" ); static const itype_id itype_backpack( "backpack" ); +static const itype_id itype_hammer( "hammer" ); +static const itype_id itype_shotgun_s( "shotgun_s" ); static const itype_id itype_sword_wood( "sword_wood" ); +static const itype_id itype_test_eoc_armor_suit( "test_eoc_armor_suit" ); static const itype_id itype_test_glock( "test_glock" ); static const itype_id itype_test_knife_combat( "test_knife_combat" ); @@ -490,7 +493,7 @@ TEST_CASE( "EOC_math_armor", "[eoc][math_parser]" ) clear_avatar(); clear_map(); avatar &a = get_avatar(); - a.worn.wear_item( a, item( "test_eoc_armor_suit" ), false, true, true ); + a.worn.wear_item( a, item( itype_test_eoc_armor_suit ), false, true, true ); dialogue d( get_talker_for( get_avatar() ), std::make_unique() ); global_variables &globvars = get_globals(); @@ -757,7 +760,7 @@ TEST_CASE( "dialogue_copy", "[eoc]" ) CHECK( d_copy.actor( false )->get_character() != nullptr ); CHECK( d_copy.actor( true )->get_character() != nullptr ); - item hammer( "hammer" ) ; + item hammer( itype_hammer ); item_location hloc( map_cursor( tripoint_bub_ms::zero ), &hammer ); computer comp( "test_computer", 0, tripoint_bub_ms::zero ); dialogue d2( get_talker_for( hloc ), get_talker_for( comp ) ); @@ -781,7 +784,7 @@ TEST_CASE( "EOC_meta_test", "[eoc]" ) standard_npc dude; monster zombie( mon_zombie ); - item hammer( "hammer" ) ; + item hammer( itype_hammer ); item_location hloc( map_cursor( tripoint_bub_ms::zero ), &hammer ); computer comp( "test_computer", 0, tripoint_bub_ms::zero ); @@ -1232,7 +1235,7 @@ TEST_CASE( "EOC_combat_event_test", "[eoc]" ) clear_map(); npc &npc_dst_ranged = spawn_npc( target_pos.xy(), "thug" ); for( loop = 0; loop < 1000; loop++ ) { - arm_shooter( get_avatar(), "shotgun_s" ); + arm_shooter( get_avatar(), itype_shotgun_s ); get_avatar().recoil = 0; get_avatar().fire_gun( target_pos, 1, *get_avatar().get_wielded_item() ); if( !npc_dst_ranged.get_value( "test_event_last_event" ).empty() ) { @@ -1251,7 +1254,7 @@ TEST_CASE( "EOC_combat_event_test", "[eoc]" ) clear_map(); monster &mon_dst_ranged = spawn_test_monster( "mon_zombie", target_pos ); for( loop = 0; loop < 1000; loop++ ) { - arm_shooter( get_avatar(), "shotgun_s" ); + arm_shooter( get_avatar(), itype_shotgun_s ); get_avatar().recoil = 0; get_avatar().fire_gun( mon_dst_ranged.pos_bub(), 1, *get_avatar().get_wielded_item() ); if( !mon_dst_ranged.get_value( "test_event_last_event" ).empty() ) { @@ -1511,7 +1514,7 @@ TEST_CASE( "EOC_run_eocs", "[eoc]" ) monster *zombie = g->place_critter_at( mon_zombie, get_map().bub_from_abs( mon_loc ) ); REQUIRE( zombie != nullptr ); - item hammer( "hammer" ); + item hammer( itype_hammer ); item_location hammer_loc( map_cursor{ guy.get_location() }, &hammer ); dialogue d2( get_talker_for( guy ), get_talker_for( hammer_loc ) ); talker *alpha_talker = d2.actor( false ); diff --git a/tests/explosion_balance_test.cpp b/tests/explosion_balance_test.cpp index c47daac875234..d01c82defe9d1 100644 --- a/tests/explosion_balance_test.cpp +++ b/tests/explosion_balance_test.cpp @@ -32,6 +32,8 @@ static const ammo_effect_str_id ammo_effect_NULL_SOURCE( "NULL_SOURCE" ); static const damage_type_id damage_bullet( "bullet" ); +static const itype_id itype_grenade_act( "grenade_act" ); + enum class outcome_type { Kill, Casualty }; @@ -66,7 +68,7 @@ static float get_damage_vs_target( const std::string &target_id ) return static_cast( damage_taken ) / static_cast( damaging_hits ); } -static void check_lethality( const std::string &explosive_id, const int range, float lethality, +static void check_lethality( const itype_id &explosive_id, const int range, float lethality, float margin, outcome_type expected_outcome ) { const epsilon_threshold target_lethality{ lethality, margin }; @@ -135,7 +137,7 @@ static void check_lethality( const std::string &explosive_id, const int range, f } } while( victims.uncertain_about( target_lethality ) ); CAPTURE( margin ); - INFO( explosive_id ); + INFO( explosive_id.c_str() ); item grenade( explosive_id ); const explosion_data &ex = dynamic_cast ( grenade.type->countdown_action.get_actor_ptr() )->explosion; @@ -173,7 +175,7 @@ static std::vector get_part_hp( vehicle *veh ) return part_hp; } -static void check_vehicle_damage( const std::string &explosive_id, const std::string &vehicle_id, +static void check_vehicle_damage( const itype_id &explosive_id, const std::string &vehicle_id, const int range, const double damage_lower_bound, const double damage_upper_bound = 1.0 ) { // Clear map @@ -236,9 +238,9 @@ TEST_CASE( "grenade_lethality_scaling_with_size", "[grenade],[explosion],[balanc TEST_CASE( "grenade_lethality", "[grenade],[explosion],[balance],[slow]" ) { - check_lethality( "grenade_act", 0, 0.99, 0.06, outcome_type::Kill ); - check_lethality( "grenade_act", 5, 0.95, 0.06, outcome_type::Kill ); - check_lethality( "grenade_act", 15, 0.40, 0.06, outcome_type::Casualty ); + check_lethality( itype_grenade_act, 0, 0.99, 0.06, outcome_type::Kill ); + check_lethality( itype_grenade_act, 5, 0.95, 0.06, outcome_type::Kill ); + check_lethality( itype_grenade_act, 15, 0.40, 0.06, outcome_type::Casualty ); } TEST_CASE( "grenade_vs_vehicle", "[grenade],[explosion],[balance]" ) @@ -258,9 +260,9 @@ TEST_CASE( "grenade_vs_vehicle", "[grenade],[explosion],[balance]" ) * heavy duty frames. */ for( size_t i = 0; i <= 20 ; ++i ) { - check_vehicle_damage( "grenade_act", "car", 5, 0.998 ); - check_vehicle_damage( "grenade_act", "motorcycle", 5, 0.997 ); - check_vehicle_damage( "grenade_act", "motorcycle", 0, 0.975, 0.9985 ); - check_vehicle_damage( "grenade_act", "humvee", 5, 1 ); + check_vehicle_damage( itype_grenade_act, "car", 5, 0.998 ); + check_vehicle_damage( itype_grenade_act, "motorcycle", 5, 0.997 ); + check_vehicle_damage( itype_grenade_act, "motorcycle", 0, 0.975, 0.9985 ); + check_vehicle_damage( itype_grenade_act, "humvee", 5, 1 ); } } diff --git a/tests/faction_camp_test.cpp b/tests/faction_camp_test.cpp index 5ab4bf3265bdc..e99e04b2292bf 100644 --- a/tests/faction_camp_test.cpp +++ b/tests/faction_camp_test.cpp @@ -14,6 +14,10 @@ #include "overmapbuffer.h" #include "player_helpers.h" +static const itype_id itype_test_100_kcal( "test_100_kcal" ); +static const itype_id itype_test_200_kcal( "test_200_kcal" ); +static const itype_id itype_test_500_kcal( "test_500_kcal" ); + static const vitamin_id vitamin_mutagen( "mutagen" ); static const vitamin_id vitamin_mutant_toxin( "mutant_toxin" ); @@ -39,7 +43,7 @@ TEST_CASE( "camp_calorie_counting", "[camp]" ) nutrients &food_supply = camp_faction->food_supply; WHEN( "a base item is added to larder" ) { food_supply *= 0; - item test_100_kcal( "test_100_kcal" ); + item test_100_kcal( itype_test_100_kcal ); tripoint_bub_ms zone_local = m.bub_from_abs( zone_loc ); m.i_clear( zone_local ); m.add_item_or_charges( zone_local, test_100_kcal ); @@ -50,8 +54,8 @@ TEST_CASE( "camp_calorie_counting", "[camp]" ) WHEN( "an item with inherited components is added to larder" ) { food_supply *= 0; - item test_100_kcal( "test_100_kcal" ); - item test_200_kcal( "test_200_kcal" ); + item test_100_kcal( itype_test_100_kcal ); + item test_200_kcal( itype_test_200_kcal ); item_components made_of; made_of.add( test_100_kcal ); made_of.add( test_100_kcal ); @@ -66,7 +70,7 @@ TEST_CASE( "camp_calorie_counting", "[camp]" ) WHEN( "an item with vitamins is added to larder" ) { food_supply *= 0; - item test_500_kcal( "test_500_kcal" ); + item test_500_kcal( itype_test_500_kcal ); tripoint_bub_ms zone_local = m.bub_from_abs( zone_loc ); m.i_clear( zone_local ); m.add_item_or_charges( zone_local, test_500_kcal ); diff --git a/tests/faction_price_rules_test.cpp b/tests/faction_price_rules_test.cpp index a4df3be5b9f3f..b931b8566f859 100644 --- a/tests/faction_price_rules_test.cpp +++ b/tests/faction_price_rules_test.cpp @@ -6,6 +6,19 @@ #include "npctrade.h" #include "player_helpers.h" +static const itype_id itype_FMCNote( "FMCNote" ); +static const itype_id itype_battery( "battery" ); +static const itype_id itype_debug_backpack( "debug_backpack" ); +static const itype_id itype_debug_modular_m4_carbine( "debug_modular_m4_carbine" ); +static const itype_id itype_hammer( "hammer" ); +static const itype_id itype_log( "log" ); +static const itype_id itype_scrap( "scrap" ); +static const itype_id itype_test_battery_disposable( "test_battery_disposable" ); +static const itype_id itype_test_bomba( "test_bomba" ); +static const itype_id itype_test_multitool( "test_multitool" ); +static const itype_id itype_test_nuclear_carafe( "test_nuclear_carafe" ); +static const itype_id itype_test_pants_fur( "test_pants_fur" ); + static const skill_id skill_speech( "speech" ); TEST_CASE( "basic_price_check", "[npc][trade]" ) @@ -29,13 +42,13 @@ TEST_CASE( "basic_price_check", "[npc][trade]" ) seller = &u; } - item m4( "debug_modular_m4_carbine" ); + item m4( itype_debug_modular_m4_carbine ); item mag( m4.magazine_default() ); int const ammo_amount = mag.remaining_ammo_capacity(); item ammo( mag.ammo_default(), calendar::turn, ammo_amount ); - item bomba( "test_bomba" ); + item bomba( itype_test_bomba ); REQUIRE( bomba.type->price_post != units::from_cent( 0 ) ); - item backpack( "debug_backpack" ); + item backpack( itype_debug_backpack ); int const price_separate = adjusted_price( &m4, 1, *buyer, *seller ) + adjusted_price( &mag, 1, *buyer, *seller ) + @@ -65,7 +78,7 @@ TEST_CASE( "faction_price_rules", "[npc][factions][trade]" ) faction const &fac = *guy.my_fac; WHEN( "item has no rules (default adjustment)" ) { - item const hammer( "hammer" ); + item const hammer( itype_hammer ); clear_character( guy ); REQUIRE( npc_trading::adjusted_price( &hammer, 1, get_avatar(), guy ) == Approx( units::to_cent( hammer.type->price_post ) * 1.25 ).margin( 1 ) ); @@ -76,14 +89,14 @@ TEST_CASE( "faction_price_rules", "[npc][factions][trade]" ) WHEN( "item is main currency (implicit price rule)" ) { guy.int_max = 1000; guy.set_skill_level( skill_speech, 10 ); - item const fmcnote( "FMCNote" ); + item const fmcnote( itype_FMCNote ); REQUIRE( npc_trading::adjusted_price( &fmcnote, 1, get_avatar(), guy ) == units::to_cent( fmcnote.type->price_post ) ); REQUIRE( npc_trading::adjusted_price( &fmcnote, 1, guy, get_avatar() ) == units::to_cent( fmcnote.type->price_post ) ); } - item const pants_fur( "test_pants_fur" ); + item const pants_fur( itype_test_pants_fur ); WHEN( "item is secondary currency (fixed_adj=0)" ) { get_avatar().int_max = 1000; get_avatar().set_skill_level( skill_speech, 10 ); @@ -93,7 +106,7 @@ TEST_CASE( "faction_price_rules", "[npc][factions][trade]" ) units::to_cent( pants_fur.type->price_post ) ); } WHEN( "faction desperately needs this item (premium=25)" ) { - item const multitool( "test_multitool" ); + item const multitool( itype_test_multitool ); REQUIRE( fac.get_price_rules( multitool, guy )->premium == 25 ); REQUIRE( fac.get_price_rules( multitool, guy )->markup == 1.1 ); THEN( "NPC selling to avatar includes premium and markup" ) { @@ -106,7 +119,7 @@ TEST_CASE( "faction_price_rules", "[npc][factions][trade]" ) } } WHEN( "faction has a custom price for this item (price=10000000)" ) { - item const log = GENERATE( item( "log" ), item( "scrap" ) ); + item const log = GENERATE( item( itype_log ), item( itype_scrap ) ); clear_character( guy ); double price = *fac.get_price_rules( log, guy )->price; REQUIRE( price == 10000000 ); @@ -118,7 +131,7 @@ TEST_CASE( "faction_price_rules", "[npc][factions][trade]" ) REQUIRE( npc_trading::adjusted_price( &log, 1, guy, get_avatar() ) == Approx( price * 0.75 ).margin( 1 ) ); } - item const carafe( "test_nuclear_carafe" ); + item const carafe( itype_test_nuclear_carafe ); WHEN( "condition for price rules not satisfied" ) { clear_character( guy ); REQUIRE( fac.get_price_rules( carafe, guy ) == nullptr ); @@ -146,8 +159,8 @@ TEST_CASE( "faction_price_rules", "[npc][factions][trade]" ) } WHEN( "price rule affects magazine contents" ) { clear_character( guy ); - item const battery( "battery" ); - item tbd( "test_battery_disposable" ); + item const battery( itype_battery ); + item tbd( itype_test_battery_disposable ); int const battery_price = *guy.get_price_rules( battery )->price; REQUIRE( battery.price( true ) != battery_price ); trade_selector::entry_t tbd_entry{ diff --git a/tests/field_test.cpp b/tests/field_test.cpp index 8216c2015b40f..25c83da0a8077 100644 --- a/tests/field_test.cpp +++ b/tests/field_test.cpp @@ -23,6 +23,10 @@ static const efftype_id effect_test_rash( "test_rash" ); static const field_type_str_id field_fd_acid( "fd_acid" ); static const field_type_str_id field_fd_test( "fd_test" ); +static const itype_id itype_test_2x4( "test_2x4" ); +static const itype_id itype_test_hazmat_hat( "test_hazmat_hat" ); +static const itype_id itype_test_hazmat_shirt( "test_hazmat_shirt" ); + static const ter_str_id ter_t_open_air( "t_open_air" ); static const ter_str_id ter_t_tree_walnut( "t_tree_walnut" ); @@ -240,7 +244,7 @@ TEST_CASE( "fire_spreading", "[field][!mayfail]" ) } SECTION( "fire spreads on flammable items" ) { for( tripoint_bub_ms p0 = p; p0 != far_p + tripoint::east; p0 += tripoint::east ) { - m.add_item( p0, item( "test_2x4" ) ); + m.add_item( p0, item( itype_test_2x4 ) ); } // note: time limit here was chosen arbitrarily. It could be too low or too high. check_spreading( 30_minutes ); @@ -509,7 +513,7 @@ TEST_CASE( "player_single_effect_field_test_head", "[field][player]" ) Character &dummy = get_avatar(); map &m = get_map(); - item head_armor( "test_hazmat_hat" ); + item head_armor( itype_test_hazmat_hat ); dummy.wear_item( head_armor ); dummy.setpos( p ); @@ -533,7 +537,7 @@ TEST_CASE( "player_single_effect_field_test_torso", "[field][player]" ) Character &dummy = get_avatar(); map &m = get_map(); - item torso_armor( "test_hazmat_shirt" ); + item torso_armor( itype_test_hazmat_shirt ); dummy.wear_item( torso_armor ); dummy.setpos( p ); @@ -557,9 +561,9 @@ TEST_CASE( "player_single_effect_field_test_all", "[field][player]" ) Character &dummy = get_avatar(); map &m = get_map(); - item torso_armor( "test_hazmat_shirt" ); + item torso_armor( itype_test_hazmat_shirt ); dummy.wear_item( torso_armor ); - item head_armor( "test_hazmat_hat" ); + item head_armor( itype_test_hazmat_hat ); dummy.wear_item( head_armor ); dummy.setpos( p ); diff --git a/tests/food_fun_for_test.cpp b/tests/food_fun_for_test.cpp index 95b4c1271e8ee..69f3a7d40aeb3 100644 --- a/tests/food_fun_for_test.cpp +++ b/tests/food_fun_for_test.cpp @@ -19,6 +19,18 @@ static const bionic_id bio_taste_blocker( "bio_taste_blocker" ); static const efftype_id effect_common_cold( "common_cold" ); static const efftype_id effect_flu( "flu" ); +static const itype_id itype_catfood( "catfood" ); +static const itype_id itype_coffee( "coffee" ); +static const itype_id itype_cola( "cola" ); +static const itype_id itype_dogfood( "dogfood" ); +static const itype_id itype_garlic( "garlic" ); +static const itype_id itype_icecream( "icecream" ); +static const itype_id itype_pine_nuts( "pine_nuts" ); +static const itype_id itype_rehydration_drink( "rehydration_drink" ); +static const itype_id itype_sheet_cotton( "sheet_cotton" ); +static const itype_id itype_toastem( "toastem" ); +static const itype_id itype_toastem_test( "toastem_test" ); + static const trait_id trait_GOURMAND( "GOURMAND" ); static const trait_id trait_SAPROPHAGE( "SAPROPHAGE" ); static const trait_id trait_SAPROVORE( "SAPROVORE" ); @@ -33,7 +45,7 @@ TEST_CASE( "fun_for_non-food", "[fun_for][nonfood]" ) std::pair actual_fun; SECTION( "non-food has no fun value" ) { - item sheet_cotton( "sheet_cotton" ); + item sheet_cotton( itype_sheet_cotton ); REQUIRE_FALSE( sheet_cotton.is_comestible() ); actual_fun = dummy.fun_for( sheet_cotton ); @@ -46,7 +58,7 @@ TEST_CASE( "fun_for_food_eaten_while_sick", "[fun_for][food][sick]" ) { avatar dummy; std::pair actual_fun; - item toastem( "toastem" ); + item toastem( itype_toastem ); REQUIRE( toastem.is_comestible() ); // Base fun value for toast-em int toastem_fun = toastem.get_comestible_fun(); @@ -79,7 +91,7 @@ TEST_CASE( "fun_for_rotten_food", "[fun_for][food][rotten]" ) std::pair actual_fun; GIVEN( "some rotten food" ) { - item nuts( "pine_nuts" ); + item nuts( itype_pine_nuts ); REQUIRE( nuts.is_comestible() ); // food rot > 1.0 is rotten nuts.set_relative_rot( 1.5 ); @@ -123,7 +135,7 @@ TEST_CASE( "fun_for_cold_food", "[fun_for][food][cold]" ) std::pair actual_fun; GIVEN( "food that tastes good, but better when cold" ) { - item cola( "cola" ); + item cola( itype_cola ); REQUIRE( cola.is_comestible() ); REQUIRE( cola.has_flag( flag_EATEN_COLD ) ); int cola_fun = cola.get_comestible_fun(); @@ -148,7 +160,7 @@ TEST_CASE( "fun_for_cold_food", "[fun_for][food][cold]" ) } GIVEN( "food that tastes bad, but better when cold" ) { - item rehydration( "rehydration_drink" ); + item rehydration( itype_rehydration_drink ); REQUIRE( rehydration.is_comestible() ); int rehydration_fun = rehydration.get_comestible_fun(); @@ -176,7 +188,7 @@ TEST_CASE( "fun_for_cold_food", "[fun_for][food][cold]" ) } GIVEN( "food that tastes good, but no better when cold" ) { - item coffee( "coffee" ); + item coffee( itype_coffee ); REQUIRE( coffee.is_comestible() ); int coffee_fun = coffee.get_comestible_fun(); @@ -214,7 +226,7 @@ TEST_CASE( "fun_for_melted_food", "[fun_for][food][melted]" ) std::pair actual_fun; GIVEN( "food that is fun but melts" ) { - item icecream( "icecream" ); + item icecream( itype_icecream ); REQUIRE( icecream.is_comestible() ); REQUIRE( icecream.has_flag( flag_MELTS ) ); int icecream_fun = icecream.get_comestible_fun(); @@ -246,7 +258,7 @@ TEST_CASE( "fun_for_cat_food", "[fun_for][food][cat][feline]" ) std::pair actual_fun; GIVEN( "cat food" ) { - item catfood( "catfood" ); + item catfood( itype_catfood ); REQUIRE( catfood.is_comestible() ); REQUIRE( catfood.has_flag( flag_FELINE ) ); @@ -277,7 +289,7 @@ TEST_CASE( "fun_for_dog_food", "[fun_for][food][dog][lupine]" ) std::pair actual_fun; GIVEN( "dog food" ) { - item dogfood( "dogfood" ); + item dogfood( itype_dogfood ); REQUIRE( dogfood.is_comestible() ); REQUIRE( dogfood.has_flag( flag_LUPINE ) ); @@ -309,7 +321,7 @@ TEST_CASE( "fun_for_gourmand", "[fun_for][food][gourmand]" ) std::pair actual_fun; GIVEN( "food that tastes good" ) { - item toastem( "toastem" ); + item toastem( itype_toastem ); REQUIRE( toastem.is_comestible() ); int toastem_fun = toastem.get_comestible_fun(); REQUIRE( toastem_fun > 0 ); @@ -334,7 +346,7 @@ TEST_CASE( "fun_for_gourmand", "[fun_for][food][gourmand]" ) } GIVEN( "food that tastes bad" ) { - item garlic( "garlic" ); + item garlic( itype_garlic ); REQUIRE( garlic.is_comestible() ); int garlic_fun = garlic.get_comestible_fun(); // At fun == -1, Gourmand trait has no effect @@ -367,7 +379,7 @@ TEST_CASE( "fun_for_food_eaten_too_often", "[fun_for][food][monotony]" ) std::pair actual_fun; // A big box of tasty toast-ems - item toastem( "toastem_test", calendar::turn ); + item toastem( itype_toastem_test, calendar::turn ); REQUIRE( toastem.is_comestible() ); // Base fun value and monotony penalty for toast-em @@ -416,7 +428,7 @@ TEST_CASE( "fun_for_bionic_bio_taste_blocker", "[fun_for][food][bionic]" ) std::pair actual_fun; GIVEN( "food that tastes bad" ) { - item garlic( "garlic" ); + item garlic( itype_garlic ); REQUIRE( garlic.is_comestible() ); int garlic_fun = garlic.get_comestible_fun(); REQUIRE( garlic_fun < 0 ); diff --git a/tests/fuel_test.cpp b/tests/fuel_test.cpp index 04e2e2ee7d771..f947701631c61 100644 --- a/tests/fuel_test.cpp +++ b/tests/fuel_test.cpp @@ -1,10 +1,13 @@ #include "cata_catch.h" #include "item.h" +static const itype_id itype_battery( "battery" ); +static const itype_id itype_gasoline( "gasoline" ); + TEST_CASE( "Fuel_energy", "[energy]" ) { - item battery( "battery" ); - item gasoline( "gasoline" ); + item battery( itype_battery ); + item gasoline( itype_gasoline ); const int64_t gasoline_per_charge = units::to_millijoule( 34200_J ); const int64_t battery_per_charge = units::to_millijoule( 1_kJ ); diff --git a/tests/invlet_test.cpp b/tests/invlet_test.cpp index 57a2493c1a858..412e1d8939085 100644 --- a/tests/invlet_test.cpp +++ b/tests/invlet_test.cpp @@ -26,6 +26,9 @@ static const itype_id itype_a( "a" ); static const itype_id itype_b( "b" ); +static const itype_id itype_backpack( "backpack" ); +static const itype_id itype_jeans( "jeans" ); +static const itype_id itype_tshirt( "tshirt" ); enum inventory_location { GROUND, @@ -461,11 +464,11 @@ static void invlet_test( avatar &dummy, const inventory_location from, const inv dummy.clear_worn(); dummy.remove_weapon(); get_map().i_clear( dummy.pos_bub() ); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); // some two items that can be wielded, worn, and picked up - item tshirt( "tshirt" ); - item jeans( "jeans" ); + item tshirt( itype_tshirt ); + item jeans( itype_jeans ); set_id( tshirt, "1" ); set_id( jeans, "2" ); @@ -543,11 +546,11 @@ static void stack_invlet_test( avatar &dummy, inventory_location from, inventory dummy.clear_worn(); dummy.remove_weapon(); get_map().i_clear( dummy.pos_bub() ); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); // some stackable item that can be wielded and worn - item tshirt1( "tshirt" ); - item tshirt2( "tshirt" ); + item tshirt1( itype_tshirt ); + item tshirt2( itype_tshirt ); set_id( tshirt1, "1" ); set_id( tshirt2, "2" ); @@ -598,8 +601,8 @@ static void swap_invlet_test( avatar &dummy, inventory_location loc ) get_map().i_clear( dummy.pos_bub() ); // two items of the same type that do not stack - item tshirt1( "tshirt" ); - item tshirt2( "tshirt" ); + item tshirt1( itype_tshirt ); + item tshirt2( itype_tshirt ); tshirt2.mod_damage( -1 ); set_id( tshirt1, "1" ); @@ -681,11 +684,11 @@ static void merge_invlet_test( avatar &dummy, inventory_location from ) dummy.clear_worn(); dummy.remove_weapon(); get_map().i_clear( dummy.pos_bub() ); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); // some stackable item - item tshirt1( "tshirt" ); - item tshirt2( "tshirt" ); + item tshirt1( itype_tshirt ); + item tshirt2( itype_tshirt ); set_id( tshirt1, "1" ); set_id( tshirt2, "2" ); diff --git a/tests/item_contents_test.cpp b/tests/item_contents_test.cpp index 0b004a00eccdc..8c5970028a78d 100644 --- a/tests/item_contents_test.cpp +++ b/tests/item_contents_test.cpp @@ -13,15 +13,19 @@ #include "units.h" static const itype_id itype_crowbar_pocket_test( "crowbar_pocket_test" ); +static const itype_id itype_hammer_pocket_test( "hammer_pocket_test" ); static const itype_id itype_jar_glass_sealed( "jar_glass_sealed" ); static const itype_id itype_log( "log" ); static const itype_id itype_pickle( "pickle" ); static const itype_id itype_purse( "purse" ); +static const itype_id itype_test_tool_belt( "test_tool_belt" ); +static const itype_id itype_tongs_pocket_test( "tongs_pocket_test" ); +static const itype_id itype_wrench_pocket_test( "wrench_pocket_test" ); TEST_CASE( "item_contents" ) { clear_map(); - item tool_belt( "test_tool_belt" ); + item tool_belt( itype_test_tool_belt ); const units::volume tool_belt_vol = tool_belt.volume(); const units::mass tool_belt_weight = tool_belt.weight(); @@ -30,10 +34,10 @@ TEST_CASE( "item_contents" ) CHECK( tool_belt.weight( true ) == tool_belt.type->weight ); CHECK( tool_belt.weight( false ) == tool_belt.type->weight ); - item hammer( "hammer_pocket_test" ); - item tongs( "tongs_pocket_test" ); - item wrench( "wrench_pocket_test" ); - item crowbar( "crowbar_pocket_test" ); + item hammer( itype_hammer_pocket_test ); + item tongs( itype_tongs_pocket_test ); + item wrench( itype_wrench_pocket_test ); + item crowbar( itype_crowbar_pocket_test ); ret_val i1 = tool_belt.put_in( hammer, pocket_type::CONTAINER ); ret_val i2 = tool_belt.put_in( tongs, pocket_type::CONTAINER ); diff --git a/tests/item_countdown_test.cpp b/tests/item_countdown_test.cpp index 771e9233d13a2..9f911f4a7345b 100644 --- a/tests/item_countdown_test.cpp +++ b/tests/item_countdown_test.cpp @@ -3,9 +3,17 @@ #include "item.h" #include "map.h" +static const itype_id itype_arrow_field_point_fletched( "arrow_field_point_fletched" ); +static const itype_id itype_arrow_flamming( "arrow_flamming" ); +static const itype_id itype_cheese_hard( "cheese_hard" ); +static const itype_id itype_grenade_act( "grenade_act" ); +static const itype_id itype_migo_plate( "migo_plate" ); +static const itype_id itype_migo_plate_undergrown( "migo_plate_undergrown" ); +static const itype_id itype_test_rock_cheese( "test_rock_cheese" ); + TEST_CASE( "countdown_action_triggering", "[item]" ) { - item grenade( "grenade_act" ); + item grenade( itype_grenade_act ); grenade.active = true; SECTION( "countdown_point is in future" ) { @@ -30,7 +38,7 @@ TEST_CASE( "countdown_action_triggering", "[item]" ) TEST_CASE( "countdown_action_revert_to", "[item]" ) { SECTION( "revert to inert item" ) { - item test_item( "arrow_flamming" ); + item test_item( itype_arrow_flamming ); test_item.active = true; test_item.countdown_point = calendar::turn; @@ -38,7 +46,7 @@ TEST_CASE( "countdown_action_revert_to", "[item]" ) CHECK( test_item.process( get_map(), nullptr, tripoint_bub_ms::zero ) == false ); // Turns into normal arrow - CHECK( test_item.typeId().str() == "arrow_field_point_fletched" ); + CHECK( test_item.typeId() == itype_arrow_field_point_fletched ); // Is not active anymore CHECK_FALSE( test_item.active ); @@ -48,7 +56,7 @@ TEST_CASE( "countdown_action_revert_to", "[item]" ) } SECTION( "revert to item with new timer" ) { - item test_item( "migo_plate_undergrown" ); + item test_item( itype_migo_plate_undergrown ); test_item.active = true; test_item.countdown_point = calendar::turn; @@ -56,7 +64,7 @@ TEST_CASE( "countdown_action_revert_to", "[item]" ) CHECK( test_item.process( get_map(), nullptr, tripoint_bub_ms::zero ) == false ); // Turns into new armor type - CHECK( test_item.typeId().str() == "migo_plate" ); + CHECK( test_item.typeId() == itype_migo_plate ); // Is still active CHECK( test_item.active ); @@ -66,7 +74,7 @@ TEST_CASE( "countdown_action_revert_to", "[item]" ) } SECTION( "revert to item that requires processing" ) { - item test_item( "test_rock_cheese" ); + item test_item( itype_test_rock_cheese ); test_item.active = true; test_item.countdown_point = calendar::turn; @@ -74,7 +82,7 @@ TEST_CASE( "countdown_action_revert_to", "[item]" ) CHECK( test_item.process( get_map(), nullptr, tripoint_bub_ms::zero ) == false ); // Turns into cheese - CHECK( test_item.typeId().str() == "cheese_hard" ); + CHECK( test_item.typeId() == itype_cheese_hard ); // Is still active CHECK( test_item.active ); diff --git a/tests/item_group_test.cpp b/tests/item_group_test.cpp index d652ebe012263..aa179e51b39e8 100644 --- a/tests/item_group_test.cpp +++ b/tests/item_group_test.cpp @@ -14,7 +14,14 @@ #include "options_helpers.h" #include "type_id.h" +static const itype_id itype_40x46mm_m1006( "40x46mm_m1006" ); +static const itype_id itype_glock_19( "glock_19" ); +static const itype_id itype_longbow( "longbow" ); static const itype_id itype_match( "match" ); +static const itype_id itype_matches( "matches" ); +static const itype_id itype_rock( "rock" ); +static const itype_id itype_test_balloon( "test_balloon" ); +static const itype_id itype_test_rock( "test_rock" ); TEST_CASE( "truncate_spawn_when_items_dont_fit", "[item_group]" ) { @@ -27,7 +34,7 @@ TEST_CASE( "truncate_spawn_when_items_dont_fit", "[item_group]" ) for( int i = 0; i < 100; ++i ) { const item_group::ItemList items = item_group::items_from( truncate_test_id ); REQUIRE( items.size() == 1 ); - REQUIRE( items[0].typeId().str() == "test_balloon" ); + REQUIRE( items[0].typeId() == itype_test_balloon ); std::list contents = items[0].all_items_top(); REQUIRE( contents.size() == 2 ); observed_pairs.emplace( contents.front()->typeId(), contents.back()->typeId() ); @@ -52,14 +59,14 @@ TEST_CASE( "spill_when_items_dont_fit", "[item_group]" ) REQUIRE( items.size() == 2 ); const item *container; const item *other; - if( items[0].typeId().str() == "test_balloon" ) { + if( items[0].typeId() == itype_test_balloon ) { container = &items[0]; other = &items[1]; } else { container = &items[1]; other = &items[0]; } - REQUIRE( container->typeId().str() == "test_balloon" ); + REQUIRE( container->typeId() == itype_test_balloon ); std::list contents = container->all_items_top(); REQUIRE( contents.size() == 2 ); observed_pairs_inside.emplace( contents.front()->typeId(), contents.back()->typeId() ); @@ -78,14 +85,14 @@ TEST_CASE( "spawn_with_default_charges_and_with_ammo", "[item_group]" ) Item_modifier default_charges; default_charges.with_ammo = 100; SECTION( "tools without ammo" ) { - item matches( "matches" ); + item matches( itype_matches ); REQUIRE( matches.ammo_default() == itype_match ); default_charges.modify( matches, "modifier test (matches ammo)" ); CHECK( matches.remaining_ammo_capacity() == 0 ); } SECTION( "gun with ammo type" ) { - item glock( "glock_19" ); + item glock( itype_glock_19 ); REQUIRE( !glock.magazine_default().is_null() ); default_charges.modify( glock, "modifier test (glock ammo)" ); CHECK( glock.remaining_ammo_capacity() == 0 ); @@ -98,14 +105,14 @@ TEST_CASE( "Item_modifier_damages_item", "[item_group]" ) damaged.damage.first = 1; damaged.damage.second = 1; SECTION( "except when it's an ammunition" ) { - item rock( "rock" ); + item rock( itype_rock ); REQUIRE( rock.damage() == 0 ); REQUIRE( rock.max_damage() == 0 ); damaged.modify( rock, "modifier test (rock damage)" ); CHECK( rock.damage() == 0 ); } SECTION( "when it can be damaged" ) { - item glock( "glock_19" ); + item glock( itype_glock_19 ); REQUIRE( glock.damage() == 0 ); REQUIRE( glock.max_damage() > 0 ); damaged.modify( glock, "modifier test (glock damage)" ); @@ -118,14 +125,14 @@ TEST_CASE( "Item_modifier_gun_fouling", "[item_group]" ) Item_modifier fouled; fouled.dirt.first = 1; SECTION( "guns can be fouled" ) { - item glock( "glock_19" ); + item glock( itype_glock_19 ); REQUIRE( !glock.has_flag( flag_PRIMITIVE_RANGED_WEAPON ) ); REQUIRE( !glock.has_var( "dirt" ) ); fouled.modify( glock, "modifier test (glock fouling)" ); CHECK( glock.get_var( "dirt", 0.0 ) > 0.0 ); } SECTION( "bows can't be fouled" ) { - item bow( "longbow" ); + item bow( itype_longbow ); REQUIRE( !bow.has_var( "dirt" ) ); REQUIRE( bow.has_flag( flag_PRIMITIVE_RANGED_WEAPON ) ); fouled.modify( bow, "modifier test (bow fouling)" ); @@ -136,8 +143,8 @@ TEST_CASE( "Item_modifier_gun_fouling", "[item_group]" ) TEST_CASE( "item_modifier_modifies_charges_for_item", "[item_group]" ) { GIVEN( "an ammo item that uses charges" ) { - const std::string item_id = "40x46mm_m1006"; - item subject( item_id ); + const std::string &item_id = itype_40x46mm_m1006.c_str(); + item subject( itype_40x46mm_m1006 ); const int default_charges = 6; @@ -247,7 +254,7 @@ TEST_CASE( "Event-based_item_spawns_do_not_spawn_outside_event", "[item_group]" REQUIRE( get_option( "EVENT_SPAWNS" ) == "items" ); item_group_id event_test_id( "test_event_item_spawn" ); - itype_id test_rock( "test_rock" ); + itype_id test_rock( itype_test_rock ); const item_group::ItemList items = item_group::items_from( event_test_id ); REQUIRE( item_group::every_possible_item_from( event_test_id ).size() == 6 ); holiday cur_event = get_holiday_from_time(); diff --git a/tests/item_location_test.cpp b/tests/item_location_test.cpp index f90d458f13476..3d1dbc3e6fbaa 100644 --- a/tests/item_location_test.cpp +++ b/tests/item_location_test.cpp @@ -17,6 +17,7 @@ #include "type_id.h" #include "visitable.h" +static const itype_id itype_backpack( "backpack" ); static const itype_id itype_jeans( "jeans" ); static const itype_id itype_tshirt( "tshirt" ); @@ -26,11 +27,11 @@ TEST_CASE( "item_location_can_maintain_reference_despite_item_removal", "[item][ map &m = get_map(); tripoint_bub_ms pos( 60, 60, 0 ); m.i_clear( pos ); - m.add_item( pos, item( "jeans" ) ); - m.add_item( pos, item( "jeans" ) ); - m.add_item( pos, item( "tshirt" ) ); - m.add_item( pos, item( "jeans" ) ); - m.add_item( pos, item( "jeans" ) ); + m.add_item( pos, item( itype_jeans ) ); + m.add_item( pos, item( itype_jeans ) ); + m.add_item( pos, item( itype_tshirt ) ); + m.add_item( pos, item( itype_jeans ) ); + m.add_item( pos, item( itype_jeans ) ); map_cursor cursor( pos ); item *tshirt = nullptr; cursor.visit_items( [&tshirt]( item * i, item * ) { @@ -63,11 +64,11 @@ TEST_CASE( "item_location_doesnt_return_stale_map_item", "[item][item_location]" map &m = get_map(); tripoint_bub_ms pos( 60, 60, 0 ); m.i_clear( pos ); - m.add_item( pos, item( "tshirt" ) ); + m.add_item( pos, item( itype_tshirt ) ); item_location item_loc( map_cursor( pos ), &m.i_at( pos ).only_item() ); REQUIRE( item_loc->typeId() == itype_tshirt ); m.i_rem( pos, &*item_loc ); - m.add_item( pos, item( "jeans" ) ); + m.add_item( pos, item( itype_jeans ) ); CHECK( !item_loc ); } @@ -75,8 +76,8 @@ TEST_CASE( "item_in_container", "[item][item_location]" ) { Character &dummy = get_player_character(); clear_avatar(); - item_location backpack = dummy.i_add( item( "backpack" ) ); - item jeans( "jeans" ); + item_location backpack = dummy.i_add( item( itype_backpack ) ); + item jeans( itype_jeans ); REQUIRE( dummy.has_item( *backpack ) ); diff --git a/tests/item_pocket_test.cpp b/tests/item_pocket_test.cpp index 7e0c0b094efc7..477b95c097334 100644 --- a/tests/item_pocket_test.cpp +++ b/tests/item_pocket_test.cpp @@ -53,11 +53,58 @@ static const item_group_id Item_spawn_data_wallet_science_stylish_full( "wallet_science_stylish_full" ); static const item_group_id Item_spawn_data_wallet_stylish_full( "wallet_stylish_full" ); +static const itype_id itype_55gal_drum( "55gal_drum" ); +static const itype_id itype_XL_holster( "XL_holster" ); +static const itype_id itype_backpack( "backpack" ); +static const itype_id itype_bag_plastic( "bag_plastic" ); //Purposefully nonsense +static const itype_id itype_barrel_small( "barrel_small" ); +static const itype_id itype_bottle_plastic( "bottle_plastic" ); +static const itype_id itype_debug_modular_m4_carbine( "debug_modular_m4_carbine" ); +static const itype_id itype_ketchup( "ketchup" ); +static const itype_id itype_mustard( "mustard" ); +static const itype_id itype_paper( "paper" ); +static const itype_id itype_pencil( "pencil" ); +static const itype_id itype_shotgun_d( "shotgun_d" ); +static const itype_id itype_shoulder_strap( "shoulder_strap" ); +static const itype_id itype_software_math( "software_math" ); +static const itype_id itype_steel_pan( "steel_pan" ); +static const itype_id itype_stock_none( "stock_none" ); +static const itype_id itype_test_45_ammo( "test_45_ammo" ); +static const itype_id itype_test_9mm_ammo( "test_9mm_ammo" ); +static const itype_id itype_test_apple( "test_apple" ); static const itype_id itype_test_backpack( "test_backpack" ); +static const itype_id itype_test_balloon( "test_balloon" ); +static const itype_id itype_test_box( "test_box" ); +static const itype_id itype_test_can_drink( "test_can_drink" ); +static const itype_id itype_test_clumsy_sword( "test_clumsy_sword" ); +static const itype_id itype_test_fire_ax( "test_fire_ax" ); +static const itype_id itype_test_flashlight( "test_flashlight" ); +static const itype_id itype_test_gas( "test_gas" ); +static const itype_id itype_test_glock( "test_glock" ); +static const itype_id itype_test_glockmag( "test_glockmag" ); +static const itype_id itype_test_halligan( "test_halligan" ); +static const itype_id itype_test_jug_large_open( "test_jug_large_open" ); static const itype_id itype_test_jug_plastic( "test_jug_plastic" ); +static const itype_id itype_test_liquid( "test_liquid" ); +static const itype_id itype_test_mini_backpack( "test_mini_backpack" ); +static const itype_id itype_test_pine_nuts( "test_pine_nuts" ); +static const itype_id itype_test_rag( "test_rag" ); +static const itype_id itype_test_robofac_armor_rig( "test_robofac_armor_rig" ); +static const itype_id itype_test_rock( "test_rock" ); +static const itype_id itype_test_rod_14cm( "test_rod_14cm" ); +static const itype_id itype_test_rod_15cm( "test_rod_15cm" ); +static const itype_id itype_test_screwdriver( "test_screwdriver" ); static const itype_id itype_test_socks( "test_socks" ); +static const itype_id itype_test_sonic_screwdriver( "test_sonic_screwdriver" ); +static const itype_id itype_test_tool_belt_pocket_mix( "test_tool_belt_pocket_mix" ); +static const itype_id itype_test_utility_belt( "test_utility_belt" ); +static const itype_id itype_test_waterskin( "test_waterskin" ); static const itype_id itype_test_watertight_open_sealed_container_1L( "test_watertight_open_sealed_container_1L" ); +static const itype_id itype_tums( "tums" ); +static const itype_id itype_usb_drive( "usb_drive" ); +static const itype_id itype_water( "water" ); +static const itype_id itype_water_clean( "water_clean" ); static const nested_mapgen_id nested_mapgen_auto_wl_test( "auto_wl_test" ); @@ -153,9 +200,9 @@ static void expect_cannot_insert( item_pocket &pocket, const item &it, TEST_CASE( "max_item_length", "[pocket][max_item_length]" ) { // Test items with different lengths - item screwdriver( "test_screwdriver" ); - item sonic( "test_sonic_screwdriver" ); - item sword( "test_clumsy_sword" ); + item screwdriver( itype_test_screwdriver ); + item sonic( itype_test_sonic_screwdriver ); + item sword( itype_test_clumsy_sword ); // Sheath that may contain items pocket_data data_sheath( pocket_type::CONTAINER ); @@ -204,11 +251,11 @@ TEST_CASE( "max_item_length", "[pocket][max_item_length]" ) // Items of such length are not currently allowed in a 1-liter pocket. GIVEN( "a 1-liter box without a defined max_item_length" ) { - item box( "test_box" ); + item box( itype_test_box ); REQUIRE( box.get_total_capacity() == 1_liter ); THEN( "it can hold an item 14 cm in length" ) { - item rod_14( "test_rod_14cm" ); + item rod_14( itype_test_rod_14cm ); REQUIRE( rod_14.length() == 14_cm ); REQUIRE( box.is_container_empty() ); @@ -218,7 +265,7 @@ TEST_CASE( "max_item_length", "[pocket][max_item_length]" ) } THEN( "it cannot hold an item 15 cm in length" ) { - item rod_15( "test_rod_15cm" ); + item rod_15( itype_test_rod_15cm ); REQUIRE( rod_15.length() == 15_cm ); REQUIRE( box.is_container_empty() ); @@ -248,11 +295,11 @@ TEST_CASE( "max_item_length", "[pocket][max_item_length]" ) TEST_CASE( "max_item_volume", "[pocket][max_item_volume]" ) { // Test items - item screwdriver( "test_screwdriver" ); - item rag( "test_rag" ); - item rock( "test_rock" ); - item gas( "test_gas" ); - item liquid( "test_liquid" ); + item screwdriver( itype_test_screwdriver ); + item rag( itype_test_rag ); + item rock( itype_test_rock ); + item gas( itype_test_gas ); + item liquid( itype_test_liquid ); // Air-tight, water-tight, jug-style container pocket_data data_jug( pocket_type::CONTAINER ); @@ -395,13 +442,13 @@ TEST_CASE( "magazine_with_ammo_restriction", "[pocket][magazine][ammo_restrictio REQUIRE( pocket_mag.empty() ); THEN( "it can contain a full clip of 9mm ammo" ) { - const item ammo_9mm( "test_9mm_ammo", calendar::turn_zero, full_clip_qty ); + const item ammo_9mm( itype_test_9mm_ammo, calendar::turn_zero, full_clip_qty ); expect_can_contain( pocket_mag, ammo_9mm ); } THEN( "it cannot contain items of the wrong ammo type" ) { - item rock( "test_rock" ); - item ammo_45( "test_45_ammo", calendar::turn_zero, 1 ); + item rock( itype_test_rock ); + item ammo_45( itype_test_45_ammo, calendar::turn_zero, 1 ); expect_cannot_contain( pocket_mag, rock, "item is not the correct ammo type", item_pocket::contain_code::ERR_AMMO ); expect_cannot_contain( pocket_mag, ammo_45, "item is not the correct ammo type", @@ -409,7 +456,7 @@ TEST_CASE( "magazine_with_ammo_restriction", "[pocket][magazine][ammo_restrictio } THEN( "it cannot contain items that are not ammo" ) { - item rag( "test_rag" ); + item rag( itype_test_rag ); expect_cannot_contain( pocket_mag, rag, "item is not ammunition", item_pocket::contain_code::ERR_AMMO ); } @@ -417,17 +464,17 @@ TEST_CASE( "magazine_with_ammo_restriction", "[pocket][magazine][ammo_restrictio WHEN( "it is partly full of ammo" ) { const int half_clip_qty = full_clip_qty / 2; - item ammo_9mm_half_clip( "test_9mm_ammo", calendar::turn_zero, half_clip_qty ); + item ammo_9mm_half_clip( itype_test_9mm_ammo, calendar::turn_zero, half_clip_qty ); expect_can_insert( pocket_mag, ammo_9mm_half_clip ); THEN( "it can contain more of the same ammo" ) { - item ammo_9mm_refill( "test_9mm_ammo", calendar::turn_zero, + item ammo_9mm_refill( itype_test_9mm_ammo, calendar::turn_zero, full_clip_qty - half_clip_qty ); expect_can_contain( pocket_mag, ammo_9mm_refill ); } THEN( "it cannot contain more ammo than ammo_restriction allows" ) { - item ammo_9mm_overfill( "test_9mm_ammo", calendar::turn_zero, + item ammo_9mm_overfill( itype_test_9mm_ammo, calendar::turn_zero, full_clip_qty - half_clip_qty + 1 ); expect_cannot_contain( pocket_mag, ammo_9mm_overfill, "tried to put too many charges of ammo in item", @@ -436,11 +483,11 @@ TEST_CASE( "magazine_with_ammo_restriction", "[pocket][magazine][ammo_restrictio } WHEN( "it is completely full of ammo" ) { - item ammo_9mm_full_clip( "test_9mm_ammo", calendar::turn_zero, full_clip_qty ); + item ammo_9mm_full_clip( itype_test_9mm_ammo, calendar::turn_zero, full_clip_qty ); expect_can_insert( pocket_mag, ammo_9mm_full_clip ); THEN( "it cannot contain any more of the same ammo" ) { - item ammo_9mm_bullet( "test_9mm_ammo", calendar::turn_zero, 1 ); + item ammo_9mm_bullet( itype_test_9mm_ammo, calendar::turn_zero, 1 ); expect_cannot_contain( pocket_mag, ammo_9mm_bullet, "tried to put too many charges of ammo in item", item_pocket::contain_code::ERR_NO_SPACE ); @@ -466,14 +513,14 @@ TEST_CASE( "magazine_with_ammo_restriction", "[pocket][magazine][ammo_restrictio TEST_CASE( "pocket_with_item_flag_restriction", "[pocket][flag_restriction]" ) { // Items with BELT_CLIP flag - item screwdriver( "test_screwdriver" ); - item sonic( "test_sonic_screwdriver" ); - item halligan( "test_halligan" ); - item axe( "test_fire_ax" ); + item screwdriver( itype_test_screwdriver ); + item sonic( itype_test_sonic_screwdriver ); + item halligan( itype_test_halligan ); + item axe( itype_test_fire_ax ); // Items without BELT_CLIP flag - item rag( "test_rag" ); - item rock( "test_rock" ); + item rag( itype_test_rag ); + item rock( itype_test_rock ); // Ensure the tools have expected volume relationships // (too small, minimum size, maximum size, too big) @@ -593,7 +640,7 @@ TEST_CASE( "pocket_with_item_flag_restriction", "[pocket][flag_restriction]" ) TEST_CASE( "holster_can_contain_one_fitting_item", "[pocket][holster]" ) { // Start with a basic test handgun from data/mods/TEST_DATA/items.json - item glock( "test_glock" ); + item glock( itype_test_glock ); // Construct data for a holster to perfectly fit this gun pocket_data data_holster( pocket_type::CONTAINER ); @@ -652,7 +699,7 @@ TEST_CASE( "holster_can_contain_one_fitting_item", "[pocket][holster]" ) GIVEN( "holster already contains an item" ) { // Put another item in the holster first item_pocket pocket_holster( &data_holster ); - expect_can_insert( pocket_holster, item( "test_glock" ) ); + expect_can_insert( pocket_holster, item( itype_test_glock ) ); THEN( "it cannot contain the item, because holster can only hold one item" ) { expect_cannot_contain( pocket_holster, glock, "holster already contains an item", @@ -681,12 +728,12 @@ TEST_CASE( "holster_can_contain_one_fitting_item", "[pocket][holster]" ) TEST_CASE( "pockets_containing_liquids", "[pocket][watertight][liquid]" ) { // Liquids - item ketchup( "ketchup", calendar::turn_zero, item::default_charges_tag{} ); - item mustard( "mustard", calendar::turn_zero, item::default_charges_tag{} ); + item ketchup( itype_ketchup, calendar::turn_zero, item::default_charges_tag{} ); + item mustard( itype_mustard, calendar::turn_zero, item::default_charges_tag{} ); // Non-liquids - item rock( "test_rock" ); - item glock( "test_glock" ); + item rock( itype_test_rock ); + item glock( itype_test_glock ); // Large watertight container pocket_data data_bucket( pocket_type::CONTAINER ); @@ -780,7 +827,7 @@ TEST_CASE( "pockets_containing_liquids", "[pocket][watertight][liquid]" ) // TEST_CASE( "pockets_containing_gases", "[pocket][airtight][gas]" ) { - item gas( "test_gas", calendar::turn_zero, item::default_charges_tag{} ); + item gas( itype_test_gas, calendar::turn_zero, item::default_charges_tag{} ); // A potentially airtight container pocket_data data_balloon( pocket_type::CONTAINER ); @@ -833,7 +880,7 @@ TEST_CASE( "pockets_containing_gases", "[pocket][airtight][gas]" ) // TEST_CASE( "rigid_and_non-rigid_or_flexible_pockets", "[pocket][rigid][flexible]" ) { - item rock( "test_rock" ); + item rock( itype_test_rock ); // Pocket with enough space for 2 rocks pocket_data data_sock( pocket_type::CONTAINER ); @@ -861,7 +908,7 @@ TEST_CASE( "rigid_and_non-rigid_or_flexible_pockets", "[pocket][rigid][flexible] WHEN( "pocket is partially filled" ) { // One rock should fill the sock half-way - expect_can_insert( pocket_sock, item( "test_rock" ) ); + expect_can_insert( pocket_sock, item( itype_test_rock ) ); REQUIRE_FALSE( pocket_sock.empty() ); THEN( "it can contain another item" ) { @@ -875,8 +922,8 @@ TEST_CASE( "rigid_and_non-rigid_or_flexible_pockets", "[pocket][rigid][flexible] WHEN( "pocket is full" ) { // Two rocks should be enough to fill it - expect_can_insert( pocket_sock, item( "test_rock" ) ); - expect_can_insert( pocket_sock, item( "test_rock" ) ); + expect_can_insert( pocket_sock, item( itype_test_rock ) ); + expect_can_insert( pocket_sock, item( itype_test_rock ) ); REQUIRE_FALSE( pocket_sock.empty() ); REQUIRE( pocket_sock.full( true ) ); @@ -911,8 +958,8 @@ TEST_CASE( "rigid_and_non-rigid_or_flexible_pockets", "[pocket][rigid][flexible] } WHEN( "pocket is full" ) { - expect_can_insert( pocket_sock, item( "test_rock" ) ); - expect_can_insert( pocket_sock, item( "test_rock" ) ); + expect_can_insert( pocket_sock, item( itype_test_rock ) ); + expect_can_insert( pocket_sock, item( itype_test_rock ) ); REQUIRE_FALSE( pocket_sock.empty() ); REQUIRE( pocket_sock.full( true ) ); @@ -938,8 +985,8 @@ TEST_CASE( "rigid_and_non-rigid_or_flexible_pockets", "[pocket][rigid][flexible] // TEST_CASE( "corpse_can_contain_anything", "[pocket][corpse]" ) { - item rock( "test_rock" ); - item glock( "test_glock" ); + item rock( itype_test_rock ); + item glock( itype_test_glock ); pocket_data data_corpse( pocket_type::CORPSE ); @@ -970,10 +1017,10 @@ TEST_CASE( "corpse_can_contain_anything", "[pocket][corpse]" ) // TEST_CASE( "sealed_containers", "[pocket][seal]" ) { - item water( "water" ); + item water( itype_water ); GIVEN( "sealable can" ) { - item can( "test_can_drink" ); + item can( itype_test_can_drink ); // Ensure it has exactly one contained pocket, and get that pocket for testing std::vector can_pockets = can.get_all_contained_pockets(); @@ -1072,9 +1119,9 @@ TEST_CASE( "when_one_pocket_is_better_than_another", "[pocket][better]" ) pocket_data data_b( pocket_type::CONTAINER ); // Candidate items to compare pockets with - item liquid( "test_liquid" ); - item apple( "test_apple" ); - item rock( "test_rock" ); + item liquid( itype_test_liquid ); + item apple( itype_test_apple ); + item rock( itype_test_rock ); SECTION( "for perishable food, lower spoil_multiplier is better" ) { REQUIRE( apple.is_comestible() ); @@ -1134,10 +1181,10 @@ TEST_CASE( "best_pocket_in_item_contents", "[pocket][item][best]" ) // Waterskins can be best pockets for liquids SECTION( "item with one watertight pocket has best_pocket for liquid" ) { // Must have a CONTAINER pocket, first and foremost - item skin( "test_waterskin" ); + item skin( itype_test_waterskin ); REQUIRE( skin.is_container() ); // Prerequisite: It can contain water - item liquid( "test_liquid" ); + item liquid( itype_test_liquid ); REQUIRE( skin.can_contain( liquid ).success() ); // Has a best pocket for liquid @@ -1147,16 +1194,16 @@ TEST_CASE( "best_pocket_in_item_contents", "[pocket][item][best]" ) // Test utility belt has pockets best for holding small and large tools, liquids and gases SECTION( "item with many different pockets can have best_pocket for different items" ) { // Utility belt has CONTAINER pockets - item util_belt( "test_utility_belt" ); + item util_belt( itype_test_utility_belt ); REQUIRE( util_belt.is_container() ); // It can contain small and large tools - item screwdriver( "test_screwdriver" ); - item halligan( "test_halligan" ); + item screwdriver( itype_test_screwdriver ); + item halligan( itype_test_halligan ); REQUIRE( util_belt.can_contain( screwdriver ).success() ); REQUIRE( util_belt.can_contain( halligan ).success() ); // It can contain liquid and gas - item liquid( "test_liquid" ); - item gas( "test_gas", calendar::turn_zero, item::default_charges_tag{} ); + item liquid( itype_test_liquid ); + item gas( itype_test_gas, calendar::turn_zero, item::default_charges_tag{} ); REQUIRE( util_belt.can_contain( liquid ).success() ); REQUIRE( util_belt.can_contain( gas ).success() ); @@ -1172,14 +1219,14 @@ TEST_CASE( "best_pocket_in_item_contents", "[pocket][item][best]" ) // best_pocket for compatible ammos. SECTION( "non-container pockets cannot be best_pocket" ) { // Gun that accepts magazines - item glock( "test_glock" ); + item glock( itype_test_glock ); REQUIRE( glock.has_pocket_type( pocket_type::MAGAZINE_WELL ) ); // Empty magazine - item glockmag( "test_glockmag", calendar::turn, 0 ); + item glockmag( itype_test_glockmag, calendar::turn, 0 ); REQUIRE( glockmag.has_pocket_type( pocket_type::MAGAZINE ) ); REQUIRE( glockmag.ammo_remaining() == 0 ); // A single 9mm bullet - item glockammo( "test_9mm_ammo", calendar::turn, 1 ); + item glockammo( itype_test_9mm_ammo, calendar::turn, 1 ); REQUIRE( glockammo.is_ammo() ); REQUIRE( glockammo.charges == 1 ); @@ -1195,9 +1242,9 @@ TEST_CASE( "best_pocket_in_item_contents", "[pocket][item][best]" ) // While sealed, they clearly cannot be the best pocket for storing anything. SECTION( "sealed pockets cannot be best_pocket" ) { // Regular aluminum beverage can and something to fill it with - item can( "test_can_drink" ); + item can( itype_test_can_drink ); REQUIRE( can.is_container() ); - item liquid( "test_liquid" ); + item liquid( itype_test_liquid ); REQUIRE( can.can_contain( liquid ).success() ); // Before being sealed, it can be best pocket for liquid @@ -1210,10 +1257,10 @@ TEST_CASE( "best_pocket_in_item_contents", "[pocket][item][best]" ) } SECTION( "pockets with favorite settings" ) { - item liquid( "test_liquid" ); + item liquid( itype_test_liquid ); WHEN( "item is blacklisted" ) { - item skin( "test_waterskin" ); + item skin( itype_test_waterskin ); REQUIRE( has_best_pocket( skin, liquid ) ); get_only_pocket( skin )->settings.blacklist_item( liquid.typeId() ); @@ -1223,7 +1270,7 @@ TEST_CASE( "best_pocket_in_item_contents", "[pocket][item][best]" ) } WHEN( "item is whitelisted" ) { - item skin( "test_waterskin" ); + item skin( itype_test_waterskin ); REQUIRE( has_best_pocket( skin, liquid ) ); get_only_pocket( skin )->settings.whitelist_item( liquid.typeId() ); @@ -1250,14 +1297,14 @@ TEST_CASE( "pocket_favorites_allow_or_restrict_items", "[pocket][favorite][item] { item_location loc; - item test_item( "test_rock" ); + item test_item( itype_test_rock ); - item test_item_same_category( "test_rag" ); + item test_item_same_category( itype_test_rag ); REQUIRE( test_item.get_category_shallow().id == test_item_same_category.get_category_shallow().id ); REQUIRE_FALSE( test_item.typeId() == test_item_same_category.typeId() ); - item test_item_different_category( "test_apple" ); + item test_item_different_category( itype_test_apple ); REQUIRE_FALSE( test_item.get_category_shallow().id == test_item_different_category.get_category_shallow().id ); REQUIRE_FALSE( test_item.typeId() == test_item_different_category.typeId() ); @@ -1413,7 +1460,7 @@ TEST_CASE( "pocket_favorites_allow_or_restrict_containers", "[pocket][favorite][ item_pocket::favorite_settings settings; GIVEN( "item container is empty" ) { - item item_plastic_bag = item( "bag_plastic" ); + item item_plastic_bag( itype_bag_plastic ); REQUIRE( item_plastic_bag.empty() ); WHEN( "item container is whitelisted" ) { @@ -1452,9 +1499,9 @@ TEST_CASE( "pocket_favorites_allow_or_restrict_containers", "[pocket][favorite][ } GIVEN( "item container is not empty" ) { - item item_plastic_bag = item( "bag_plastic" ); - item item_paper = item( "paper" ); - item item_pencil = item( "pencil" ); + item item_plastic_bag = item( itype_bag_plastic ); + item item_paper = item( itype_paper ); + item item_pencil = item( itype_pencil ); item_plastic_bag.force_insert_item( item_paper, pocket_container ); item_plastic_bag.force_insert_item( item_pencil, pocket_container ); @@ -1465,7 +1512,7 @@ TEST_CASE( "pocket_favorites_allow_or_restrict_containers", "[pocket][favorite][ THEN( "container should be accepted" ) { REQUIRE( settings.accepts_item( item_plastic_bag ) ); - REQUIRE_FALSE( settings.accepts_item( item( "bag_plastic" ) ) ); + REQUIRE_FALSE( settings.accepts_item( item( itype_bag_plastic ) ) ); } WHEN( "item container is blacklisted" ) { settings.blacklist_item( item_plastic_bag.typeId() ); @@ -1495,7 +1542,7 @@ TEST_CASE( "pocket_favorites_allow_or_restrict_containers", "[pocket][favorite][ THEN( "container should be accepted" ) { REQUIRE( settings.accepts_item( item_plastic_bag ) ); - REQUIRE_FALSE( settings.accepts_item( item( "bag_plastic" ) ) ); + REQUIRE_FALSE( settings.accepts_item( item( itype_bag_plastic ) ) ); } WHEN( "item container category is blacklisted" ) { settings.blacklist_category( item_plastic_bag.get_category_shallow().id ); @@ -1527,8 +1574,8 @@ TEST_CASE( "pocket_favorites_allow_or_restrict_containers", "[pocket][favorite][ } GIVEN( "item container contains liquid" ) { - item item_clean_water = item( "water_clean" ); - item item_bottled_water = item( "bottle_plastic" ); + item item_clean_water = item( itype_water_clean ); + item item_bottled_water = item( itype_bottle_plastic ); REQUIRE( item_bottled_water.fill_with( item_clean_water ) > 0 ); WHEN( "liquid item is whitelisted" ) { @@ -1537,7 +1584,7 @@ TEST_CASE( "pocket_favorites_allow_or_restrict_containers", "[pocket][favorite][ THEN( "item container containing liquid item should be accepted" ) { REQUIRE( settings.accepts_item( item_bottled_water ) ); - REQUIRE_FALSE( settings.accepts_item( item( "bottle_plastic" ) ) ); + REQUIRE_FALSE( settings.accepts_item( item( itype_bottle_plastic ) ) ); } } WHEN( "liquid item is blacklisted" ) { @@ -1546,11 +1593,11 @@ TEST_CASE( "pocket_favorites_allow_or_restrict_containers", "[pocket][favorite][ THEN( "item container containing liquid item should not be accepted" ) { REQUIRE_FALSE( settings.accepts_item( item_bottled_water ) ); - REQUIRE( settings.accepts_item( item( "bottle_plastic" ) ) ); + REQUIRE( settings.accepts_item( item( itype_bottle_plastic ) ) ); } } WHEN( "liquid item is not listed in rules" ) { - settings.whitelist_item( item( "paper" ).typeId() ); + settings.whitelist_item( itype_paper ); THEN( "item container containing liquid item should not be accepted" ) { REQUIRE_FALSE( settings.accepts_item( item_bottled_water ) ); @@ -1656,7 +1703,7 @@ TEST_CASE( "character_best_pocket", "[pocket][character][best]" ) item socks( itype_test_socks ); item backpack( itype_test_backpack ); item container( itype_test_jug_plastic ); - item filler( "test_rag" ); + item filler( itype_test_rag ); // wear the backpack item. REQUIRE( dummy.wear_item( backpack ) ); @@ -1729,8 +1776,8 @@ TEST_CASE( "character_best_pocket", "[pocket][character][best]" ) TEST_CASE( "guns_and_gunmods", "[pocket][gunmod]" ) { - item m4a1( "debug_modular_m4_carbine" ); - item strap( "shoulder_strap" ); + item m4a1( itype_debug_modular_m4_carbine ); + item strap( itype_shoulder_strap ); // Guns cannot "contain" gunmods, but gunmods can be inserted into guns CHECK_FALSE( m4a1.can_contain( strap ).success() ); CHECK( m4a1.put_in( strap, pocket_type::MOD ).success() ); @@ -1738,8 +1785,8 @@ TEST_CASE( "guns_and_gunmods", "[pocket][gunmod]" ) TEST_CASE( "usb_drives_and_software", "[pocket][software]" ) { - item usb( "usb_drive" ); - item software( "software_math" ); + item usb( itype_usb_drive ); + item software( itype_software_math ); // USB drives aren't containers, and cannot "contain" software, but software can be inserted CHECK_FALSE( usb.can_contain( software ).success() ); CHECK( usb.put_in( software, pocket_type::SOFTWARE ).success() ); @@ -1819,11 +1866,11 @@ static item_location give_item_to_char( Character &u, item_location &i ) static void test_pickup_autoinsert_sub_sub( bool autopickup, bool wear, bool soft_nested ) { - item cont_top_soft( "test_backpack" ); - item cont_nest_soft( "test_balloon" ); - item cont_nest_rigid( "test_jug_large_open" ); - item rigid_obj( "test_rock" ); - item soft_obj( "test_rag" ); + item cont_top_soft( itype_test_backpack ); + item cont_nest_soft( itype_test_balloon ); + item cont_nest_rigid( itype_test_jug_large_open ); + item rigid_obj( itype_test_rock ); + item soft_obj( itype_test_rag ); map &m = get_map(); Character &u = get_player_character(); @@ -2059,7 +2106,7 @@ static void test_pickup_autoinsert_sub_sub( bool autopickup, bool wear, bool sof } else { cont2.remove_item(); } - item stack( "test_pine_nuts" ); + item stack( itype_test_pine_nuts ); item_location c = give_item_to_char( u, soft_nested ? cont2 : cont1 ); WHEN( "item stack too large to fit in top-level container" ) { stack.charges = 300; @@ -2086,7 +2133,7 @@ static void test_pickup_autoinsert_sub_sub( bool autopickup, bool wear, bool sof } else { cont2.remove_item(); } - item stack( "test_pine_nuts" ); + item stack( itype_test_pine_nuts ); item_location c = give_item_to_char( u, soft_nested ? cont2 : cont1 ); for( item_pocket *&pkts : c->get_contents().get_all_contained_pockets() ) { pkts->settings.blacklist_item( stack.typeId() ); @@ -2116,7 +2163,7 @@ static void test_pickup_autoinsert_sub_sub( bool autopickup, bool wear, bool sof } else { cont2.remove_item(); } - item stack( "test_pine_nuts" ); + item stack( itype_test_pine_nuts ); item_location c = give_item_to_char( u, soft_nested ? cont2 : cont1 ); for( item_pocket *&pkts : c->get_contents().get_all_contained_pockets() ) { pkts->settings.whitelist_item( obj2->typeId() ); @@ -2253,9 +2300,9 @@ TEST_CASE( "multipocket_liquid_transfer_test", "[pocket][item][liquid]" ) clear_avatar(); map &m = get_map(); Character &u = get_player_character(); - item water( "water" ); + item water( itype_water ); item cont_jug( itype_test_jug_plastic ); - item cont_suit( "test_robofac_armor_rig" ); + item cont_suit( itype_test_robofac_armor_rig ); // Place a container at the character's feet item_location jug_w_water( map_cursor( u.get_location() ), &m.add_item_or_charges( u.pos_bub(), @@ -2470,8 +2517,8 @@ TEST_CASE( "full_wallet_spawn_test", "[pocket][item]" ) TEST_CASE( "best_pocket_for_pocket-holster_mix", "[pocket][item]" ) { avatar &u = get_avatar(); - item tool_belt( "test_tool_belt_pocket_mix" ); - item flashlight( "test_flashlight" ); + item tool_belt( itype_test_tool_belt_pocket_mix ); + item flashlight( itype_test_flashlight ); GIVEN( "character wearing a tool belt" ) { clear_avatar(); @@ -2612,9 +2659,9 @@ TEST_CASE( "best_pocket_for_pocket-holster_mix", "[pocket][item]" ) TEST_CASE( "item_cannot_contain_contents_it_already_has", "[item][pocket]" ) { - item backpack( "test_backpack" ); - item bottle( "bottle_plastic" ); - item water( "water" ); + item backpack( itype_test_backpack ); + item bottle( itype_bottle_plastic ); + item water( itype_water ); water.charges = 1; bottle.fill_with( water, 1 ); @@ -2661,12 +2708,12 @@ TEST_CASE( "item_cannot_contain_contents_it_already_has", "[item][pocket]" ) TEST_CASE( "Sawed_off_fits_in_large_holster", "[item][pocket]" ) { - item double_barrel( "shotgun_d" ); - item large_holster( "XL_holster" ); + item double_barrel( itype_shotgun_d ); + item large_holster( itype_XL_holster ); //add the mods - double_barrel.put_in( item( "stock_none", calendar::turn ), pocket_type::MOD ); - double_barrel.put_in( item( "barrel_small", calendar::turn ), pocket_type::MOD ); + double_barrel.put_in( item( itype_stock_none, calendar::turn ), pocket_type::MOD ); + double_barrel.put_in( item( itype_barrel_small, calendar::turn ), pocket_type::MOD ); CHECK( large_holster.can_contain( double_barrel ).success() ); @@ -2676,9 +2723,9 @@ TEST_CASE( "Sawed_off_fits_in_large_holster", "[item][pocket]" ) // need to make sure we don't try to fit things larger than the parent pockets remaining volume inside the child pocket if it is non-rigid TEST_CASE( "bag_with_restrictions_and_nested_bag_does_not_fit_too_large_items", "[item][pocket]" ) { - item backpack( "test_backpack" ); - item backpack_two( "test_backpack" ); - item mini_backpack( "test_mini_backpack" ); + item backpack( itype_test_backpack ); + item backpack_two( itype_test_backpack ); + item mini_backpack( itype_test_mini_backpack ); mini_backpack.put_in( backpack, pocket_type::CONTAINER ); REQUIRE( !mini_backpack.is_container_empty() ); @@ -2700,8 +2747,8 @@ TEST_CASE( "pocket_leak" ) clear_map(); avatar &u = get_avatar(); map &here = get_map(); - item backpack( "test_backpack" ); - item water( "water" ); + item backpack( itype_test_backpack ); + item water( itype_water ); water.set_item_temperature( water.get_freeze_point() ); REQUIRE( water.is_frozen_liquid() ); REQUIRE( backpack.put_in( water, pocket_type::CONTAINER ).success() ); @@ -2721,7 +2768,7 @@ TEST_CASE( "pocket_leak" ) WHEN( "nested container" ) { bool const top_watertight = GENERATE( true, false ); CAPTURE( top_watertight ); - item top( top_watertight ? "55gal_drum" : "test_backpack" ); + item top( top_watertight ? itype_55gal_drum : itype_test_backpack ); REQUIRE( top.is_watertight_container() == top_watertight ); REQUIRE( top.put_in( backpack, pocket_type::CONTAINER ).success() ); u.wield( top ); @@ -2883,8 +2930,8 @@ TEST_CASE( "unload_from_spillable_container", "[item][pocket]" ) clear_map(); avatar &u = get_avatar(); map &here = get_map(); - item pill( "tums" ); // "antacid pill" - REQUIRE( u.wear_item( item( "backpack" ) ) ); + item pill( itype_tums ); // "antacid pill" + REQUIRE( u.wear_item( item( itype_backpack ) ) ); item_location backpack_loc = u.top_items_loc().front(); item *backpack = backpack_loc.get_item(); GIVEN( "spillable container contains two pillbottles, one with 4 pills and one with 1 pill" ) { @@ -2896,7 +2943,7 @@ TEST_CASE( "unload_from_spillable_container", "[item][pocket]" ) // It's a bit odd that we managed to put bottles into the frying // pan in the first place, since the pan would normally reject that // with a message stating that it would spill. - REQUIRE( backpack->put_in( item( "steel_pan" ), pocket_type::CONTAINER ).success() ); + REQUIRE( backpack->put_in( item( itype_steel_pan ), pocket_type::CONTAINER ).success() ); item *steelpan = backpack->all_items_top().front(); REQUIRE( steelpan->put_in( pill.in_its_container( 1 ), pocket_type::CONTAINER ).success() ); REQUIRE( steelpan->put_in( pill.in_its_container( 4 ), pocket_type::CONTAINER ).success() ); diff --git a/tests/item_test.cpp b/tests/item_test.cpp index f2caa0a34370a..8e4c13ebc0238 100644 --- a/tests/item_test.cpp +++ b/tests/item_test.cpp @@ -39,11 +39,54 @@ static const item_category_id item_category_guns( "guns" ); static const item_category_id item_category_spare_parts( "spare_parts" ); static const item_category_id item_category_tools( "tools" ); +static const itype_id itype_10gal_hat( "10gal_hat" ); +static const itype_id itype_ammonia_hydroxide( "ammonia_hydroxide" ); +static const itype_id itype_arm_splint( "arm_splint" ); +static const itype_id itype_arm_warmers( "arm_warmers" ); +static const itype_id itype_armor_mc_lightplate( "armor_mc_lightplate" ); +static const itype_id itype_aspirin( "aspirin" ); +static const itype_id itype_attachable_ear_muffs( "attachable_ear_muffs" ); +static const itype_id itype_backpack( "backpack" ); +static const itype_id itype_bag_plastic( "bag_plastic" ); +static const itype_id itype_battery( "battery" ); +static const itype_id itype_bottle_plastic_small( "bottle_plastic_small" ); +static const itype_id itype_butter( "butter" ); +static const itype_id itype_cash_card( "cash_card" ); +static const itype_id itype_chem_black_powder( "chem_black_powder" ); +static const itype_id itype_chem_muriatic_acid( "chem_muriatic_acid" ); +static const itype_id itype_detergent( "detergent" ); +static const itype_id itype_duffelbag( "duffelbag" ); +static const itype_id itype_gunpowder( "gunpowder" ); +static const itype_id itype_hammer( "hammer" ); +static const itype_id itype_hat_hard( "hat_hard" ); +static const itype_id itype_jeans( "jeans" ); +static const itype_id itype_legrig( "legrig" ); +static const itype_id itype_money( "money" ); +static const itype_id itype_neccowafers( "neccowafers" ); +static const itype_id itype_nitrox( "nitrox" ); +static const itype_id itype_pale_ale( "pale_ale" ); +static const itype_id itype_rocuronium( "rocuronium" ); +static const itype_id itype_shoulder_strap( "shoulder_strap" ); +static const itype_id itype_single_malt_whiskey( "single_malt_whiskey" ); +static const itype_id itype_software_hacking( "software_hacking" ); +static const itype_id itype_software_useless( "software_useless" ); +static const itype_id itype_test_armguard( "test_armguard" ); static const itype_id itype_test_backpack( "test_backpack" ); +static const itype_id itype_test_consolidate( "test_consolidate" ); static const itype_id itype_test_duffelbag( "test_duffelbag" ); +static const itype_id itype_test_exo_lense_module( "test_exo_lense_module" ); +static const itype_id itype_test_liquid( "test_liquid" ); +static const itype_id itype_test_modular_exosuit( "test_modular_exosuit" ); static const itype_id itype_test_mp3( "test_mp3" ); +static const itype_id itype_test_rock( "test_rock" ); static const itype_id itype_test_smart_phone( "test_smart_phone" ); static const itype_id itype_test_waterproof_bag( "test_waterproof_bag" ); +static const itype_id itype_towel( "towel" ); +static const itype_id itype_usb_drive( "usb_drive" ); +static const itype_id itype_walnut( "walnut" ); +static const itype_id itype_water( "water" ); +static const itype_id itype_win70( "win70" ); +static const itype_id itype_wrapper( "wrapper" ); static const json_character_flag json_flag_DEAF( "DEAF" ); @@ -51,7 +94,7 @@ TEST_CASE( "item_volume", "[item]" ) { // Need to pick some item here which is count_by_charges and for which each // charge is at least 1_ml. Battery works for now. - item i( "battery", calendar::turn_zero, item::default_charges_tag() ); + item i( itype_battery, calendar::turn_zero, item::default_charges_tag() ); REQUIRE( i.count_by_charges() ); // Would be better with Catch2 generators const units::volume big_volume = units::from_milliliter( std::numeric_limits::max() / 2 ); @@ -69,17 +112,17 @@ TEST_CASE( "item_volume", "[item]" ) TEST_CASE( "simple_item_layers", "[item]" ) { - CHECK( item( "arm_warmers" ).get_layer().front() == layer_level::SKINTIGHT ); - CHECK( item( "10gal_hat" ).get_layer().front() == layer_level::NORMAL ); + CHECK( item( itype_arm_warmers ).get_layer().front() == layer_level::SKINTIGHT ); + CHECK( item( itype_10gal_hat ).get_layer().front() == layer_level::NORMAL ); // intentionally no waist layer check since it is obsoleted - CHECK( item( "armor_mc_lightplate" ).get_layer().front() == layer_level::OUTER ); - CHECK( item( "legrig" ).get_layer().front() == layer_level::BELTED ); + CHECK( item( itype_armor_mc_lightplate ).get_layer().front() == layer_level::OUTER ); + CHECK( item( itype_legrig ).get_layer().front() == layer_level::BELTED ); } TEST_CASE( "gun_layer", "[item]" ) { - item gun( "win70" ); - item mod( "shoulder_strap" ); + item gun( itype_win70 ); + item mod( itype_shoulder_strap ); CHECK( gun.is_gunmod_compatible( mod ).success() ); gun.put_in( mod, pocket_type::MOD ); CHECK( gun.get_layer().front() == layer_level::BELTED ); @@ -89,11 +132,11 @@ TEST_CASE( "gun_layer", "[item]" ) TEST_CASE( "stacking_cash_cards", "[item]" ) { // Differently-charged cash cards should stack if neither is zero. - item cash0( "cash_card", calendar::turn_zero ); - item cash1( "cash_card", calendar::turn_zero ); - item cash2( "cash_card", calendar::turn_zero ); - cash1.put_in( item( "money", calendar::turn_zero, 1 ), pocket_type::MAGAZINE ); - cash2.put_in( item( "money", calendar::turn_zero, 2 ), pocket_type::MAGAZINE ); + item cash0( itype_cash_card, calendar::turn_zero ); + item cash1( itype_cash_card, calendar::turn_zero ); + item cash2( itype_cash_card, calendar::turn_zero ); + cash1.put_in( item( itype_money, calendar::turn_zero, 1 ), pocket_type::MAGAZINE ); + cash2.put_in( item( itype_money, calendar::turn_zero, 2 ), pocket_type::MAGAZINE ); CHECK( !cash0.stacks_with( cash1 ) ); //CHECK( cash1.stacks_with( cash2 ) ); Enable this once cash card stacking is brought back. } @@ -102,8 +145,8 @@ TEST_CASE( "stacking_cash_cards", "[item]" ) TEST_CASE( "stacking_over_time", "[item]" ) { - item A( "neccowafers" ); - item B( "neccowafers" ); + item A( itype_neccowafers ); + item B( itype_neccowafers ); GIVEN( "Two items with the same birthday" ) { REQUIRE( A.stacks_with( B ) ); @@ -199,9 +242,9 @@ TEST_CASE( "stacking_over_time", "[item]" ) TEST_CASE( "liquids_at_different_temperatures", "[item][temperature][stack][combine]" ) { - item liquid_hot( "test_liquid" ); - item liquid_cold( "test_liquid" ); - item liquid_filthy( "test_liquid" ); + item liquid_hot( itype_test_liquid ); + item liquid_cold( itype_test_liquid ); + item liquid_filthy( itype_test_liquid ); // heat_up/cold_up sets temperature of item and corresponding HOT/COLD flags liquid_hot.heat_up(); // 60 C (333.15 K) @@ -279,9 +322,9 @@ TEST_CASE( "corpse_length_sanity_check", "[item]" ) } } -static void check_spawning_in_container( const std::string &item_type ) +static void check_spawning_in_container( const itype_id &item_type ) { - item test_item{ itype_id( item_type ) }; + item test_item( item_type ); REQUIRE( test_item.type->default_container ); item container_item = test_item.in_its_container( 1 ); CHECK( container_item.typeId() == *test_item.type->default_container ); @@ -303,22 +346,22 @@ static void check_spawning_in_container( const std::string &item_type ) TEST_CASE( "items_spawn_in_their_default_containers", "[item]" ) { - check_spawning_in_container( "water" ); - check_spawning_in_container( "gunpowder" ); - check_spawning_in_container( "nitrox" ); - check_spawning_in_container( "ammonia_hydroxide" ); - check_spawning_in_container( "detergent" ); - check_spawning_in_container( "pale_ale" ); - check_spawning_in_container( "single_malt_whiskey" ); - check_spawning_in_container( "rocuronium" ); - check_spawning_in_container( "chem_muriatic_acid" ); - check_spawning_in_container( "chem_black_powder" ); - check_spawning_in_container( "software_useless" ); + check_spawning_in_container( itype_water ); + check_spawning_in_container( itype_gunpowder ); + check_spawning_in_container( itype_nitrox ); + check_spawning_in_container( itype_ammonia_hydroxide ); + check_spawning_in_container( itype_detergent ); + check_spawning_in_container( itype_pale_ale ); + check_spawning_in_container( itype_single_malt_whiskey ); + check_spawning_in_container( itype_rocuronium ); + check_spawning_in_container( itype_chem_muriatic_acid ); + check_spawning_in_container( itype_chem_black_powder ); + check_spawning_in_container( itype_software_useless ); } TEST_CASE( "item_variables_round-trip_accurately", "[item]" ) { - item i( "water" ); + item i( itype_water ); i.set_var( "A", 17 ); CHECK( i.get_var( "A", 0 ) == 17 ); i.set_var( "B", 0.125 ); @@ -334,13 +377,13 @@ TEST_CASE( "water_affect_items_while_swimming_check", "[item][water][swimming]" GIVEN( "an item with flag WATER_DISSOLVE" ) { - REQUIRE( item( "aspirin" ).has_flag( flag_WATER_DISSOLVE ) ); + REQUIRE( item( itype_aspirin ).has_flag( flag_WATER_DISSOLVE ) ); WHEN( "item in hand" ) { guy.unwield(); guy.clear_worn(); - item aspirin( "aspirin" ); + item aspirin( itype_aspirin ); REQUIRE( guy.wield( aspirin ) ); @@ -354,8 +397,8 @@ TEST_CASE( "water_affect_items_while_swimming_check", "[item][water][swimming]" guy.unwield(); guy.clear_worn(); - item aspirin( "aspirin" ); - item backpack( "backpack" ); + item aspirin( itype_aspirin ); + item backpack( itype_backpack ); backpack.put_in( aspirin, pocket_type::CONTAINER ); @@ -371,8 +414,8 @@ TEST_CASE( "water_affect_items_while_swimming_check", "[item][water][swimming]" guy.unwield(); guy.clear_worn(); - item aspirin( "aspirin" ); - item bottle_small( "bottle_plastic_small" ); + item aspirin( itype_aspirin ); + item bottle_small( itype_bottle_plastic_small ); bottle_small.put_in( aspirin, pocket_type::CONTAINER ); @@ -388,9 +431,9 @@ TEST_CASE( "water_affect_items_while_swimming_check", "[item][water][swimming]" guy.unwield(); guy.clear_worn(); - item aspirin( "aspirin" ); - item backpack( "backpack" ); - item duffelbag( "duffelbag" ); + item aspirin( itype_aspirin ); + item backpack( itype_backpack ); + item duffelbag( itype_duffelbag ); backpack.put_in( aspirin, pocket_type::CONTAINER ); duffelbag.put_in( backpack, pocket_type::CONTAINER ); @@ -407,9 +450,9 @@ TEST_CASE( "water_affect_items_while_swimming_check", "[item][water][swimming]" guy.unwield(); guy.clear_worn(); - item aspirin( "aspirin" ); - item backpack( "backpack" ); - item body_bag( "test_waterproof_bag" ); + item aspirin( itype_aspirin ); + item backpack( itype_backpack ); + item body_bag( itype_test_waterproof_bag ); backpack.put_in( aspirin, pocket_type::CONTAINER ); body_bag.put_in( backpack, pocket_type::CONTAINER ); @@ -468,7 +511,7 @@ TEST_CASE( "water_affect_items_while_swimming_check", "[item][water][swimming]" guy.clear_worn(); item smart_phone( itype_test_smart_phone ); - item body_bag( "test_waterproof_bag" ); + item body_bag( itype_test_waterproof_bag ); body_bag.put_in( smart_phone, pocket_type::CONTAINER ); @@ -664,7 +707,7 @@ TEST_CASE( "water_affect_items_while_swimming_check", "[item][water][swimming]" guy.unwield(); guy.clear_worn(); - item towel( "towel" ); + item towel( itype_towel ); REQUIRE( guy.wield( towel ) ); @@ -678,7 +721,7 @@ TEST_CASE( "water_affect_items_while_swimming_check", "[item][water][swimming]" guy.unwield(); guy.clear_worn(); - item towel( "towel" ); + item towel( itype_towel ); REQUIRE( guy.wear_item( towel ) ); @@ -692,8 +735,8 @@ TEST_CASE( "water_affect_items_while_swimming_check", "[item][water][swimming]" guy.unwield(); guy.clear_worn(); - item towel( "towel" ); - item backpack( "backpack" ); + item towel( itype_towel ); + item backpack( itype_backpack ); backpack.put_in( towel, pocket_type::CONTAINER ); @@ -709,8 +752,8 @@ TEST_CASE( "water_affect_items_while_swimming_check", "[item][water][swimming]" guy.unwield(); guy.clear_worn(); - item towel( "towel" ); - item body_bag( "test_waterproof_bag" ); + item towel( itype_towel ); + item body_bag( itype_test_waterproof_bag ); body_bag.put_in( towel, pocket_type::CONTAINER ); @@ -834,7 +877,7 @@ TEST_CASE( "item_material_density_blacklist_is_pruned", "[item]" ) TEST_CASE( "armor_entry_consolidate_check", "[item][armor]" ) { - item test_consolidate( "test_consolidate" ); + item test_consolidate( itype_test_consolidate ); //check this item has a single armor entry, not 3 like is written in the json explicitly @@ -849,8 +892,8 @@ TEST_CASE( "module_inheritance", "[item][armor]" ) guy.clear_mutations(); guy.clear_worn(); - item test_exo( "test_modular_exosuit" ); - item test_module( "test_exo_lense_module" ); + item test_exo( itype_test_modular_exosuit ); + item test_module( itype_test_exo_lense_module ); test_exo.force_insert_item( test_module, pocket_type::CONTAINER ); @@ -859,8 +902,8 @@ TEST_CASE( "module_inheritance", "[item][armor]" ) CHECK( guy.worn.worn_with_flag( json_flag_FIX_NEARSIGHT ) ); clear_avatar(); - item hat_hard( "hat_hard" ); - item ear_muffs( "attachable_ear_muffs" ); + item hat_hard( itype_hat_hard ); + item ear_muffs( itype_attachable_ear_muffs ); REQUIRE( hat_hard.put_in( ear_muffs, pocket_type::CONTAINER ).success() ); REQUIRE( !hat_hard.has_flag( json_flag_DEAF ) ); guy.wear_item( hat_hard ); @@ -875,7 +918,7 @@ TEST_CASE( "rigid_armor_compliance", "[item][armor]" ) avatar &guy = get_avatar(); clear_avatar(); // check if you can swap a rigid armor - item test_armguard( "test_armguard" ); + item test_armguard( itype_test_armguard ); REQUIRE( guy.wield( test_armguard ) ); REQUIRE( guy.wear( guy.used_weapon(), false ) ); @@ -889,15 +932,15 @@ TEST_CASE( "rigid_armor_compliance", "[item][armor]" ) // check if you can't wear 3 rigid armors clear_avatar(); - item first_test_armguard( "test_armguard" ); + item first_test_armguard( itype_test_armguard ); REQUIRE( guy.wield( first_test_armguard ) ); REQUIRE( guy.wear( guy.used_weapon(), false ) ); - item second_test_armguard( "test_armguard" ); + item second_test_armguard( itype_test_armguard ); REQUIRE( guy.wield( second_test_armguard ) ); REQUIRE( guy.wear( guy.used_weapon(), false ) ); - item third_test_armguard( "test_armguard" ); + item third_test_armguard( itype_test_armguard ); REQUIRE( guy.wield( third_test_armguard ) ); REQUIRE( !guy.wear( guy.used_weapon(), false ) ); } @@ -907,11 +950,11 @@ TEST_CASE( "rigid_splint_compliance", "[item][armor]" ) avatar &guy = get_avatar(); clear_avatar(); - item test_armguard( "test_armguard" ); - item second_test_armguard( "test_armguard" ); - item splint( "arm_splint" ); - item second_splint( "arm_splint" ); - item third_splint( "arm_splint" ); + item test_armguard( itype_test_armguard ); + item second_test_armguard( itype_test_armguard ); + item splint( itype_arm_splint ); + item second_splint( itype_arm_splint ); + item third_splint( itype_arm_splint ); // check if you can wear a splint clear_avatar(); @@ -950,10 +993,10 @@ TEST_CASE( "rigid_splint_compliance", "[item][armor]" ) TEST_CASE( "item_single_type_contents", "[item]" ) { - item rock( "test_rock" ); + item rock( itype_test_rock ); std::array const variants = { "test_rock_blue", "test_rock_green" }; - item walnut( "walnut" ); - item bag( "bag_plastic" ); + item walnut( itype_walnut ); + item bag( itype_bag_plastic ); REQUIRE( bag.get_category_of_contents().id == item_category_container ); int const num = GENERATE( 1, 2 ); bool ret = true; @@ -973,7 +1016,7 @@ TEST_CASE( "item_single_type_contents", "[item]" ) // 2 rock and 1 walnuts - rocks dominate CHECK( bag.get_category_of_contents().id == item_category_spare_parts ); REQUIRE( bag.put_in( walnut, pocket_type::CONTAINER ).success() ); - item hammer( "hammer" ); + item hammer( itype_hammer ); REQUIRE( hammer.get_category_of_contents().id != rock.get_category_of_contents().id ); REQUIRE( hammer.get_category_of_contents().id != walnut.get_category_of_contents().id ); REQUIRE( bag.put_in( hammer, pocket_type::CONTAINER ).success() ); @@ -982,7 +1025,7 @@ TEST_CASE( "item_single_type_contents", "[item]" ) } SECTION( "clothing" ) { - item jeans( "jeans" ); + item jeans( itype_jeans ); REQUIRE( jeans.get_category_of_contents().id == item_category_clothing ); REQUIRE( walnut.get_category_of_contents().id == item_category_food ); REQUIRE( jeans.put_in( walnut, pocket_type::CONTAINER ).success() ); @@ -990,8 +1033,8 @@ TEST_CASE( "item_single_type_contents", "[item]" ) } SECTION( "software" ) { - item usb_drive( "usb_drive" ); - item software_hacking( "software_hacking" ); + item usb_drive( itype_usb_drive ); + item software_hacking( itype_software_hacking ); REQUIRE( usb_drive.get_category_of_contents().id == item_category_tools ); REQUIRE( usb_drive.put_in( software_hacking, pocket_type::SOFTWARE ).success() ); CHECK( usb_drive.get_category_of_contents().id == item_category_tools ); @@ -1000,10 +1043,10 @@ TEST_CASE( "item_single_type_contents", "[item]" ) TEST_CASE( "item_nested_contents", "[item]" ) { - item walnut( "walnut" ); - item outer_bag( "bag_plastic" ); - item inner_bag1( "bag_plastic" ); - item inner_bag2( "bag_plastic" ); + item walnut( itype_walnut ); + item outer_bag( itype_bag_plastic ); + item inner_bag1( itype_bag_plastic ); + item inner_bag2( itype_bag_plastic ); REQUIRE( inner_bag1.put_in( walnut, pocket_type::CONTAINER ).success() ); REQUIRE( inner_bag1.put_in( walnut, pocket_type::CONTAINER ).success() ); @@ -1026,17 +1069,17 @@ TEST_CASE( "item_nested_contents", "[item]" ) TEST_CASE( "item_rotten_contents", "[item]" ) { - item wrapper( "wrapper" ); + item wrapper( itype_wrapper ); REQUIRE( wrapper.get_category_of_contents().id == item_category_container ); - item butter_rotten( "butter" ); + item butter_rotten( itype_butter ); butter_rotten.set_relative_rot( 1.01 ); REQUIRE( wrapper.put_in( butter_rotten, pocket_type::CONTAINER ).success() ); REQUIRE( wrapper.put_in( butter_rotten, pocket_type::CONTAINER ).success() ); CAPTURE( wrapper.display_name() ); CHECK( wrapper.get_category_of_contents().id == item_category_food ); - item butter( "butter" ); + item butter( itype_butter ); butter.set_relative_rot( 0.5 ); REQUIRE( wrapper.put_in( butter, pocket_type::CONTAINER ).success() ); CAPTURE( wrapper.display_name() ); diff --git a/tests/item_tick_action_test.cpp b/tests/item_tick_action_test.cpp index c3eb054656ae3..0bf1026b1256d 100644 --- a/tests/item_tick_action_test.cpp +++ b/tests/item_tick_action_test.cpp @@ -3,14 +3,17 @@ #include "item.h" #include "map.h" +static const itype_id itype_chainsaw_off( "chainsaw_off" ); +static const itype_id itype_chainsaw_on( "chainsaw_on" ); + TEST_CASE( "tick_action_triggering", "[item]" ) { - item chainsaw( "chainsaw_on" ); + item chainsaw( itype_chainsaw_on ); chainsaw.active = true; // The chainsaw has no fuel and turns off via its tick_action chainsaw.process( get_map(), nullptr, tripoint_bub_ms::zero ); - CHECK( chainsaw.typeId().str() == "chainsaw_off" ); + CHECK( chainsaw.typeId() == itype_chainsaw_off ); CHECK( chainsaw.active == false ); } diff --git a/tests/item_tname_test.cpp b/tests/item_tname_test.cpp index 6746a7375391c..09fc519da61f4 100644 --- a/tests/item_tname_test.cpp +++ b/tests/item_tname_test.cpp @@ -22,13 +22,39 @@ static const fault_id fault_gun_dirt( "fault_gun_dirt" ); static const item_category_id item_category_veh_parts( "veh_parts" ); +static const itype_id itype_backpack( "backpack" ); static const itype_id itype_backpack_hiking( "backpack_hiking" ); static const itype_id itype_bag_garbage( "bag_garbage" ); static const itype_id itype_bag_plastic( "bag_plastic" ); +static const itype_id itype_carrot( "carrot" ); +static const itype_id itype_coffee_pod( "coffee_pod" ); +static const itype_id itype_corpse( "corpse" ); static const itype_id itype_hammer( "hammer" ); +static const itype_id itype_hk_mp5( "hk_mp5" ); +static const itype_id itype_holster( "holster" ); +static const itype_id itype_jeans( "jeans" ); +static const itype_id itype_juniper( "juniper" ); +static const itype_id itype_katana( "katana" ); +static const itype_id itype_longshirt( "longshirt" ); +static const itype_id itype_milkshake( "milkshake" ); +static const itype_id itype_mushroom( "mushroom" ); +static const itype_id itype_pants( "pants" ); +static const itype_id itype_pepper( "pepper" ); +static const itype_id itype_pine_nuts( "pine_nuts" ); +static const itype_id itype_protein_bar_evac( "protein_bar_evac" ); static const itype_id itype_purse( "purse" ); static const itype_id itype_rock( "rock" ); +static const itype_id itype_salt( "salt" ); +static const itype_id itype_sauerkraut( "sauerkraut" ); +static const itype_id itype_sheet_cotton( "sheet_cotton" ); +static const itype_id itype_software_medical( "software_medical" ); +static const itype_id itype_test_baseball( "test_baseball" ); +static const itype_id itype_test_load_bearing_vest( "test_load_bearing_vest" ); static const itype_id itype_test_rock( "test_rock" ); +static const itype_id itype_usb_drive( "usb_drive" ); +static const itype_id itype_wheel( "wheel" ); +static const itype_id itype_wheel_armor( "wheel_armor" ); +static const itype_id itype_wheel_wide( "wheel_wide" ); static const skill_id skill_survival( "survival" ); @@ -57,7 +83,7 @@ TEST_CASE( "food_with_hidden_effects", "[item][tname][hidden]" ) player_character.clear_mutations(); GIVEN( "food with hidden poison" ) { - item coffee = item( "coffee_pod" ); + item coffee = item( itype_coffee_pod ); REQUIRE( coffee.is_food() ); REQUIRE( coffee.has_flag( flag_HIDDEN_POISON ) ); @@ -81,7 +107,7 @@ TEST_CASE( "food_with_hidden_effects", "[item][tname][hidden]" ) } GIVEN( "food with hidden hallucinogen" ) { - item mushroom = item( "mushroom" ); + item mushroom = item( itype_mushroom ); mushroom.set_flag( flag_HIDDEN_HALLU ); REQUIRE( mushroom.is_food() ); REQUIRE( mushroom.has_flag( flag_HIDDEN_HALLU ) ); @@ -109,7 +135,7 @@ TEST_CASE( "food_with_hidden_effects", "[item][tname][hidden]" ) TEST_CASE( "items_with_a_temperature_flag", "[item][tname][temperature]" ) { GIVEN( "food that can melt" ) { - item shake( "milkshake" ); + item shake( itype_milkshake ); REQUIRE( shake.is_food() ); REQUIRE( shake.has_flag( flag_MELTS ) ); @@ -140,7 +166,7 @@ TEST_CASE( "items_with_a_temperature_flag", "[item][tname][temperature]" ) } GIVEN( "food that cannot melt" ) { - item nut( "pine_nuts" ); + item nut( itype_pine_nuts ); REQUIRE( nut.is_food() ); REQUIRE_FALSE( nut.has_flag( flag_MELTS ) ); @@ -204,7 +230,7 @@ TEST_CASE( "items_with_a_temperature_flag", "[item][tname][temperature]" ) } GIVEN( "an item that is not food or a corpse" ) { - item hammer( "hammer" ); + item hammer( itype_hammer ); REQUIRE_FALSE( hammer.is_food() ); REQUIRE_FALSE( hammer.is_corpse() ); @@ -239,7 +265,7 @@ TEST_CASE( "items_with_a_temperature_flag", "[item][tname][temperature]" ) TEST_CASE( "wet_item", "[item][tname][wet]" ) { - item sheet_cotton( "sheet_cotton" ); + item sheet_cotton( itype_sheet_cotton ); sheet_cotton.set_flag( flag_WET ); REQUIRE( sheet_cotton.has_flag( flag_WET ) ); @@ -248,7 +274,7 @@ TEST_CASE( "wet_item", "[item][tname][wet]" ) TEST_CASE( "filthy_item", "[item][tname][filthy]" ) { - item sheet_cotton( "sheet_cotton" ); + item sheet_cotton( itype_sheet_cotton ); sheet_cotton.set_flag( flag_FILTHY ); REQUIRE( sheet_cotton.is_filthy() ); @@ -257,7 +283,7 @@ TEST_CASE( "filthy_item", "[item][tname][filthy]" ) TEST_CASE( "diamond_item", "[item][tname][diamond]" ) { - item katana( "katana" ); + item katana( itype_katana ); katana.set_flag( flag_DIAMOND ); REQUIRE( katana.has_flag( flag_DIAMOND ) ); @@ -266,9 +292,9 @@ TEST_CASE( "diamond_item", "[item][tname][diamond]" ) TEST_CASE( "wheel_diameter", "[item][tname][wheel]" ) { - item wheel17 = item( "wheel" ); - item wheel24 = item( "wheel_wide" ); - item wheel32 = item( "wheel_armor" ); + item wheel17 = item( itype_wheel ); + item wheel24 = item( itype_wheel_wide ); + item wheel32 = item( itype_wheel_armor ); REQUIRE( wheel17.type->wheel->diameter == 17 ); REQUIRE( wheel24.type->wheel->diameter == 24 ); @@ -282,8 +308,8 @@ TEST_CASE( "wheel_diameter", "[item][tname][wheel]" ) TEST_CASE( "item_health_or_damage_bar", "[item][tname][health][damage]" ) { GIVEN( "some clothing" ) { - item shirt( "longshirt" ); - item deg_test( "test_baseball" ); + item shirt( itype_longshirt ); + item deg_test( itype_test_baseball ); REQUIRE( shirt.is_armor() ); REQUIRE( deg_test.type->category_force == item_category_veh_parts ); @@ -411,8 +437,8 @@ TEST_CASE( "item_health_or_damage_bar", "[item][tname][health][damage]" ) GIVEN( "ITEM_HEALTH option set to 'desc'" ) { override_option opt( "ITEM_HEALTH", "descriptions" ); - item shirt( "longshirt" ); - item corpse( "corpse" ); + item shirt( itype_longshirt ); + item corpse( itype_corpse ); REQUIRE( shirt.is_armor() ); int dam25 = shirt.max_damage() / 4; @@ -510,7 +536,7 @@ TEST_CASE( "item_health_or_damage_bar", "[item][tname][health][damage]" ) GIVEN( "ITEM_HEALTH option set to 'both'" ) { override_option opt( "ITEM_HEALTH", "both" ); - item shirt( "longshirt" ); + item shirt( itype_longshirt ); REQUIRE( shirt.is_armor() ); int dam25 = shirt.max_damage() / 4; @@ -581,7 +607,7 @@ TEST_CASE( "item_health_or_damage_bar", "[item][tname][health][damage]" ) TEST_CASE( "weapon_fouling", "[item][tname][fouling][dirt]" ) { GIVEN( "a gun with potential fouling" ) { - item gun( "hk_mp5" ); + item gun( itype_hk_mp5 ); Character &player_character = get_player_character(); // Ensure the player and gun are normal size to prevent "too big" or "too small" suffix in tname @@ -642,8 +668,8 @@ TEST_CASE( "weapon_fouling", "[item][tname][fouling][dirt]" ) // make sure ordering still works with pockets TEST_CASE( "molle_vest_additional_pockets", "[item][tname]" ) { - item addition_vest( "test_load_bearing_vest" ); - addition_vest.get_contents().add_pocket( item( "holster" ) ); + item addition_vest( itype_test_load_bearing_vest ); + addition_vest.get_contents().add_pocket( item( itype_holster ) ); CHECK( addition_vest.tname( 1 ) == "++\u00A0load bearing vest+1" ); @@ -793,8 +819,8 @@ TEST_CASE( "nested_items_tname", "[item][tname]" ) } SECTION( "non-standard pocket: software" ) { - item usb_drive( "usb_drive" ); - item medisoft( "software_medical" ); + item usb_drive( itype_usb_drive ); + item medisoft( itype_software_medical ); std::string const medisoft_nested_tname = colorize( medisoft.tname(), medisoft.color_in_inventory() ); REQUIRE( usb_drive.is_software_storage() ); @@ -808,13 +834,13 @@ TEST_CASE( "nested_items_tname", "[item][tname]" ) type_only.set( tname::segments::TYPE ); SECTION( "aggregated food stats" ) { avatar &u = get_avatar(); - item salt( "salt" ); + item salt( itype_salt ); std::string const cat_food_str = salt.get_category_shallow().name_noun( 2 ); - item pepper( "pepper" ); - item juniper( "juniper" ); - item ration( "protein_bar_evac" ); - item carrot( "carrot" ); - item sauerkraut( "sauerkraut" ); + item pepper( itype_pepper ); + item juniper( itype_juniper ); + item ration( itype_protein_bar_evac ); + item carrot( itype_carrot ); + item sauerkraut( itype_sauerkraut ); item bag( itype_bag_plastic ); std::string const carrots_tname = carrot.tname( 2, type_only ); @@ -899,11 +925,11 @@ TEST_CASE( "nested_items_tname", "[item][tname]" ) } SECTION( "aggregated clothing stats" ) { - item pants( "pants" ); + item pants( itype_pants ); pants.clear_itype_variant(); pants.set_flag( flag_FIT ); bool same_item = GENERATE( true, false ); - item second_item( same_item ? "pants" : "jeans" ); + item second_item( same_item ? itype_pants : itype_jeans ); second_item.clear_itype_variant(); second_item.set_flag( flag_FIT ); REQUIRE( ( pants.has_flag( flag_VARSIZE ) && second_item.has_flag( flag_VARSIZE ) ) ); @@ -951,7 +977,7 @@ TEST_CASE( "nested_items_tname", "[item][tname]" ) #ifdef LOCALIZE TEST_CASE( "tname_i18n_order", "[item][tname][translations]" ) { - item backpack( "backpack" ); + item backpack( itype_backpack ); backpack.burnt = 1; backpack.set_flag( flag_FILTHY ); REQUIRE( backpack.tname() == "++ burnt backpack (filthy)" ); diff --git a/tests/item_type_name_test.cpp b/tests/item_type_name_test.cpp index 516acc06560b6..c8f26fa58dc4b 100644 --- a/tests/item_type_name_test.cpp +++ b/tests/item_type_name_test.cpp @@ -8,6 +8,7 @@ // Test cases focused on item::type_name static const itype_id itype_blood( "blood" ); +static const itype_id itype_shotgun_410( "shotgun_410" ); static const itype_id itype_test_block_of_cheese( "test_block_of_cheese" ); static const itype_id itype_test_book( "test_book" ); static const itype_id itype_test_food( "test_food" ); @@ -86,7 +87,7 @@ TEST_CASE( "item_name_pluralization", "[item][type_name][plural]" ) TEST_CASE( "custom_named_item", "[item][type_name][named]" ) { // Shop smart. Shop S-Mart. - item shotgun( "shotgun_410" ); + item shotgun( itype_shotgun_410 ); shotgun.set_var( "name", "Boomstick" ); REQUIRE( shotgun.get_var( "name" ) == "Boomstick" ); @@ -97,7 +98,7 @@ TEST_CASE( "blood_item", "[item][type_name][blood]" ) { SECTION( "blood from a zombie corpse" ) { item corpse = item::make_corpse( mon_zombie ); - item blood( "blood" ); + item blood( itype_blood ); blood.set_mtype( corpse.get_mtype() ); REQUIRE( blood.typeId() == itype_blood ); REQUIRE_FALSE( blood.is_corpse() ); @@ -107,7 +108,7 @@ TEST_CASE( "blood_item", "[item][type_name][blood]" ) SECTION( "blood from a chicken corpse" ) { item corpse = item::make_corpse( mon_chicken ); - item blood( "blood" ); + item blood( itype_blood ); blood.set_mtype( corpse.get_mtype() ); REQUIRE( blood.typeId() == itype_blood ); REQUIRE_FALSE( blood.is_corpse() ); @@ -116,7 +117,7 @@ TEST_CASE( "blood_item", "[item][type_name][blood]" ) } SECTION( "blood from an unknown corpse" ) { - item blood( "blood" ); + item blood( itype_blood ); REQUIRE( blood.typeId() == itype_blood ); REQUIRE_FALSE( blood.is_corpse() ); diff --git a/tests/iteminfo_test.cpp b/tests/iteminfo_test.cpp index 5421aef027d28..00d30fd1d1489 100644 --- a/tests/iteminfo_test.cpp +++ b/tests/iteminfo_test.cpp @@ -24,9 +24,27 @@ #include "units.h" #include "value_ptr.h" +static const itype_id itype_attachable_ear_muffs( "attachable_ear_muffs" ); +static const itype_id itype_backpack( "backpack" ); +static const itype_id itype_ballistic_vest_esapi( "ballistic_vest_esapi" ); +static const itype_id itype_bio_ethanol( "bio_ethanol" ); +static const itype_id itype_bio_nostril( "bio_nostril" ); +static const itype_id itype_bio_power_storage( "bio_power_storage" ); +static const itype_id itype_bio_purifier( "bio_purifier" ); +static const itype_id itype_candle( "candle" ); static const itype_id itype_candle_wax( "candle_wax" ); static const itype_id itype_dress_shirt( "dress_shirt" ); +static const itype_id itype_face_shield( "face_shield" ); +static const itype_id itype_hat_hard( "hat_hard" ); +static const itype_id itype_icecream( "icecream" ); +static const itype_id itype_iodine( "iodine" ); static const itype_id itype_match( "match" ); +static const itype_id itype_medium_battery_cell( "medium_battery_cell" ); +static const itype_id itype_nape_protector( "nape_protector" ); +static const itype_id itype_oxy_torch( "oxy_torch" ); +static const itype_id itype_test_2x4( "test_2x4" ); +static const itype_id itype_test_9mm_ammo( "test_9mm_ammo" ); +static const itype_id itype_test_apple( "test_apple" ); static const itype_id itype_test_armor_chitin( "test_armor_chitin" ); static const itype_id itype_test_armor_chitin_copy( "test_armor_chitin_copy" ); static const itype_id itype_test_armor_chitin_copy_prop( "test_armor_chitin_copy_prop" ); @@ -36,6 +54,54 @@ static const itype_id itype_test_armor_chitin_copy_w_armor_prop( "test_armor_chitin_copy_w_armor_prop" ); static const itype_id itype_test_armor_chitin_copy_w_armor_rel( "test_armor_chitin_copy_w_armor_rel" ); +static const itype_id itype_test_arrow_wood( "test_arrow_wood" ); +static const itype_id itype_test_backpack( "test_backpack" ); +static const itype_id itype_test_balloon( "test_balloon" ); +static const itype_id itype_test_battery_disposable( "test_battery_disposable" ); +static const itype_id itype_test_bitter_almond( "test_bitter_almond" ); +static const itype_id itype_test_brew_wine( "test_brew_wine" ); +static const itype_id itype_test_briefcase( "test_briefcase" ); +static const itype_id itype_test_cmdline_book( "test_cmdline_book" ); +static const itype_id itype_test_compbow( "test_compbow" ); +static const itype_id itype_test_complex_tanktop( "test_complex_tanktop" ); +static const itype_id itype_test_condom( "test_condom" ); +static const itype_id itype_test_cordless_drill( "test_cordless_drill" ); +static const itype_id itype_test_crafted_suppressor( "test_crafted_suppressor" ); +static const itype_id itype_test_dragon_book( "test_dragon_book" ); +static const itype_id itype_test_ear_plugs( "test_ear_plugs" ); +static const itype_id itype_test_fire_ax( "test_fire_ax" ); +static const itype_id itype_test_glock( "test_glock" ); +static const itype_id itype_test_gum( "test_gum" ); +static const itype_id itype_test_halligan( "test_halligan" ); +static const itype_id itype_test_hallu_nutmeg( "test_hallu_nutmeg" ); +static const itype_id itype_test_hazmat_suit( "test_hazmat_suit" ); +static const itype_id itype_test_jack_small( "test_jack_small" ); +static const itype_id itype_test_jug_plastic( "test_jug_plastic" ); +static const itype_id itype_test_longshirt( "test_longshirt" ); +static const itype_id itype_test_matches( "test_matches" ); +static const itype_id itype_test_meower_armor( "test_meower_armor" ); +static const itype_id itype_test_nuclear_carafe( "test_nuclear_carafe" ); +static const itype_id itype_test_pants_faux_fur( "test_pants_faux_fur" ); +static const itype_id itype_test_pine_nuts( "test_pine_nuts" ); +static const itype_id itype_test_pipe( "test_pipe" ); +static const itype_id itype_test_plate( "test_plate" ); +static const itype_id itype_test_pointy_stick( "test_pointy_stick" ); +static const itype_id itype_test_portion_faux_fur_pants_suit( "test_portion_faux_fur_pants_suit" ); +static const itype_id itype_test_power_armor( "test_power_armor" ); +static const itype_id itype_test_quiver( "test_quiver" ); +static const itype_id itype_test_rag( "test_rag" ); +static const itype_id itype_test_rock( "test_rock" ); +static const itype_id itype_test_sheet_metal( "test_sheet_metal" ); +static const itype_id itype_test_smart_phone( "test_smart_phone" ); +static const itype_id itype_test_socks( "test_socks" ); +static const itype_id itype_test_soldering_iron( "test_soldering_iron" ); +static const itype_id itype_test_sonic_screwdriver( "test_sonic_screwdriver" ); +static const itype_id itype_test_swat_armor( "test_swat_armor" ); +static const itype_id itype_test_thumb( "test_thumb" ); +static const itype_id itype_test_tool_belt_pocket_mix( "test_tool_belt_pocket_mix" ); +static const itype_id itype_test_waterskin( "test_waterskin" ); +static const itype_id itype_test_wine( "test_wine" ); +static const itype_id itype_test_zentai_resist_stab_cut( "test_zentai_resist_stab_cut" ); static const itype_id itype_textbook_chemistry( "textbook_chemistry" ); static const itype_id itype_tshirt( "tshirt" ); static const itype_id itype_zentai( "zentai" ); @@ -120,7 +186,7 @@ TEST_CASE( "item_volume_and_weight", "[iteminfo][volume][weight]" ) { clear_avatar(); - item plank( "test_2x4" ); + item plank( itype_test_2x4 ); // Volume and weight are shown together, though the units may differ std::vector vol_weight = { iteminfo_parts::BASE_VOLUME, iteminfo_parts::BASE_WEIGHT }; @@ -184,7 +250,7 @@ TEST_CASE( "item_material_category_description", "[iteminfo][material][category] std::vector description = { iteminfo_parts::DESCRIPTION }; SECTION( "fire ax" ) { - item axe( "test_fire_ax" ); + item axe( itype_test_fire_ax ); CHECK( item_info_str( axe, material ) == "Material: Steel, Wood\n" ); @@ -198,7 +264,7 @@ TEST_CASE( "item_material_category_description", "[iteminfo][material][category] } SECTION( "plank" ) { - item plank( "test_2x4" ); + item plank( itype_test_2x4 ); CHECK( item_info_str( plank, material ) == "Material: Wood\n" ); @@ -223,14 +289,14 @@ TEST_CASE( "item_owner", "[iteminfo][owner]" ) clear_avatar(); SECTION( "item owned by player" ) { - item my_rock( "test_rock" ); + item my_rock( itype_test_rock ); my_rock.set_owner( get_player_character() ); REQUIRE_FALSE( my_rock.get_owner().is_null() ); CHECK( item_info_str( my_rock, { iteminfo_parts::BASE_OWNER } ) == "Owner: Your Followers\n" ); } SECTION( "item with no owner" ) { - item nobodys_rock( "test_rock" ); + item nobodys_rock( itype_test_rock ); REQUIRE( nobodys_rock.get_owner().is_null() ); CHECK( item_info_str( nobodys_rock, { iteminfo_parts::BASE_OWNER } ).empty() ); } @@ -256,8 +322,8 @@ TEST_CASE( "item_requirements", "[iteminfo][requirements]" ) std::vector reqs = { iteminfo_parts::BASE_REQUIREMENTS }; - item compbow( "test_compbow" ); - item sonic( "test_sonic_screwdriver" ); + item compbow( itype_test_compbow ); + item sonic( itype_test_sonic_screwdriver ); REQUIRE( compbow.type->min_str == 6 ); CHECK( item_info_str( compbow, reqs ) == @@ -284,7 +350,7 @@ TEST_CASE( "iteminfo_contents", "[iteminfo][contents]" ) // Amount is shown for items having count_by_charges(), and are not food or medication // This includes all kinds of ammo and arrows, thread, and some chemicals like sulfur. - item ammo( "test_9mm_ammo" ); + item ammo( itype_test_9mm_ammo ); std::vector amount = { iteminfo_parts::BASE_AMOUNT }; CHECK( item_info_str( ammo, amount ) == "--\nAmount: 50\n" ); } @@ -313,7 +379,7 @@ TEST_CASE( "med_info", "[iteminfo][med]" ) // Items with comestible_type "MED" SECTION( "item that is medication shows medicinal attributes in med_info" ) { - item gum( "test_gum" ); + item gum( itype_test_gum ); REQUIRE( gum.is_medication() ); CHECK( item_info_str( gum, quench ) == @@ -336,7 +402,7 @@ TEST_CASE( "med_info", "[iteminfo][med]" ) } SECTION( "item that is not medication does not show med_info" ) { - item apple( "test_apple" ); + item apple( itype_test_apple ); REQUIRE_FALSE( apple.is_medication() ); CHECK( item_info_str( apple, quench ).empty() ); @@ -362,7 +428,7 @@ TEST_CASE( "item_price_and_barter_value", "[iteminfo][price]" ) std::vector price_barter = { iteminfo_parts::BASE_PRICE, iteminfo_parts::BASE_BARTER }; SECTION( "item with different price and barter value" ) { - item pipe( "test_pipe" ); + item pipe( itype_test_pipe ); REQUIRE( pipe.price( false ) == 7500 ); REQUIRE( pipe.price( true ) == 300 ); @@ -372,7 +438,7 @@ TEST_CASE( "item_price_and_barter_value", "[iteminfo][price]" ) } SECTION( "item with same price and barter value shows only price" ) { - item nuts( "test_pine_nuts" ); + item nuts( itype_test_pine_nuts ); REQUIRE( nuts.price( false ) == 136 ); REQUIRE( nuts.price( true ) == 136 ); @@ -382,7 +448,7 @@ TEST_CASE( "item_price_and_barter_value", "[iteminfo][price]" ) } SECTION( "item with no price or barter value" ) { - item rock( "test_rock" ); + item rock( itype_test_rock ); REQUIRE( rock.price( false ) == 0 ); REQUIRE( rock.price( true ) == 0 ); @@ -411,7 +477,7 @@ TEST_CASE( "item_rigidity", "[iteminfo][rigidity]" ) std::vector encumbrance = { iteminfo_parts::ARMOR_ENCUMBRANCE }; SECTION( "items with rigid pockets have a single encumbrance value" ) { - item briefcase( "test_briefcase" ); + item briefcase( itype_test_briefcase ); REQUIRE( briefcase.all_pockets_rigid() ); CHECK( item_info_str( briefcase, encumbrance ) == "--\n" @@ -420,10 +486,10 @@ TEST_CASE( "item_rigidity", "[iteminfo][rigidity]" ) } SECTION( "non-rigid items indicate their flexible volume/encumbrance" ) { - item waterskin( "test_waterskin" ); - item backpack( "test_backpack" ); - item quiver( "test_quiver" ); - item condom( "test_condom" ); + item waterskin( itype_test_waterskin ); + item backpack( itype_test_backpack ); + item quiver( itype_test_quiver ); + item condom( itype_test_condom ); SECTION( "rigidity indicator" ) { REQUIRE_FALSE( waterskin.all_pockets_rigid() ); @@ -492,11 +558,11 @@ TEST_CASE( "weapon_attack_ratings_and_moves", "[iteminfo][weapon]" ) REQUIRE( player_character.get_str() == 8 ); REQUIRE( player_character.get_dex() == 8 ); - item rag( "test_rag" ); - item rock( "test_rock" ); - item halligan( "test_halligan" ); - item mr_pointy( "test_pointy_stick" ); - item arrow( "test_arrow_wood" ); + item rag( itype_test_rag ); + item rock( itype_test_rock ); + item halligan( itype_test_halligan ); + item mr_pointy( itype_test_pointy_stick ); + item arrow( itype_test_arrow_wood ); SECTION( "melee damage" ) { // Melee damage comes from the "bashing" and "cutting" attributes in JSON @@ -706,7 +772,7 @@ TEST_CASE( "techniques_when_wielded", "[iteminfo][weapon][techniques]" ) { clear_avatar(); - item halligan( "test_halligan" ); + item halligan( itype_test_halligan ); CHECK( item_info_str( halligan, { iteminfo_parts::DESCRIPTION_TECHNIQUES } ) == "--\n" "Techniques when wielded:" @@ -717,7 +783,7 @@ TEST_CASE( "techniques_when_wielded", "[iteminfo][weapon][techniques]" ) " Block:" " Medium blocking ability \n" ); - item plank( "test_2x4" ); + item plank( itype_test_2x4 ); CHECK( item_info_str( plank, { iteminfo_parts::DESCRIPTION_TECHNIQUES } ) == "--\n" "Techniques when wielded:" @@ -777,7 +843,7 @@ TEST_CASE( "armor_coverage_warmth_and_encumbrance", "[iteminfo][armor][coverage] SECTION( "armor with coverage shows covered body parts, warmth, encumbrance, and protection values" ) { // Long-sleeved shirt covering torso and arms - item longshirt( "test_longshirt" ); + item longshirt( itype_test_longshirt ); verify_item_coverage( longshirt, { { bodypart_id( "torso" ), 90 }, @@ -852,7 +918,7 @@ TEST_CASE( "armor_coverage_warmth_and_encumbrance", "[iteminfo][armor][coverage] "Encumbrance" " 3: The arms. The torso.\n" ); - item swat_armor( "test_swat_armor" ); + item swat_armor( itype_test_swat_armor ); REQUIRE( swat_armor.get_covered_body_parts().any() ); CHECK( item_info_str( swat_armor, { iteminfo_parts::ARMOR_BODYPARTS } ) == @@ -933,7 +999,7 @@ TEST_CASE( "armor_coverage_warmth_and_encumbrance", "[iteminfo][armor][coverage] " The torso.\n" ); // Test copy-from - item faux_fur_pants( "test_pants_faux_fur" ); + item faux_fur_pants( itype_test_pants_faux_fur ); REQUIRE( faux_fur_pants.get_covered_body_parts().any() ); CHECK( item_info_str( faux_fur_pants, { iteminfo_parts::ARMOR_BODYPARTS } ) == @@ -1002,7 +1068,7 @@ TEST_CASE( "armor_coverage_warmth_and_encumbrance", "[iteminfo][armor][coverage] } ); - item faux_fur_suit( "test_portion_faux_fur_pants_suit" ); + item faux_fur_suit( itype_test_portion_faux_fur_pants_suit ); REQUIRE( faux_fur_suit.get_covered_body_parts().any() ); CHECK( item_info_str( faux_fur_suit, { iteminfo_parts::ARMOR_BODYPARTS } ) == @@ -1092,7 +1158,7 @@ TEST_CASE( "armor_coverage_warmth_and_encumbrance", "[iteminfo][armor][coverage] " The r. leg." " The torso.\n" ); // test complex materials armors - item super_tank_top( "test_complex_tanktop" ); + item super_tank_top( itype_test_complex_tanktop ); REQUIRE( super_tank_top.get_covered_body_parts().any() ); CHECK( item_info_str( super_tank_top, { iteminfo_parts::ARMOR_BODYPARTS } ) == @@ -1151,7 +1217,7 @@ TEST_CASE( "armor_coverage_warmth_and_encumbrance", "[iteminfo][armor][coverage] SECTION( "armor with no coverage omits irrelevant info" ) { // Ear plugs with no coverage, and no other info to display - item ear_plugs( "test_ear_plugs" ); + item ear_plugs( itype_test_ear_plugs ); REQUIRE_FALSE( ear_plugs.get_covered_body_parts().any() ); CHECK( item_info_str( ear_plugs, { iteminfo_parts::ARMOR_BODYPARTS, @@ -1171,7 +1237,7 @@ TEST_CASE( "armor_rigidity", "[iteminfo][armor][coverage]" ) clear_avatar(); // test complex materials armors - item super_tank_top( "test_complex_tanktop" ); + item super_tank_top( itype_test_complex_tanktop ); REQUIRE( super_tank_top.get_covered_body_parts().any() ); CHECK( item_info_str( super_tank_top, { iteminfo_parts::ARMOR_RIGIDITY } ) == @@ -1202,18 +1268,18 @@ TEST_CASE( "armor_fit_and_sizing", "[iteminfo][armor][fit]" ) //std::vector powerarmor_rad = { iteminfo_parts::DESCRIPTION_FLAGS_POWERARMOR_RADIATIONHINT }; // Items with VARSIZE flag can be fitted - item socks( "test_socks" ); + item socks( itype_test_socks ); CHECK( item_info_str( socks, varsize ) == "--\n" "* This clothing can be refitted.\n" ); // Sided armor is show as sided - item briefcase( "test_briefcase" ); + item briefcase( itype_test_briefcase ); CHECK( item_info_str( briefcase, sided ) == "--\n" "* This item can be worn on either side of the body.\n" ); - item power_armor( "test_power_armor" ); + item power_armor( itype_test_power_armor ); CHECK_THAT( item_info_str( power_armor, powerarmor ), Catch::EndsWith( "* This gear is a part of power armor.\n" ) ); } @@ -1247,7 +1313,7 @@ TEST_CASE( "helmet_with_pockets_stats", "[iteminfo][armor][protection]" ) bodypart_id bp_eyes = body_part_eyes.id(); sub_bodypart_id eye_r = sub_body_part_eyes_right.id(); - item hh( "hat_hard" ); + item hh( itype_hat_hard ); THEN( "base stats" ) { //resistance stats CHECK( hh.resist( STATIC( damage_type_id( "bash" ) ), false, bp_head ) == Approx( 8.f ) ); @@ -1260,7 +1326,7 @@ TEST_CASE( "helmet_with_pockets_stats", "[iteminfo][armor][protection]" ) WHEN( "inserting face shield" ) { - item face_shield( "face_shield" ); + item face_shield( itype_face_shield ); REQUIRE( hh.put_in( face_shield, pocket_type::CONTAINER ).success() ); THEN( "eyes should be protected" ) { CHECK( hh.resist( STATIC( damage_type_id( "bash" ) ), false, bp_head ) == Approx( 8.f ) ); @@ -1276,7 +1342,7 @@ TEST_CASE( "helmet_with_pockets_stats", "[iteminfo][armor][protection]" ) } } WHEN( "adding nape protector to the helmet" ) { - item nape_protector( "nape_protector" ); + item nape_protector( itype_nape_protector ); REQUIRE( hh.put_in( nape_protector, pocket_type::CONTAINER ).success() ); THEN( "head's warmth is increased" ) { CHECK( nape_protector.get_warmth( bp_head ) == 2 ); @@ -1284,7 +1350,7 @@ TEST_CASE( "helmet_with_pockets_stats", "[iteminfo][armor][protection]" ) CHECK( hh.get_warmth( bp_head ) == 4 ); } WHEN( "adding ear muffs to the helmet" ) { - item ear_muffs( "attachable_ear_muffs" ); + item ear_muffs( itype_attachable_ear_muffs ); REQUIRE( hh.put_in( ear_muffs, pocket_type::CONTAINER ).success() ); THEN( "head's warmth should be increased even more" ) { CHECK( ear_muffs.get_warmth( bp_head ) == 2 ); @@ -1300,13 +1366,13 @@ TEST_CASE( "vest_with_plate_stats", "[iteminfo][armor][protection]" ) { bodypart_id bp_torso = body_part_torso.id(); - item vest = item( "ballistic_vest_esapi" ); + item vest = item( itype_ballistic_vest_esapi ); //nylon: 1 (mat resist) * 1 (thickness) //kevlar: 1.5 * 4.4 CHECK( vest.resist( STATIC( damage_type_id( "bash" ) ), false, bp_torso ) == Approx( 7.6f ) ); WHEN( "inserting plate" ) { - CHECK( vest.put_in( item( "test_plate" ), pocket_type::CONTAINER ).success() ); + CHECK( vest.put_in( item( itype_test_plate ), pocket_type::CONTAINER ).success() ); THEN( "resist should be increased" ) { //previous + 1 * 25 @@ -1355,7 +1421,7 @@ TEST_CASE( "armor_protection", "[iteminfo][armor][protection]" ) // Long-sleeved shirt, material:cotton, thickness:0.2 // 1/1/1 bash/cut/bullet x 1 thickness // 0/0/0 acid/fire/env - item longshirt( "test_longshirt" ); + item longshirt( itype_test_longshirt ); expected_armor_values( longshirt, 0.2f, 0.2f, 0.16f, 0.2f ); REQUIRE( longshirt.get_covered_body_parts().any() ); @@ -1374,7 +1440,7 @@ TEST_CASE( "armor_protection", "[iteminfo][armor][protection]" ) // Hazmat suit, material:plastic, thickness:2 // 2/2/1 bash/cut/bullet x 2 thickness // 9/1/20 acid/fire/env - item hazmat( "test_hazmat_suit" ); + item hazmat( itype_test_hazmat_suit ); REQUIRE( hazmat.get_covered_body_parts().any() ); expected_armor_values( hazmat, 4, 4, 3.2, 2, 9, 1, 20 ); @@ -1421,7 +1487,7 @@ TEST_CASE( "armor_protection", "[iteminfo][armor][protection]" ) SECTION( "check that material resistances are properly overriden" ) { // Zentai suit, material:lycra_resist_override_stab, thickness:1 // 2/2/2/50 bash/cut/bullet/stab x 1 thickness - item zentai( "test_zentai_resist_stab_cut" ); + item zentai( itype_test_zentai_resist_stab_cut ); REQUIRE( zentai.get_covered_body_parts().any() ); expected_armor_values( zentai, 2, 2, 50, 2, 9, 2, 10 ); @@ -1467,7 +1533,7 @@ TEST_CASE( "armor_protection", "[iteminfo][armor][protection]" ) } SECTION( "complex protection from physical and environmental damage" ) { - item super_tanktop( "test_complex_tanktop" ); + item super_tanktop( itype_test_complex_tanktop ); REQUIRE( super_tanktop.get_covered_body_parts().any() ); // these values are averaged values but test that assumed armor portion is working at all expected_armor_values( super_tanktop, 15.33333f, 15.33333f, 12.26667f, 10.66667f ); @@ -1507,7 +1573,7 @@ TEST_CASE( "armor_protection", "[iteminfo][armor][protection]" ) // material:layered_kevlar, thickness:2 // 1.5/2/5 bash/cut/bullet x 2 thickness // 5/3/10 acid/fire/env - item meower_armor( "test_meower_armor" ); + item meower_armor( itype_test_meower_armor ); expected_armor_values( meower_armor, 3, 4, 3.2, 10, 5, 3, 10 ); const std::string info = item_info_str( meower_armor, protection ); @@ -1556,8 +1622,8 @@ TEST_CASE( "book_info", "[iteminfo][book]" ) // std::vector num_unread = { iteminfo_parts::BOOK_NUMUNREADCHAPTERS }; // std::vector included_recipes = { iteminfo_parts::BOOK_INCLUDED_RECIPES }; - item dragon( "test_dragon_book" ); - item cmdline( "test_cmdline_book" ); + item dragon( itype_test_dragon_book ); + item cmdline( itype_test_cmdline_book ); // TODO: add martial arts book to test data REQUIRE( dragon.is_book() ); @@ -1665,9 +1731,9 @@ TEST_CASE( "gun_or_other_ranged_weapon_attributes", "[iteminfo][weapon][gun]" ) { clear_avatar(); - item compbow( "test_compbow" ); - item glock( "test_glock" ); - item rag( "test_rag" ); + item compbow( itype_test_compbow ); + item glock( itype_test_glock ); + item rag( itype_test_rag ); SECTION( "weapon damage including floating-point multiplier" ) { // Ranged damage info is displayed on a single line, in three parts: @@ -1878,7 +1944,7 @@ TEST_CASE( "gun_armor_piercing_dispersion_and_other_stats", "[iteminfo][gun][mis //std::vector ammo_upscost = { iteminfo_parts::AMMO_UPSCOST }; //std::vector gun_casings = { iteminfo_parts::DESCRIPTION_GUN_CASINGS }; - item glock( "test_glock" ); + item glock( itype_test_glock ); CHECK( item_info_str( glock, dmg_loaded ) == "--\n+26\n" ); @@ -1942,7 +2008,7 @@ TEST_CASE( "gunmod_info", "[iteminfo][gunmod]" ) //std::vector add_mod = { iteminfo_parts::GUNMOD_ADD_MOD }; //std::vector blacklist_mod = { iteminfo_parts::GUNMOD_BLACKLIST_MOD }; - item supp( "test_crafted_suppressor" ); + item supp( itype_test_crafted_suppressor ); REQUIRE( supp.is_gunmod() ); /* FIXME: This only applies if is_gun() ?? @@ -2020,7 +2086,7 @@ TEST_CASE( "ammunition", "[iteminfo][ammo]" ) }; SECTION( "simple item with ammo damage" ) { - item rock( "test_rock" ); + item rock( itype_test_rock ); CHECK( item_info_str( rock, ammo ) == "--\n" @@ -2031,7 +2097,7 @@ TEST_CASE( "ammunition", "[iteminfo][ammo]" ) } SECTION( "batteries" ) { - item batt_dispose( "test_battery_disposable" ); + item batt_dispose( itype_test_battery_disposable ); // FIXME: is_battery is only true if type = "BATTERY" // no items in the game have this property anymore @@ -2051,7 +2117,7 @@ TEST_CASE( "nutrients_in_food", "[iteminfo][food]" ) { clear_avatar(); - item ice_cream( "icecream" ); + item ice_cream( itype_icecream ); SECTION( "fixed nutrient values in regular item" ) { CHECK( item_info_str( ice_cream, { iteminfo_parts::FOOD_NUTRITION, iteminfo_parts::FOOD_QUENCH } ) @@ -2098,7 +2164,7 @@ TEST_CASE( "food_freshness_and_lifetime", "[iteminfo][food]" ) player_character.empty_skills(); REQUIRE_FALSE( player_character.can_estimate_rot() ); - item nuts( "test_pine_nuts" ); + item nuts( itype_test_pine_nuts ); REQUIRE( nuts.goes_bad() ); // TODO: @@ -2144,9 +2210,9 @@ TEST_CASE( "basic_food_info", "[iteminfo][food]" ) //std::vector smell = { iteminfo_parts::FOOD_SMELL }; //std::vector vit_effects = { iteminfo_parts::FOOD_VIT_EFFECTS }; - item apple( "test_apple" ); - item nuts( "test_pine_nuts" ); - item wine( "test_wine" ); + item apple( itype_test_apple ); + item nuts( itype_test_pine_nuts ); + item wine( itype_test_wine ); REQUIRE( apple.is_food() ); REQUIRE( nuts.is_food() ); @@ -2191,7 +2257,7 @@ TEST_CASE( "food_character_is_allergic_to", "[iteminfo][food][allergy]" ) REQUIRE( player_character.has_trait( trait_ANTIFRUIT ) ); THEN( "fruit indicates an allergic reaction" ) { - item apple( "test_apple" ); + item apple( itype_test_apple ); REQUIRE( apple.has_flag( flag_ALLERGEN_FRUIT ) ); CHECK( item_info_str( apple, allergen ) == "--\n" @@ -2199,7 +2265,7 @@ TEST_CASE( "food_character_is_allergic_to", "[iteminfo][food][allergy]" ) } THEN( "nuts do not indicate an allergic reaction" ) { - item nuts( "test_pine_nuts" ); + item nuts( itype_test_pine_nuts ); REQUIRE_FALSE( nuts.has_flag( flag_ALLERGEN_FRUIT ) ); CHECK( item_info_str( nuts, allergen ).empty() ); } @@ -2216,8 +2282,8 @@ TEST_CASE( "food_with_hidden_poison_or_hallucinogen", "[iteminfo][food][poison][ clear_avatar(); // Test food with hidden effects - item almond( "test_bitter_almond" ); - item nutmeg( "test_hallu_nutmeg" ); + item almond( itype_test_bitter_almond ); + item nutmeg( itype_test_hallu_nutmeg ); // Ensure they are food REQUIRE( almond.is_food() ); @@ -2298,7 +2364,7 @@ TEST_CASE( "food_that_is_made_of_human_flesh", "[iteminfo][food][cannibal]" ) std::vector cannibal = { iteminfo_parts::FOOD_CANNIBALISM }; - item thumb( "test_thumb" ); + item thumb( itype_test_thumb ); REQUIRE( thumb.has_vitamin( vitamin_human_flesh_vitamin ) ); GIVEN( "character is not a cannibal" ) { @@ -2337,13 +2403,13 @@ TEST_CASE( "item_conductivity", "[iteminfo][conductivity]" ) std::vector conductivity = { iteminfo_parts::DESCRIPTION_CONDUCTIVITY }; SECTION( "non-conductive items" ) { - item plank( "test_2x4" ); + item plank( itype_test_2x4 ); REQUIRE_FALSE( plank.conductive() ); CHECK( item_info_str( plank, conductivity ) == "--\n" "* This item does not conduct electricity.\n" ); - item axe( "test_fire_ax" ); + item axe( itype_test_fire_ax ); REQUIRE_FALSE( axe.conductive() ); CHECK( item_info_str( axe, conductivity ) == "--\n" @@ -2352,21 +2418,21 @@ TEST_CASE( "item_conductivity", "[iteminfo][conductivity]" ) SECTION( "conductive items" ) { // Pipe is made of conductive material (steel) - item pipe( "test_pipe" ); + item pipe( itype_test_pipe ); REQUIRE( pipe.conductive() ); CHECK( item_info_str( pipe, conductivity ) == "--\n" "* This item conducts electricity.\n" ); // Halligan bar is made of conductive material (steel) - item halligan( "test_halligan" ); + item halligan( itype_test_halligan ); REQUIRE( halligan.conductive() ); CHECK( item_info_str( halligan, conductivity ) == "--\n" "* This item conducts electricity.\n" ); // Balloon is made of non-conductive rubber, but has CONDUCTIVE flag - item balloon( "test_balloon" ); + item balloon( itype_test_balloon ); REQUIRE( balloon.conductive() ); CHECK( item_info_str( balloon, conductivity ) == "--\n" @@ -2387,7 +2453,7 @@ TEST_CASE( "list_of_item_qualities", "[iteminfo][quality]" ) std::vector qualities = { iteminfo_parts::QUALITIES }; SECTION( "Halligan bar" ) { - item halligan( "test_halligan" ); + item halligan( itype_test_halligan ); CHECK( item_info_str( halligan, qualities ) == "--\n" "Has qualities:\n" @@ -2398,7 +2464,7 @@ TEST_CASE( "list_of_item_qualities", "[iteminfo][quality]" ) } SECTION( "bottle jack" ) { - item jack( "test_jack_small" ); + item jack( itype_test_jack_small ); SECTION( "metric units" ) { override_option opt_kg( "USE_METRIC_WEIGHTS", "kg" ); @@ -2419,7 +2485,7 @@ TEST_CASE( "list_of_item_qualities", "[iteminfo][quality]" ) } SECTION( "sonic screwdriver" ) { - item sonic( "test_sonic_screwdriver" ); + item sonic( itype_test_sonic_screwdriver ); CHECK( item_info_str( sonic, qualities ) == "--\n" @@ -2433,8 +2499,8 @@ TEST_CASE( "list_of_item_qualities", "[iteminfo][quality]" ) SECTION( "cordless drill" ) { // Cordless drill has both qualities and charged_qualities - item drill( "test_cordless_drill" ); - item battery( "medium_battery_cell" ); + item drill( itype_test_cordless_drill ); + item battery( itype_medium_battery_cell ); // Without enough charges CHECK( item_info_str( drill, qualities ) == @@ -2471,7 +2537,7 @@ TEST_CASE( "list_of_item_actions", "[iteminfo][action]" ) std::vector actions = { iteminfo_parts::ACTIONS }; SECTION( "Halligan bar" ) { - item halligan( "test_halligan" ); + item halligan( itype_test_halligan ); CHECK( item_info_str( halligan, actions ) == "--\n" "Actions: Pry crate, window, door or nails, Dig pit here, Dig water channel here, Fill pit / tamp ground, and Upturn earth\n" ); @@ -2493,7 +2559,7 @@ TEST_CASE( "tool_info", "[iteminfo][tool]" ) SECTION( "maximum charges" ) { std::vector capacity = { iteminfo_parts::TOOL_CAPACITY }; - item matches( "test_matches" ); + item matches( itype_test_matches ); CHECK( item_info_str( matches, capacity ) == "--\n" "Maximum 20 charges of match.\n" ); @@ -2502,7 +2568,7 @@ TEST_CASE( "tool_info", "[iteminfo][tool]" ) SECTION( "tool with charges" ) { std::vector charges = { iteminfo_parts::TOOL_CHARGES }; - item matches( "test_matches" ); + item matches( itype_test_matches ); matches.ammo_set( itype_match ); REQUIRE( matches.ammo_remaining() > 0 ); @@ -2514,7 +2580,7 @@ TEST_CASE( "tool_info", "[iteminfo][tool]" ) SECTION( "candle with feedback on burnout" ) { std::vector burnout = { iteminfo_parts::TOOL_BURNOUT }; - item candle( "candle" ); + item candle( itype_candle ); candle.ammo_set( itype_candle_wax ); REQUIRE( candle.ammo_remaining() > 0 ); @@ -2531,7 +2597,7 @@ TEST_CASE( "tool_info", "[iteminfo][tool]" ) SECTION( "UPS charged tool" ) { std::vector recharge_ups = { iteminfo_parts::DESCRIPTION_RECHARGE_UPSMODDED }; - item smartphone( "test_smart_phone" ); + item smartphone( itype_test_smart_phone ); REQUIRE( smartphone.has_flag( flag_USE_UPS ) ); CHECK( item_info_str( smartphone, recharge_ups ) == @@ -2546,7 +2612,7 @@ TEST_CASE( "tool_info", "[iteminfo][tool]" ) std::vector magazine_compat = { iteminfo_parts::TOOL_MAGAZINE_COMPATIBLE }; // Rag has no magazine capacity - item rag( "test_rag" ); + item rag( itype_test_rag ); REQUIRE_FALSE( rag.magazine_integral() ); REQUIRE( rag.magazine_compatible().empty() ); @@ -2554,7 +2620,7 @@ TEST_CASE( "tool_info", "[iteminfo][tool]" ) // Acetylene torch is a tool with compatible magazines // Other tools with "Compatible magazine": electric hair trimmer, circular saw - item oxy_torch( "oxy_torch" ); + item oxy_torch( itype_oxy_torch ); REQUIRE_FALSE( oxy_torch.magazine_integral() ); REQUIRE_FALSE( oxy_torch.magazine_compatible().empty() ); @@ -2590,10 +2656,10 @@ TEST_CASE( "bionic_info", "[iteminfo][bionic]" ) clear_avatar(); - item burner( "bio_ethanol" ); - item power( "bio_power_storage" ); - item nostril( "bio_nostril" ); - item purifier( "bio_purifier" ); + item burner( itype_bio_ethanol ); + item power( itype_bio_power_storage ); + item nostril( itype_bio_nostril ); + item purifier( itype_bio_purifier ); REQUIRE( burner.is_bionic() ); REQUIRE( power.is_bionic() ); @@ -2638,9 +2704,9 @@ TEST_CASE( "repairable_and_with_what_tools", "[iteminfo][repair]" ) { clear_avatar(); - item halligan( "test_halligan" ); - item hazmat( "test_hazmat_suit" ); - item rock( "test_rock" ); + item halligan( itype_test_halligan ); + item hazmat( itype_test_hazmat_suit ); + item rock( itype_test_rock ); std::vector repaired = { iteminfo_parts::DESCRIPTION_REPAIREDWITH }; @@ -2669,8 +2735,8 @@ TEST_CASE( "disassembly_time_and_yield", "[iteminfo][disassembly]" ) std::vector disassemble = { iteminfo_parts::DESCRIPTION_COMPONENTS_DISASSEMBLE }; - item iron( "test_soldering_iron" ); - item metal( "test_sheet_metal" ); + item iron( itype_test_soldering_iron ); + item metal( itype_test_sheet_metal ); CHECK( item_info_str( iron, disassemble ) == "--\n" @@ -2701,8 +2767,8 @@ TEST_CASE( "item_description_flags", "[iteminfo][flags]" ) std::vector flags = { iteminfo_parts::DESCRIPTION_FLAGS }; - item halligan( "test_halligan" ); - item hazmat( "test_hazmat_suit" ); + item halligan( itype_test_halligan ); + item hazmat( itype_test_hazmat_suit ); // Halligan bar has a couple flags REQUIRE( halligan.has_flag( flag_BELT_CLIP ) ); @@ -2750,8 +2816,8 @@ TEST_CASE( "show_available_recipes_with_item_as_an_ingredient", "[iteminfo][reci std::vector crafting = { iteminfo_parts::DESCRIPTION_APPLICABLE_RECIPES }; GIVEN( "character has a potassium iodide tablet and no skill" ) { - player_character.worn.wear_item( player_character, item( "backpack" ), false, false ); - item_location iodine = player_character.i_add( item( "iodine" ) ); + player_character.worn.wear_item( player_character, item( itype_backpack ), false, false ); + item_location iodine = player_character.i_add( item( itype_iodine ) ); player_character.empty_skills(); REQUIRE( !player_character.knows_recipe( purtab ) ); @@ -2783,7 +2849,7 @@ TEST_CASE( "show_available_recipes_with_item_as_an_ingredient", "[iteminfo][reci } WHEN( "they have the recipe in a book, but not memorized" ) { - item_location textbook = player_character.i_add( item( "textbook_chemistry" ) ); + item_location textbook = player_character.i_add( item( itype_textbook_chemistry ) ); player_character.identify( *textbook ); REQUIRE( player_character.has_identified( itype_textbook_chemistry ) ); player_character.invalidate_crafting_inventory(); @@ -2816,7 +2882,7 @@ TEST_CASE( "pocket_info_for_a_simple_container", "[iteminfo][pocket][container]" { clear_avatar(); - item test_waterskin( "test_waterskin" ); + item test_waterskin( itype_test_waterskin ); std::vector pockets = { iteminfo_parts::DESCRIPTION_POCKETS }; override_option opt_vol( "VOLUME_UNITS", "l" ); @@ -2842,7 +2908,7 @@ TEST_CASE( "pocket_info_units_-_imperial_or_metric", "[iteminfo][pocket][units]" { clear_avatar(); - item test_jug( "test_jug_plastic" ); + item test_jug( itype_test_jug_plastic ); std::vector pockets = { iteminfo_parts::DESCRIPTION_POCKETS }; GIVEN( "metric units" ) { @@ -2889,7 +2955,7 @@ TEST_CASE( "pocket_info_for_a_multi-pocket_item", "[iteminfo][pocket][multiple]" { clear_avatar(); - item test_belt( "test_tool_belt_pocket_mix" ); + item test_belt( itype_test_tool_belt_pocket_mix ); std::vector pockets = { iteminfo_parts::DESCRIPTION_POCKETS }; override_option opt_vol( "VOLUME_UNITS", "l" ); @@ -2940,7 +3006,7 @@ TEST_CASE( "ammo_restriction_info", "[iteminfo][ammo_restriction]" ) std::vector pockets = { iteminfo_parts::DESCRIPTION_POCKETS }; // Quiver is a CONTAINER with ammo_restriction "arrow" or "bolt" - item quiver( "test_quiver" ); + item quiver( itype_test_quiver ); // Not a magazine, but it should have ammo_types REQUIRE_FALSE( quiver.is_magazine() ); REQUIRE_FALSE( quiver.ammo_types().empty() ); @@ -2958,7 +3024,7 @@ TEST_CASE( "ammo_restriction_info", "[iteminfo][ammo_restriction]" ) std::vector mag_cap = { iteminfo_parts::MAGAZINE_CAPACITY }; // Matches are TOOL with MAGAZINE pocket, and ammo_restriction "match" - item matches( "test_matches" ); + item matches( itype_test_matches ); REQUIRE( matches.is_magazine() ); REQUIRE_FALSE( matches.ammo_types().empty() ); // But they have the NO_RELOAD flag, so their capacity should not be displayed @@ -2966,7 +3032,7 @@ TEST_CASE( "ammo_restriction_info", "[iteminfo][ammo_restriction]" ) CHECK( item_info_str( matches, mag_cap ).empty() ); // Compound bow is a GUN with integral MAGAZINE pocket, ammo_restriction "arrow" - item compbow( "test_compbow" ); + item compbow( itype_test_compbow ); REQUIRE( compbow.is_magazine() ); REQUIRE_FALSE( compbow.ammo_types().empty() ); // It can be reloaded, so its magazine capacity should be displayed @@ -3034,7 +3100,7 @@ TEST_CASE( "final_info", "[iteminfo][final]" ) Character &player_character = get_player_character(); SECTION( "material allergy" ) { - item socks( "test_socks" ); + item socks( itype_test_socks ); REQUIRE( socks.made_of( material_wool ) ); WHEN( "avatar has a wool allergy" ) { @@ -3051,7 +3117,7 @@ TEST_CASE( "final_info", "[iteminfo][final]" ) std::vector brew_duration = { iteminfo_parts::DESCRIPTION_BREWABLE_DURATION }; std::vector brew_products = { iteminfo_parts::DESCRIPTION_BREWABLE_PRODUCTS }; - item wine_must( "test_brew_wine" ); + item wine_must( itype_test_brew_wine ); REQUIRE( wine_must.brewing_time() == 12_hours ); // TODO: DESCRIPTION_ACTIVATABLE_TRANSFORMATION (sourdough?) @@ -3069,7 +3135,7 @@ TEST_CASE( "final_info", "[iteminfo][final]" ) SECTION( "radioactivity" ) { std::vector radioactive = { iteminfo_parts::DESCRIPTION_RADIOACTIVITY_ALWAYS }; - item carafe( "test_nuclear_carafe" ); + item carafe( itype_test_nuclear_carafe ); REQUIRE( carafe.has_flag( flag_RADIOACTIVE ) ); REQUIRE( carafe.has_flag( flag_LEAK_ALWAYS ) ); @@ -3096,7 +3162,7 @@ TEST_CASE( "item_debug_info", "[iteminfo][debug][!mayfail][.]" ) SECTION( "debug info displayed when debug_mode is true" ) { // Lightly aged pine nuts - item nuts( "test_pine_nuts" ); + item nuts( itype_test_pine_nuts ); calendar::turn += 8_hours; // Quick-check a couple expected values for debug info REQUIRE( nuts.age() == 8_hours ); diff --git a/tests/itemname_test.cpp b/tests/itemname_test.cpp index 97159cd6daeb2..f08fa2ef447db 100644 --- a/tests/itemname_test.cpp +++ b/tests/itemname_test.cpp @@ -12,6 +12,14 @@ #include "ret_val.h" #include "type_id.h" +static const itype_id itype_butter( "butter" ); +static const itype_id itype_bookplate( "bookplate" ); +static const itype_id itype_bootsheath( "bootsheath" ); +static const itype_id itype_test_arrow_wood( "test_arrow_wood" ); +static const itype_id itype_test_quiver( "test_quiver" ); +static const itype_id itype_tunic( "tunic" ); +static const itype_id itype_wrapper( "wrapper" ); + static const trait_id trait_HUGE_OK( "HUGE_OK" ); static const trait_id trait_SMALL_OK( "SMALL_OK" ); @@ -22,21 +30,21 @@ TEST_CASE( "item_sizing_display", "[item][iteminfo][display_name][sizing]" ) player_character.clear_mutations(); WHEN( "the item is a normal size" ) { - std::string name = item( "bookplate" ).display_name(); + std::string name = item( itype_bookplate ).display_name(); THEN( "the item name has no qualifier" ) { CHECK( name == "++\u00A0bookplate" ); } } WHEN( "the item is oversized" ) { - std::string name = item( "bootsheath" ).display_name(); + std::string name = item( itype_bootsheath ).display_name(); THEN( "the item name has no qualifier" ) { CHECK( name == "++\u00A0ankle sheath" ); } } WHEN( "the item is undersized" ) { - item i = item( "tunic" ); + item i = item( itype_tunic ); i.set_flag( flag_UNDERSIZE ); i.set_flag( flag_FIT ); std::string name = i.display_name(); @@ -58,21 +66,21 @@ TEST_CASE( "item_sizing_display", "[item][iteminfo][display_name][sizing]" ) player_character.toggle_trait( trait_HUGE_OK ); WHEN( "the item is a normal size" ) { - std::string name = item( "bookplate" ).display_name(); + std::string name = item( itype_bookplate ).display_name(); THEN( "the item name says its too small" ) { CHECK( name == "++\u00A0bookplate (too small)" ); } } WHEN( "the item is oversized" ) { - std::string name = item( "bootsheath" ).display_name(); + std::string name = item( itype_bootsheath ).display_name(); THEN( "the item name has no qualifier" ) { CHECK( name == "++\u00A0ankle sheath" ); } } WHEN( "the item is undersized" ) { - item i = item( "tunic" ); + item i = item( itype_tunic ); i.set_flag( flag_UNDERSIZE ); i.set_flag( flag_FIT ); std::string name = i.display_name(); @@ -94,21 +102,21 @@ TEST_CASE( "item_sizing_display", "[item][iteminfo][display_name][sizing]" ) player_character.toggle_trait( trait_SMALL_OK ); WHEN( "the item is a normal size" ) { - std::string name = item( "bookplate" ).display_name(); + std::string name = item( itype_bookplate ).display_name(); THEN( "the item name says its too big" ) { CHECK( name == "++\u00A0bookplate (too big)" ); } } WHEN( "the item is oversized" ) { - std::string name = item( "bootsheath" ).display_name(); + std::string name = item( itype_bootsheath ).display_name(); THEN( "the item name has no qualifier" ) { CHECK( name == "++\u00A0ankle sheath (huge!)" ); } } WHEN( "the item is undersized" ) { - item i = item( "tunic" ); + item i = item( itype_tunic ); i.set_flag( flag_UNDERSIZE ); i.set_flag( flag_FIT ); std::string name = i.display_name(); @@ -129,12 +137,12 @@ TEST_CASE( "display_name_includes_item_contents", "[item][display_name][contents { clear_avatar(); - item arrow( "test_arrow_wood", calendar::turn_zero, item::default_charges_tag{} ); + item arrow( itype_test_arrow_wood, calendar::turn_zero, item::default_charges_tag{} ); // Arrows are ammo with a default count of 10 REQUIRE( arrow.is_ammo() ); REQUIRE( arrow.count() == 10 ); - item quiver( "test_quiver" ); + item quiver( itype_test_quiver ); // Quivers are not magazines, nor do they have magazines REQUIRE_FALSE( quiver.is_magazine() ); REQUIRE_FALSE( quiver.magazine_current() ); @@ -162,10 +170,10 @@ TEST_CASE( "display_name_rotten_food", "[item][display_name][contents]" ) { clear_avatar(); - item wrapper( "wrapper" ); - item butter_std( "butter" ); - item butter_rot1( "butter" ); - item butter_rot2( "butter" ); + item wrapper( itype_wrapper ); + item butter_std( itype_butter ); + item butter_rot1( itype_butter ); + item butter_rot2( itype_butter ); butter_std.set_relative_rot( 0.5 ); butter_rot1.set_relative_rot( 1.01 ); butter_rot2.set_relative_rot( 1.02 ); diff --git a/tests/iuse_actor_test.cpp b/tests/iuse_actor_test.cpp index f0c0f0f924faf..3c5a5371487bd 100644 --- a/tests/iuse_actor_test.cpp +++ b/tests/iuse_actor_test.cpp @@ -33,8 +33,44 @@ static const ammotype ammo_battery( "battery" ); +static const itype_id itype_acidchitin_harness_dog( "acidchitin_harness_dog" ); +static const itype_id itype_backpack_hiking( "backpack_hiking" ); +static const itype_id itype_blanket( "blanket" ); static const itype_id itype_bot_manhack( "bot_manhack" ); +static const itype_id itype_boxpack( "boxpack" ); +static const itype_id itype_bunker_coat( "bunker_coat" ); +static const itype_id itype_bunker_pants( "bunker_pants" ); +static const itype_id itype_burette( "burette" ); +static const itype_id itype_camera( "camera" ); +static const itype_id itype_case_violin( "case_violin" ); +static const itype_id itype_cell_phone( "cell_phone" ); +static const itype_id itype_chitin_harness_dog( "chitin_harness_dog" ); +static const itype_id itype_down_mattress( "down_mattress" ); +static const itype_id itype_dress_wedding( "dress_wedding" ); +static const itype_id itype_eink_tablet_pc( "eink_tablet_pc" ); +static const itype_id itype_flashlight( "flashlight" ); +static const itype_id itype_kevlar_harness( "kevlar_harness" ); +static const itype_id itype_knife_huge( "knife_huge" ); +static const itype_id itype_laptop( "laptop" ); +static const itype_id itype_leather_harness_dog( "leather_harness_dog" ); +static const itype_id itype_leatherbone_harness_dog( "leatherbone_harness_dog" ); +static const itype_id itype_log( "log" ); static const itype_id itype_medium_battery_cell( "medium_battery_cell" ); +static const itype_id itype_peacoat( "peacoat" ); +static const itype_id itype_plastic_boat_hull( "plastic_boat_hull" ); +static const itype_id itype_radio( "radio" ); +static const itype_id itype_rubber_harness_dog( "rubber_harness_dog" ); +static const itype_id itype_stick( "stick" ); +static const itype_id itype_stick_long( "stick_long" ); +static const itype_id itype_tazer( "tazer" ); +static const itype_id itype_touring_suit( "touring_suit" ); +static const itype_id itype_under_armor( "under_armor" ); +static const itype_id itype_voltmeter( "voltmeter" ); +static const itype_id itype_wetsuit( "wetsuit" ); +static const itype_id itype_wetsuit_booties( "wetsuit_booties" ); +static const itype_id itype_wetsuit_gloves( "wetsuit_gloves" ); +static const itype_id itype_wetsuit_hood( "wetsuit_hood" ); +static const itype_id itype_wetsuit_spring( "wetsuit_spring" ); static const mtype_id mon_manhack( "mon_manhack" ); @@ -62,7 +98,7 @@ TEST_CASE( "manhack", "[iuse_actor][manhack]" ) clear_map(); g->clear_zombies(); - item_location test_item = player_character.i_add( item( "bot_manhack", calendar::turn_zero, + item_location test_item = player_character.i_add( item( itype_bot_manhack, calendar::turn_zero, item::default_charges_tag{} ) ); REQUIRE( player_character.has_item( *test_item ) ); @@ -88,8 +124,8 @@ TEST_CASE( "tool_transform_when_activated", "[iuse][tool][transform]" ) clear_avatar(); GIVEN( "flashlight with a charged battery installed" ) { - item flashlight( "flashlight" ); - item bat_cell( "medium_battery_cell" ); + item flashlight( itype_flashlight ); + item bat_cell( itype_medium_battery_cell ); REQUIRE( flashlight.can_reload_with( item( itype_medium_battery_cell ), true ) ); // Charge the battery @@ -123,7 +159,7 @@ TEST_CASE( "tool_transform_when_activated", "[iuse][tool][transform]" ) } } -static void cut_up_yields( const std::string &target ) +static void cut_up_yields( const itype_id &target ) { map &here = get_map(); Character &guy = get_avatar(); @@ -133,10 +169,10 @@ static void cut_up_yields( const std::string &target ) //guy.set_skill_level( skill_id( "fabrication" ), 10 ); here.i_at( guy.pos_bub() ).clear(); - CAPTURE( target ); + CAPTURE( target.c_str() ); salvage_actor test_actor; - item cut_up_target{ target }; - item tool{ "knife_huge" }; + item cut_up_target( target ); + item tool( itype_knife_huge ); const std::map &target_materials = cut_up_target.made_of(); const float mat_total = cut_up_target.type->mat_portion_total == 0 ? 1 : cut_up_target.type->mat_portion_total; @@ -167,40 +203,40 @@ static void cut_up_yields( const std::string &target ) TEST_CASE( "cut_up_yields" ) { - cut_up_yields( "blanket" ); - cut_up_yields( "backpack_hiking" ); - cut_up_yields( "boxpack" ); - cut_up_yields( "case_violin" ); - cut_up_yields( "down_mattress" ); - cut_up_yields( "plastic_boat_hull" ); - cut_up_yields( "bunker_coat" ); - cut_up_yields( "bunker_pants" ); - cut_up_yields( "kevlar_harness" ); - cut_up_yields( "touring_suit" ); - cut_up_yields( "dress_wedding" ); - cut_up_yields( "wetsuit" ); - cut_up_yields( "wetsuit_booties" ); - cut_up_yields( "wetsuit_hood" ); - cut_up_yields( "wetsuit_spring" ); - cut_up_yields( "wetsuit_gloves" ); - cut_up_yields( "peacoat" ); - cut_up_yields( "log" ); - cut_up_yields( "stick" ); - cut_up_yields( "stick_long" ); - cut_up_yields( "tazer" ); - cut_up_yields( "laptop" ); - cut_up_yields( "voltmeter" ); - cut_up_yields( "burette" ); - cut_up_yields( "eink_tablet_pc" ); - cut_up_yields( "camera" ); - cut_up_yields( "cell_phone" ); - cut_up_yields( "laptop" ); - cut_up_yields( "radio" ); - cut_up_yields( "under_armor" ); - cut_up_yields( "acidchitin_harness_dog" ); - cut_up_yields( "chitin_harness_dog" ); - cut_up_yields( "leather_harness_dog" ); - cut_up_yields( "leatherbone_harness_dog" ); - cut_up_yields( "kevlar_harness" ); - cut_up_yields( "rubber_harness_dog" ); + cut_up_yields( itype_blanket ); + cut_up_yields( itype_backpack_hiking ); + cut_up_yields( itype_boxpack ); + cut_up_yields( itype_case_violin ); + cut_up_yields( itype_down_mattress ); + cut_up_yields( itype_plastic_boat_hull ); + cut_up_yields( itype_bunker_coat ); + cut_up_yields( itype_bunker_pants ); + cut_up_yields( itype_kevlar_harness ); + cut_up_yields( itype_touring_suit ); + cut_up_yields( itype_dress_wedding ); + cut_up_yields( itype_wetsuit ); + cut_up_yields( itype_wetsuit_booties ); + cut_up_yields( itype_wetsuit_hood ); + cut_up_yields( itype_wetsuit_spring ); + cut_up_yields( itype_wetsuit_gloves ); + cut_up_yields( itype_peacoat ); + cut_up_yields( itype_log ); + cut_up_yields( itype_stick ); + cut_up_yields( itype_stick_long ); + cut_up_yields( itype_tazer ); + cut_up_yields( itype_laptop ); + cut_up_yields( itype_voltmeter ); + cut_up_yields( itype_burette ); + cut_up_yields( itype_eink_tablet_pc ); + cut_up_yields( itype_camera ); + cut_up_yields( itype_cell_phone ); + cut_up_yields( itype_laptop ); + cut_up_yields( itype_radio ); + cut_up_yields( itype_under_armor ); + cut_up_yields( itype_acidchitin_harness_dog ); + cut_up_yields( itype_chitin_harness_dog ); + cut_up_yields( itype_leather_harness_dog ); + cut_up_yields( itype_leatherbone_harness_dog ); + cut_up_yields( itype_kevlar_harness ); + cut_up_yields( itype_rubber_harness_dog ); } diff --git a/tests/iuse_test.cpp b/tests/iuse_test.cpp index 78a5fbb96914c..dc03d7056db2a 100644 --- a/tests/iuse_test.cpp +++ b/tests/iuse_test.cpp @@ -51,14 +51,24 @@ static const itype_id itype_55gal_drum( "55gal_drum" ); static const itype_id itype_albuterol( "albuterol" ); static const itype_id itype_antifungal( "antifungal" ); static const itype_id itype_antiparasitic( "antiparasitic" ); +static const itype_id itype_atomic_coffee( "atomic_coffee" ); static const itype_id itype_backpack( "backpack" ); +static const itype_id itype_coffee( "coffee" ); static const itype_id itype_diazepam( "diazepam" ); +static const itype_id itype_inhaler( "inhaler" ); +static const itype_id itype_oxygen( "oxygen" ); +static const itype_id itype_oxygen_tank( "oxygen_tank" ); +static const itype_id itype_panacea( "panacea" ); static const itype_id itype_pur_tablets( "pur_tablets" ); +static const itype_id itype_prozac( "prozac" ); +static const itype_id itype_saline( "saline" ); static const itype_id itype_thorazine( "thorazine" ); +static const itype_id itype_towel( "towel" ); static const itype_id itype_towel_wet( "towel_wet" ); static const itype_id itype_water( "water" ); static const itype_id itype_water_clean( "water_clean" ); static const itype_id itype_water_purifying( "water_purifying" ); +static const itype_id itype_xanax( "xanax" ); static const morale_type morale_wet( "morale_wet" ); @@ -72,7 +82,7 @@ TEST_CASE( "eyedrops", "[iuse][eyedrops]" ) REQUIRE( dummy.has_part( bodypart_id( "eyes" ) ) ); dummy.normalize(); - item eyedrops( "saline", calendar::turn_zero, item::default_charges_tag{} ); + item eyedrops( itype_saline, calendar::turn_zero, item::default_charges_tag{} ); int charges_before = eyedrops.charges; REQUIRE( charges_before > 0 ); @@ -299,9 +309,8 @@ TEST_CASE( "oxygen_tank", "[iuse][oxygen_bottle]" ) avatar dummy; dummy.normalize(); - item oxygen( "oxygen_tank" ); - itype_id o2_ammo( "oxygen" ); - oxygen.ammo_set( o2_ammo ); + item oxygen( itype_oxygen_tank ); + oxygen.ammo_set( itype_oxygen ); int charges_before = oxygen.ammo_remaining(); REQUIRE( charges_before > 0 ); @@ -414,14 +423,14 @@ TEST_CASE( "caffeine_and_atomic_caffeine", "[iuse][caff][atomic_caff]" ) REQUIRE( dummy.get_rad() == 0 ); SECTION( "coffee reduces sleepiness, but does not give stimulant effect" ) { - item coffee( "coffee", calendar::turn_zero, item::default_charges_tag{} ); + item coffee( itype_coffee, calendar::turn_zero, item::default_charges_tag{} ); dummy.consume( coffee ); CHECK( dummy.get_sleepiness() == sleepiness_before - coffee.get_comestible()->sleepiness_mod ); CHECK( dummy.get_stim() == coffee.get_comestible()->stim ); } SECTION( "atomic caffeine greatly reduces sleepiness, and increases stimulant effect" ) { - item atomic_coffee( "atomic_coffee", calendar::turn_zero, item::default_charges_tag{} ); + item atomic_coffee( itype_atomic_coffee, calendar::turn_zero, item::default_charges_tag{} ); dummy.consume( atomic_coffee ); CHECK( dummy.get_sleepiness() == sleepiness_before - atomic_coffee.get_comestible()->sleepiness_mod ); @@ -434,7 +443,7 @@ TEST_CASE( "towel", "[iuse][towel]" ) avatar dummy; dummy.normalize(); - item towel( "towel", calendar::turn_zero, item::default_charges_tag{} ); + item towel( itype_towel, calendar::turn_zero, item::default_charges_tag{} ); GIVEN( "avatar is wet" ) { // Saturate torso, head, and both arms @@ -618,7 +627,7 @@ TEST_CASE( "prozac", "[iuse][prozac]" ) avatar dummy; dummy.normalize(); - item prozac( "prozac", calendar::turn_zero, item::default_charges_tag{} ); + item prozac( itype_prozac, calendar::turn_zero, item::default_charges_tag{} ); SECTION( "prozac gives prozac and visible prozac effect" ) { REQUIRE_FALSE( dummy.has_effect( effect_took_prozac ) ); @@ -643,7 +652,7 @@ TEST_CASE( "inhaler", "[iuse][inhaler]" ) { clear_avatar(); avatar &dummy = get_avatar(); - item inhaler( "inhaler" ); + item inhaler( itype_inhaler ); inhaler.ammo_set( itype_albuterol ); REQUIRE( inhaler.ammo_remaining() > 0 ); @@ -686,7 +695,7 @@ TEST_CASE( "panacea", "[iuse][panacea]" ) avatar dummy; dummy.normalize(); - item panacea( "panacea", calendar::turn_zero, item::default_charges_tag{} ); + item panacea( itype_panacea, calendar::turn_zero, item::default_charges_tag{} ); SECTION( "panacea gives cure-all effect" ) { REQUIRE_FALSE( dummy.has_effect( effect_cureall ) ); @@ -701,7 +710,7 @@ TEST_CASE( "xanax", "[iuse][xanax]" ) avatar dummy; dummy.normalize(); - item xanax( "xanax", calendar::turn_zero, item::default_charges_tag{} ); + item xanax( itype_xanax, calendar::turn_zero, item::default_charges_tag{} ); SECTION( "xanax gives xanax and visible xanax effects" ) { REQUIRE_FALSE( dummy.has_effect( effect_took_xanax ) ); diff --git a/tests/limb_test.cpp b/tests/limb_test.cpp index 3c6e12ff0c8fe..d774b01056eb3 100644 --- a/tests/limb_test.cpp +++ b/tests/limb_test.cpp @@ -30,6 +30,14 @@ static const efftype_id effect_winded_arm_r( "winded_arm_r" ); static const enchantment_id enchantment_ENCH_TEST_BIRD_PARTS( "ENCH_TEST_BIRD_PARTS" ); static const enchantment_id enchantment_ENCH_TEST_LIZARD_TAIL( "ENCH_TEST_LIZARD_TAIL" ); +static const itype_id itype_test_bird_boots( "test_bird_boots" ); +static const itype_id itype_test_jumpsuit_cotton( "test_jumpsuit_cotton" ); +static const itype_id itype_test_liquid( "test_liquid" ); +static const itype_id itype_test_pine_nuts( "test_pine_nuts" ); +static const itype_id itype_test_shackles( "test_shackles" ); +static const itype_id itype_test_winglets( "test_winglets" ); +static const itype_id itype_test_winglets_left( "test_winglets_left" ); + static const json_character_flag json_flag_WALL_CLING( "WALL_CLING" ); static const sub_bodypart_str_id @@ -91,7 +99,7 @@ TEST_CASE( "Gaining_losing_limbs", "[limb]" ) TEST_CASE( "limb_conditional_flags", "[character][encumbrance][limb]" ) { standard_npc dude( "Test NPC" ); - item wing_cover_left( "test_winglets_left" ); + item wing_cover_left( itype_test_winglets_left ); create_bird_char( dude ); // Flags are recognized and counted correctly REQUIRE( dude.has_bodypart_with_flag( json_flag_WALL_CLING ) ); @@ -122,7 +130,7 @@ TEST_CASE( "Limb_ugliness_calculations", "[character][npc][limb]" ) { standard_npc dude( "Test NPC" ); standard_npc beholder( "Beholder" ); - item wing_covers( "test_winglets" ); + item wing_covers( itype_test_winglets ); // We start at +/- 3 because of being unarmed REQUIRE( beholder.get_opinion_values( dude ).fear == -3 ); REQUIRE( beholder.get_opinion_values( dude ).trust == 3 ); @@ -232,8 +240,8 @@ TEST_CASE( "drying_rate", "[character][limb]" ) TEST_CASE( "Limb_consumption", "[limb]" ) { standard_npc dude( "Test NPC" ); - const item solid( "test_pine_nuts" ); - const item liquid( "test_liquid" ); + const item solid( itype_test_pine_nuts ); + const item liquid( itype_test_liquid ); clear_character( dude, true ); // Normal chars are normal REQUIRE( dude.get_modifier( character_modifier_liquid_consume_mod ) == 1.0f ); @@ -250,10 +258,10 @@ TEST_CASE( "Limb_consumption", "[limb]" ) TEST_CASE( "Limb_armor_coverage", "[character][limb][armor]" ) { standard_npc dude( "Test NPC" ); - item test_shackles( "test_shackles" ); - item test_jumpsuit_cotton( "test_jumpsuit_cotton" ); - item wing_covers( "test_winglets" ); - item bird_boots( "test_bird_boots" ); + item test_shackles( itype_test_shackles ); + item test_jumpsuit_cotton( itype_test_jumpsuit_cotton ); + item wing_covers( itype_test_winglets ); + item bird_boots( itype_test_bird_boots ); REQUIRE( test_jumpsuit_cotton.covers( body_part_arm_l ) ); REQUIRE( test_jumpsuit_cotton.portion_for_bodypart( body_part_arm_l )->coverage == 95 ); diff --git a/tests/map_bash_test.cpp b/tests/map_bash_test.cpp index 08c9f3efb82d5..d0aa93edfadbb 100644 --- a/tests/map_bash_test.cpp +++ b/tests/map_bash_test.cpp @@ -9,6 +9,10 @@ static const furn_str_id furn_test_f_bash_persist( "test_f_bash_persist" ); static const furn_str_id furn_test_f_eoc( "test_f_eoc" ); +static const itype_id itype_backpack( "backpack" ); +static const itype_id itype_remington_870( "remington_870" ); +static const itype_id itype_shot_bird( "shot_bird" ); + static const ter_str_id ter_t_floor( "t_floor" ); static const ter_str_id ter_test_t_bash_persist( "test_t_bash_persist" ); static const ter_str_id ter_test_t_pit_shallow( "test_t_pit_shallow" ); @@ -207,37 +211,37 @@ TEST_CASE( "shooting_at_terrain", "[map][bash][ranged]" ) // Make a shooter standard_npc shooter( "Shooter", { 10, 10, 0 } ); shooter.set_body(); - shooter.worn.wear_item( shooter, item( "backpack" ), false, false ); + shooter.worn.wear_item( shooter, item( itype_backpack ), false, false ); SECTION( "birdshot vs adobe wall point blank" ) { - arm_shooter( shooter, "remington_870", {}, "shot_bird" ); + arm_shooter( shooter, itype_remington_870, {}, itype_shot_bird ); shoot_at_terrain( shooter, "t_adobe_brick_wall", shooter.pos_bub() + point::east, false ); } SECTION( "birdshot vs adobe wall near" ) { - arm_shooter( shooter, "remington_870", {}, "shot_bird" ); + arm_shooter( shooter, itype_remington_870, {}, itype_shot_bird ); shoot_at_terrain( shooter, "t_adobe_brick_wall", shooter.pos_bub() + point::east * 2, false ); } SECTION( "birdshot vs opaque glass door point blank" ) { - arm_shooter( shooter, "remington_870", {}, "shot_bird" ); + arm_shooter( shooter, itype_remington_870, {}, itype_shot_bird ); shoot_at_terrain( shooter, "test_t_door_glass_opaque_c", shooter.pos_bub() + point::east, true ); } SECTION( "birdshot vs opaque glass door near" ) { - arm_shooter( shooter, "remington_870", {}, "shot_bird" ); + arm_shooter( shooter, itype_remington_870, {}, itype_shot_bird ); shoot_at_terrain( shooter, "test_t_door_glass_opaque_c", shooter.pos_bub() + point::east * 2, false ); } SECTION( "birdshot vs door near" ) { - arm_shooter( shooter, "remington_870", {}, "shot_bird" ); + arm_shooter( shooter, itype_remington_870, {}, itype_shot_bird ); shoot_at_terrain( shooter, "t_door_c", shooter.pos_bub() + point::east * 2, false ); } // I thought I saw some failures based on whether an unseen monster was present, // But I think it was just shooting at door wthout a 100% chance to break it and getting unlucky. SECTION( "birdshot through door at nothing" ) { - arm_shooter( shooter, "remington_870", {}, "shot_bird" ); + arm_shooter( shooter, itype_remington_870, {}, itype_shot_bird ); shoot_at_terrain( shooter, "t_door_c", shooter.pos_bub() + point::east, true, shooter.pos_bub() + point::east * 2 ); } SECTION( "birdshot through door at monster" ) { - arm_shooter( shooter, "remington_870", {}, "shot_bird" ); + arm_shooter( shooter, itype_remington_870, {}, itype_shot_bird ); spawn_test_monster( "mon_zombie", shooter.pos_bub() + point::east * 2 ); shoot_at_terrain( shooter, "t_door_c", shooter.pos_bub() + point::east, true, shooter.pos_bub() + point::east * 2 ); @@ -246,19 +250,19 @@ TEST_CASE( "shooting_at_terrain", "[map][bash][ranged]" ) // These are failing because you can't shoot transparent terrain. /* SECTION( "birdshot vs glass door point blank" ) { - arm_shooter( shooter, "remington_870", {}, "shot_bird" ); + arm_shooter( shooter, itype_remington_870, {}, itype_shot_bird ); shoot_at_terrain( shooter, "t_door_glass_c", shooter.pos_bub() + point::east, true ); } SECTION( "birdshot vs glass door near" ) { - arm_shooter( shooter, "remington_870", {}, "shot_bird" ); + arm_shooter( shooter, itype_remington_870, {}, itype_shot_bird ); shoot_at_terrain( shooter, "t_door_glass_c", shooter.pos_bub() + point::east * 2, false ); } SECTION( "birdshot vs screen door point blank" ) { - arm_shooter( shooter, "remington_870", {}, "shot_bird" ); + arm_shooter( shooter, itype_remington_870, {}, itype_shot_bird ); shoot_at_terrain( shooter, "t_door_screen_c", shooter.pos_bub() + point::east, true ); } SECTION( "birdshot vs screen door near" ) { - arm_shooter( shooter, "remington_870", {}, "shot_bird" ); + arm_shooter( shooter, itype_remington_870, {}, itype_shot_bird ); shoot_at_terrain( shooter, "t_door_screen_c", shooter.pos_bub() + point::east * 2, true ); } */ diff --git a/tests/map_helpers.cpp b/tests/map_helpers.cpp index 39643b6792a77..7c03283ee5516 100644 --- a/tests/map_helpers.cpp +++ b/tests/map_helpers.cpp @@ -29,6 +29,10 @@ #include "submap.h" #include "type_id.h" +static const itype_id itype_blindfold( "blindfold" ); +static const itype_id itype_medium_battery_cell( "medium_battery_cell" ); +static const itype_id itype_wearable_light_on( "wearable_light_on" ); + static const ter_str_id ter_t_grass( "t_grass" ); static const ter_str_id ter_t_open_air( "t_open_air" ); static const ter_str_id ter_t_rock( "t_rock" ); @@ -224,8 +228,8 @@ void build_water_test_map( const ter_id &surface, const ter_id &mid, const ter_i void player_add_headlamp() { - item headlamp( "wearable_light_on" ); - item battery( "medium_battery_cell" ); + item headlamp( itype_wearable_light_on ); + item battery( itype_medium_battery_cell ); battery.ammo_set( battery.ammo_default(), -1 ); headlamp.put_in( battery, pocket_type::MAGAZINE_WELL ); Character &you = get_player_character(); @@ -234,7 +238,7 @@ void player_add_headlamp() void player_wear_blindfold() { - item blindfold( "blindfold" ); + item blindfold( itype_blindfold ); Character &you = get_player_character(); you.worn.wear_item( you, blindfold, false, true ); } diff --git a/tests/map_test.cpp b/tests/map_test.cpp index 79ef5ed3cbf83..7adc06d2ba63c 100644 --- a/tests/map_test.cpp +++ b/tests/map_test.cpp @@ -15,6 +15,12 @@ #include "submap.h" #include "type_id.h" +static const itype_id itype_almond_milk( "almond_milk" ); +static const itype_id itype_bag_plastic( "bag_plastic" ); +static const itype_id itype_bottle_plastic( "bottle_plastic" ); +static const itype_id itype_cookies( "cookies" ); +static const itype_id itype_disinfectant( "disinfectant" ); + TEST_CASE( "map_coordinate_conversion_functions" ) { map &here = get_map(); @@ -177,9 +183,9 @@ TEST_CASE( "inactive_container_with_active_contents", "[active_item][map]" ) tripoint_bub_ms const test_loc; tripoint_abs_sm const test_loc_sm = project_to( here.getglobal( test_loc ) ); - item bottle_plastic( "bottle_plastic" ); + item bottle_plastic( itype_bottle_plastic ); REQUIRE( !bottle_plastic.needs_processing() ); - item disinfectant( "disinfectant" ); + item disinfectant( itype_disinfectant ); REQUIRE( disinfectant.needs_processing() ); ret_val const ret = @@ -222,7 +228,7 @@ TEST_CASE( "milk_rotting", "[active_item][map]" ) get_weather().forced_temperature = units::from_celsius( 21 ); REQUIRE( units::to_celsius( get_weather().get_temperature( test_loc ) ) == 21 ); - item almond_milk( "almond_milk" ); + item almond_milk( itype_almond_milk ); item *bp = nullptr; bool const in_container = GENERATE( true, false ); @@ -231,7 +237,7 @@ TEST_CASE( "milk_rotting", "[active_item][map]" ) if( in_container ) { sealed = GENERATE( true, false ); - item bottle_plastic( "bottle_plastic" ); + item bottle_plastic( itype_bottle_plastic ); ret_val const ret = bottle_plastic.put_in( almond_milk, pocket_type::CONTAINER ); REQUIRE( ret.success() ); @@ -275,8 +281,8 @@ TEST_CASE( "active_monster_drops", "[active_item][map]" ) bool const cookie_rotten_before_death = GENERATE( true, false ); CAPTURE( cookie_rotten_before_death ); - item bag_plastic( "bag_plastic" ); - item cookie( "cookies" ); + item bag_plastic( itype_bag_plastic ); + item cookie( itype_cookies ); REQUIRE( cookie.needs_processing() ); if( cookie_rotten_before_death ) { cookie.set_relative_rot( 10 ); diff --git a/tests/martial_art_test.cpp b/tests/martial_art_test.cpp index 89e26836cb55f..80cd87f89b708 100644 --- a/tests/martial_art_test.cpp +++ b/tests/martial_art_test.cpp @@ -20,6 +20,7 @@ static const enchantment_id enchantment_ENCH_TEST_BIRD_PARTS( "ENCH_TEST_BIRD_PA static const itype_id itype_club_wooden( "club_wooden" ); static const itype_id itype_sword_crude( "sword_crude" ); +static const itype_id itype_test_eoc_armor_suit( "test_eoc_armor_suit" ); static const itype_id itype_test_weapon1( "test_weapon1" ); static const itype_id itype_test_weapon2( "test_weapon2" ); @@ -136,7 +137,7 @@ TEST_CASE( "Attack_vector_test", "[martial_arts][limb]" ) } SECTION( "Encumbrance" ) { REQUIRE( dude.get_all_body_parts_of_type( body_part_type::type::tail ).empty() ); - item test_eoc_armor_suit( "test_eoc_armor_suit" ); + item test_eoc_armor_suit( itype_test_eoc_armor_suit ); REQUIRE( dude.wear_item( test_eoc_armor_suit, false ) ); CHECK( !dude.evaluate_technique( tec, target_1, dude.used_weapon(), false, false, false ) ); diff --git a/tests/materials_test.cpp b/tests/materials_test.cpp index 3cb1c2eeeb05a..a1343beaa6bcf 100644 --- a/tests/materials_test.cpp +++ b/tests/materials_test.cpp @@ -16,6 +16,13 @@ static const damage_type_id damage_cut( "cut" ); static const damage_type_id damage_heat( "heat" ); static const damage_type_id damage_stab( "stab" ); +static const itype_id itype_test_fire_ax_mostly_steel( "test_fire_ax_mostly_steel" ); +static const itype_id itype_test_fire_ax_mostly_wood( "test_fire_ax_mostly_wood" ); +static const itype_id itype_test_glass_pipe_mostly_glass( "test_glass_pipe_mostly_glass" ); +static const itype_id itype_test_glass_pipe_mostly_steel( "test_glass_pipe_mostly_steel" ); +static const itype_id itype_test_shears_mostly_plastic( "test_shears_mostly_plastic" ); +static const itype_id itype_test_shears_mostly_steel( "test_shears_mostly_steel" ); + static const material_id material_glass( "glass" ); static const material_id material_lycra( "lycra" ); static const material_id material_lycra_resist_override_stab( "lycra_resist_override_stab" ); @@ -40,8 +47,8 @@ static void check_near( const std::string &subject, float prob, const float expe TEST_CASE( "Resistance_vs_material_portions", "[material]" ) { - const item mostly_steel( "test_shears_mostly_steel" ); - const item mostly_plastic( "test_shears_mostly_plastic" ); + const item mostly_steel( itype_test_shears_mostly_steel ); + const item mostly_plastic( itype_test_shears_mostly_plastic ); REQUIRE( mostly_steel.get_base_material().id == material_steel ); REQUIRE( mostly_plastic.get_base_material().id == material_plastic ); @@ -57,8 +64,8 @@ TEST_CASE( "Resistance_vs_material_portions", "[material]" ) TEST_CASE( "Portioned_material_flammability", "[material]" ) { - const item mostly_steel( "test_fire_ax_mostly_steel" ); - const item mostly_wood( "test_fire_ax_mostly_wood" ); + const item mostly_steel( itype_test_fire_ax_mostly_steel ); + const item mostly_wood( itype_test_fire_ax_mostly_wood ); REQUIRE( mostly_steel.get_base_material().id == material_steel ); REQUIRE( mostly_wood.get_base_material().id == material_wood ); @@ -77,8 +84,8 @@ TEST_CASE( "Glass_portion_breakability", "[material] [slow]" ) { clear_creatures(); standard_npc dude( "TestCharacter", dude_pos, {}, 0, 8, 8, 8, 8 ); - item mostly_glass( "test_glass_pipe_mostly_glass" ); - item mostly_steel( "test_glass_pipe_mostly_steel" ); + item mostly_glass( itype_test_glass_pipe_mostly_glass ); + item mostly_steel( itype_test_glass_pipe_mostly_steel ); REQUIRE( mostly_glass.get_base_material().id == material_glass ); REQUIRE( mostly_steel.get_base_material().id == material_steel ); diff --git a/tests/melee_dodge_hit_test.cpp b/tests/melee_dodge_hit_test.cpp index a92325d146e05..27c748cdb43fd 100644 --- a/tests/melee_dodge_hit_test.cpp +++ b/tests/melee_dodge_hit_test.cpp @@ -18,6 +18,10 @@ #include "point.h" #include "type_id.h" +static const itype_id itype_roller_shoes_on( "roller_shoes_on" ); +static const itype_id itype_test_roller_blades( "test_roller_blades" ); +static const itype_id itype_test_rollerskates( "test_rollerskates" ); + static const mtype_id mon_zombie( "mon_zombie" ); static const mtype_id mon_zombie_smoker( "mon_zombie_smoker" ); @@ -271,9 +275,9 @@ TEST_CASE( "player_get_dodge_with_effects", "[player][melee][dodge][effect]" ) } SECTION( "skating: amateur or pro?" ) { - item skates( "test_rollerskates" ); - item blades( "test_roller_blades" ); - item heelys( "roller_shoes_on" ); + item skates( itype_test_rollerskates ); + item blades( itype_test_roller_blades ); + item heelys( itype_roller_shoes_on ); REQUIRE( skates.has_flag( flag_ROLLER_QUAD ) ); REQUIRE( blades.has_flag( flag_ROLLER_INLINE ) ); diff --git a/tests/melee_test.cpp b/tests/melee_test.cpp index 5395214b7d077..dbf5c273c4a23 100644 --- a/tests/melee_test.cpp +++ b/tests/melee_test.cpp @@ -20,6 +20,13 @@ static const damage_type_id damage_test_fire( "test_fire" ); static const efftype_id effect_sleep( "sleep" ); +static const itype_id itype_2x4( "2x4" ); +static const itype_id itype_katana( "katana" ); +static const itype_id itype_test_fire_sword( "test_fire_sword" ); +static const itype_id itype_test_zentai( "test_zentai" ); +static const itype_id itype_test_zentai_immune_test_fire( "test_zentai_immune_test_fire" ); +static const itype_id itype_test_zentai_resist_test_fire( "test_zentai_resist_test_fire" ); + static const move_mode_id move_mode_prone( "prone" ); static const mtype_id mon_manhack( "mon_manhack" ); @@ -102,7 +109,7 @@ TEST_CASE( "Character_attacking_a_zombie", "[.melee]" ) SECTION( "8/8/8/8, 3 all skills, plank" ) { standard_npc dude( "TestCharacter", dude_pos, {}, 3, 8, 8, 8, 8 ); - dude.set_wielded_item( item( "2x4" ) ); + dude.set_wielded_item( item( itype_2x4 ) ); const float prob = brute_probability( dude, zed, num_iters ); INFO( full_attack_details( dude ) ); check_near( prob, 0.8f, 0.05f ); @@ -110,7 +117,7 @@ TEST_CASE( "Character_attacking_a_zombie", "[.melee]" ) SECTION( "10/10/10/10, 8 all skills, katana" ) { standard_npc dude( "TestCharacter", dude_pos, {}, 8, 10, 10, 10, 10 ); - dude.set_wielded_item( item( "katana" ) ); + dude.set_wielded_item( item( itype_katana ) ); const float prob = brute_probability( dude, zed, num_iters ); INFO( full_attack_details( dude ) ); check_near( prob, 0.975f, 0.025f ); @@ -131,7 +138,7 @@ TEST_CASE( "Character_attacking_a_manhack", "[.melee]" ) SECTION( "8/8/8/8, 3 all skills, plank" ) { standard_npc dude( "TestCharacter", dude_pos, {}, 3, 8, 8, 8, 8 ); - dude.set_wielded_item( item( "2x4" ) ); + dude.set_wielded_item( item( itype_2x4 ) ); const float prob = brute_probability( dude, manhack, num_iters ); INFO( full_attack_details( dude ) ); check_near( prob, 0.4f, 0.05f ); @@ -139,7 +146,7 @@ TEST_CASE( "Character_attacking_a_manhack", "[.melee]" ) SECTION( "10/10/10/10, 8 all skills, katana" ) { standard_npc dude( "TestCharacter", dude_pos, {}, 8, 10, 10, 10, 10 ); - dude.set_wielded_item( item( "katana" ) ); + dude.set_wielded_item( item( itype_katana ) ); const float prob = brute_probability( dude, manhack, num_iters ); INFO( full_attack_details( dude ) ); check_near( prob, 0.7f, 0.05f ); @@ -336,7 +343,7 @@ static void check_damage_from_test_fire( const std::string &mon_id, int expected REQUIRE( mon.get_hp() == mon.get_hp_max() ); REQUIRE( dude.get_value( "general_dmg_type_test_test_fire" ).empty() ); REQUIRE( mon.get_value( "general_dmg_type_test_test_fire" ).empty() ); - dude.set_wielded_item( item( "test_fire_sword" ) ); + dude.set_wielded_item( item( itype_test_fire_sword ) ); dude.melee_attack( mon, false ); if( mon.get_hp() < mon.get_hp_max() ) { total_hits++; @@ -363,7 +370,7 @@ static void check_eocs_from_test_fire( const std::string &mon_id ) REQUIRE( mon.get_hp() == mon.get_hp_max() ); REQUIRE( dude.get_value( "general_dmg_type_test_test_fire" ).empty() ); REQUIRE( mon.get_value( "general_dmg_type_test_test_fire" ).empty() ); - item firesword( "test_fire_sword" ); + item firesword( itype_test_fire_sword ); dude.set_wielded_item( firesword ); for( int i = 0; i < 1000; ++i ) { if( dude.melee_attack( mon, false ) && !dude.get_value( "test_bp" ).empty() ) { @@ -382,7 +389,7 @@ static void check_eocs_from_test_fire( const std::string &mon_id ) CHECK( eoc_total_dmg == firesword.damage_melee( damage_test_fire ) ); } -static void check_damage_from_test_fire( const std::vector &armor_items, +static void check_damage_from_test_fire( const std::vector &armor_items, const bodypart_id &checked_bp, int expected_resist, bool is_immune, float expected_avg_dmg ) { int total_dmg = 0; @@ -392,7 +399,7 @@ static void check_damage_from_test_fire( const std::vector &armor_i clear_creatures(); standard_npc dude( "TestCharacter", dude_pos, {}, 8, 10, 10, 10, 10 ); standard_npc dude2( "TestCharacter2", dude_pos + tripoint::east, {}, 0, 0, 0, 0, 0 ); - for( const std::string &itm : armor_items ) { + for( const itype_id &itm : armor_items ) { REQUIRE( dude2.wear_item( item( itm ), false ).has_value() ); } dude2.set_movement_mode( move_mode_prone ); // no dodging allowed :) @@ -402,7 +409,7 @@ static void check_damage_from_test_fire( const std::vector &armor_i REQUIRE( dude2.get_hp() == dude2.get_hp_max() ); REQUIRE( dude.get_value( "general_dmg_type_test_test_fire" ).empty() ); REQUIRE( dude2.get_value( "general_dmg_type_test_test_fire" ).empty() ); - dude.set_wielded_item( item( "test_fire_sword" ) ); + dude.set_wielded_item( item( itype_test_fire_sword ) ); dude.melee_attack( dude2, false ); if( dude2.get_hp() < dude2.get_hp_max() ) { total_hits++; @@ -441,17 +448,17 @@ TEST_CASE( "Damage_type_effectiveness_vs_monster_resistance", "[melee][damage][e } SECTION( "Attacking an NPC with no resistance to test_fire" ) { - check_damage_from_test_fire( std::vector { "test_zentai" }, + check_damage_from_test_fire( { itype_test_zentai }, body_part_torso, 0, false, 14.84f ); } SECTION( "Attacking an NPC that is resistant to test_fire" ) { - check_damage_from_test_fire( std::vector { "test_zentai_resist_test_fire" }, + check_damage_from_test_fire( { itype_test_zentai_resist_test_fire }, body_part_torso, 2, false, 11.5f ); } SECTION( "Attacking an NPC that is immune to test_fire" ) { - check_damage_from_test_fire( std::vector { "test_zentai_immune_test_fire" }, + check_damage_from_test_fire( { itype_test_zentai_immune_test_fire }, body_part_torso, 0, true, 6.87f ); } } diff --git a/tests/modify_morale_test.cpp b/tests/modify_morale_test.cpp index eb7c283cca89a..2cfbe314d6fcb 100644 --- a/tests/modify_morale_test.cpp +++ b/tests/modify_morale_test.cpp @@ -14,6 +14,39 @@ #include "point.h" #include "type_id.h" +static const itype_id itype_apple( "apple" ); +static const itype_id itype_aspirin( "aspirin" ); +static const itype_id itype_backpack( "backpack" ); +static const itype_id itype_bone_human( "bone_human" ); +static const itype_id itype_broccoli( "broccoli" ); +static const itype_id itype_caff_gum( "caff_gum" ); +static const itype_id itype_caffeine( "caffeine" ); +static const itype_id itype_cig( "cig" ); +static const itype_id itype_codeine( "codeine" ); +static const itype_id itype_cigar( "cigar" ); +static const itype_id itype_crack( "crack" ); +static const itype_id itype_dayquil( "dayquil" ); +static const itype_id itype_disinfectant( "disinfectant" ); +static const itype_id itype_ecig( "ecig" ); +static const itype_id itype_garlic( "garlic" ); +static const itype_id itype_gum( "gum" ); +static const itype_id itype_heroin( "heroin" ); +static const itype_id itype_honeycomb( "honeycomb" ); +static const itype_id itype_joint( "joint" ); +static const itype_id itype_lsd( "lsd" ); +static const itype_id itype_meat( "meat" ); +static const itype_id itype_meth( "meth" ); +static const itype_id itype_milk( "milk" ); +static const itype_id itype_morphine( "morphine" ); +static const itype_id itype_neccowafers( "neccowafers" ); +static const itype_id itype_nic_gum( "nic_gum" ); +static const itype_id itype_oxycodone( "oxycodone" ); +static const itype_id itype_sourdough_bread( "sourdough_bread" ); +static const itype_id itype_toastem( "toastem" ); +static const itype_id itype_tobacco( "tobacco" ); +static const itype_id itype_weed( "weed" ); +static const itype_id itype_wheat( "wheat" ); + static const morale_type morale_antifruit( "morale_antifruit" ); static const morale_type morale_antijunk( "morale_antijunk" ); static const morale_type morale_antimeat( "morale_antimeat" ); @@ -64,11 +97,11 @@ static const vitamin_id vitamin_human_flesh_vitamin( "human_flesh_vitamin" ); TEST_CASE( "food_enjoyability", "[food][modify_morale][fun]" ) { avatar dummy; - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); std::pair fun; GIVEN( "food with positive fun" ) { - item_location toastem = dummy.i_add( item( "toastem" ) ); + item_location toastem = dummy.i_add( item( itype_toastem ) ); fun = dummy.fun_for( *toastem ); REQUIRE( fun.first > 0 ); @@ -79,7 +112,7 @@ TEST_CASE( "food_enjoyability", "[food][modify_morale][fun]" ) } GIVEN( "food with negative fun" ) { - item_location garlic = dummy.i_add( item( "garlic" ) ); + item_location garlic = dummy.i_add( item( itype_garlic ) ); fun = dummy.fun_for( *garlic ); REQUIRE( fun.first < 0 ); @@ -98,28 +131,28 @@ TEST_CASE( "dining_with_table_and_chair", "[food][modify_morale][table][chair]" dummy.set_body(); const tripoint_bub_ms avatar_pos( 60, 60, 0 ); dummy.setpos( avatar_pos ); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); // Morale bonus only applies to unspoiled food that is not junk - item_location bread = dummy.i_add( item( "sourdough_bread" ) ); + item_location bread = dummy.i_add( item( itype_sourdough_bread ) ); REQUIRE( bread->is_fresh() ); REQUIRE_FALSE( bread->has_flag( flag_ALLERGEN_JUNK ) ); // Much of the below code is to support the "Rigid Table Manners" trait, notoriously prone to // causing unexpected morale effects from bandages, aspirin, cigs etc. (#38698, #39580) // Table-related morale effects should not apply to any of the following items: - const std::vector no_table_eating_bonus = { + const std::vector no_table_eating_bonus = { { - "aspirin", - "caffeine", - "cig", - "codeine", - "crack", - "dayquil", - "disinfectant", - "joint", - "oxycodone", - "weed" + itype_aspirin, + itype_caffeine, + itype_cig, + itype_codeine, + itype_crack, + itype_dayquil, + itype_disinfectant, + itype_joint, + itype_oxycodone, + itype_weed } }; @@ -147,10 +180,10 @@ TEST_CASE( "dining_with_table_and_chair", "[food][modify_morale][table][chair]" CHECK( dummy.has_morale( morale_ate_without_table ) <= -2 ); } - for( const std::string &item_name : no_table_eating_bonus ) { - item test_item( item_name ); + for( const itype_id &item_id : no_table_eating_bonus ) { + item test_item( item_id ); - THEN( "they get no morale penalty for using " + item_name + " at a table" ) { + THEN( "they get no morale penalty for using " << item_id.c_str() << " at a table" ) { dummy.clear_morale(); dummy.modify_morale( test_item ); CHECK_FALSE( dummy.has_morale( morale_ate_without_table ) ); @@ -174,10 +207,10 @@ TEST_CASE( "dining_with_table_and_chair", "[food][modify_morale][table][chair]" CHECK( dummy.has_morale( morale_ate_with_table ) >= 1 ); } - for( const std::string &item_name : no_table_eating_bonus ) { - item test_item( item_name ); + for( const itype_id &item_id : no_table_eating_bonus ) { + item test_item( item_id ); - THEN( "they get no morale bonus for using " + item_name + " at a table" ) { + THEN( "they get no morale bonus for using " << item_id.c_str() << " at a table" ) { dummy.clear_morale(); dummy.modify_morale( test_item ); CHECK_FALSE( dummy.has_morale( morale_ate_with_table ) ); @@ -195,10 +228,10 @@ TEST_CASE( "dining_with_table_and_chair", "[food][modify_morale][table][chair]" CHECK( dummy.has_morale( morale_ate_with_table ) >= 3 ); } - for( const std::string &item_name : no_table_eating_bonus ) { - item test_item( item_name ); + for( const itype_id &item_id : no_table_eating_bonus ) { + item test_item( item_id ); - THEN( "they get no morale bonus for using " + item_name + " at a table" ) { + THEN( "they get no morale bonus for using " << item_id.c_str() << " at a table" ) { dummy.clear_morale(); dummy.modify_morale( test_item ); CHECK_FALSE( dummy.has_morale( morale_ate_with_table ) ); @@ -211,10 +244,10 @@ TEST_CASE( "dining_with_table_and_chair", "[food][modify_morale][table][chair]" TEST_CASE( "eating_hot_food", "[food][modify_morale][hot]" ) { avatar dummy; - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); GIVEN( "some food that tastes better when hot" ) { - item_location bread = dummy.i_add( item( "sourdough_bread" ) ); + item_location bread = dummy.i_add( item( itype_sourdough_bread ) ); REQUIRE( bread->has_flag( flag_EATEN_HOT ) ); WHEN( "it is hot" ) { @@ -245,22 +278,22 @@ TEST_CASE( "drugs", "[food][modify_morale][drug]" ) avatar dummy; std::pair fun; - const std::vector drugs_to_test = { + const std::vector drugs_to_test = { { - "gum", - "caff_gum", - "nic_gum", - "cig", - "ecig", - "cigar", - "joint", - "lsd", - "weed", - "crack", - "meth", - "heroin", - "tobacco", - "morphine" + itype_gum, + itype_caff_gum, + itype_nic_gum, + itype_cig, + itype_ecig, + itype_cigar, + itype_joint, + itype_lsd, + itype_weed, + itype_crack, + itype_meth, + itype_heroin, + itype_tobacco, + itype_morphine } }; @@ -268,12 +301,12 @@ TEST_CASE( "drugs", "[food][modify_morale][drug]" ) dummy.clear_morale(); REQUIRE( dummy.has_morale( morale_food_good ) == 0 ); - for( const std::string &drug_name : drugs_to_test ) { - item drug( drug_name ); + for( const itype_id &drug_id : drugs_to_test ) { + item drug( drug_id ); fun = dummy.fun_for( drug ); REQUIRE( fun.first > 0 ); - THEN( "they enjoy " + drug_name ) { + THEN( "they enjoy " << drug_id.c_str() ) { dummy.modify_morale( drug ); CHECK( dummy.has_morale( morale_food_good ) >= fun.first ); } @@ -285,9 +318,9 @@ TEST_CASE( "cannibalism", "[food][modify_morale][cannibal]" ) { avatar dummy; dummy.set_body(); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); - item_location human = dummy.i_add( item( "bone_human" ) ); + item_location human = dummy.i_add( item( itype_bone_human ) ); REQUIRE( human->has_vitamin( vitamin_human_flesh_vitamin ) ); GIVEN( "character is not a cannibal or sapiovore" ) { @@ -361,10 +394,10 @@ TEST_CASE( "sweet_junk_food", "[food][modify_morale][junk][sweet]" ) { avatar dummy; dummy.set_body(); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); GIVEN( "some sweet junk food" ) { - item_location necco = dummy.i_add( item( "neccowafers" ) ); + item_location necco = dummy.i_add( item( itype_neccowafers ) ); WHEN( "character has a sweet tooth" ) { dummy.toggle_trait( trait_PROJUNK ); @@ -415,9 +448,9 @@ TEST_CASE( "junk_food_that_is_not_ingested", "[modify_morale][junk][no_ingest]" { avatar dummy; dummy.set_body(); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); - item_location caff_gum = dummy.i_add( item( "caff_gum" ) ); + item_location caff_gum = dummy.i_add( item( itype_caff_gum ) ); // This is a regression test for gum having "junk" material, and being // treated as junk food (despite not being ingested). At the time of @@ -481,7 +514,7 @@ TEST_CASE( "food_allergies_and_intolerances", "[food][modify_morale][allergy]" ) { avatar dummy; dummy.set_body(); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); int penalty = -75; GIVEN( "character is vegetarian" ) { @@ -489,7 +522,7 @@ TEST_CASE( "food_allergies_and_intolerances", "[food][modify_morale][allergy]" ) REQUIRE( dummy.has_trait( trait_VEGETARIAN ) ); THEN( "they get a morale penalty for eating meat" ) { - item_location meat = dummy.i_add( item( "meat" ) ); + item_location meat = dummy.i_add( item( itype_meat ) ); REQUIRE( meat->has_flag( flag_ALLERGEN_MEAT ) ); dummy.clear_morale(); dummy.modify_morale( *meat ); @@ -502,7 +535,7 @@ TEST_CASE( "food_allergies_and_intolerances", "[food][modify_morale][allergy]" ) REQUIRE( dummy.has_trait( trait_LACTOSE ) ); THEN( "they get a morale penalty for drinking milk" ) { - item_location milk_container = dummy.i_add( item( "milk" ).in_its_container() ); + item_location milk_container = dummy.i_add( item( itype_milk ).in_its_container() ); item &milk = milk_container->only_item(); REQUIRE( milk.has_flag( flag_ALLERGEN_MILK ) ); dummy.clear_morale(); @@ -516,7 +549,7 @@ TEST_CASE( "food_allergies_and_intolerances", "[food][modify_morale][allergy]" ) REQUIRE( dummy.has_trait( trait_ANTIWHEAT ) ); THEN( "they get a morale penalty for eating wheat" ) { - item_location wheat = dummy.i_add( item( "wheat" ) ); + item_location wheat = dummy.i_add( item( itype_wheat ) ); REQUIRE( wheat->has_flag( flag_ALLERGEN_WHEAT ) ); dummy.clear_morale(); dummy.modify_morale( *wheat ); @@ -529,7 +562,7 @@ TEST_CASE( "food_allergies_and_intolerances", "[food][modify_morale][allergy]" ) REQUIRE( dummy.has_trait( trait_MEATARIAN ) ); THEN( "they get a morale penalty for eating vegetables" ) { - item_location veggy = dummy.i_add( item( "broccoli" ) ); + item_location veggy = dummy.i_add( item( itype_broccoli ) ); REQUIRE( veggy->has_flag( flag_ALLERGEN_VEGGY ) ); dummy.clear_morale(); dummy.modify_morale( *veggy ); @@ -542,7 +575,7 @@ TEST_CASE( "food_allergies_and_intolerances", "[food][modify_morale][allergy]" ) REQUIRE( dummy.has_trait( trait_ANTIFRUIT ) ); THEN( "they get a morale penalty for eating fruit" ) { - item_location fruit = dummy.i_add( item( "apple" ) ); + item_location fruit = dummy.i_add( item( itype_apple ) ); REQUIRE( fruit->has_flag( flag_ALLERGEN_FRUIT ) ); dummy.clear_morale(); dummy.modify_morale( *fruit ); @@ -555,7 +588,7 @@ TEST_CASE( "food_allergies_and_intolerances", "[food][modify_morale][allergy]" ) REQUIRE( dummy.has_trait( trait_ANTIJUNK ) ); THEN( "they get a morale penalty for eating junk food" ) { - item_location junk = dummy.i_add( item( "neccowafers" ) ); + item_location junk = dummy.i_add( item( itype_neccowafers ) ); REQUIRE( junk->has_flag( flag_ALLERGEN_JUNK ) ); dummy.clear_morale(); dummy.modify_morale( *junk ); @@ -568,7 +601,7 @@ TEST_CASE( "saprophage_character", "[food][modify_morale][saprophage]" ) { avatar dummy; dummy.set_body(); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); GIVEN( "character is a saprophage, preferring rotted food" ) { dummy.clear_morale(); @@ -576,7 +609,7 @@ TEST_CASE( "saprophage_character", "[food][modify_morale][saprophage]" ) REQUIRE( dummy.has_trait( trait_SAPROPHAGE ) ); AND_GIVEN( "some rotten chewable food" ) { - item_location toastem = dummy.i_add( item( "toastem" ) ); + item_location toastem = dummy.i_add( item( itype_toastem ) ); // food rot > 1.0 is rotten toastem->set_relative_rot( 1.5 ); REQUIRE( toastem->rotten() ); @@ -588,7 +621,7 @@ TEST_CASE( "saprophage_character", "[food][modify_morale][saprophage]" ) } AND_GIVEN( "some fresh chewable food" ) { - item_location toastem = dummy.i_add( item( "toastem" ) ); + item_location toastem = dummy.i_add( item( itype_toastem ) ); // food rot < 0.1 is fresh toastem->set_relative_rot( 0.0 ); REQUIRE( toastem->is_fresh() ); @@ -605,9 +638,9 @@ TEST_CASE( "ursine_honey", "[food][modify_morale][ursine][honey]" ) { avatar dummy; dummy.set_body(); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); - item_location honeycomb = dummy.i_add( item( "honeycomb" ) ); + item_location honeycomb = dummy.i_add( item( itype_honeycomb ) ); REQUIRE( honeycomb->has_flag( flag_URSINE_HONEY ) ); GIVEN( "character is post-threshold ursine" ) { diff --git a/tests/mondefense_test.cpp b/tests/mondefense_test.cpp index dfbf1f75b253a..bb20b53b6c616 100644 --- a/tests/mondefense_test.cpp +++ b/tests/mondefense_test.cpp @@ -14,6 +14,12 @@ static const bionic_id bio_power_storage( "bio_power_storage" ); static const gun_mode_id gun_mode_MELEE( "MELEE" ); +static const itype_id itype_glock_19( "glock_19" ); +static const itype_id itype_knuckle_nail( "knuckle_nail" ); +static const itype_id itype_pike( "pike" ); +static const itype_id itype_reach_bow( "reach_bow" ); +static const itype_id itype_rock( "rock" ); + static const mtype_id mon_zombie_electric( "mon_zombie_electric" ); static const mtype_id mon_zomborg( "mon_zomborg" ); @@ -40,7 +46,7 @@ TEST_CASE( "zapback_npc_unarmed", "[mondefense]" ) TEST_CASE( "zapback_npc_nonconductive_weapon", "[mondefense]" ) { standard_npc attacker( "Attacker" ); - item rock( "rock" ); + item rock( itype_rock ); attacker.wield( rock ); test_zapback( attacker, false ); } @@ -49,7 +55,7 @@ TEST_CASE( "zapback_npc_nonconductive_unarmed_weapon", "[mondefense]" ) { standard_npc attacker( "Attacker" ); // AFAICT this is the only nonconductive unarmed weapon. - item knuckle_nail( "knuckle_nail" ); + item knuckle_nail( itype_knuckle_nail ); attacker.wield( knuckle_nail ); test_zapback( attacker, false ); } @@ -57,7 +63,7 @@ TEST_CASE( "zapback_npc_nonconductive_unarmed_weapon", "[mondefense]" ) TEST_CASE( "zapback_npc_reach_weapon", "[mondefense]" ) { standard_npc attacker( "Attacker" ); - item pike( "pike" ); + item pike( itype_pike ); attacker.wield( pike ); test_zapback( attacker, false ); } @@ -65,7 +71,7 @@ TEST_CASE( "zapback_npc_reach_weapon", "[mondefense]" ) TEST_CASE( "zapback_npc_ranged_weapon", "[mondefense]" ) { standard_npc attacker( "Attacker" ); - item gun( "glock_19" ); + item gun( itype_glock_19 ); attacker.wield( gun ); dealt_projectile_attack attack; test_zapback( attacker, false, &attack ); @@ -81,7 +87,7 @@ TEST_CASE( "zapback_npc_thrown_weapon", "[mondefense]" ) TEST_CASE( "zapback_npc_firing_ranged_reach_weapon", "[mondefense]" ) { standard_npc attacker( "Attacker" ); - item ranged_reach_weapon( "reach_bow" ); + item ranged_reach_weapon( itype_reach_bow ); attacker.wield( ranged_reach_weapon ); dealt_projectile_attack attack; test_zapback( attacker, false, &attack ); @@ -90,7 +96,7 @@ TEST_CASE( "zapback_npc_firing_ranged_reach_weapon", "[mondefense]" ) TEST_CASE( "zapback_npc_meleeattack_ranged_reach_weapon", "[mondefense]" ) { standard_npc attacker( "Attacker" ); - item ranged_reach_weapon( "reach_bow" ); + item ranged_reach_weapon( itype_reach_bow ); REQUIRE( ranged_reach_weapon.gun_set_mode( gun_mode_MELEE ) ); attacker.wield( ranged_reach_weapon ); test_zapback( attacker, true ); diff --git a/tests/morale_test.cpp b/tests/morale_test.cpp index 121bdbfff1654..7af60142fb47d 100644 --- a/tests/morale_test.cpp +++ b/tests/morale_test.cpp @@ -18,6 +18,15 @@ static const efftype_id effect_cold( "cold" ); static const efftype_id effect_hot( "hot" ); static const efftype_id effect_took_prozac( "took_prozac" ); +static const itype_id itype_boots( "boots" ); +static const itype_id itype_dress_wedding( "dress_wedding" ); +static const itype_id itype_heels( "heels" ); +static const itype_id itype_legpouch( "legpouch" ); +static const itype_id itype_sf_watch( "sf_watch" ); +static const itype_id itype_shotgun_s( "shotgun_s" ); +static const itype_id itype_tinfoil_hat( "tinfoil_hat" ); +static const itype_id itype_veil_wedding( "veil_wedding" ); + static const morale_type morale_book( "morale_book" ); static const morale_type morale_food_bad( "morale_food_bad" ); static const morale_type morale_food_good( "morale_food_good" ); @@ -264,7 +273,7 @@ TEST_CASE( "player_morale_ranged_kill_of_unaware_hostile_bandit", "[player_moral CHECK( badguy.sees( player.pos() ) == false ); for( size_t loop = 0; loop < 1000; loop++ ) { player.set_body(); - arm_shooter( player, "shotgun_s" ); + arm_shooter( player, itype_shotgun_s ); player.recoil = 0; player.fire_gun( bandit_pos, 1, *player.get_wielded_item() ); if( badguy.is_dead_state() ) { @@ -280,9 +289,9 @@ TEST_CASE( "player_morale_fancy_clothes", "[player_morale]" ) player_morale m; GIVEN( "a set of super fancy bride's clothes" ) { - const item dress_wedding( "dress_wedding", calendar::turn_zero ); // legs, torso | 8 + 2 | 10 - const item veil_wedding( "veil_wedding", calendar::turn_zero ); // eyes, mouth | 4 + 2 | 6 - const item heels( "heels", calendar::turn_zero ); // not super fancy, feet | 1 | 1 + const item dress_wedding( itype_dress_wedding, calendar::turn_zero ); // legs, torso | 8 + 2 | 10 + const item veil_wedding( itype_veil_wedding, calendar::turn_zero ); // eyes, mouth | 4 + 2 | 6 + const item heels( itype_heels, calendar::turn_zero ); // not super fancy, feet | 1 | 1 m.on_item_wear( dress_wedding ); m.on_item_wear( veil_wedding ); @@ -320,7 +329,7 @@ TEST_CASE( "player_morale_fancy_clothes", "[player_morale]" ) } } AND_WHEN( "tries to be even fancier" ) { - const item watch( "sf_watch", calendar::turn_zero ); + const item watch( itype_sf_watch, calendar::turn_zero ); m.on_item_wear( watch ); THEN( "there's a limit" ) { CHECK( m.get_level() == 20 ); @@ -454,7 +463,7 @@ TEST_CASE( "player_morale_plant", "[player_morale]" ) CHECK( m.has( morale_perm_constrained ) == 0 ); WHEN( "wearing a hat" ) { - const item hat( "tinfoil_hat", calendar::turn_zero ); + const item hat( itype_tinfoil_hat, calendar::turn_zero ); m.on_item_wear( hat ); THEN( "the flowers need sunlight" ) { @@ -468,7 +477,7 @@ TEST_CASE( "player_morale_plant", "[player_morale]" ) } WHEN( "wearing a legpouch" ) { - item legpouch( "legpouch", calendar::turn_zero ); + item legpouch( itype_legpouch, calendar::turn_zero ); legpouch.set_side( side::LEFT ); m.on_item_wear( legpouch ); @@ -478,7 +487,7 @@ TEST_CASE( "player_morale_plant", "[player_morale]" ) } WHEN( "wearing a pair of boots" ) { - const item boots( "boots", calendar::turn_zero ); + const item boots( itype_boots, calendar::turn_zero ); m.on_item_wear( boots ); THEN( "all of the roots are suffering" ) { @@ -486,7 +495,7 @@ TEST_CASE( "player_morale_plant", "[player_morale]" ) } AND_WHEN( "even more constrains" ) { - const item hat( "tinfoil_hat", calendar::turn_zero ); + const item hat( itype_tinfoil_hat, calendar::turn_zero ); m.on_item_wear( hat ); THEN( "it can't be worse" ) { diff --git a/tests/move_cost_test.cpp b/tests/move_cost_test.cpp index 66c76512a92dd..494b03c52f1c5 100644 --- a/tests/move_cost_test.cpp +++ b/tests/move_cost_test.cpp @@ -29,6 +29,14 @@ character_modifier_limb_speed_movecost_mod( "limb_speed_movecost_mod" ); static const efftype_id effect_downed( "downed" ); +static const itype_id itype_roller_blades( "roller_blades" ); +static const itype_id itype_roller_shoes_on( "roller_shoes_on" ); +static const itype_id itype_rollerskates( "rollerskates" ); +static const itype_id itype_sneakers( "sneakers" ); +static const itype_id itype_swim_fins( "swim_fins" ); +static const itype_id itype_test_briefcase( "test_briefcase" ); +static const itype_id itype_test_hazmat_suit( "test_hazmat_suit" ); + static const move_mode_id move_mode_crouch( "crouch" ); static const move_mode_id move_mode_prone( "prone" ); static const move_mode_id move_mode_run( "run" ); @@ -47,7 +55,7 @@ TEST_CASE( "being_knocked_down_triples_movement_cost", "[move_cost][downed]" ) clear_avatar(); // Put on sneakers to normalize run cost to 100 - ava.wear_item( item( "sneakers" ) ); + ava.wear_item( item( itype_sneakers ) ); REQUIRE( ava.run_cost( 100 ) == 100 ); ava.add_effect( effect_downed, 1_turns ); @@ -78,7 +86,7 @@ TEST_CASE( "footwear_may_affect_movement_cost", "[move_cost][shoes]" ) SECTION( "wearing sneakers" ) { ava.clear_worn(); - ava.wear_item( item( "sneakers" ) ); + ava.wear_item( item( itype_sneakers ) ); REQUIRE( ava.is_wearing_shoes() ); REQUIRE( ava.get_modifier( character_modifier_limb_run_cost_mod ) == Approx( 1.0 ) ); // Sneakers eliminate the no-shoes penalty @@ -87,7 +95,7 @@ TEST_CASE( "footwear_may_affect_movement_cost", "[move_cost][shoes]" ) SECTION( "wearing swim fins" ) { ava.clear_worn(); - ava.wear_item( item( "swim_fins" ) ); + ava.wear_item( item( itype_swim_fins ) ); REQUIRE( ava.is_wearing_shoes() ); REQUIRE( ava.get_modifier( character_modifier_limb_run_cost_mod ) == Approx( 1.11696 ) ); // Swim fins multiply cost by 1.5 @@ -96,7 +104,7 @@ TEST_CASE( "footwear_may_affect_movement_cost", "[move_cost][shoes]" ) GIVEN( "wearing rollerblades (ROLLER_INLINE)" ) { ava.clear_worn(); - ava.wear_item( item( "roller_blades" ) ); + ava.wear_item( item( itype_roller_blades ) ); REQUIRE( ava.worn_with_flag( flag_ROLLER_INLINE ) ); REQUIRE( ava.get_modifier( character_modifier_limb_run_cost_mod ) == Approx( 1.11696 ) ); WHEN( "on pavement and running" ) { @@ -116,7 +124,7 @@ TEST_CASE( "footwear_may_affect_movement_cost", "[move_cost][shoes]" ) GIVEN( "wearing roller skates (ROLLER_QUAD)" ) { ava.clear_worn(); - ava.wear_item( item( "rollerskates" ) ); + ava.wear_item( item( itype_rollerskates ) ); REQUIRE( ava.worn_with_flag( flag_ROLLER_QUAD ) ); REQUIRE( ava.get_modifier( character_modifier_limb_run_cost_mod ) == Approx( 1.11696 ) ); WHEN( "on pavement and running" ) { @@ -136,7 +144,7 @@ TEST_CASE( "footwear_may_affect_movement_cost", "[move_cost][shoes]" ) GIVEN( "wearing heelys (ROLLER_ONE)" ) { ava.clear_worn(); - ava.wear_item( item( "roller_shoes_on" ) ); + ava.wear_item( item( itype_roller_shoes_on ) ); REQUIRE( ava.worn_with_flag( flag_ROLLER_ONE ) ); REQUIRE( ava.get_modifier( character_modifier_limb_run_cost_mod ) == Approx( 1.0 ) ); WHEN( "on pavement and running" ) { @@ -167,7 +175,7 @@ TEST_CASE( "mutations_may_affect_movement_cost", "[move_cost][mutation]" ) GIVEN( "no mutations" ) { THEN( "wearing sneakers gives baseline 100 movement speed" ) { ava.clear_worn(); - ava.wear_item( item( "sneakers" ) ); + ava.wear_item( item( itype_sneakers ) ); CHECK( ava.run_cost( 100 ) == Approx( base_cost ) ); } THEN( "being barefoot gives a +16 movement cost penalty" ) { @@ -208,7 +216,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) avatar &u = get_avatar(); clear_avatar(); clear_map(); - u.wear_item( item( "sneakers" ) ); + u.wear_item( item( itype_sneakers ) ); u.set_moves( 0 ); WHEN( "is walking" ) { @@ -242,8 +250,8 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) GIVEN( "Character is uninjured and has 30 arm encumbrance" ) { avatar &u = get_avatar(); clear_avatar(); - u.wear_item( item( "sneakers" ) ); - u.wear_item( item( "test_briefcase" ) ); + u.wear_item( item( itype_sneakers ) ); + u.wear_item( item( itype_test_briefcase ) ); u.set_moves( 0 ); WHEN( "is walking" ) { @@ -277,7 +285,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) GIVEN( "Character is uninjured and has 37 encumbrance, all limbs" ) { avatar &u = get_avatar(); clear_avatar(); - u.wear_item( item( "test_hazmat_suit" ) ); + u.wear_item( item( itype_test_hazmat_suit ) ); u.set_moves( 0 ); WHEN( "is walking" ) { @@ -312,7 +320,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) GIVEN( "Character has damaged arm and is unencumbered" ) { avatar &u = get_avatar(); clear_avatar(); - u.wear_item( item( "sneakers" ) ); + u.wear_item( item( itype_sneakers ) ); u.set_part_hp_cur( body_part_arm_l, 10 ); u.set_moves( 0 ); @@ -347,8 +355,8 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) GIVEN( "Character has damaged arm and 30 arm encumbrance" ) { avatar &u = get_avatar(); clear_avatar(); - u.wear_item( item( "sneakers" ) ); - u.wear_item( item( "test_briefcase" ) ); + u.wear_item( item( itype_sneakers ) ); + u.wear_item( item( itype_test_briefcase ) ); u.set_part_hp_cur( body_part_arm_l, 10 ); u.set_moves( 0 ); @@ -383,7 +391,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) GIVEN( "Character has damaged arm and 37 encumbrance, all limbs" ) { avatar &u = get_avatar(); clear_avatar(); - u.wear_item( item( "test_hazmat_suit" ) ); + u.wear_item( item( itype_test_hazmat_suit ) ); u.set_part_hp_cur( body_part_arm_l, 10 ); u.set_moves( 0 ); @@ -419,7 +427,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) GIVEN( "Character has 2 broken legs and is unencumbered" ) { avatar &u = get_avatar(); clear_avatar(); - u.wear_item( item( "sneakers" ) ); + u.wear_item( item( itype_sneakers ) ); u.set_part_hp_cur( body_part_leg_l, 0 ); u.set_part_hp_cur( body_part_leg_r, 0 ); u.set_moves( 0 ); @@ -438,8 +446,8 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) GIVEN( "Character has 2 broken legs arm and 30 arm encumbrance" ) { avatar &u = get_avatar(); clear_avatar(); - u.wear_item( item( "sneakers" ) ); - u.wear_item( item( "test_briefcase" ) ); + u.wear_item( item( itype_sneakers ) ); + u.wear_item( item( itype_test_briefcase ) ); u.set_part_hp_cur( body_part_leg_l, 0 ); u.set_part_hp_cur( body_part_leg_r, 0 ); u.set_moves( 0 ); @@ -458,7 +466,7 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) GIVEN( "Character has 2 broken legs and 37 encumbrance, all limbs" ) { avatar &u = get_avatar(); clear_avatar(); - u.wear_item( item( "test_hazmat_suit" ) ); + u.wear_item( item( itype_test_hazmat_suit ) ); u.set_part_hp_cur( body_part_leg_l, 0 ); u.set_part_hp_cur( body_part_leg_r, 0 ); u.set_moves( 0 ); diff --git a/tests/npc_attack_test.cpp b/tests/npc_attack_test.cpp index 5cb8d409b6cfe..8aebf1e6063c3 100644 --- a/tests/npc_attack_test.cpp +++ b/tests/npc_attack_test.cpp @@ -15,7 +15,9 @@ static const faction_id faction_your_followers( "your_followers" ); static const itype_id itype_combat_exoskeleton_medium( "combat_exoskeleton_medium" ); static const itype_id itype_combat_exoskeleton_medium_on( "combat_exoskeleton_medium_on" ); +static const itype_id itype_heavy_battery_cell( "heavy_battery_cell" ); static const itype_id itype_knife_large( "knife_large" ); +static const itype_id itype_modular_m16a4( "modular_m16a4" ); static const itype_id itype_rock( "rock" ); static const itype_id itype_wearable_light( "wearable_light" ); @@ -77,7 +79,7 @@ TEST_CASE( "NPC_faces_zombies", "[npc_attack]" ) monster *zombie = npc_attack_setup::spawn_zombie_at_range( 1 ); WHEN( "NPC only has a large knife" ) { - item weapon( "knife_large" ); + item weapon( itype_knife_large ); main_npc.set_wielded_item( weapon ); REQUIRE( main_npc.get_wielded_item()->typeId() == itype_knife_large ); @@ -93,7 +95,7 @@ TEST_CASE( "NPC_faces_zombies", "[npc_attack]" ) } } WHEN( "NPC only has an m16a4" ) { - arm_shooter( main_npc, "modular_m16a4" ); + arm_shooter( main_npc, itype_modular_m16a4 ); WHEN( "NPC is allowed to use loud ranged weapons" ) { main_npc.rules.set_flag( ally_rule::use_guns ); @@ -136,7 +138,7 @@ TEST_CASE( "NPC_faces_zombies", "[npc_attack]" ) } } WHEN( "NPC only has a bunch of rocks" ) { - item weapon( "rock" ); + item weapon( itype_rock ); main_npc.set_wielded_item( weapon ); REQUIRE( main_npc.get_wielded_item()->typeId() == itype_rock ); @@ -150,7 +152,7 @@ TEST_CASE( "NPC_faces_zombies", "[npc_attack]" ) WHEN( "NPC has an exoskeleton" ) { main_npc.clear_worn(); - item armor( "combat_exoskeleton_medium" ); + item armor( itype_combat_exoskeleton_medium ); std::optional::iterator> wear_success = main_npc.wear_item( armor ); item &worn_armor = **wear_success; @@ -161,7 +163,7 @@ TEST_CASE( "NPC_faces_zombies", "[npc_attack]" ) WHEN( "NPC has a battery for their armor" ) { - item battery = item( "heavy_battery_cell" ); + item battery = item( itype_heavy_battery_cell ); battery.ammo_set( battery.ammo_default() ); worn_armor.put_in( battery, pocket_type::MAGAZINE_WELL ); @@ -189,7 +191,7 @@ TEST_CASE( "NPC_faces_zombies", "[npc_attack]" ) WHEN( "NPC has a headlamp" ) { main_npc.clear_worn(); - item headlamp( "wearable_light" ); + item headlamp( itype_wearable_light ); std::optional::iterator> wear_success = main_npc.wear_item( headlamp ); REQUIRE( wear_success ); @@ -208,7 +210,7 @@ TEST_CASE( "NPC_faces_zombies", "[npc_attack]" ) monster *zombie = npc_attack_setup::spawn_zombie_at_range( 5 ); WHEN( "NPC only has a large knife" ) { - item weapon( "knife_large" ); + item weapon( itype_knife_large ); main_npc.set_wielded_item( weapon ); REQUIRE( main_npc.get_wielded_item()->typeId() == itype_knife_large ); @@ -225,7 +227,7 @@ TEST_CASE( "NPC_faces_zombies", "[npc_attack]" ) } WHEN( "NPC only has a bunch of rocks" ) { - item weapon( "rock", calendar::turn, 5 ); + item weapon( itype_rock, calendar::turn, 5 ); main_npc.set_wielded_item( weapon ); REQUIRE( main_npc.get_wielded_item()->typeId() == itype_rock ); @@ -242,7 +244,7 @@ TEST_CASE( "NPC_faces_zombies", "[npc_attack]" ) monster *zombie_far = npc_attack_setup::spawn_zombie_at_range( 8 ); WHEN( "NPC only has a large knife" ) { - item weapon( "knife_large" ); + item weapon( itype_knife_large ); main_npc.set_wielded_item( weapon ); REQUIRE( main_npc.get_wielded_item()->typeId() == itype_knife_large ); @@ -292,7 +294,7 @@ TEST_CASE( "NPC_faces_zombies", "[npc_attack]" ) } GIVEN( "There is no zombie nearby. " ) { WHEN( "NPC is wearing active exoskeleton. " ) { - item armor( "combat_exoskeleton_medium_on" ); + item armor( itype_combat_exoskeleton_medium_on ); armor.activate(); std::optional::iterator> wear_success = main_npc.wear_item( armor ); REQUIRE( wear_success ); diff --git a/tests/npc_blacklist_test.cpp b/tests/npc_blacklist_test.cpp index 58b99a81fc05d..18e78ee77dca4 100644 --- a/tests/npc_blacklist_test.cpp +++ b/tests/npc_blacklist_test.cpp @@ -1,6 +1,8 @@ #include "cata_catch.h" #include "npc.h" +static const itype_id itype_bow_saw( "bow_saw" ); + static npc_template_id const npc_template_test_npc_trader( "test_npc_trader" ); TEST_CASE( "npc_blacklist", "[npc][trade]" ) @@ -8,7 +10,7 @@ TEST_CASE( "npc_blacklist", "[npc][trade]" ) npc guy; guy.load_npc_template( npc_template_test_npc_trader ); - REQUIRE( guy.wants_to_buy( item( "bow_saw" ) ) ); + REQUIRE( guy.wants_to_buy( item( itype_bow_saw ) ) ); guy.set_value( "bool_bigotry_hates_bow_saws", "yes" ); - REQUIRE( !guy.wants_to_buy( item( "bow_saw" ) ) ); + REQUIRE( !guy.wants_to_buy( item( itype_bow_saw ) ) ); } diff --git a/tests/npc_shop_cons_rates_test.cpp b/tests/npc_shop_cons_rates_test.cpp index 6f24a1843ead8..8717607422dbf 100644 --- a/tests/npc_shop_cons_rates_test.cpp +++ b/tests/npc_shop_cons_rates_test.cpp @@ -2,6 +2,15 @@ #include "npc.h" #include "npc_class.h" +static const itype_id itype_FMCNote( "FMCNote" ); +static const itype_id itype_bow_saw( "bow_saw" ); +static const itype_id itype_coin_dollar( "coin_dollar" ); +static const itype_id itype_coin_gold( "coin_gold" ); +static const itype_id itype_glass_shard( "glass_shard" ); +static const itype_id itype_hammer( "hammer" ); +static const itype_id itype_test_nuclear_carafe( "test_nuclear_carafe" ); +static const itype_id itype_test_pipe( "test_pipe" ); + static npc_template_id const npc_template_test_npc_trader( "test_npc_trader" ); TEST_CASE( "npc_shop_cons_rates", "[npc][trade]" ) @@ -12,33 +21,33 @@ TEST_CASE( "npc_shop_cons_rates", "[npc][trade]" ) shopkeeper_cons_rates const &myrates = guy.myclass->get_shopkeeper_cons_rates(); WHEN( "item has no matches" ) { - REQUIRE( myrates.get_rate( item( "hammer" ), guy ) == myrates.default_rate ); + REQUIRE( myrates.get_rate( item( itype_hammer ), guy ) == myrates.default_rate ); } WHEN( "item is matched by junk threshold" ) { - item const glass_shard( "glass_shard" ); + item const glass_shard( itype_glass_shard ); REQUIRE( glass_shard.price_no_contents( true ) < units::to_cent( myrates.junk_threshold ) ); REQUIRE( myrates.get_rate( glass_shard, guy ) == -1 ); } WHEN( "item is matched by typeid" ) { - REQUIRE( myrates.get_rate( item( "bow_saw" ), guy ) == 2 ); + REQUIRE( myrates.get_rate( item( itype_bow_saw ), guy ) == 2 ); } WHEN( "item is matched by typeid and condition is true" ) { guy.set_value( "bool_dinner_bow_saw_eater", "yes" ); - REQUIRE( myrates.get_rate( item( "bow_saw" ), guy ) == 99 ); + REQUIRE( myrates.get_rate( item( itype_bow_saw ), guy ) == 99 ); } WHEN( "item is matched by category" ) { - REQUIRE( myrates.get_rate( item( "coin_gold" ), guy ) == 10 ); + REQUIRE( myrates.get_rate( item( itype_coin_gold ), guy ) == 10 ); } WHEN( "item is matched by category but it's junk" ) { - REQUIRE( myrates.get_rate( item( "coin_dollar" ), guy ) == -1 ); + REQUIRE( myrates.get_rate( item( itype_coin_dollar ), guy ) == -1 ); } WHEN( "item is matched by item_group" ) { - REQUIRE( myrates.get_rate( item( "test_pipe" ), guy ) == 100 ); + REQUIRE( myrates.get_rate( item( itype_test_pipe ), guy ) == 100 ); } WHEN( "item is matched by entry with both item_group and category" ) { - REQUIRE( myrates.get_rate( item( "test_nuclear_carafe" ), guy ) == 50 ); + REQUIRE( myrates.get_rate( item( itype_test_nuclear_carafe ), guy ) == 50 ); } WHEN( "item is matched by category and an overriding entry" ) { - REQUIRE( myrates.get_rate( item( "FMCNote" ), guy ) == 25 ); + REQUIRE( myrates.get_rate( item( itype_FMCNote ), guy ) == 25 ); } } diff --git a/tests/npc_shopkeeper_item_groups_test.cpp b/tests/npc_shopkeeper_item_groups_test.cpp index 713c14ed57221..f5a3b7e129a82 100644 --- a/tests/npc_shopkeeper_item_groups_test.cpp +++ b/tests/npc_shopkeeper_item_groups_test.cpp @@ -9,6 +9,13 @@ #include "npc_class.h" #include "player_helpers.h" +static const itype_id itype_bag_plastic( "bag_plastic" ); +static const itype_id itype_hammer( "hammer" ); +static const itype_id itype_scrap( "scrap" ); +static const itype_id itype_test_backpack( "test_backpack" ); +static const itype_id itype_test_multitool( "test_multitool" ); +static const itype_id itype_test_pants_fur( "test_pants_fur" ); + static npc_template_id const npc_template_test_npc_trader( "test_npc_trader" ); static std::pair has_and_can_restock( npc const &guy, item const &it ) @@ -33,7 +40,7 @@ TEST_CASE( "npc_shopkeeper_item_groups", "[npc][trade]" ) npc &guy = *g->find_npc( id ); GIVEN( "item in basic group with no conditions" ) { - item pants( "test_pants_fur" ); + item pants( itype_test_pants_fur ); pants.set_owner( guy ); THEN( "item is available for selling and restocking" ) { std::pair har_pants = has_and_can_restock( guy, pants ); @@ -47,14 +54,14 @@ TEST_CASE( "npc_shopkeeper_item_groups", "[npc][trade]" ) g->load_npcs(); creature_tracker &creatures = get_creature_tracker(); REQUIRE( creatures.creature_at( npc_pos ) != nullptr ); - item backpack( "test_backpack" ); + item backpack( itype_test_backpack ); backpack.set_owner( guy ); REQUIRE( guy.wants_to_sell( { map_cursor{ tripoint_bub_ms::zero }, &backpack } ) ); WHEN( "backpack is worn - not available for sale" ) { auto backpack_iter = *guy.wear_item( backpack ); item &it = *backpack_iter; REQUIRE( !guy.wants_to_sell( { map_cursor{ tripoint_bub_ms::zero }, &it } ) ); - item scrap( "scrap" ); + item scrap( itype_scrap ); scrap.set_owner( guy ); REQUIRE( guy.wants_to_sell( { map_cursor{ tripoint_bub_ms::zero }, &scrap } ) ); item_location const scrap_inv = guy.i_add( scrap ); @@ -72,7 +79,7 @@ TEST_CASE( "npc_shopkeeper_item_groups", "[npc][trade]" ) } GIVEN( "item in group gated by non-strict condition" ) { - item hammer( "hammer" ); + item hammer( itype_hammer ); hammer.set_owner( guy ); WHEN( "condition not met" ) { std::pair har_hammer = has_and_can_restock( guy, hammer ); @@ -94,7 +101,7 @@ TEST_CASE( "npc_shopkeeper_item_groups", "[npc][trade]" ) } GIVEN( "item in group gated by strict condition" ) { - item multitool( "test_multitool" ); + item multitool( itype_test_multitool ); multitool.set_owner( guy ); WHEN( "condition not met" ) { std::pair har_multitool = has_and_can_restock( guy, multitool ); @@ -116,8 +123,8 @@ TEST_CASE( "npc_shopkeeper_item_groups", "[npc][trade]" ) } GIVEN( "containter with single item type and conditions only for contents" ) { - item multitool( "test_multitool" ); - item bag( "bag_plastic" ); + item multitool( itype_test_multitool ); + item bag( itype_bag_plastic ); int const num = GENERATE( 1, 2 ); bool ret = true; for( int i = 0; i < num; i++ ) { diff --git a/tests/npc_talk_test.cpp b/tests/npc_talk_test.cpp index eea6b093e2e2f..1367a52c6114a 100644 --- a/tests/npc_talk_test.cpp +++ b/tests/npc_talk_test.cpp @@ -42,8 +42,11 @@ static const efftype_id effect_sleep( "sleep" ); static const item_category_id item_category_food( "food" ); static const item_category_id item_category_manual( "manual" ); +static const itype_id itype_backpack( "backpack" ); +static const itype_id itype_badge_marshal( "badge_marshal" ); static const itype_id itype_beer( "beer" ); static const itype_id itype_bottle_glass( "bottle_glass" ); +static const itype_id itype_bottle_plastic( "bottle_plastic" ); static const itype_id itype_dnd_handbook( "dnd_handbook" ); static const itype_id itype_knife_huge( "knife_huge" ); static const itype_id itype_manual_speech( "manual_speech" ); @@ -260,7 +263,7 @@ TEST_CASE( "npc_talk_wearing_and_trait", "[npc_talk]" ) CHECK( d.responses[0].text == "This is a basic test response." ); CHECK( d.responses[1].text == "This is a trait test response." ); CHECK( d.responses[2].text == "This is a short trait test response." ); - player_character.wear_item( item( "badge_marshal" ) ); + player_character.wear_item( item( itype_badge_marshal ) ); gen_response_lines( d, 4 ); CHECK( d.responses[0].text == "This is a basic test response." ); CHECK( d.responses[1].text == "This is a trait test response." ); @@ -635,20 +638,20 @@ TEST_CASE( "npc_talk_items", "[npc_talk]" ) gen_response_lines( d, 1 ); CHECK( d.responses[0].text == "This is a basic test response." ); - const auto has_item = [&]( Character & p, const std::string & id, int count ) { + const auto has_item = [&]( Character & p, const itype_id & id, int count ) { item old_item = item( id ); if( old_item.count_by_charges() ) { - return p.has_charges( itype_id( id ), count ); + return p.has_charges( id, count ); } else { - return p.has_amount( itype_id( id ), count ); + return p.has_amount( id, count ); } }; const auto has_beer_bottle = [&]( Character & p, int count ) { - return has_item( p, "bottle_glass", 1 ) && has_item( p, "beer", count ); + return has_item( p, itype_bottle_glass, 1 ) && has_item( p, itype_beer, count ); }; player_character.cash = 1000; player_character.int_cur = 8; - player_character.worn.wear_item( player_character, item( "backpack" ), false, false ); + player_character.worn.wear_item( player_character, item( itype_backpack ), false, false ); d.add_topic( "TALK_TEST_EFFECTS" ); gen_response_lines( d, 19 ); // add and remove effect @@ -691,10 +694,10 @@ TEST_CASE( "npc_talk_items", "[npc_talk]" ) effects.apply( d ); CHECK( talker_npc.op_of_u.owed == 500 ); CHECK( has_beer_bottle( player_character, 2 ) ); - REQUIRE_FALSE( has_item( player_character, "bottle_plastic", 1 ) ); + REQUIRE_FALSE( has_item( player_character, itype_bottle_plastic, 1 ) ); effects = d.responses[10].success; effects.apply( d ); - CHECK( has_item( player_character, "bottle_plastic", 1 ) ); + CHECK( has_item( player_character, itype_bottle_plastic, 1 ) ); CHECK( talker_npc.op_of_u.owed == 500 ); effects = d.responses[11].success; effects.apply( d ); @@ -775,7 +778,7 @@ TEST_CASE( "npc_talk_items", "[npc_talk]" ) // test sell and consume d.add_topic( "TALK_TEST_EFFECTS" ); gen_response_lines( d, 19 ); - REQUIRE( has_item( player_character, "bottle_plastic", 1 ) ); + REQUIRE( has_item( player_character, itype_bottle_plastic, 1 ) ); REQUIRE( has_beer_bottle( player_character, 2 ) ); const std::vector glass_bottles = player_character.items_with( []( const item & it ) { return it.typeId() == itype_bottle_glass; @@ -784,21 +787,21 @@ TEST_CASE( "npc_talk_items", "[npc_talk]" ) REQUIRE( player_character.wield( *glass_bottles.front() ) ); effects = d.responses[14].success; effects.apply( d ); - CHECK_FALSE( has_item( player_character, "bottle_plastic", 1 ) ); - CHECK_FALSE( has_item( player_character, "beer", 1 ) ); - CHECK( has_item( talker_npc, "bottle_plastic", 1 ) ); - CHECK( has_item( talker_npc, "beer", 2 ) ); + CHECK_FALSE( has_item( player_character, itype_bottle_plastic, 1 ) ); + CHECK_FALSE( has_item( player_character, itype_beer, 1 ) ); + CHECK( has_item( talker_npc, itype_bottle_plastic, 1 ) ); + CHECK( has_item( talker_npc, itype_beer, 2 ) ); effects = d.responses[15].success; effects.apply( d ); - CHECK_FALSE( has_item( talker_npc, "beer", 2 ) ); - CHECK( has_item( talker_npc, "beer", 1 ) ); + CHECK_FALSE( has_item( talker_npc, itype_beer, 2 ) ); + CHECK( has_item( talker_npc, itype_beer, 1 ) ); effects = d.responses[16].success; effects.apply( d ); - CHECK( has_item( player_character, "beer", 1 ) ); + CHECK( has_item( player_character, itype_beer, 1 ) ); effects = d.responses[17].success; effects.apply( d ); - CHECK( has_item( player_character, "beer", 0 ) ); - CHECK_FALSE( has_item( player_character, "beer", 1 ) ); + CHECK( has_item( player_character, itype_beer, 0 ) ); + CHECK_FALSE( has_item( player_character, itype_beer, 1 ) ); } TEST_CASE( "npc_talk_vars", "[npc_talk]" ) @@ -1131,7 +1134,7 @@ TEST_CASE( "npc_compare_int", "[npc_talk]" ) player_character.set_hunger( 26 ); player_character.set_thirst( 27 ); player_character.set_stored_kcal( 118169 ); - player_character.worn.wear_item( player_character, item( "backpack" ), false, false ); + player_character.worn.wear_item( player_character, item( itype_backpack ), false, false ); player_character.inv->add_item( item( itype_bottle_glass ) ); player_character.inv->add_item( item( itype_bottle_glass ) ); player_character.inv->add_item( item( itype_bottle_glass ) ); diff --git a/tests/npc_test.cpp b/tests/npc_test.cpp index 1ce6850feee52..43be10321a54f 100644 --- a/tests/npc_test.cpp +++ b/tests/npc_test.cpp @@ -43,6 +43,9 @@ static const efftype_id effect_sleep( "sleep" ); static const item_group_id Item_spawn_data_test_NPC_guns( "test_NPC_guns" ); static const item_group_id Item_spawn_data_trash_forest( "trash_forest" ); +static const itype_id itype_debug_backpack( "debug_backpack" ); +static const itype_id itype_M24( "M24" ); + static const trait_id trait_WEB_WEAVER( "WEB_WEAVER" ); static const vpart_id vpart_frame( "frame" ); @@ -594,9 +597,9 @@ TEST_CASE( "npc_uses_guns", "[npc_ai]" ) REQUIRE( rl_dist( player_character.pos_bub(), hostile.pos_bub() ) >= 4 ); hostile.set_attitude( NPCATT_KILL ); hostile.name = "Enemy NPC"; - arm_shooter( hostile, "M24" ); + arm_shooter( hostile, itype_M24 ); // Give them an excuse to use it by making them aware the player (an enemy) exists - arm_shooter( player_character, "M24" ); + arm_shooter( player_character, itype_M24 ); hostile.regen_ai_cache(); float danger_around = hostile.danger_assessment(); CHECK( danger_around > 1.0f ); @@ -627,7 +630,7 @@ TEST_CASE( "npc_prefers_guns", "[npc_ai]" ) REQUIRE( rl_dist( player_character.pos_bub(), hostile.pos_bub() ) >= 4 ); hostile.set_attitude( NPCATT_KILL ); hostile.name = "Enemy NPC"; - item backpack( "debug_backpack" ); + item backpack( itype_debug_backpack ); hostile.wear_item( backpack ); // Give them a TON of junk for( item &some_trash : item_group::items_from( Item_spawn_data_trash_forest ) ) { @@ -638,7 +641,7 @@ TEST_CASE( "npc_prefers_guns", "[npc_ai]" ) hostile.i_add( some_gun_item ); } // Make them realize we exist and COULD maybe hurt them! Or something. Otherwise they won't re-wield. - arm_shooter( player_character, "M24" ); + arm_shooter( player_character, itype_M24 ); hostile.regen_ai_cache(); float danger_around = hostile.danger_assessment(); CHECK( danger_around > 1.0f ); diff --git a/tests/player_activities_test.cpp b/tests/player_activities_test.cpp index ae98243c58445..ec86fc83ad6aa 100644 --- a/tests/player_activities_test.cpp +++ b/tests/player_activities_test.cpp @@ -49,6 +49,7 @@ static const furn_str_id furn_test_f_prying1( "test_f_prying1" ); static const itype_id itype_book_binder( "book_binder" ); static const itype_id itype_glass_shard( "glass_shard" ); static const itype_id itype_oxyacetylene( "oxyacetylene" ); +static const itype_id itype_stethoscope( "stethoscope" ); static const itype_id itype_tent_kit( "tent_kit" ); static const itype_id itype_test_2x4( "test_2x4" ); static const itype_id itype_test_backpack( "test_backpack" ); @@ -200,7 +201,7 @@ TEST_CASE( "safecracking", "[activity][safecracking]" ) } GIVEN( "player has a stethoscope" ) { - dummy.i_add( item( "stethoscope" ) ); + dummy.i_add( item( itype_stethoscope ) ); mp.furn_set( safe, furn_f_safe_l ); REQUIRE( dummy.cache_has_item_with( flag_SAFECRACK ) ); REQUIRE( !dummy.has_flag( json_flag_SAFECRACK_NO_TOOL ) ); @@ -235,7 +236,7 @@ TEST_CASE( "safecracking", "[activity][safecracking]" ) GIVEN( "player has a stethoscope" ) { dummy.clear_bionics(); - dummy.i_add( item( "stethoscope" ) ); + dummy.i_add( item( itype_stethoscope ) ); mp.furn_set( safe, furn_f_safe_l ); REQUIRE( dummy.cache_has_item_with( flag_SAFECRACK ) ); REQUIRE( !dummy.has_flag( json_flag_SAFECRACK_NO_TOOL ) ); @@ -288,7 +289,7 @@ TEST_CASE( "safecracking", "[activity][safecracking]" ) dummy.activity.start_or_resume( dummy, false ); GIVEN( "player cracks one safe" ) { - dummy.i_add( item( "stethoscope" ) ); + dummy.i_add( item( itype_stethoscope ) ); mp.furn_set( safe, furn_f_safe_l ); REQUIRE( dummy.cache_has_item_with( flag_SAFECRACK ) ); REQUIRE( dummy.activity.id() == ACT_CRACKING ); diff --git a/tests/player_helpers.cpp b/tests/player_helpers.cpp index 695ae72a772bf..7709d692038e5 100644 --- a/tests/player_helpers.cpp +++ b/tests/player_helpers.cpp @@ -30,15 +30,16 @@ #include "type_id.h" static const itype_id itype_debug_backpack( "debug_backpack" ); +static const itype_id itype_debug_nutrition( "debug_nutrition" ); static const move_mode_id move_mode_walk( "walk" ); -int get_remaining_charges( const std::string &tool_id ) +int get_remaining_charges( const itype_id &tool_id ) { const inventory crafting_inv = get_player_character().crafting_inventory(); std::vector items = crafting_inv.items_with( [tool_id]( const item & i ) { - return i.typeId() == itype_id( tool_id ); + return i.typeId() == tool_id; } ); int remaining_charges = 0; for( const item *instance : items ) { @@ -47,11 +48,11 @@ int get_remaining_charges( const std::string &tool_id ) return remaining_charges; } -bool player_has_item_of_type( const std::string &type ) +bool player_has_item_of_type( const itype_id &id ) { std::vector matching_items = get_player_character().inv->items_with( [&]( const item & i ) { - return i.type->get_id() == itype_id( type ); + return i.typeId() == id; } ); return !matching_items.empty(); @@ -89,7 +90,7 @@ void clear_character( Character &dummy, bool skip_nutrition ) dummy.health_tally = 0; dummy.update_body( calendar::turn, calendar::turn ); // sets last_updated to current turn if( !skip_nutrition ) { - item food( "debug_nutrition" ); + item food( itype_debug_nutrition ); dummy.consume( food ); } @@ -152,29 +153,29 @@ void clear_character( Character &dummy, bool skip_nutrition ) dummy.set_focus( dummy.calc_focus_equilibrium() ); } -void arm_shooter( Character &shooter, const std::string &gun_type, - const std::vector &mods, - const std::string &ammo_type ) +void arm_shooter( Character &shooter, const itype_id &gun_type, + const std::vector &mods, + const itype_id &ammo_type ) { shooter.remove_weapon(); // XL so arrows can fit. if( !shooter.is_wearing( itype_debug_backpack ) ) { - shooter.worn.wear_item( shooter, item( "debug_backpack" ), false, false ); + shooter.worn.wear_item( shooter, item( itype_debug_backpack ), false, false ); } - const itype_id &gun_id{ itype_id( gun_type ) }; + const itype_id &gun_id( gun_type ); // Give shooter a loaded gun of the requested type. item_location gun = shooter.i_add( item( gun_id ) ); - itype_id ammo_id; + itype_id ammo_id = ammo_type; // if ammo is not supplied we want the default - if( ammo_type.empty() ) { + if( ammo_type.is_null() ) { if( gun->ammo_default().is_null() ) { ammo_id = item( gun->magazine_default() ).ammo_default(); } else { ammo_id = gun->ammo_default(); } } else { - ammo_id = itype_id( ammo_type ); + ammo_id = ammo_type; } const ammotype &type_of_ammo = item::find_type( ammo_id )->ammo->type; if( gun->magazine_integral() ) { @@ -193,8 +194,8 @@ void arm_shooter( Character &shooter, const std::string &gun_type, magazine->reload( shooter, ammo, magazine->ammo_capacity( type_of_ammo ) ); gun->reload( shooter, magazine, magazine->ammo_capacity( type_of_ammo ) ); } - for( const std::string &mod : mods ) { - gun->put_in( item( itype_id( mod ) ), pocket_type::MOD ); + for( const itype_id &mod : mods ) { + gun->put_in( item( mod ), pocket_type::MOD ); } shooter.wield( *gun ); } @@ -208,12 +209,12 @@ void clear_avatar() avatar.reset_all_missions(); } -void equip_shooter( npc &shooter, const std::vector &apparel ) +void equip_shooter( npc &shooter, const std::vector &apparel ) { CHECK( !shooter.in_vehicle ); shooter.clear_worn(); shooter.inv->clear(); - for( const std::string &article : apparel ) { + for( const itype_id &article : apparel ) { shooter.wear_item( item( article ) ); } } @@ -285,7 +286,7 @@ void give_and_activate_bionic( Character &you, bionic_id const &bioid ) } } -item tool_with_ammo( const std::string &tool, const int qty ) +item tool_with_ammo( const itype_id &tool, const int qty ) { item tool_it( tool ); if( !tool_it.ammo_default().is_null() ) { diff --git a/tests/player_helpers.h b/tests/player_helpers.h index 9e95c1e491ca6..da391f688091e 100644 --- a/tests/player_helpers.h +++ b/tests/player_helpers.h @@ -12,8 +12,8 @@ class item; class Character; struct point; -int get_remaining_charges( const std::string &tool_id ); -bool player_has_item_of_type( const std::string & ); +int get_remaining_charges( const itype_id &tool_id ); +bool player_has_item_of_type( const itype_id &id ); bool character_has_item_with_var_val( const Character &they, const std::string &var, const std::string &val ); void clear_character( Character &, bool skip_nutrition = false ); @@ -25,12 +25,12 @@ npc &spawn_npc( const point_bub_ms &, const std::string &npc_class ); void set_single_trait( Character &dummy, const std::string &trait_name ); void give_and_activate_bionic( Character &, bionic_id const & ); -item tool_with_ammo( const std::string &tool, int qty ); +item tool_with_ammo( const itype_id &tool, int qty ); -void arm_shooter( Character &shooter, const std::string &gun_type, - const std::vector &mods = {}, - const std::string &ammo_type = "" ); +void arm_shooter( Character &shooter, const itype_id &gun_type, + const std::vector &mods = {}, + const itype_id &ammo_type = itype_id::NULL_ID() ); -void equip_shooter( npc &shooter, const std::vector &apparel ); +void equip_shooter( npc &shooter, const std::vector &apparel ); #endif // CATA_TESTS_PLAYER_HELPERS_H diff --git a/tests/player_test.cpp b/tests/player_test.cpp index 8a0625c3cefad..1070574487d1c 100644 --- a/tests/player_test.cpp +++ b/tests/player_test.cpp @@ -11,6 +11,34 @@ #include "type_id.h" #include "weather.h" +static const itype_id itype_balclava( "balclava" ); +static const itype_id itype_bandana( "bandana" ); +static const itype_id itype_boots( "boots" ); +static const itype_id itype_boots_winter( "boots_winter" ); +static const itype_id itype_coat_winter( "coat_winter" ); +static const itype_id itype_gloves_fingerless( "gloves_fingerless" ); +static const itype_id itype_gloves_liner( "gloves_liner" ); +static const itype_id itype_gloves_winter( "gloves_winter" ); +static const itype_id itype_gloves_wool( "gloves_wool" ); +static const itype_id itype_goggles_ski( "goggles_ski" ); +static const itype_id itype_hat_ball( "hat_ball" ); +static const itype_id itype_hat_hunting( "hat_hunting" ); +static const itype_id itype_hat_knit( "hat_knit" ); +static const itype_id itype_jeans( "jeans" ); +static const itype_id itype_long_underpants( "long_underpants" ); +static const itype_id itype_pants_army( "pants_army" ); +static const itype_id itype_pants_fur( "pants_fur" ); +static const itype_id itype_sneakers( "sneakers" ); +static const itype_id itype_socks( "socks" ); +static const itype_id itype_socks_wool( "socks_wool" ); +static const itype_id itype_test_jumpsuit_cotton( "test_jumpsuit_cotton" ); +static const itype_id itype_test_jumpsuit_fur( "test_jumpsuit_fur" ); +static const itype_id itype_test_jumpsuit_lycra( "test_jumpsuit_lycra" ); +static const itype_id itype_trenchcoat( "trenchcoat" ); +static const itype_id itype_tshirt( "tshirt" ); +static const itype_id itype_under_armor( "under_armor" ); +static const itype_id itype_vest( "vest" ); + // Set the stage for a particular ambient and target temperature and run update_bodytemp() until // core body temperature settles. static void temperature_check( Character *p, const int ambient_temp, @@ -60,7 +88,7 @@ static void temperature_and_sweat_check( Character *p, const int ambient_temp, CHECK( high > p->get_part_temp_cur( bodypart_id( "torso" ) ) ); } -static void equip_clothing( Character *p, const std::string &clothing ) +static void equip_clothing( Character *p, const itype_id &clothing ) { const item article( clothing, calendar::turn_zero ); p->wear_item( article ); @@ -105,46 +133,46 @@ TEST_CASE( "player_body_temperatures_converge_on_expected_values", "[.bodytemp]" } SECTION( "Lightly clothed target temperatures" ) { - equip_clothing( &dummy, "hat_ball" ); - equip_clothing( &dummy, "bandana" ); - equip_clothing( &dummy, "tshirt" ); - equip_clothing( &dummy, "gloves_fingerless" ); - equip_clothing( &dummy, "jeans" ); - equip_clothing( &dummy, "socks" ); - equip_clothing( &dummy, "sneakers" ); + equip_clothing( &dummy, itype_hat_ball ); + equip_clothing( &dummy, itype_bandana ); + equip_clothing( &dummy, itype_tshirt ); + equip_clothing( &dummy, itype_gloves_fingerless ); + equip_clothing( &dummy, itype_jeans ); + equip_clothing( &dummy, itype_socks ); + equip_clothing( &dummy, itype_sneakers ); //test_temperature_spread( &dummy, { -3, 12, 27, 42, 57, 72, 87 } ); test_temperature_spread( &dummy, {{ -17, 10, 35, 62, 77, 90, 100 }} ); } SECTION( "Heavily clothed target temperatures" ) { - equip_clothing( &dummy, "hat_knit" ); - equip_clothing( &dummy, "tshirt" ); - equip_clothing( &dummy, "vest" ); - equip_clothing( &dummy, "trenchcoat" ); - equip_clothing( &dummy, "gloves_wool" ); - equip_clothing( &dummy, "long_underpants" ); - equip_clothing( &dummy, "pants_army" ); - equip_clothing( &dummy, "socks_wool" ); - equip_clothing( &dummy, "boots" ); + equip_clothing( &dummy, itype_hat_knit ); + equip_clothing( &dummy, itype_tshirt ); + equip_clothing( &dummy, itype_vest ); + equip_clothing( &dummy, itype_trenchcoat ); + equip_clothing( &dummy, itype_gloves_wool ); + equip_clothing( &dummy, itype_long_underpants ); + equip_clothing( &dummy, itype_pants_army ); + equip_clothing( &dummy, itype_socks_wool ); + equip_clothing( &dummy, itype_boots ); //test_temperature_spread( &dummy, { -25, -10, 5, 20, 35, 50, 65 } ); test_temperature_spread( &dummy, {{ -39, -14, 17, 46, 70, 84, 96 }} ); } SECTION( "Arctic gear target temperatures" ) { - equip_clothing( &dummy, "balclava" ); - equip_clothing( &dummy, "goggles_ski" ); - equip_clothing( &dummy, "hat_hunting" ); - equip_clothing( &dummy, "under_armor" ); - equip_clothing( &dummy, "vest" ); - equip_clothing( &dummy, "coat_winter" ); - equip_clothing( &dummy, "gloves_liner" ); - equip_clothing( &dummy, "gloves_winter" ); - equip_clothing( &dummy, "long_underpants" ); - equip_clothing( &dummy, "pants_fur" ); - equip_clothing( &dummy, "socks_wool" ); - equip_clothing( &dummy, "boots_winter" ); + equip_clothing( &dummy, itype_balclava ); + equip_clothing( &dummy, itype_goggles_ski ); + equip_clothing( &dummy, itype_hat_hunting ); + equip_clothing( &dummy, itype_under_armor ); + equip_clothing( &dummy, itype_vest ); + equip_clothing( &dummy, itype_coat_winter ); + equip_clothing( &dummy, itype_gloves_liner ); + equip_clothing( &dummy, itype_gloves_winter ); + equip_clothing( &dummy, itype_long_underpants ); + equip_clothing( &dummy, itype_pants_fur ); + equip_clothing( &dummy, itype_socks_wool ); + equip_clothing( &dummy, itype_boots_winter ); //test_temperature_spread( &dummy, { -47, -32, -17, -2, 13, 28, 43 } ); test_temperature_spread( &dummy, {{ -115, -87, -54, -6, 36, 64, 80 }} ); @@ -157,9 +185,9 @@ TEST_CASE( "sweating", "[char][suffer][.bodytemp]" ) clear_character( dummy ); // three different materials of breathability, same warmth - item fur_jumper( "test_jumpsuit_fur" ); - item lycra_jumper( "test_jumpsuit_lycra" ); - item cotton_jumper( "test_jumpsuit_cotton" ); + item fur_jumper( itype_test_jumpsuit_fur ); + item lycra_jumper( itype_test_jumpsuit_lycra ); + item cotton_jumper( itype_test_jumpsuit_cotton ); GIVEN( "avatar wears outfit and sweats for an hour" ) { WHEN( "wearing fur" ) { diff --git a/tests/ranged_balance_test.cpp b/tests/ranged_balance_test.cpp index 4f6ff022cb729..8e0265267ef49 100644 --- a/tests/ranged_balance_test.cpp +++ b/tests/ranged_balance_test.cpp @@ -37,6 +37,55 @@ static const character_modifier_id character_modifier_ranged_dispersion_manip_mod( "ranged_dispersion_manip_mod" ); +static const itype_id itype_556_m855a1( "556_m855a1" ); +static const itype_id itype_M24( "M24" ); +static const itype_id itype_armguard_hard( "itype_armguard_hard" ); +static const itype_id itype_armguard_soft( "itype_armguard_soft" ); +static const itype_id itype_arrow_cf( "arrow_cf" ); +static const itype_id itype_arrow_field_point_fletched( "arrow_field_point_fletched" ); +static const itype_id itype_backpack( "backpack" ); +static const itype_id itype_balclava( "balclava" ); +static const itype_id itype_bastsandals( "itype_bastsandals" ); +static const itype_id itype_beekeeping_gloves( "itype_beekeeping_gloves" ); +static const itype_id itype_bolt_cf( "bolt_cf" ); +static const itype_id itype_bolt_makeshift( "bolt_makeshift" ); +static const itype_id itype_bolt_steel( "bolt_steel" ); +static const itype_id itype_bow_sight( "bow_sight" ); +static const itype_id itype_bow_sight_pin( "bow_sight_pin" ); +static const itype_id itype_choke( "choke" ); +static const itype_id itype_cloak_wool( "cloak_wool" ); +static const itype_id itype_compbow_high( "compbow_high" ); +static const itype_id itype_compcrossbow( "compcrossbow" ); +static const itype_id itype_compositecrossbow( "compositecrossbow" ); +static const itype_id itype_cowboy_hat( "itype_cowboy_hat" ); +static const itype_id itype_crossbow( "crossbow" ); +static const itype_id itype_debug_modular_m4_carbine( "debug_modular_m4_carbine" ); +static const itype_id itype_fn_p90( "fn_p90" ); +static const itype_id itype_footrags_wool( "footrags_wool" ); +static const itype_id itype_glasses_safety( "glasses_safety" ); +static const itype_id itype_glock_19( "itype_glock_19" ); +static const itype_id itype_gloves_wraps_fur( "gloves_wraps_fur" ); +static const itype_id itype_hk_mp5( "hk_mp5" ); +static const itype_id itype_holo_sight( "holo_sight" ); +static const itype_id itype_m14ebr( "m14ebr" ); +static const itype_id itype_mask_guy_fawkes( "itype_mask_guy_fawkes" ); +static const itype_id itype_mossberg_590( "mossberg_590" ); +static const itype_id itype_mossberg_930( "mossberg_930" ); +static const itype_id itype_mp40semi( "mp40semi" ); +static const itype_id itype_recurbow( "recurbow" ); +static const itype_id itype_red_dot_sight( "red_dot_sight" ); +static const itype_id itype_remington_870( "remington_870" ); +static const itype_id itype_rifle_scope( "rifle_scope" ); +static const itype_id itype_shortbow( "shortbow" ); +static const itype_id itype_shot_00( "shot_00" ); +static const itype_id itype_shot_bird( "shot_bird" ); +static const itype_id itype_shotgun_s( "shotgun_s" ); +static const itype_id itype_sw629( "sw629" ); +static const itype_id itype_sw_619( "sw_619" ); +static const itype_id itype_tele_sight( "tele_sight" ); +static const itype_id itype_test_armor_chitin( "itype_test_armor_chitin" ); +static const itype_id itype_test_shot_00_fire_damage( "test_shot_00_fire_damage" ); + using firing_statistics = statistics; class Threshold @@ -241,37 +290,37 @@ TEST_CASE( "unskilled_shooter_accuracy", "[ranged] [balance] [slow]" ) clear_map(); standard_npc shooter( "Shooter", shooter_pos, {}, 0, 8, 8, 8, 7 ); shooter.set_body(); - shooter.worn.wear_item( shooter, item( "backpack" ), false, false ); - equip_shooter( shooter, { "bastsandals", "armguard_hard", "armguard_soft", "test_armor_chitin", "beekeeping_gloves", "mask_guy_fawkes", "cowboy_hat" } ); + shooter.worn.wear_item( shooter, item( itype_backpack ), false, false ); + equip_shooter( shooter, { itype_bastsandals, itype_armguard_hard, itype_armguard_soft, itype_test_armor_chitin, itype_beekeeping_gloves, itype_mask_guy_fawkes, itype_cowboy_hat } ); assert_encumbrance( shooter, 10 ); SECTION( "an unskilled shooter with a common pistol" ) { - arm_shooter( shooter, "glock_19" ); + arm_shooter( shooter, itype_glock_19 ); test_shooting_scenario( shooter, 4, 5, 17 ); test_fast_shooting( shooter, 60, 0.15 ); } SECTION( "an unskilled archer with a common bow" ) { - arm_shooter( shooter, "shortbow", { "bow_sight_pin" }, "arrow_field_point_fletched" ); + arm_shooter( shooter, itype_shortbow, { itype_bow_sight_pin }, itype_arrow_field_point_fletched ); test_shooting_scenario( shooter, 4, 4, 13 ); test_fast_shooting( shooter, 90, 0.1 ); } SECTION( "an unskilled archer with a common crossbow" ) { - arm_shooter( shooter, "crossbow", {}, "bolt_makeshift" ); + arm_shooter( shooter, itype_crossbow, {}, itype_bolt_makeshift ); test_shooting_scenario( shooter, 4, 5, 17 ); test_fast_shooting( shooter, 80, 0.15 ); } SECTION( "an unskilled shooter with a common shotgun" ) { - arm_shooter( shooter, "remington_870" ); + arm_shooter( shooter, itype_remington_870 ); test_shooting_scenario( shooter, 4, 4, 19 ); test_fast_shooting( shooter, 80, 0.15 ); } SECTION( "an unskilled shooter with a common smg" ) { - arm_shooter( shooter, "mp40semi" ); + arm_shooter( shooter, itype_mp40semi ); test_shooting_scenario( shooter, 4, 5, 18 ); test_fast_shooting( shooter, 80, 0.04 ); } SECTION( "an unskilled shooter with a common rifle" ) { - arm_shooter( shooter, "debug_modular_m4_carbine" ); + arm_shooter( shooter, itype_debug_modular_m4_carbine ); test_shooting_scenario( shooter, 5, 5, 25 ); test_fast_shooting( shooter, 100, 0.15 ); } @@ -283,41 +332,41 @@ TEST_CASE( "competent_shooter_accuracy", "[ranged] [balance]" ) clear_map(); standard_npc shooter( "Shooter", shooter_pos, {}, 5, 10, 10, 10, 10 ); shooter.set_body(); - equip_shooter( shooter, { "cloak_wool", "footrags_wool", "gloves_wraps_fur", "glasses_safety", "balclava" } ); + equip_shooter( shooter, { itype_cloak_wool, itype_footrags_wool, itype_gloves_wraps_fur, itype_glasses_safety, itype_balclava } ); assert_encumbrance( shooter, 5 ); SECTION( "a skilled shooter with an accurate pistol" ) { - arm_shooter( shooter, "sw_619", { "red_dot_sight" } ); + arm_shooter( shooter, itype_sw_619, { itype_red_dot_sight } ); test_shooting_scenario( shooter, 10, 12, 35 ); test_fast_shooting( shooter, 40, 0.35 ); } SECTION( "a skilled archer with an accurate bow" ) { - arm_shooter( shooter, "recurbow", { "bow_sight" } ); + arm_shooter( shooter, itype_recurbow, { itype_bow_sight } ); test_shooting_scenario( shooter, 8, 10, 35 ); test_fast_shooting( shooter, 70, 0.35 ); } SECTION( "a skilled archer with an accurate crossbow" ) { - arm_shooter( shooter, "compositecrossbow", { "tele_sight" }, "bolt_steel" ); + arm_shooter( shooter, itype_compositecrossbow, { itype_tele_sight }, itype_bolt_steel ); test_shooting_scenario( shooter, 9, 10, 35 ); test_fast_shooting( shooter, 70, 0.35 ); } SECTION( "a skilled shooter with a nice shotgun" ) { - arm_shooter( shooter, "mossberg_590" ); + arm_shooter( shooter, itype_mossberg_590 ); test_shooting_scenario( shooter, 9, 12, 35 ); test_fast_shooting( shooter, 70, 0.35 ); } SECTION( "a skilled shooter with a nice smg" ) { - arm_shooter( shooter, "hk_mp5", { "red_dot_sight" } ); + arm_shooter( shooter, itype_hk_mp5, { itype_red_dot_sight } ); test_shooting_scenario( shooter, 9, 12, 35 ); test_fast_shooting( shooter, 80, 0.3 ); } SECTION( "a skilled shooter with a carbine" ) { - arm_shooter( shooter, "debug_modular_m4_carbine", { "red_dot_sight" }, "556_m855a1" ); + arm_shooter( shooter, itype_debug_modular_m4_carbine, { itype_red_dot_sight }, itype_556_m855a1 ); test_shooting_scenario( shooter, 10, 15, 48 ); test_fast_shooting( shooter, 80, 0.3 ); } SECTION( "a skilled shooter with an available sniper rifle" ) { - arm_shooter( shooter, "M24" ); + arm_shooter( shooter, itype_M24 ); test_shooting_scenario( shooter, 10, 10, 80 ); test_fast_shooting( shooter, 80, 0.4 ); } @@ -333,37 +382,37 @@ TEST_CASE( "expert_shooter_accuracy", "[ranged] [balance]" ) assert_encumbrance( shooter, 0 ); SECTION( "an expert shooter with an excellent pistol" ) { - arm_shooter( shooter, "sw629", { "holo_sight" } ); + arm_shooter( shooter, itype_sw629, { itype_holo_sight } ); test_shooting_scenario( shooter, 18, 20, 140 ); test_fast_shooting( shooter, 35, 0.5 ); } SECTION( "an expert archer with an excellent bow" ) { - arm_shooter( shooter, "compbow_high", { "holo_sight" }, "arrow_cf" ); + arm_shooter( shooter, itype_compbow_high, { itype_holo_sight }, itype_arrow_cf ); test_shooting_scenario( shooter, 12, 20, 80 ); test_fast_shooting( shooter, 50, 0.4 ); } SECTION( "an expert archer with an excellent crossbow" ) { - arm_shooter( shooter, "compcrossbow", { "holo_sight" }, "bolt_cf" ); + arm_shooter( shooter, itype_compcrossbow, { itype_holo_sight }, itype_bolt_cf ); test_shooting_scenario( shooter, 12, 20, 100 ); test_fast_shooting( shooter, 50, 0.4 ); } SECTION( "an expert shooter with an excellent shotgun" ) { - arm_shooter( shooter, "mossberg_930", { "holo_sight" } ); + arm_shooter( shooter, itype_mossberg_930, { itype_holo_sight } ); test_shooting_scenario( shooter, 18, 24, 124 ); test_fast_shooting( shooter, 60, 0.5 ); } SECTION( "an expert shooter with an excellent smg" ) { - arm_shooter( shooter, "fn_p90", { "holo_sight" } ); + arm_shooter( shooter, itype_fn_p90, { itype_holo_sight } ); test_shooting_scenario( shooter, 20, 30, 190 ); test_fast_shooting( shooter, 60, 0.5 ); } SECTION( "an expert shooter with an excellent rifle with holo_sight" ) { - arm_shooter( shooter, "m14ebr", { "holo_sight" } ); + arm_shooter( shooter, itype_m14ebr, { itype_holo_sight } ); test_shooting_scenario( shooter, 30, 40, 500 ); test_fast_shooting( shooter, 65, 0.5 ); } SECTION( "an expert shooter with an excellent rifle with rifle_scope" ) { - arm_shooter( shooter, "m14ebr", { "rifle_scope" } ); + arm_shooter( shooter, itype_m14ebr, { itype_rifle_scope } ); test_shooting_scenario( shooter, 25, 40, 1000 ); test_fast_shooting( shooter, 65, 0.5 ); } @@ -439,8 +488,8 @@ TEST_CASE( "synthetic_range_test", "[.]" ) } } -static void shoot_monster( const std::string &gun_type, const std::vector &mods, - const std::string &ammo_type, int range, +static void shoot_monster( const itype_id &gun_type, const std::vector &mods, + const itype_id &ammo_type, int range, int expected_damage, const std::string &monster_type, const std::function &other_checks = nullptr ) { @@ -489,55 +538,55 @@ TEST_CASE( "shot_features", "[gun]" "[slow]" ) // Unarmored target // Minor damage at range. // More serious damage at close range. - shoot_monster( "shotgun_s", {}, "shot_bird", 5, 20, "mon_test_shotgun_0_bullet" ); + shoot_monster( itype_shotgun_s, {}, itype_shot_bird, 5, 20, "mon_test_shotgun_0_bullet" ); // Grevious damage at point blank. - shoot_monster( "shotgun_s", {}, "shot_bird", 1, 62, "mon_test_shotgun_0_bullet" ); + shoot_monster( itype_shotgun_s, {}, itype_shot_bird, 1, 62, "mon_test_shotgun_0_bullet" ); // Triviallly armored target (armor_bullet: 1) // Can rarely if ever inflict damage at range. - // shoot_monster( "shot_bird", 10, 0, 5, "mon_zombie_tough" ); + // shoot_monster( itype_shot_bird, 10, 0, 5, "mon_zombie_tough" ); // Can barely hurt at close range. // Can seriously injure trivially armored enemy at point blank, - shoot_monster( "shotgun_s", {}, "shot_bird", 1, 62, "mon_zombie_tough" ); + shoot_monster( itype_shotgun_s, {}, itype_shot_bird, 1, 62, "mon_zombie_tough" ); // Armored target (armor_bullet: 5) // Can't hurt at range // Can't hurt at close range. // Serioualy injure at point blank. - shoot_monster( "shotgun_s", {}, "shot_bird", 1, 61, "mon_zombie_brute" ); + shoot_monster( itype_shotgun_s, {}, itype_shot_bird, 1, 61, "mon_zombie_brute" ); // TODO: can't harm heavily armored enemies at point blank // Heavily Armored target (armor_bullet: 36) // Can't hurt at range, - shoot_monster( "shotgun_s", {}, "shot_bird", 12, 3, "mon_skeleton_hulk" ); + shoot_monster( itype_shotgun_s, {}, itype_shot_bird, 12, 3, "mon_skeleton_hulk" ); // Can't hurt at close range. - shoot_monster( "shotgun_s", {}, "shot_bird", 5, 6, "mon_skeleton_hulk" ); + shoot_monster( itype_shotgun_s, {}, itype_shot_bird, 5, 6, "mon_skeleton_hulk" ); // Barely injure at point blank. - shoot_monster( "shotgun_s", {}, "shot_bird", 1, 31, "mon_skeleton_hulk" ); + shoot_monster( itype_shotgun_s, {}, itype_shot_bird, 1, 31, "mon_skeleton_hulk" ); // TODO: can't harm heavily armored enemies even at point blank. // BUCKSHOT // Unarmored target - shoot_monster( "shotgun_s", {}, "shot_00", 18, 72, "mon_test_shotgun_0_bullet" ); + shoot_monster( itype_shotgun_s, {}, itype_shot_00, 18, 72, "mon_test_shotgun_0_bullet" ); // Heavy damage at range. - shoot_monster( "shotgun_s", {}, "shot_00", 12, 107, "mon_test_shotgun_0_bullet" ); + shoot_monster( itype_shotgun_s, {}, itype_shot_00, 12, 107, "mon_test_shotgun_0_bullet" ); // More damage at close range. - shoot_monster( "shotgun_s", {}, "shot_00", 5, 165, "mon_test_shotgun_0_bullet" ); + shoot_monster( itype_shotgun_s, {}, itype_shot_00, 5, 165, "mon_test_shotgun_0_bullet" ); // Extreme damage at point blank range. - shoot_monster( "shotgun_s", {}, "shot_00", 1, 75, "mon_test_shotgun_0_bullet" ); + shoot_monster( itype_shotgun_s, {}, itype_shot_00, 1, 75, "mon_test_shotgun_0_bullet" ); // Lightly armored target (armor_bullet: 5) // Outcomes for lightly armored enemies are very similar. - shoot_monster( "shotgun_s", {}, "shot_00", 18, 20, "mon_zombie_brute" ); - shoot_monster( "shotgun_s", {}, "shot_00", 12, 40, "mon_zombie_brute" ); - shoot_monster( "shotgun_s", {}, "shot_00", 5, 116, "mon_zombie_brute" ); - shoot_monster( "shotgun_s", {}, "shot_00", 1, 73, "mon_zombie_brute" ); + shoot_monster( itype_shotgun_s, {}, itype_shot_00, 18, 20, "mon_zombie_brute" ); + shoot_monster( itype_shotgun_s, {}, itype_shot_00, 12, 40, "mon_zombie_brute" ); + shoot_monster( itype_shotgun_s, {}, itype_shot_00, 5, 116, "mon_zombie_brute" ); + shoot_monster( itype_shotgun_s, {}, itype_shot_00, 1, 73, "mon_zombie_brute" ); // Armored target (armor_bullet: 10) - shoot_monster( "shotgun_s", {}, "shot_00", 18, 8, "mon_smoker_brute" ); - shoot_monster( "shotgun_s", {}, "shot_00", 12, 18, "mon_smoker_brute" ); - shoot_monster( "shotgun_s", {}, "shot_00", 5, 47, "mon_smoker_brute" ); - shoot_monster( "shotgun_s", {}, "shot_00", 1, 72, "mon_smoker_brute" ); + shoot_monster( itype_shotgun_s, {}, itype_shot_00, 18, 8, "mon_smoker_brute" ); + shoot_monster( itype_shotgun_s, {}, itype_shot_00, 12, 18, "mon_smoker_brute" ); + shoot_monster( itype_shotgun_s, {}, itype_shot_00, 5, 47, "mon_smoker_brute" ); + shoot_monster( itype_shotgun_s, {}, itype_shot_00, 1, 72, "mon_smoker_brute" ); } TEST_CASE( "shot_features_with_choke", "[gun]" "[slow]" ) @@ -546,38 +595,45 @@ TEST_CASE( "shot_features_with_choke", "[gun]" "[slow]" ) // Unarmored target // This test result is difficult to converge // After more attempts, the average value is about 7 - // shoot_monster( "shotgun_s", { "choke" }, "shot_bird", 18, 7, "mon_test_shotgun_0_bullet" ); - shoot_monster( "shotgun_s", {"choke"}, "shot_bird", 12, 15, "mon_test_shotgun_0_bullet" ); - shoot_monster( "shotgun_s", { "choke" }, "shot_bird", 5, 20, "mon_test_shotgun_0_bullet" ); + // shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_bird, 18, 7, "mon_test_shotgun_0_bullet" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_bird, 12, 15, + "mon_test_shotgun_0_bullet" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_bird, 5, 20, + "mon_test_shotgun_0_bullet" ); // All the results of tests at point blank are abonormal - shoot_monster( "shotgun_s", { "choke" }, "shot_bird", 1, 62, "mon_test_shotgun_0_bullet" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_bird, 1, 62, + "mon_test_shotgun_0_bullet" ); // Triviallly armored target (armor_bullet: 1) - shoot_monster( "shotgun_s", { "choke" }, "shot_bird", 1, 62, "mon_zombie_tough" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_bird, 1, 62, "mon_zombie_tough" ); // Armored target (armor_bullet: 5) - shoot_monster( "shotgun_s", { "choke" }, "shot_bird", 1, 61, "mon_zombie_brute" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_bird, 1, 61, "mon_zombie_brute" ); // Unarmored target - shoot_monster( "shotgun_s", { "choke" }, "shot_00", 18, 95, "mon_test_shotgun_0_bullet" ); - shoot_monster( "shotgun_s", { "choke" }, "shot_00", 12, 131, "mon_test_shotgun_0_bullet" ); - shoot_monster( "shotgun_s", { "choke" }, "shot_00", 5, 165, "mon_test_shotgun_0_bullet" ); - shoot_monster( "shotgun_s", { "choke" }, "shot_00", 1, 75, "mon_test_shotgun_0_bullet" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 18, 95, + "mon_test_shotgun_0_bullet" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 12, 131, + "mon_test_shotgun_0_bullet" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 5, 165, + "mon_test_shotgun_0_bullet" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 1, 75, + "mon_test_shotgun_0_bullet" ); // Triviallly armored target (armor_bullet: 1) - shoot_monster( "shotgun_s", { "choke" }, "shot_00", 18, 32, "mon_zombie_tough" ); - shoot_monster( "shotgun_s", { "choke" }, "shot_00", 12, 61, "mon_zombie_tough" ); - shoot_monster( "shotgun_s", { "choke" }, "shot_00", 5, 105, "mon_zombie_tough" ); - shoot_monster( "shotgun_s", { "choke" }, "shot_00", 1, 100, "mon_zombie_tough" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 18, 32, "mon_zombie_tough" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 12, 61, "mon_zombie_tough" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 5, 105, "mon_zombie_tough" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 1, 100, "mon_zombie_tough" ); // Armored target (armor_bullet: 5) - shoot_monster( "shotgun_s", { "choke" }, "shot_00", 18, 25, "mon_zombie_brute" ); - shoot_monster( "shotgun_s", { "choke" }, "shot_00", 12, 54, "mon_zombie_brute" ); - shoot_monster( "shotgun_s", { "choke" }, "shot_00", 5, 124, "mon_zombie_brute" ); - shoot_monster( "shotgun_s", { "choke" }, "shot_00", 1, 73, "mon_zombie_brute" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 18, 25, "mon_zombie_brute" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 12, 54, "mon_zombie_brute" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 5, 124, "mon_zombie_brute" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 1, 73, "mon_zombie_brute" ); // Armored target (armor_bullet: 10) - shoot_monster( "shotgun_s", { "choke" }, "shot_00", 18, 10, "mon_smoker_brute" ); - shoot_monster( "shotgun_s", { "choke" }, "shot_00", 12, 11, "mon_smoker_brute" ); - shoot_monster( "shotgun_s", { "choke" }, "shot_00", 5, 62, "mon_smoker_brute" ); - shoot_monster( "shotgun_s", { "choke" }, "shot_00", 1, 71, "mon_smoker_brute" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 18, 10, "mon_smoker_brute" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 12, 11, "mon_smoker_brute" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 5, 62, "mon_smoker_brute" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 1, 71, "mon_smoker_brute" ); } TEST_CASE( "shot_custom_damage_type", "[gun]" "[slow]" ) @@ -589,13 +645,13 @@ TEST_CASE( "shot_custom_damage_type", "[gun]" "[slow]" ) }; // Check that ballistics damage processes weird damage types and on-hit EOCs // note: shotguns can miss one-shot critical hit rarely - shoot_monster( "shotgun_s", {}, "test_shot_00_fire_damage", 1, 80, + shoot_monster( itype_shotgun_s, {}, itype_test_shot_00_fire_damage, 1, 80, "mon_test_zombie", check_eocs ); - shoot_monster( "shotgun_s", {}, "test_shot_00_fire_damage", 1, 80, + shoot_monster( itype_shotgun_s, {}, itype_test_shot_00_fire_damage, 1, 80, "mon_test_fire_resist", check_eocs ); - shoot_monster( "shotgun_s", {}, "test_shot_00_fire_damage", 1, 18, + shoot_monster( itype_shotgun_s, {}, itype_test_shot_00_fire_damage, 1, 18, "mon_test_fire_vresist", check_eocs ); - shoot_monster( "shotgun_s", {}, "test_shot_00_fire_damage", 1, 0, + shoot_monster( itype_shotgun_s, {}, itype_test_shot_00_fire_damage, 1, 0, "mon_test_fire_immune", check_eocs ); } diff --git a/tests/reading_test.cpp b/tests/reading_test.cpp index 27b57d00e86fe..efa3d0a34ca56 100644 --- a/tests/reading_test.cpp +++ b/tests/reading_test.cpp @@ -23,6 +23,18 @@ static const efftype_id effect_darkness( "darkness" ); static const flag_id json_flag_INSPIRATIONAL( "INSPIRATIONAL" ); +static const itype_id itype_atomic_lamp( "atomic_lamp" ); +static const itype_id itype_backpack( "backpack" ); +static const itype_id itype_child_book( "child_book" ); +static const itype_id itype_holybook_pastafarian( "holybook_pastafarian" ); +static const itype_id itype_mag_throwing( "mag_throwing" ); +static const itype_id itype_novel_western( "novel_western" ); +static const itype_id itype_recipe_alpha( "recipe_alpha" ); +static const itype_id itype_sheet_cotton( "sheet_cotton" ); +static const itype_id itype_test_battery_disposable( "test_battery_disposable" ); +static const itype_id itype_test_ebook_reader( "test_ebook_reader" ); +static const itype_id itype_test_textbook_fabrication( "test_textbook_fabrication" ); + static const limb_score_id limb_score_vision( "vision" ); static const morale_type morale_feeling_bad( "morale_feeling_bad" ); @@ -37,7 +49,7 @@ static const trait_id trait_SPIRITUAL( "SPIRITUAL" ); TEST_CASE( "clearing_identified_books", "[reading][book][identify][clear]" ) { - item book( "child_book" ); + item book( itype_child_book ); SECTION( "using local avatar" ) { avatar dummy; dummy.identify( book ); @@ -56,11 +68,11 @@ TEST_CASE( "identifying_unread_books", "[reading][book][identify]" ) { clear_avatar(); Character &dummy = get_avatar(); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); GIVEN( "character has some unidentified books" ) { - item_location book1 = dummy.i_add( item( "novel_western" ) ); - item_location book2 = dummy.i_add( item( "mag_throwing" ) ); + item_location book1 = dummy.i_add( item( itype_novel_western ) ); + item_location book2 = dummy.i_add( item( itype_mag_throwing ) ); REQUIRE_FALSE( dummy.has_identified( book1->typeId() ) ); REQUIRE_FALSE( dummy.has_identified( book2->typeId() ) ); @@ -82,10 +94,10 @@ TEST_CASE( "reading_a_book_for_fun", "[reading][book][fun]" ) clear_avatar(); Character &dummy = get_avatar(); dummy.set_body(); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); GIVEN( "a fun book" ) { - item_location book = dummy.i_add( item( "novel_western" ) ); + item_location book = dummy.i_add( item( itype_novel_western ) ); REQUIRE( book->type->book ); REQUIRE( book->type->book->fun > 0 ); int book_fun = book->type->book->fun; @@ -122,7 +134,7 @@ TEST_CASE( "reading_a_book_for_fun", "[reading][book][fun]" ) } GIVEN( "a fun book that is also inspirational" ) { - item_location book = dummy.i_add( item( "holybook_pastafarian" ) ); + item_location book = dummy.i_add( item( itype_holybook_pastafarian ) ); REQUIRE( book->has_flag( json_flag_INSPIRATIONAL ) ); REQUIRE( book->type->book ); REQUIRE( book->type->book->fun > 0 ); @@ -153,7 +165,7 @@ TEST_CASE( "character_reading_speed", "[reading][character][speed]" ) { clear_avatar(); Character &dummy = get_avatar(); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); // Note: read_speed() returns number of moves; // 6000 == 60 seconds @@ -203,12 +215,12 @@ TEST_CASE( "estimated_reading_time_for_a_book", "[reading][book][time]" ) REQUIRE( dummy.has_part( bodypart_id( "eyes" ) ) ); REQUIRE( dummy.get_limb_score( limb_score_vision ) != 0 ); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); // Easy, medium, and hard books - item_location child = dummy.i_add( item( "child_book" ) ); - item_location western = dummy.i_add( item( "novel_western" ) ); - item_location alpha = dummy.i_add( item( "recipe_alpha" ) ); + item_location child = dummy.i_add( item( itype_child_book ) ); + item_location western = dummy.i_add( item( itype_novel_western ) ); + item_location alpha = dummy.i_add( item( itype_recipe_alpha ) ); // Ensure the books are actually books REQUIRE( child->type->book ); @@ -225,7 +237,7 @@ TEST_CASE( "estimated_reading_time_for_a_book", "[reading][book][time]" ) REQUIRE_FALSE( dummy.has_identified( western->typeId() ) ); // Get some light - dummy.i_add( item( "atomic_lamp" ) ); + dummy.i_add( item( itype_atomic_lamp ) ); REQUIRE( dummy.fine_detail_vision_mod() == 1 ); THEN( "identifying books takes 1/10th of the normal reading time" ) { @@ -244,7 +256,7 @@ TEST_CASE( "estimated_reading_time_for_a_book", "[reading][book][time]" ) REQUIRE( dummy.has_identified( alpha->typeId() ) ); // Get some light - dummy.i_add( item( "atomic_lamp" ) ); + dummy.i_add( item( itype_atomic_lamp ) ); REQUIRE( dummy.fine_detail_vision_mod() == 1 ); WHEN( "player has average intelligence" ) { @@ -293,17 +305,17 @@ TEST_CASE( "reasons_for_not_being_able_to_read", "[reading][reasons]" ) clear_map(); Character &dummy = get_avatar(); dummy.set_body(); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); set_time_to_day(); std::vector reasons; std::vector expect_reasons; - item_location child = dummy.i_add( item( "child_book" ) ); - item_location western = dummy.i_add( item( "novel_western" ) ); - item_location alpha = dummy.i_add( item( "recipe_alpha" ) ); + item_location child = dummy.i_add( item( itype_child_book ) ); + item_location western = dummy.i_add( item( itype_novel_western ) ); + item_location alpha = dummy.i_add( item( itype_recipe_alpha ) ); SECTION( "you cannot read what is not readable" ) { - item_location sheet_cotton = dummy.i_add( item( "sheet_cotton" ) ); + item_location sheet_cotton = dummy.i_add( item( itype_sheet_cotton ) ); REQUIRE_FALSE( sheet_cotton->is_book() ); CHECK( dummy.get_book_reader( *sheet_cotton, reasons ) == nullptr ); @@ -334,7 +346,7 @@ TEST_CASE( "reasons_for_not_being_able_to_read", "[reading][reasons]" ) dummy.identify( *alpha ); // Get some light - dummy.i_add( item( "atomic_lamp" ) ); + dummy.i_add( item( itype_atomic_lamp ) ); REQUIRE( dummy.fine_detail_vision_mod() == 1 ); THEN( "you cannot read while illiterate" ) { @@ -396,13 +408,13 @@ TEST_CASE( "determining_book_mastery", "[reading][book][mastery]" ) avatar dummy; dummy.set_body(); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); - item_location child = dummy.i_add( item( "child_book" ) ); - item_location alpha = dummy.i_add( item( "recipe_alpha" ) ); + item_location child = dummy.i_add( item( itype_child_book ) ); + item_location alpha = dummy.i_add( item( itype_recipe_alpha ) ); SECTION( "you cannot determine mastery for non-book items" ) { - item_location sheet_cotton = dummy.i_add( item( "sheet_cotton" ) ); + item_location sheet_cotton = dummy.i_add( item( itype_sheet_cotton ) ); REQUIRE_FALSE( sheet_cotton->is_book() ); CHECK( dummy.get_book_mastery( *sheet_cotton ) == book_mastery::CANT_DETERMINE ); } @@ -447,9 +459,9 @@ TEST_CASE( "reading_a_book_for_skill", "[reading][book][skill]" ) clear_avatar(); Character &dummy = get_avatar(); dummy.set_body(); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); - item_location alpha = dummy.i_add( item( "recipe_alpha" ) ); + item_location alpha = dummy.i_add( item( itype_recipe_alpha ) ); REQUIRE( alpha->is_book() ); dummy.identify( *alpha ); @@ -484,16 +496,16 @@ TEST_CASE( "reading_a_book_with_an_ebook_reader", "[reading][book][ereader]" ) WHEN( "reading a book" ) { - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); - dummy.i_add( item( "atomic_lamp" ) ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); + dummy.i_add( item( itype_atomic_lamp ) ); REQUIRE( dummy.fine_detail_vision_mod() == 1 ); - item_location ereader = dummy.i_add( item( "test_ebook_reader" ) ); + item_location ereader = dummy.i_add( item( itype_test_ebook_reader ) ); - item book{"test_textbook_fabrication"}; + item book( itype_test_textbook_fabrication ); ereader->put_in( book, pocket_type::EBOOK ); - item battery( "test_battery_disposable" ); + item battery( itype_test_battery_disposable ); battery.ammo_set( battery.ammo_default(), 100 ); ereader->put_in( battery, pocket_type::MAGAZINE_WELL ); diff --git a/tests/reload_magazine_test.cpp b/tests/reload_magazine_test.cpp index 19b22b5f078ed..084f9c1cc6048 100644 --- a/tests/reload_magazine_test.cpp +++ b/tests/reload_magazine_test.cpp @@ -25,6 +25,7 @@ static const itype_id itype_357mag_fmj( "357mag_fmj" ); static const itype_id itype_38_special( "38_special" ); static const itype_id itype_556( "556" ); static const itype_id itype_9mm( "9mm" ); +static const itype_id itype_backpack( "backpack" ); static const itype_id itype_debug_modular_m4_carbine( "debug_modular_m4_carbine" ); static const itype_id itype_glockmag( "glockmag" ); static const itype_id itype_stanag30( "stanag30" ); @@ -52,14 +53,14 @@ TEST_CASE( "reload_magazine", "[magazine] [visitable] [item] [item_location] [re player_character.clear_worn(); player_character.inv->clear(); player_character.remove_weapon(); - player_character.wear_item( item( "backpack" ) ); // so we don't drop anything + player_character.wear_item( item( itype_backpack ) ); // so we don't drop anything item_location mag = player_character.i_add( item( mag_id ) ); - const item ammo_it( "556" ); // any type of compatible ammo - const item alt_ammo_it( "223" ); // any alternative type of compatible ammo - const item bad_ammo_it( "9mm" ); // any type of incompatible ammo - const item mag_it( "stanag30" ); // must be set to default magazine - const item bad_mag_it( "glockmag" ); // any incompatible magazine + const item ammo_it( itype_556 ); // any type of compatible ammo + const item alt_ammo_it( itype_223 ); // any alternative type of compatible ammo + const item bad_ammo_it( itype_9mm ); // any type of incompatible ammo + const item mag_it( itype_stanag30 ); // must be set to default magazine + const item bad_mag_it( itype_glockmag ); // any incompatible magazine CHECK( mag->is_magazine() ); CHECK( mag->is_reloadable() ); CHECK( mag->can_reload_with( ammo_it, true ) ); @@ -337,7 +338,7 @@ TEST_CASE( "reload_revolver", "[visitable] [item] [item_location] [reload]" ) const itype_id bad_ammo = itype_9mm; // any type of incompatible ammo const int mag_cap = 7; // amount of bullets that fit into cylinder - const item ammo_it( "38_special" ); // any type of compatible ammo + const item ammo_it( itype_38_special ); // any type of compatible ammo CHECK( ammo_id != alt_ammo ); CHECK( ammo_id != bad_ammo ); @@ -347,7 +348,7 @@ TEST_CASE( "reload_revolver", "[visitable] [item] [item_location] [reload]" ) player_character.clear_worn(); player_character.inv->clear(); player_character.remove_weapon(); - player_character.wear_item( item( "backpack" ) ); // so we don't drop anything + player_character.wear_item( item( itype_backpack ) ); // so we don't drop anything GIVEN( "an empty gun with an integral magazine" ) { item_location gun = player_character.i_add( item( gun_id ) ); diff --git a/tests/reload_option_test.cpp b/tests/reload_option_test.cpp index e5cfe3ac23b8d..568ea795aa6a5 100644 --- a/tests/reload_option_test.cpp +++ b/tests/reload_option_test.cpp @@ -14,14 +14,29 @@ static const flag_id json_flag_RELOAD_ONE( "RELOAD_ONE" ); +static const itype_id itype_2lcanteen( "2lcanteen" ); +static const itype_id itype_308( "308" ); +static const itype_id itype_38_special( "38_special" ); +static const itype_id itype_38_speedloader( "38_speedloader" ); +static const itype_id itype_9mm( "9mm" ); +static const itype_id itype_ammolink308( "ammolink308" ); +static const itype_id itype_backpack( "backpack" ); +static const itype_id itype_belt308( "belt308" ); +static const itype_id itype_bottle_plastic( "bottle_plastic" ); +static const itype_id itype_glock_19( "glock_19" ); +static const itype_id itype_glockmag( "glockmag" ); +static const itype_id itype_m134( "m134" ); +static const itype_id itype_sw_619( "sw_619" ); +static const itype_id itype_water_clean( "water_clean" ); + TEST_CASE( "revolver_reload_option", "[reload],[reload_option],[gun]" ) { avatar dummy; - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); - item_location gun = dummy.i_add( item( "sw_619", calendar::turn_zero, 0 ) ); + item_location gun = dummy.i_add( item( itype_sw_619, calendar::turn_zero, 0 ) ); const ammotype &gun_ammo_type = item::find_type( gun->ammo_default() )->ammo->type; - item_location ammo = dummy.i_add( item( "38_special", calendar::turn_zero, + item_location ammo = dummy.i_add( item( itype_38_special, calendar::turn_zero, gun->ammo_capacity( gun_ammo_type ) ) ); REQUIRE( gun->has_flag( json_flag_RELOAD_ONE ) ); REQUIRE( gun->ammo_remaining() == 0 ); @@ -29,7 +44,7 @@ TEST_CASE( "revolver_reload_option", "[reload],[reload_option],[gun]" ) const item::reload_option gun_option( &dummy, gun, ammo ); REQUIRE( gun_option.qty() == 1 ); - item_location speedloader = dummy.i_add( item( "38_speedloader", calendar::turn_zero, 0 ) ); + item_location speedloader = dummy.i_add( item( itype_38_speedloader, calendar::turn_zero, 0 ) ); REQUIRE( speedloader->ammo_remaining() == 0 ); const item::reload_option speedloader_option( &dummy, speedloader, ammo ); @@ -43,18 +58,18 @@ TEST_CASE( "revolver_reload_option", "[reload],[reload_option],[gun]" ) TEST_CASE( "magazine_reload_option", "[reload],[reload_option],[gun]" ) { avatar dummy; - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); - item_location magazine = dummy.i_add( item( "glockmag", calendar::turn_zero, 0 ) ); + item_location magazine = dummy.i_add( item( itype_glockmag, calendar::turn_zero, 0 ) ); const ammotype &mag_ammo_type = item::find_type( magazine->ammo_default() )->ammo->type; - item_location ammo = dummy.i_add( item( "9mm", calendar::turn_zero, + item_location ammo = dummy.i_add( item( itype_9mm, calendar::turn_zero, magazine->ammo_capacity( mag_ammo_type ) ) ); const item::reload_option magazine_option( &dummy, magazine, ammo ); CHECK( magazine_option.qty() == magazine->ammo_capacity( mag_ammo_type ) ); magazine->put_in( *ammo, pocket_type::MAGAZINE ); - item_location gun = dummy.i_add( item( "glock_19", calendar::turn_zero, 0 ) ); + item_location gun = dummy.i_add( item( itype_glock_19, calendar::turn_zero, 0 ) ); const item::reload_option gun_option( &dummy, gun, magazine ); CHECK( gun_option.qty() == 1 ); } @@ -63,13 +78,14 @@ TEST_CASE( "belt_reload_option", "[reload],[reload_option],[gun]" ) { avatar dummy; dummy.set_body(); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); - item_location belt = dummy.i_add( item( "belt308", calendar::turn_zero, 0 ) ); + item_location belt = dummy.i_add( item( itype_belt308, calendar::turn_zero, 0 ) ); const ammotype &belt_ammo_type = item::find_type( belt->ammo_default() )->ammo->type; - item_location ammo = dummy.i_add( item( "308", calendar::turn_zero, + item_location ammo = dummy.i_add( item( itype_308, calendar::turn_zero, belt->ammo_capacity( belt_ammo_type ) ) ); - dummy.i_add( item( "ammolink308", calendar::turn_zero, belt->ammo_capacity( belt_ammo_type ) ) ); + dummy.i_add( item( itype_ammolink308, calendar::turn_zero, + belt->ammo_capacity( belt_ammo_type ) ) ); // Belt is populated with "charges" rounds by the item constructor. belt->ammo_unset(); @@ -78,7 +94,7 @@ TEST_CASE( "belt_reload_option", "[reload],[reload_option],[gun]" ) CHECK( belt_option.qty() == belt->ammo_capacity( belt_ammo_type ) ); belt->put_in( *ammo, pocket_type::MAGAZINE ); - item_location gun = dummy.i_add( item( "m134", calendar::turn_zero, 0 ) ); + item_location gun = dummy.i_add( item( itype_m134, calendar::turn_zero, 0 ) ); const item::reload_option gun_option( &dummy, gun, belt ); @@ -88,11 +104,11 @@ TEST_CASE( "belt_reload_option", "[reload],[reload_option],[gun]" ) TEST_CASE( "canteen_reload_option", "[reload],[reload_option],[liquid]" ) { avatar dummy; - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); - item plastic_bottle( "bottle_plastic" ); + item plastic_bottle( itype_bottle_plastic ); item_location bottle = dummy.i_add( plastic_bottle ); - item water( "water_clean", calendar::turn_zero, 2 ); + item water( itype_water_clean, calendar::turn_zero, 2 ); // add an extra bottle with water item_location water_bottle = dummy.i_add( plastic_bottle ); water_bottle->put_in( water, pocket_type::CONTAINER ); @@ -100,7 +116,7 @@ TEST_CASE( "canteen_reload_option", "[reload],[reload_option],[liquid]" ) const item::reload_option bottle_option( &dummy, bottle, water_bottle ); CHECK( bottle_option.qty() == bottle->get_remaining_capacity_for_liquid( water, true ) ); - item_location canteen = dummy.i_add( item( "2lcanteen" ) ); + item_location canteen = dummy.i_add( item( itype_2lcanteen ) ); const item::reload_option canteen_option( &dummy, canteen, water_bottle ); diff --git a/tests/reload_time_test.cpp b/tests/reload_time_test.cpp index 730f2d07ee531..bafb030d4f658 100644 --- a/tests/reload_time_test.cpp +++ b/tests/reload_time_test.cpp @@ -13,10 +13,24 @@ #include #include "map_helpers.h" +static const itype_id itype_ammo_pouch( "ammo_pouch" ); +static const itype_id itype_arrow_wood( "arrow_wood" ); +static const itype_id itype_backpack( "backpack" ); +static const itype_id itype_long_duffelbag( "long_duffelbag" ); +static const itype_id itype_longbow( "longbow" ); +static const itype_id itype_pants( "pants" ); +static const itype_id itype_pebble( "pebble" ); +static const itype_id itype_quiver( "quiver" ); +static const itype_id itype_rock( "rock" ); +static const itype_id itype_slingshot( "slingshot" ); +static const itype_id itype_staff_sling( "staff_sling" ); +static const itype_id itype_stone_pouch( "stone_pouch" ); +static const itype_id itype_tool_belt( "tool_belt" ); + static const mtype_id pseudo_debug_mon( "pseudo_debug_mon" ); -static void check_reload_time( const std::string &weapon, const std::string &ammo, - const std::string &container, int expected_moves ) +static void check_reload_time( const itype_id &weapon, const itype_id &ammo, + const itype_id &container, int expected_moves ) { const tripoint_bub_ms test_origin( 60, 60, 0 ); const tripoint_bub_ms spot( 61, 60, 0 ); @@ -25,7 +39,7 @@ static void check_reload_time( const std::string &weapon, const std::string &amm g->place_critter_at( pseudo_debug_mon, spot ); shooter.setpos( test_origin ); shooter.set_wielded_item( item( weapon, calendar::turn_zero, 0 ) ); - if( container.empty() ) { + if( container.is_null() ) { get_map().add_item( test_origin, item( ammo ) ); } else { shooter.worn.wear_item( shooter, item( container ), false, false ); @@ -60,47 +74,47 @@ TEST_CASE( "reload_from_inventory_times", "[reload],[inventory],[balance]" ) clear_avatar(); SECTION( "reloading a slingshot" ) { SECTION( "from a backpack" ) { - check_reload_time( "slingshot", "pebble", "backpack", 400 ); + check_reload_time( itype_slingshot, itype_pebble, itype_backpack, 400 ); } SECTION( "from an ammo pouch" ) { - check_reload_time( "slingshot", "pebble", "ammo_pouch", 137 ); + check_reload_time( itype_slingshot, itype_pebble, itype_ammo_pouch, 137 ); } SECTION( "from a tool belt" ) { - check_reload_time( "slingshot", "pebble", "tool_belt", 200 ); + check_reload_time( itype_slingshot, itype_pebble, itype_tool_belt, 200 ); } SECTION( "from a pocket" ) { - check_reload_time( "slingshot", "pebble", "pants", 200 ); + check_reload_time( itype_slingshot, itype_pebble, itype_pants, 200 ); } SECTION( "from the ground" ) { - check_reload_time( "slingshot", "pebble", "", 180 ); + check_reload_time( itype_slingshot, itype_pebble, itype_id::NULL_ID(), 180 ); } } SECTION( "reloading a staff sling" ) { SECTION( "from a backpack" ) { - check_reload_time( "staff_sling", "rock", "backpack", 595 ); + check_reload_time( itype_staff_sling, itype_rock, itype_backpack, 595 ); } SECTION( "from a stone pouch" ) { - check_reload_time( "staff_sling", "rock", "stone_pouch", 315 ); + check_reload_time( itype_staff_sling, itype_rock, itype_stone_pouch, 315 ); } SECTION( "from a tool belt" ) { - check_reload_time( "staff_sling", "rock", "tool_belt", 380 ); + check_reload_time( itype_staff_sling, itype_rock, itype_tool_belt, 380 ); } SECTION( "from a pocket" ) { - check_reload_time( "staff_sling", "rock", "pants", 395 ); + check_reload_time( itype_staff_sling, itype_rock, itype_pants, 395 ); } SECTION( "from the ground" ) { - check_reload_time( "staff_sling", "rock", "", 370 ); + check_reload_time( itype_staff_sling, itype_rock, itype_id::NULL_ID(), 370 ); } } SECTION( "reloading a bow" ) { SECTION( "from a duffel bag" ) { - check_reload_time( "longbow", "arrow_wood", "long_duffelbag", 410 ); + check_reload_time( itype_longbow, itype_arrow_wood, itype_long_duffelbag, 410 ); } SECTION( "from a quiver" ) { - check_reload_time( "longbow", "arrow_wood", "quiver", 130 ); + check_reload_time( itype_longbow, itype_arrow_wood, itype_quiver, 130 ); } SECTION( "from the ground" ) { - check_reload_time( "longbow", "arrow_wood", "", 190 ); + check_reload_time( itype_longbow, itype_arrow_wood, itype_id::NULL_ID(), 190 ); } } } diff --git a/tests/reloading_test.cpp b/tests/reloading_test.cpp index 3b0617e84cda9..ad3cb657a7e1d 100644 --- a/tests/reloading_test.cpp +++ b/tests/reloading_test.cpp @@ -26,9 +26,38 @@ static const flag_id json_flag_CASING( "CASING" ); static const flag_id json_flag_SPEEDLOADER( "SPEEDLOADER" ); +static const itype_id itype_10mm_fmj( "10mm_fmj" ); +static const itype_id itype_223( "223" ); +static const itype_id itype_2lcanteen( "2lcanteen" ); +static const itype_id itype_38_special( "38_special" ); +static const itype_id itype_38_speedloader( "38_speedloader" ); +static const itype_id itype_40_casing( "40_casing" ); +static const itype_id itype_40_speedloader6( "40_speedloader6" ); +static const itype_id itype_40sw( "40sw" ); +static const itype_id itype_40x46mm_m118_casing( "40x46mm_m118_casing" ); +static const itype_id itype_40x46mm_m433( "40x46mm_m433" ); +static const itype_id itype_556( "556" ); +static const itype_id itype_9mm( "9mm" ); +static const itype_id itype_9mmfmj( "9mmfmj" ); +static const itype_id itype_backpack( "backpack" ); +static const itype_id itype_bigback( "bigback" ); +static const itype_id itype_bottle_plastic( "bottle_plastic" ); +static const itype_id itype_bottle_plastic_small( "bottle_plastic_small" ); +static const itype_id itype_bottle_twoliter( "bottle_twoliter" ); +static const itype_id itype_bp_40sw( "bp_40sw" ); +static const itype_id itype_cranberry_juice( "cranberry_juice" ); +static const itype_id itype_debug_modular_m4_carbine( "debug_modular_m4_carbine" ); static const itype_id itype_glock_19( "glock_19" ); static const itype_id itype_glockbigmag( "glockbigmag" ); static const itype_id itype_glockmag( "glockmag" ); +static const itype_id itype_jug_plastic( "jug_plastic" ); +static const itype_id itype_m203( "m203" ); +static const itype_id itype_milk( "milk" ); +static const itype_id itype_pebble( "pebble" ); +static const itype_id itype_stanag30( "stanag30" ); +static const itype_id itype_sw_610( "sw_610" ); +static const itype_id itype_sw_619( "sw_619" ); +static const itype_id itype_water_clean( "water_clean" ); static void test_reloading( item &target, item &ammo, bool expect_success = true ) { @@ -38,7 +67,7 @@ static void test_reloading( item &target, item &ammo, bool expect_success = true clear_avatar(); // Make sure the player doesn't drop anything :P - dummy.wear_item( item( "backpack", calendar::turn_zero ) ); + dummy.wear_item( item( itype_backpack, calendar::turn_zero ) ); dummy.i_add( ammo ); dummy.set_wielded_item( target ); @@ -72,74 +101,74 @@ TEST_CASE( "reload_magazines", "[reload]" ) SECTION( "empty magazine" ) { - item mag( "stanag30" ); + item mag( itype_stanag30 ); SECTION( "with one round" ) { - item ammo( "556" ); + item ammo( itype_556 ); test_reloading( mag, ammo ); } SECTION( "with large stack of rounds" ) { - item ammo( "556", calendar::turn, 500 ); + item ammo( itype_556, calendar::turn, 500 ); test_reloading( mag, ammo ); } SECTION( "with wrong ammo" ) { - item ammo( "9mm" ); + item ammo( itype_9mm ); test_reloading( mag, ammo, false ); } } SECTION( "partially empty magazine" ) { - item mag( "stanag30" ); - mag.put_in( item( "556", calendar::turn, 1 ), pocket_type::MAGAZINE ); + item mag( itype_stanag30 ); + mag.put_in( item( itype_556, calendar::turn, 1 ), pocket_type::MAGAZINE ); REQUIRE( mag.ammo_remaining() == 1 ); SECTION( "with one round" ) { - item ammo( "556" ); + item ammo( itype_556 ); test_reloading( mag, ammo ); } SECTION( "with large stack of rounds" ) { - item ammo( "556", calendar::turn, 500 ); + item ammo( itype_556, calendar::turn, 500 ); test_reloading( mag, ammo ); } SECTION( "with one ammo of different type" ) { - item ammo( "223" ); + item ammo( itype_223 ); test_reloading( mag, ammo ); } SECTION( "with wrong ammo" ) { - item ammo( "9mm" ); + item ammo( itype_9mm ); test_reloading( mag, ammo, false ); } } SECTION( "full magazine" ) { - item mag( "stanag30" ); - mag.put_in( item( "556", calendar::turn, 30 ), pocket_type::MAGAZINE ); + item mag( itype_stanag30 ); + mag.put_in( item( itype_556, calendar::turn, 30 ), pocket_type::MAGAZINE ); REQUIRE( mag.ammo_remaining() == 30 ); SECTION( "with one round" ) { - item ammo( "556" ); + item ammo( itype_556 ); test_reloading( mag, ammo, false ); } SECTION( "with large stack of rounds" ) { - item ammo( "556", calendar::turn, 500 ); + item ammo( itype_556, calendar::turn, 500 ); test_reloading( mag, ammo, false ); } SECTION( "with one ammo of different type" ) { - item ammo( "223" ); + item ammo( itype_223 ); test_reloading( mag, ammo, false ); } SECTION( "with wrong ammo" ) { - item ammo( "9mm" ); + item ammo( itype_9mm ); test_reloading( mag, ammo, false ); } } @@ -150,63 +179,63 @@ TEST_CASE( "reload_gun_with_casings", "[reload],[gun]" ) { SECTION( "empty gun" ) { - item gun( "sw_610" ); + item gun( itype_sw_610 ); SECTION( "with one round" ) { - item ammo( "40sw" ); + item ammo( itype_40sw ); test_reloading( gun, ammo ); } } SECTION( "gun with casings and ammo" ) { - item gun( "sw_610" ); - gun.put_in( item( "40sw", calendar::turn, 3 ), pocket_type::MAGAZINE ); - gun.force_insert_item( item( "40_casing", calendar::turn, 3 ).set_flag( json_flag_CASING ), + item gun( itype_sw_610 ); + gun.put_in( item( itype_40sw, calendar::turn, 3 ), pocket_type::MAGAZINE ); + gun.force_insert_item( item( itype_40_casing, calendar::turn, 3 ).set_flag( json_flag_CASING ), pocket_type::MAGAZINE ); SECTION( "with one round" ) { - item ammo( "40sw" ); + item ammo( itype_40sw ); test_reloading( gun, ammo ); } SECTION( "with large stack of rounds" ) { - item ammo( "40sw", calendar::turn, 500 ); + item ammo( itype_40sw, calendar::turn, 500 ); test_reloading( gun, ammo ); } SECTION( "with one ammo of different type" ) { - item ammo( "bp_40sw" ); + item ammo( itype_bp_40sw ); test_reloading( gun, ammo ); } SECTION( "with one ammo of different ammo type" ) { - item ammo( "10mm_fmj" ); + item ammo( itype_10mm_fmj ); test_reloading( gun, ammo, false ); } SECTION( "with wrong ammo" ) { - item ammo( "9mm" ); + item ammo( itype_9mm ); test_reloading( gun, ammo, false ); } } SECTION( "full of casings" ) { - item gun( "sw_610" ); - gun.force_insert_item( item( "40_casing", calendar::turn, 6 ).set_flag( json_flag_CASING ), + item gun( itype_sw_610 ); + gun.force_insert_item( item( itype_40_casing, calendar::turn, 6 ).set_flag( json_flag_CASING ), pocket_type::MAGAZINE ); SECTION( "with one round" ) { - item ammo( "40sw" ); + item ammo( itype_40sw ); test_reloading( gun, ammo ); } SECTION( "with large stack of rounds" ) { - item ammo( "40sw", calendar::turn, 500 ); + item ammo( itype_40sw, calendar::turn, 500 ); test_reloading( gun, ammo ); } SECTION( "with wrong ammo" ) { - item ammo( "9mm" ); + item ammo( itype_9mm ); test_reloading( gun, ammo, false ); } } @@ -215,117 +244,117 @@ TEST_CASE( "reload_gun_with_casings", "[reload],[gun]" ) TEST_CASE( "reload_gun_with_magazine", "[reload],[gun]" ) { SECTION( "empty gun" ) { - item gun( "glock_19" ); + item gun( itype_glock_19 ); SECTION( "with empty magazine" ) { - item mag( "glockmag" ); + item mag( itype_glockmag ); test_reloading( gun, mag ); } SECTION( "with full magazine" ) { - item mag( "glockmag" ); - mag.put_in( item( "9mm", calendar::turn, 15 ), pocket_type::MAGAZINE ); + item mag( itype_glockmag ); + mag.put_in( item( itype_9mm, calendar::turn, 15 ), pocket_type::MAGAZINE ); REQUIRE( mag.ammo_remaining() == 15 ); test_reloading( gun, mag ); } SECTION( "with magazine of wrong ammo" ) { - item mag( "glockmag" ); - mag.force_insert_item( item( "556", calendar::turn, 15 ), pocket_type::MAGAZINE ); + item mag( itype_glockmag ); + mag.force_insert_item( item( itype_556, calendar::turn, 15 ), pocket_type::MAGAZINE ); REQUIRE( mag.ammo_remaining() == 15 ); test_reloading( gun, mag, false ); } } SECTION( "gun with empty magazine" ) { - item gun( "glock_19" ); - gun.put_in( item( "glockmag" ), pocket_type::MAGAZINE_WELL ); + item gun( itype_glock_19 ); + gun.put_in( item( itype_glockmag ), pocket_type::MAGAZINE_WELL ); SECTION( "with empty magazine" ) { - item mag( "glockmag" ); + item mag( itype_glockmag ); test_reloading( gun, mag, false ); } SECTION( "with full magazine" ) { - item mag( "glockmag" ); - mag.put_in( item( "9mm", calendar::turn, 15 ), pocket_type::MAGAZINE ); + item mag( itype_glockmag ); + mag.put_in( item( itype_9mm, calendar::turn, 15 ), pocket_type::MAGAZINE ); REQUIRE( mag.ammo_remaining() == 15 ); test_reloading( gun, mag ); } SECTION( "with magazine of wrong ammo" ) { - item mag( "glockmag" ); - mag.force_insert_item( item( "556", calendar::turn, 15 ), pocket_type::MAGAZINE ); + item mag( itype_glockmag ); + mag.force_insert_item( item( itype_556, calendar::turn, 15 ), pocket_type::MAGAZINE ); REQUIRE( mag.ammo_remaining() == 15 ); test_reloading( gun, mag, false ); } } SECTION( "gun with partially empty magazine" ) { - item gun( "glock_19" ); - item old_mag( "glockmag" ); - old_mag.put_in( item( "9mm", calendar::turn, 2 ), pocket_type::MAGAZINE ); + item gun( itype_glock_19 ); + item old_mag( itype_glockmag ); + old_mag.put_in( item( itype_9mm, calendar::turn, 2 ), pocket_type::MAGAZINE ); REQUIRE( old_mag.ammo_remaining() == 2 ); gun.put_in( old_mag, pocket_type::MAGAZINE_WELL ); REQUIRE( gun.ammo_remaining() == 2 ); SECTION( "with empty magazine" ) { - item mag( "glockmag" ); + item mag( itype_glockmag ); test_reloading( gun, mag ); } SECTION( "with full magazine" ) { - item mag( "glockmag" ); - mag.put_in( item( "9mm", calendar::turn, 15 ), pocket_type::MAGAZINE ); + item mag( itype_glockmag ); + mag.put_in( item( itype_9mm, calendar::turn, 15 ), pocket_type::MAGAZINE ); REQUIRE( mag.ammo_remaining() == 15 ); test_reloading( gun, mag ); } SECTION( "with full magazine with different ammo" ) { - item mag( "glockmag" ); - mag.put_in( item( "9mmfmj", calendar::turn, 15 ), pocket_type::MAGAZINE ); + item mag( itype_glockmag ); + mag.put_in( item( itype_9mmfmj, calendar::turn, 15 ), pocket_type::MAGAZINE ); REQUIRE( mag.ammo_remaining() == 15 ); test_reloading( gun, mag ); } SECTION( "with magazine of wrong ammo" ) { - item mag( "glockmag" ); - mag.force_insert_item( item( "556", calendar::turn, 15 ), pocket_type::MAGAZINE ); + item mag( itype_glockmag ); + mag.force_insert_item( item( itype_556, calendar::turn, 15 ), pocket_type::MAGAZINE ); REQUIRE( mag.ammo_remaining() == 15 ); test_reloading( gun, mag, false ); } } SECTION( "gun with full magazine" ) { - item gun( "glock_19" ); - item old_mag( "glockmag" ); - old_mag.put_in( item( "9mm", calendar::turn, 15 ), pocket_type::MAGAZINE ); + item gun( itype_glock_19 ); + item old_mag( itype_glockmag ); + old_mag.put_in( item( itype_9mm, calendar::turn, 15 ), pocket_type::MAGAZINE ); REQUIRE( old_mag.ammo_remaining() == 15 ); gun.put_in( old_mag, pocket_type::MAGAZINE_WELL ); REQUIRE( gun.ammo_remaining() == 15 ); SECTION( "with empty magazine" ) { - item mag( "glockmag" ); + item mag( itype_glockmag ); test_reloading( gun, mag, false ); } SECTION( "with full magazine" ) { - item mag( "glockmag" ); - mag.put_in( item( "9mm", calendar::turn, 15 ), pocket_type::MAGAZINE ); + item mag( itype_glockmag ); + mag.put_in( item( itype_9mm, calendar::turn, 15 ), pocket_type::MAGAZINE ); REQUIRE( mag.ammo_remaining() == 15 ); test_reloading( gun, mag, false ); } SECTION( "with full magazine with different ammo" ) { - item mag( "glockmag" ); - mag.put_in( item( "9mmfmj", calendar::turn, 15 ), pocket_type::MAGAZINE ); + item mag( itype_glockmag ); + mag.put_in( item( itype_9mmfmj, calendar::turn, 15 ), pocket_type::MAGAZINE ); REQUIRE( mag.ammo_remaining() == 15 ); test_reloading( gun, mag, false ); } SECTION( "with magazine of wrong ammo" ) { - item mag( "glockmag" ); - mag.force_insert_item( item( "556", calendar::turn, 15 ), pocket_type::MAGAZINE ); + item mag( itype_glockmag ); + mag.force_insert_item( item( itype_556, calendar::turn, 15 ), pocket_type::MAGAZINE ); REQUIRE( mag.ammo_remaining() == 15 ); test_reloading( gun, mag, false ); } @@ -335,47 +364,47 @@ TEST_CASE( "reload_gun_with_magazine", "[reload],[gun]" ) TEST_CASE( "liquid_reloading", "[reload]" ) { SECTION( "empty bottle" ) { - item container( "bottle_plastic" ); + item container( itype_bottle_plastic ); SECTION( "with water" ) { - item liquid_container( "bottle_plastic" ); - liquid_container.put_in( item( "water_clean" ), pocket_type::CONTAINER ); + item liquid_container( itype_bottle_plastic ); + liquid_container.put_in( item( itype_water_clean ), pocket_type::CONTAINER ); test_reloading( container, liquid_container ); } SECTION( "with lots of water" ) { - item liquid_container( "bottle_twoliter" ); - liquid_container.put_in( item( "water_clean", calendar::turn, 8 ), + item liquid_container( itype_bottle_twoliter ); + liquid_container.put_in( item( itype_water_clean, calendar::turn, 8 ), pocket_type::CONTAINER ); test_reloading( container, liquid_container ); } SECTION( "with frozen water" ) { - item liquid( "water_clean" ); + item liquid( itype_water_clean ); liquid.set_item_temperature( units::from_kelvin( 200 ) ); REQUIRE( liquid.is_frozen_liquid() ); test_reloading( container, liquid, false ); } SECTION( "with frozen water from container" ) { - item liquid( "water_clean" ); + item liquid( itype_water_clean ); liquid.set_item_temperature( units::from_kelvin( 200 ) ); REQUIRE( liquid.is_frozen_liquid() ); - item liquid_container( "bottle_plastic" ); + item liquid_container( itype_bottle_plastic ); liquid_container.put_in( liquid, pocket_type::CONTAINER ); test_reloading( container, liquid_container, false ); } SECTION( "with non-liquid" ) { - item liquid( "9mm" ); + item liquid( itype_9mm ); test_reloading( container, liquid, false ); } SECTION( "with non-liquid from container" ) { - item liquid_container( "bottle_plastic" ); - liquid_container.put_in( item( "9mm" ), pocket_type::CONTAINER ); + item liquid_container( itype_bottle_plastic ); + liquid_container.put_in( item( itype_9mm ), pocket_type::CONTAINER ); test_reloading( container, liquid_container, false ); } } @@ -383,98 +412,98 @@ TEST_CASE( "liquid_reloading", "[reload]" ) // Note: The reloading doesn't care which item is what. The liquid can go from either bottle to the other. SECTION( "partially empty bottle" ) { - item container( "bottle_twoliter" ); - container.put_in( item( "water_clean", calendar::turn, 1 ), pocket_type::CONTAINER ); + item container( itype_bottle_twoliter ); + container.put_in( item( itype_water_clean, calendar::turn, 1 ), pocket_type::CONTAINER ); REQUIRE( !container.is_container_empty() ); REQUIRE( !container.is_container_full() ); SECTION( "with one water" ) { - item liquid_container( "bottle_plastic" ); - liquid_container.put_in( item( "water_clean" ), pocket_type::CONTAINER ); + item liquid_container( itype_bottle_plastic ); + liquid_container.put_in( item( itype_water_clean ), pocket_type::CONTAINER ); test_reloading( container, liquid_container ); } SECTION( "with lots of water" ) { - item liquid_container( "bottle_twoliter" ); - liquid_container.put_in( item( "water_clean", calendar::turn, 8 ), + item liquid_container( itype_bottle_twoliter ); + liquid_container.put_in( item( itype_water_clean, calendar::turn, 8 ), pocket_type::CONTAINER ); test_reloading( container, liquid_container ); } SECTION( "with frozen water" ) { - item liquid( "water_clean" ); + item liquid( itype_water_clean ); liquid.set_item_temperature( units::from_kelvin( 200 ) ); REQUIRE( liquid.is_frozen_liquid() ); test_reloading( container, liquid, false ); } SECTION( "with frozen water from container" ) { - item liquid( "water_clean" ); + item liquid( itype_water_clean ); liquid.set_item_temperature( units::from_kelvin( 200 ) ); REQUIRE( liquid.is_frozen_liquid() ); - item liquid_container( "bottle_plastic" ); + item liquid_container( itype_bottle_plastic ); liquid_container.put_in( liquid, pocket_type::CONTAINER ); test_reloading( container, liquid_container, false ); } SECTION( "with liquid of different type" ) { - item liquid_container( "bottle_plastic" ); - liquid_container.put_in( item( "cranberry_juice" ), pocket_type::CONTAINER ); + item liquid_container( itype_bottle_plastic ); + liquid_container.put_in( item( itype_cranberry_juice ), pocket_type::CONTAINER ); test_reloading( container, liquid_container, false ); } SECTION( "with non-liquid" ) { - item liquid( "9mm" ); + item liquid( itype_9mm ); test_reloading( container, liquid, false ); } } SECTION( "full bottle" ) { - item container( "bottle_plastic" ); - container.put_in( item( "water_clean", calendar::turn, 2 ), pocket_type::CONTAINER ); + item container( itype_bottle_plastic ); + container.put_in( item( itype_water_clean, calendar::turn, 2 ), pocket_type::CONTAINER ); REQUIRE( container.is_container_full() ); SECTION( "with one water" ) { - item liquid_container( "bottle_plastic_small" ); - liquid_container.put_in( item( "water_clean" ), pocket_type::CONTAINER ); + item liquid_container( itype_bottle_plastic_small ); + liquid_container.put_in( item( itype_water_clean ), pocket_type::CONTAINER ); test_reloading( container, liquid_container, false ); } SECTION( "with lots of water" ) { - item liquid_container( "bottle_twoliter" ); - liquid_container.put_in( item( "water_clean", calendar::turn, 8 ), + item liquid_container( itype_bottle_twoliter ); + liquid_container.put_in( item( itype_water_clean, calendar::turn, 8 ), pocket_type::CONTAINER ); test_reloading( container, liquid_container, false ); } SECTION( "with frozen water" ) { - item liquid( "water_clean" ); + item liquid( itype_water_clean ); liquid.set_item_temperature( units::from_kelvin( 200 ) ); REQUIRE( liquid.is_frozen_liquid() ); test_reloading( container, liquid, false ); } SECTION( "with frozen water from container" ) { - item liquid( "water_clean" ); + item liquid( itype_water_clean ); liquid.set_item_temperature( units::from_kelvin( 200 ) ); REQUIRE( liquid.is_frozen_liquid() ); - item liquid_container( "bottle_plastic" ); + item liquid_container( itype_bottle_plastic ); liquid_container.put_in( liquid, pocket_type::CONTAINER ); test_reloading( container, liquid_container, false ); } SECTION( "with liquid of different type" ) { - item liquid_container( "bottle_plastic" ); - liquid_container.put_in( item( "cranberry_juice" ), pocket_type::CONTAINER ); + item liquid_container( itype_bottle_plastic ); + liquid_container.put_in( item( itype_cranberry_juice ), pocket_type::CONTAINER ); test_reloading( container, liquid_container, false ); } SECTION( "with non-liquid" ) { - item liquid( "9mm" ); + item liquid( itype_9mm ); test_reloading( container, liquid, false ); } } @@ -483,17 +512,17 @@ TEST_CASE( "liquid_reloading", "[reload]" ) TEST_CASE( "speedloader_reloading", "[reload],[gun]" ) { SECTION( "empty gun" ) { - item gun( "sw_610" ); + item gun( itype_sw_610 ); SECTION( "empty speedloader" ) { - item speedloader( "40_speedloader6" ); + item speedloader( itype_40_speedloader6 ); test_reloading( gun, speedloader, false ); } SECTION( "partially empty speedloader" ) { - item speedloader( "40_speedloader6" ); - speedloader.put_in( item( "40sw", calendar::turn, 3 ), pocket_type::MAGAZINE ); + item speedloader( itype_40_speedloader6 ); + speedloader.put_in( item( itype_40sw, calendar::turn, 3 ), pocket_type::MAGAZINE ); REQUIRE( !speedloader.empty() ); REQUIRE( !speedloader.is_magazine_full() ); @@ -502,8 +531,8 @@ TEST_CASE( "speedloader_reloading", "[reload],[gun]" ) } SECTION( "full speedloader" ) { - item speedloader( "40_speedloader6" ); - speedloader.put_in( item( "40sw", calendar::turn, 6 ), pocket_type::MAGAZINE ); + item speedloader( itype_40_speedloader6 ); + speedloader.put_in( item( itype_40sw, calendar::turn, 6 ), pocket_type::MAGAZINE ); REQUIRE( speedloader.is_magazine_full() ); @@ -511,8 +540,8 @@ TEST_CASE( "speedloader_reloading", "[reload],[gun]" ) } SECTION( "speedloader with wrong ammo" ) { - item speedloader( "40_speedloader6" ); - speedloader.force_insert_item( item( "9mm", calendar::turn, 6 ), + item speedloader( itype_40_speedloader6 ); + speedloader.force_insert_item( item( itype_9mm, calendar::turn, 6 ), pocket_type::MAGAZINE ); REQUIRE( speedloader.is_magazine_full() ); @@ -522,19 +551,19 @@ TEST_CASE( "speedloader_reloading", "[reload],[gun]" ) } SECTION( "full gun" ) { - item gun( "sw_610" ); - gun.put_in( item( "40sw", calendar::turn, 6 ), pocket_type::MAGAZINE ); + item gun( itype_sw_610 ); + gun.put_in( item( itype_40sw, calendar::turn, 6 ), pocket_type::MAGAZINE ); REQUIRE( gun.is_magazine_full() ); SECTION( "empty speedloader" ) { - item speedloader( "40_speedloader6" ); + item speedloader( itype_40_speedloader6 ); test_reloading( gun, speedloader, false ); } SECTION( "partially empty speedloader" ) { - item speedloader( "40_speedloader6" ); - speedloader.put_in( item( "40sw", calendar::turn, 3 ), pocket_type::MAGAZINE ); + item speedloader( itype_40_speedloader6 ); + speedloader.put_in( item( itype_40sw, calendar::turn, 3 ), pocket_type::MAGAZINE ); REQUIRE( !speedloader.empty() ); REQUIRE( !speedloader.is_magazine_full() ); @@ -543,8 +572,8 @@ TEST_CASE( "speedloader_reloading", "[reload],[gun]" ) } SECTION( "full speedloader" ) { - item speedloader( "40_speedloader6" ); - speedloader.put_in( item( "40sw", calendar::turn, 6 ), pocket_type::MAGAZINE ); + item speedloader( itype_40_speedloader6 ); + speedloader.put_in( item( itype_40sw, calendar::turn, 6 ), pocket_type::MAGAZINE ); REQUIRE( speedloader.is_magazine_full() ); @@ -552,8 +581,8 @@ TEST_CASE( "speedloader_reloading", "[reload],[gun]" ) } SECTION( "speedloader with wrong ammo" ) { - item speedloader( "40_speedloader6" ); - speedloader.force_insert_item( item( "9mm", calendar::turn, 6 ), + item speedloader( itype_40_speedloader6 ); + speedloader.force_insert_item( item( itype_9mm, calendar::turn, 6 ), pocket_type::MAGAZINE ); REQUIRE( speedloader.is_magazine_full() ); @@ -563,19 +592,19 @@ TEST_CASE( "speedloader_reloading", "[reload],[gun]" ) } SECTION( "gun full of casings" ) { - item gun( "sw_610" ); - gun.force_insert_item( item( "40_casing", calendar::turn, 6 ).set_flag( json_flag_CASING ), + item gun( itype_sw_610 ); + gun.force_insert_item( item( itype_40_casing, calendar::turn, 6 ).set_flag( json_flag_CASING ), pocket_type::MAGAZINE ); SECTION( "empty speedloader" ) { - item speedloader( "40_speedloader6" ); + item speedloader( itype_40_speedloader6 ); test_reloading( gun, speedloader, false ); } SECTION( "partially empty speedloader" ) { - item speedloader( "40_speedloader6" ); - speedloader.put_in( item( "40sw", calendar::turn, 3 ), pocket_type::MAGAZINE ); + item speedloader( itype_40_speedloader6 ); + speedloader.put_in( item( itype_40sw, calendar::turn, 3 ), pocket_type::MAGAZINE ); REQUIRE( !speedloader.empty() ); REQUIRE( !speedloader.is_magazine_full() ); @@ -584,8 +613,8 @@ TEST_CASE( "speedloader_reloading", "[reload],[gun]" ) } SECTION( "full speedloader" ) { - item speedloader( "40_speedloader6" ); - speedloader.put_in( item( "40sw", calendar::turn, 6 ), pocket_type::MAGAZINE ); + item speedloader( itype_40_speedloader6 ); + speedloader.put_in( item( itype_40sw, calendar::turn, 6 ), pocket_type::MAGAZINE ); REQUIRE( speedloader.is_magazine_full() ); @@ -593,8 +622,8 @@ TEST_CASE( "speedloader_reloading", "[reload],[gun]" ) } SECTION( "speedloader with wrong ammo" ) { - item speedloader( "40_speedloader6" ); - speedloader.force_insert_item( item( "9mm", calendar::turn, 6 ), + item speedloader( itype_40_speedloader6 ); + speedloader.force_insert_item( item( itype_9mm, calendar::turn, 6 ), pocket_type::MAGAZINE ); REQUIRE( speedloader.is_magazine_full() ); @@ -607,163 +636,163 @@ TEST_CASE( "speedloader_reloading", "[reload],[gun]" ) TEST_CASE( "gunmod_reloading", "[reload],[gun]" ) { SECTION( "empty gun and gunmod" ) { - item gun( "debug_modular_m4_carbine" ); - item mod( "m203" ); + item gun( itype_debug_modular_m4_carbine ); + item mod( itype_m203 ); gun.force_insert_item( mod, pocket_type::MOD ); SECTION( "wrong ammo" ) { - item ammo( "9mm" ); + item ammo( itype_9mm ); test_reloading( gun, ammo, false ); } SECTION( "full magazine for the gun" ) { - item mag( "stanag30" ); - mag.put_in( item( "556", calendar::turn, 30 ), pocket_type::MAGAZINE ); + item mag( itype_stanag30 ); + mag.put_in( item( itype_556, calendar::turn, 30 ), pocket_type::MAGAZINE ); test_reloading( gun, mag ); } SECTION( "ammo for the mod" ) { - item ammo( "40x46mm_m433" ); + item ammo( itype_40x46mm_m433 ); test_reloading( gun, ammo ); } } SECTION( "partially empty gun and empty gunmod" ) { - item gun( "debug_modular_m4_carbine" ); - item mod( "m203" ); - item mag1( "stanag30" ); - mag1.put_in( item( "556", calendar::turn, 10 ), pocket_type::MAGAZINE ); + item gun( itype_debug_modular_m4_carbine ); + item mod( itype_m203 ); + item mag1( itype_stanag30 ); + mag1.put_in( item( itype_556, calendar::turn, 10 ), pocket_type::MAGAZINE ); gun.force_insert_item( mod, pocket_type::MOD ); gun.put_in( mag1, pocket_type::MAGAZINE_WELL ); SECTION( "wrong ammo" ) { - item ammo( "9mm" ); + item ammo( itype_9mm ); test_reloading( gun, ammo, false ); } SECTION( "full magazine for the gun" ) { - item mag( "stanag30" ); - mag.put_in( item( "556", calendar::turn, 30 ), pocket_type::MAGAZINE ); + item mag( itype_stanag30 ); + mag.put_in( item( itype_556, calendar::turn, 30 ), pocket_type::MAGAZINE ); test_reloading( gun, mag ); } SECTION( "ammo for the mod" ) { - item ammo( "40x46mm_m433" ); + item ammo( itype_40x46mm_m433 ); test_reloading( gun, ammo ); } SECTION( "ammo for the gun" ) { - item ammo( "556" ); + item ammo( itype_556 ); test_reloading( gun, ammo ); } } SECTION( "partially empty gun and full gunmod" ) { - item gun( "debug_modular_m4_carbine" ); - item mod( "m203" ); - item mag1( "stanag30" ); - mag1.put_in( item( "556", calendar::turn, 10 ), pocket_type::MAGAZINE ); - mod.put_in( item( "40x46mm_m433", calendar::turn, 1 ), pocket_type::MAGAZINE ); + item gun( itype_debug_modular_m4_carbine ); + item mod( itype_m203 ); + item mag1( itype_stanag30 ); + mag1.put_in( item( itype_556, calendar::turn, 10 ), pocket_type::MAGAZINE ); + mod.put_in( item( itype_40x46mm_m433, calendar::turn, 1 ), pocket_type::MAGAZINE ); gun.force_insert_item( mod, pocket_type::MOD ); gun.put_in( mag1, pocket_type::MAGAZINE_WELL ); SECTION( "wrong ammo" ) { - item ammo( "9mm" ); + item ammo( itype_9mm ); test_reloading( gun, ammo, false ); } SECTION( "full magazine for the gun" ) { - item mag( "stanag30" ); - mag.put_in( item( "556", calendar::turn, 30 ), pocket_type::MAGAZINE ); + item mag( itype_stanag30 ); + mag.put_in( item( itype_556, calendar::turn, 30 ), pocket_type::MAGAZINE ); test_reloading( gun, mag ); } SECTION( "ammo for the mod" ) { - item ammo( "40x46mm_m433" ); + item ammo( itype_40x46mm_m433 ); test_reloading( gun, ammo, false ); } SECTION( "ammo for the gun" ) { - item ammo( "556" ); + item ammo( itype_556 ); test_reloading( gun, ammo ); } } SECTION( "partially empty gun and gunmod with casing" ) { - item gun( "debug_modular_m4_carbine" ); - item mod( "m203" ); - item mag1( "stanag30" ); - mag1.put_in( item( "556", calendar::turn, 10 ), pocket_type::MAGAZINE ); - mod.force_insert_item( item( "40x46mm_m118_casing" ).set_flag( json_flag_CASING ), + item gun( itype_debug_modular_m4_carbine ); + item mod( itype_m203 ); + item mag1( itype_stanag30 ); + mag1.put_in( item( itype_556, calendar::turn, 10 ), pocket_type::MAGAZINE ); + mod.force_insert_item( item( itype_40x46mm_m118_casing ).set_flag( json_flag_CASING ), pocket_type::MAGAZINE ); gun.force_insert_item( mod, pocket_type::MOD ); gun.put_in( mag1, pocket_type::MAGAZINE_WELL ); SECTION( "wrong ammo" ) { - item ammo( "9mm" ); + item ammo( itype_9mm ); test_reloading( gun, ammo, false ); } SECTION( "full magazine for the gun" ) { - item mag( "stanag30" ); - mag.put_in( item( "556", calendar::turn, 30 ), pocket_type::MAGAZINE ); + item mag( itype_stanag30 ); + mag.put_in( item( itype_556, calendar::turn, 30 ), pocket_type::MAGAZINE ); test_reloading( gun, mag ); } SECTION( "ammo for the mod" ) { - item ammo( "40x46mm_m433" ); + item ammo( itype_40x46mm_m433 ); test_reloading( gun, ammo ); } SECTION( "ammo for the gun" ) { - item ammo( "556" ); + item ammo( itype_556 ); test_reloading( gun, ammo ); } } SECTION( "full gun and empty gunmod" ) { - item gun( "debug_modular_m4_carbine" ); - item mod( "m203" ); - item mag1( "stanag30" ); - mag1.put_in( item( "556", calendar::turn, 30 ), pocket_type::MAGAZINE ); + item gun( itype_debug_modular_m4_carbine ); + item mod( itype_m203 ); + item mag1( itype_stanag30 ); + mag1.put_in( item( itype_556, calendar::turn, 30 ), pocket_type::MAGAZINE ); gun.force_insert_item( mod, pocket_type::MOD ); gun.put_in( mag1, pocket_type::MAGAZINE_WELL ); SECTION( "wrong ammo" ) { - item ammo( "9mm" ); + item ammo( itype_9mm ); test_reloading( gun, ammo, false ); } SECTION( "full magazine for the gun" ) { - item mag( "stanag30" ); - mag.put_in( item( "556", calendar::turn, 30 ), pocket_type::MAGAZINE ); + item mag( itype_stanag30 ); + mag.put_in( item( itype_556, calendar::turn, 30 ), pocket_type::MAGAZINE ); test_reloading( gun, mag, false ); } SECTION( "ammo for the mod" ) { - item ammo( "40x46mm_m433" ); + item ammo( itype_40x46mm_m433 ); test_reloading( gun, ammo ); } SECTION( "ammo for the gun" ) { - item ammo( "556" ); + item ammo( itype_556 ); test_reloading( gun, ammo, false ); } @@ -776,10 +805,10 @@ TEST_CASE( "reload_gun_with_integral_magazine", "[reload],[gun]" ) clear_avatar(); // Make sure the player doesn't drop anything :P - dummy.wear_item( item( "backpack", calendar::turn_zero ) ); + dummy.wear_item( item( itype_backpack, calendar::turn_zero ) ); - item_location ammo = dummy.i_add( item( "40sw", calendar::turn_zero, item::default_charges_tag{} ) ); - item_location gun = dummy.i_add( item( "sw_610", calendar::turn_zero, item::default_charges_tag{} ) ); + item_location ammo = dummy.i_add( item( itype_40sw, calendar::turn_zero, item::default_charges_tag{} ) ); + item_location gun = dummy.i_add( item( itype_sw_610, calendar::turn_zero, item::default_charges_tag{} ) ); REQUIRE( dummy.has_item( *ammo ) ); REQUIRE( gun->ammo_remaining() == 0 ); @@ -797,12 +826,12 @@ TEST_CASE( "reload_gun_with_integral_magazine_using_speedloader", "[reload],[gun clear_avatar(); // Make sure the player doesn't drop anything :P - dummy.wear_item( item( "backpack", calendar::turn_zero ) ); + dummy.wear_item( item( itype_backpack, calendar::turn_zero ) ); - item_location speedloader = dummy.i_add( item( "38_speedloader", calendar::turn_zero, false ) ); - item_location ammo = dummy.i_add( item( "38_special", calendar::turn_zero, + item_location speedloader = dummy.i_add( item( itype_38_speedloader, calendar::turn_zero, false ) ); + item_location ammo = dummy.i_add( item( itype_38_special, calendar::turn_zero, speedloader->remaining_ammo_capacity() ) ); - item_location gun = dummy.i_add( item( "sw_619", calendar::turn_zero, false ) ); + item_location gun = dummy.i_add( item( itype_sw_619, calendar::turn_zero, false ) ); REQUIRE( dummy.has_item( *ammo ) ); REQUIRE( gun->ammo_remaining() == 0 ); @@ -840,18 +869,18 @@ TEST_CASE( "reload_gun_with_swappable_magazine", "[reload],[gun]" ) clear_avatar(); // Make sure the player doesn't drop anything :P - dummy.wear_item( item( "backpack", calendar::turn_zero ) ); + dummy.wear_item( item( itype_backpack, calendar::turn_zero ) ); - item_location ammo = dummy.i_add( item( "9mm", calendar::turn_zero, item::default_charges_tag{} ) ); + item_location ammo = dummy.i_add( item( itype_9mm, calendar::turn_zero, item::default_charges_tag{} ) ); const cata::value_ptr &ammo_type = ammo->type->ammo; REQUIRE( ammo_type ); - const item mag( "glockmag", calendar::turn_zero, 0 ); + const item mag( itype_glockmag, calendar::turn_zero, 0 ); const cata::value_ptr &magazine_type = mag.type->magazine; REQUIRE( magazine_type ); REQUIRE( magazine_type->type.count( ammo_type->type ) != 0 ); - item gun( "glock_19" ); + item gun( itype_glock_19 ); gun.put_in( mag, pocket_type::MAGAZINE_WELL ); REQUIRE( gun.magazine_current() != nullptr ); REQUIRE( gun.magazine_current()->ammo_types().count( ammo_type->type ) != 0 ); @@ -916,7 +945,7 @@ TEST_CASE( "automatic_reloading_action", "[reload],[gun]" ) clear_avatar(); // Make sure the player doesn't drop anything :P - dummy.wear_item( item( "backpack", calendar::turn_zero ) ); + dummy.wear_item( item( itype_backpack, calendar::turn_zero ) ); GIVEN( "an unarmed player" ) { REQUIRE( !dummy.is_armed() ); @@ -929,10 +958,10 @@ TEST_CASE( "automatic_reloading_action", "[reload],[gun]" ) } GIVEN( "a player armed with a revolver and ammo for it" ) { - item_location ammo = dummy.i_add( item( "40sw", calendar::turn_zero, 100 ) ); + item_location ammo = dummy.i_add( item( itype_40sw, calendar::turn_zero, 100 ) ); REQUIRE( ammo->is_ammo() ); - dummy.set_wielded_item( item( "sw_610", calendar::turn_zero, 0 ) ); + dummy.set_wielded_item( item( itype_sw_610, calendar::turn_zero, 0 ) ); REQUIRE( dummy.get_wielded_item()->ammo_remaining() == 0 ); REQUIRE( dummy.get_wielded_item().can_reload_with( ammo, false ) ); @@ -946,7 +975,7 @@ TEST_CASE( "automatic_reloading_action", "[reload],[gun]" ) } } GIVEN( "the player has another gun with ammo" ) { - item_location gun2 = dummy.i_add( item( "sw_610", calendar::turn_zero, 0 ) ); + item_location gun2 = dummy.i_add( item( itype_sw_610, calendar::turn_zero, 0 ) ); REQUIRE( gun2->ammo_remaining() == 0 ); REQUIRE( gun2.can_reload_with( ammo, false ) ); WHEN( "the player triggers auto reload until the first revolver is full" ) { @@ -966,18 +995,18 @@ TEST_CASE( "automatic_reloading_action", "[reload],[gun]" ) GIVEN( "a player wielding an unloaded gun, carrying an unloaded magazine, and carrying ammo for the magazine" ) { dummy.clear_worn(); - dummy.worn.wear_item( dummy, item( "backpack" ), false, false ); - item_location ammo = dummy.i_add( item( "9mm", calendar::turn_zero, 50 ) ); + dummy.worn.wear_item( dummy, item( itype_backpack ), false, false ); + item_location ammo = dummy.i_add( item( itype_9mm, calendar::turn_zero, 50 ) ); const cata::value_ptr &ammo_type = ammo->type->ammo; REQUIRE( ammo_type ); - item_location mag = dummy.i_add( item( "glockmag", calendar::turn_zero, 0 ) ); + item_location mag = dummy.i_add( item( itype_glockmag, calendar::turn_zero, 0 ) ); const cata::value_ptr &magazine_type = mag->type->magazine; REQUIRE( magazine_type ); REQUIRE( magazine_type->type.count( ammo_type->type ) != 0 ); REQUIRE( mag->ammo_remaining() == 0 ); - dummy.set_wielded_item( item( "glock_19", calendar::turn_zero, 0 ) ); + dummy.set_wielded_item( item( itype_glock_19, calendar::turn_zero, 0 ) ); REQUIRE( dummy.get_wielded_item()->ammo_remaining() == 0 ); WHEN( "the player triggers auto reload" ) { @@ -1010,7 +1039,7 @@ TEST_CASE( "automatic_reloading_action", "[reload],[gun]" ) } } GIVEN( "the player also has an extended magazine" ) { - item_location mag2 = dummy.i_add( item( "glockbigmag", calendar::turn_zero, 0 ) ); + item_location mag2 = dummy.i_add( item( itype_glockbigmag, calendar::turn_zero, 0 ) ); const cata::value_ptr &magazine_type2 = mag2->type->magazine; REQUIRE( magazine_type2 ); REQUIRE( magazine_type2->type.count( ammo_type->type ) != 0 ); @@ -1069,13 +1098,13 @@ TEST_CASE( "reload_liquid_container", "[reload],[liquid]" ) Character &dummy = get_avatar(); clear_avatar(); clear_map(); - item backpack( item( "bigback" ) ); + item backpack( itype_bigback ); dummy.wear_item( backpack ); - item canteen( item( "2lcanteen" ) ); + item canteen( itype_2lcanteen ); REQUIRE( dummy.wield( canteen ) ) ; - item_location ammo_jug = dummy.i_add( item( "jug_plastic" ) ); - ammo_jug->put_in( item( "water_clean", calendar::turn_zero, 2 ), + item_location ammo_jug = dummy.i_add( item( itype_jug_plastic ) ); + ammo_jug->put_in( item( itype_water_clean, calendar::turn_zero, 2 ), pocket_type::CONTAINER ); units::volume ammo_volume = ammo_jug->total_contained_volume(); @@ -1088,7 +1117,7 @@ TEST_CASE( "reload_liquid_container", "[reload],[liquid]" ) } SECTION( "reload liquid into partially filled container with same type liquid" ) { - item water_one( "water_clean", calendar::turn_zero, 1 ); + item water_one( itype_water_clean, calendar::turn_zero, 1 ); units::volume initial_volume = water_one.volume(); dummy.get_wielded_item()->put_in( water_one, pocket_type::CONTAINER ); g->reload_wielded(); @@ -1099,7 +1128,7 @@ TEST_CASE( "reload_liquid_container", "[reload],[liquid]" ) } SECTION( "reload liquid into partially filled container with different type liquid" ) { - item milk_one( "milk", calendar::turn_zero, 1 ); + item milk_one( itype_milk, calendar::turn_zero, 1 ); units::volume initial_volume = milk_one.volume(); dummy.get_wielded_item()->put_in( milk_one, pocket_type::CONTAINER ); g->reload_wielded(); @@ -1111,7 +1140,7 @@ TEST_CASE( "reload_liquid_container", "[reload],[liquid]" ) } SECTION( "reload liquid into container containing a non-liquid" ) { - item pebble( "pebble", calendar::turn_zero, 1 ); + item pebble( itype_pebble, calendar::turn_zero, 1 ); units::volume initial_volume = pebble.volume(); dummy.get_wielded_item()->put_in( pebble, pocket_type::CONTAINER ); g->reload_wielded(); @@ -1123,7 +1152,7 @@ TEST_CASE( "reload_liquid_container", "[reload],[liquid]" ) } SECTION( "reload liquid container with more liquid than it can hold" ) { - ammo_jug->fill_with( item( "water_clean", calendar::turn_zero, 1 ) ); + ammo_jug->fill_with( item( itype_water_clean, calendar::turn_zero, 1 ) ); ammo_volume = ammo_jug->total_contained_volume(); g->reload_wielded(); REQUIRE( dummy.activity ); @@ -1143,8 +1172,8 @@ TEST_CASE( "reload_liquid_container", "[reload],[liquid]" ) SECTION( "liquid in container on floor" ) { ammo_jug.remove_item(); ammo_jug = item_location( map_cursor( near_point ), &here.add_item( near_point, - item( "bottle_plastic" ) ) ); - ammo_jug->fill_with( item( "water_clean" ) ); + item( itype_bottle_plastic ) ) ); + ammo_jug->fill_with( item( itype_water_clean ) ); ammo_volume = ammo_jug->total_contained_volume(); g->reload_wielded(); REQUIRE( dummy.activity ); diff --git a/tests/rot_test.cpp b/tests/rot_test.cpp index db82a3f304457..39acfda432ba4 100644 --- a/tests/rot_test.cpp +++ b/tests/rot_test.cpp @@ -9,6 +9,9 @@ static const flag_id json_flag_FROZEN( "FROZEN" ); +static const itype_id itype_meat_cooked( "meat_cooked" ); +static const itype_id itype_offal_canned( "offal_canned" ); + static void set_map_temperature( units::temperature new_temperature ) { get_weather().temperature = new_temperature; @@ -30,11 +33,11 @@ TEST_CASE( "Rate_of_rotting", "[rot]" ) calendar::turn = calendar::start_of_cataclysm + 1_minutes; } - item normal_item( "meat_cooked" ); + item normal_item( itype_meat_cooked ); - item freeze_item( "offal_canned" ); + item freeze_item( itype_offal_canned ); - item sealed_item( "offal_canned" ); + item sealed_item( itype_offal_canned ); sealed_item = sealed_item.in_its_container(); set_map_temperature( units::from_fahrenheit( 65 ) ); // 18,3 C @@ -84,7 +87,7 @@ TEST_CASE( "Items_rot_away", "[rot]" ) calendar::turn = calendar::start_of_cataclysm + 1_minutes; } - item test_item( "meat_cooked" ); + item test_item( itype_meat_cooked ); // Process item once to set all of its values. test_item.process( get_map(), nullptr, tripoint_bub_ms::zero, 1, temperature_flag::HEATER ); @@ -101,7 +104,7 @@ TEST_CASE( "Items_rot_away", "[rot]" ) TEST_CASE( "Hourly_rotpoints", "[rot]" ) { - item normal_item( "meat_cooked" ); + item normal_item( itype_meat_cooked ); // No rot below 32F/0C CHECK( normal_item.calc_hourly_rotpoints_at_temp( units::from_celsius( 0 ) ) == 0 ); diff --git a/tests/stomach_contents_test.cpp b/tests/stomach_contents_test.cpp index 71522fda4cf4d..c5c56ec0d1868 100644 --- a/tests/stomach_contents_test.cpp +++ b/tests/stomach_contents_test.cpp @@ -15,6 +15,13 @@ static const efftype_id effect_tapeworm( "tapeworm" ); +static const itype_id itype_beansnrice( "beansnrice" ); +static const itype_id itype_debug_nutrition( "debug_nutrition" ); +static const itype_id itype_debug_orange( "debug_orange" ); +static const itype_id itype_debug_vitamins( "debug_vitamins" ); +static const itype_id itype_meat_cooked( "meat_cooked" ); +static const itype_id itype_veggy( "veggy" ); + static const trait_id trait_HUNGER3( "HUNGER3" ); static const vitamin_id vitamin_calcium( "calcium" ); @@ -102,7 +109,7 @@ static void eat_all_nutrients( Character &you ) { // Vitamin target: 100% DV -- or 96 vitamin "units" since all vitamins currently decay every 15m. // Energy target: 2100 kcal -- debug target will be completely sedentary. - item f( "debug_nutrition" ); + item f( itype_debug_nutrition ); you.consume( f ); } @@ -197,7 +204,7 @@ TEST_CASE( "vitamin_equilibrium", "[vitamins]" ) REQUIRE( subject.vitamin_get( vitamin_vitC ) == -100 ); REQUIRE( subject.vitamin_get( vitamin_calcium ) == -100 ); REQUIRE( subject.vitamin_get( vitamin_iron ) == -100 ); - item f( "debug_orange" ); + item f( itype_debug_orange ); // check that 100% of daily vit C is by default 96 units CHECK( subject.compute_effective_nutrients( f ).get_vitamin( vitamin_vitC ) == 96 ); @@ -227,7 +234,7 @@ TEST_CASE( "vitamin_multivitamin", "[vitamins]" ) REQUIRE( subject.vitamin_get( vitamin_vitC ) == -100 ); REQUIRE( subject.vitamin_get( vitamin_calcium ) == -100 ); REQUIRE( subject.vitamin_get( vitamin_iron ) == -100 ); - item f( "debug_vitamins" ); + item f( itype_debug_vitamins ); subject.consume( f ); @@ -263,7 +270,7 @@ TEST_CASE( "vitamin_daily", "[vitamins]" ) REQUIRE( subject.get_daily_vitamin( vitamin_iron ) == 0 ); REQUIRE( subject.get_health_tally() == 0 ); - item f( "debug_vitamins" ); + item f( itype_debug_vitamins ); subject.consume( f ); @@ -414,9 +421,9 @@ TEST_CASE( "hunger" ) } CHECK( hunger_time <= 270 ); CHECK( hunger_time >= 240 ); - item f( "meat_cooked" ); + item f( itype_meat_cooked ); dummy.consume( f ); - f = item( "meat_cooked" ); + f = item( itype_meat_cooked ); dummy.consume( f ); dummy.set_thirst( 0 ); dummy.update_body(); @@ -429,9 +436,9 @@ TEST_CASE( "hunger" ) } CHECK( hunger_time <= 240 ); CHECK( hunger_time >= 210 ); - f = item( "beansnrice" ); + f = item( itype_beansnrice ); dummy.consume( f ); - f = item( "beansnrice" ); + f = item( itype_beansnrice ); dummy.consume( f ); dummy.update_body(); print_stomach_contents( dummy, print_tests ); @@ -446,7 +453,7 @@ TEST_CASE( "hunger" ) printf( "eat 16 veggy\n" ); } for( int i = 0; i < 16; i++ ) { - f = item( "veggy" ); + f = item( itype_veggy ); dummy.consume( f ); } dummy.update_body(); @@ -465,7 +472,7 @@ TEST_CASE( "hunger" ) dummy.mutate_towards( trait_HUNGER3 ); } for( int i = 0; i < 16; i++ ) { - f = item( "veggy" ); + f = item( itype_veggy ); dummy.consume( f ); } dummy.update_body(); diff --git a/tests/temp_crafting_inv_test.cpp b/tests/temp_crafting_inv_test.cpp index 88b7a69ba862d..d25f7be89da30 100644 --- a/tests/temp_crafting_inv_test.cpp +++ b/tests/temp_crafting_inv_test.cpp @@ -4,7 +4,9 @@ #include "item.h" #include "type_id.h" +static const itype_id itype_test_fire_ax( "test_fire_ax" ); static const itype_id itype_test_gum( "test_gum" ); +static const itype_id itype_test_halligan( "itype_test_halligan" ); static const quality_id qual_AXE( "AXE" ); static const quality_id qual_DIG( "DIG" ); @@ -16,7 +18,7 @@ TEST_CASE( "temp_crafting_inv_test_amount", "[crafting][inventory]" ) temp_crafting_inventory inv; CHECK( inv.size() == 0 ); - item gum( "test_gum", calendar::turn_zero, item::default_charges_tag{} ); + item gum( itype_test_gum, calendar::turn_zero, item::default_charges_tag{} ); inv.add_item_ref( gum ); CHECK( inv.size() == 1 ); @@ -33,7 +35,7 @@ TEST_CASE( "temp_crafting_inv_test_amount", "[crafting][inventory]" ) TEST_CASE( "temp_crafting_inv_test_quality", "[crafting][inventory]" ) { temp_crafting_inventory inv; - inv.add_item_copy( item( "test_halligan" ) ); + inv.add_item_copy( item( itype_test_halligan ) ); CHECK( inv.has_quality( qual_HAMMER, 1 ) ); CHECK( inv.has_quality( qual_HAMMER, 2 ) ); @@ -41,7 +43,7 @@ TEST_CASE( "temp_crafting_inv_test_quality", "[crafting][inventory]" ) CHECK( inv.has_quality( qual_DIG, 1 ) ); CHECK_FALSE( inv.has_quality( qual_AXE ) ); - inv.add_item_copy( item( "test_fire_ax" ) ); + inv.add_item_copy( item( itype_test_fire_ax ) ); CHECK( inv.has_quality( qual_AXE ) ); CHECK( inv.max_quality( qual_PRY ) == 4 ); diff --git a/tests/temperature_test.cpp b/tests/temperature_test.cpp index 4e98e474bdf46..f6a69504c0f0a 100644 --- a/tests/temperature_test.cpp +++ b/tests/temperature_test.cpp @@ -9,6 +9,9 @@ #include "point.h" #include "weather.h" +static const itype_id itype_meat_cooked( "meat_cooked" ); +static const itype_id itype_water( "water" ); + static void set_map_temperature( units::temperature new_temperature ) { get_weather().temperature = new_temperature; @@ -17,7 +20,7 @@ static void set_map_temperature( units::temperature new_temperature ) TEST_CASE( "Item_spawns_with_right_thermal_attributes", "[temperature]" ) { - item D( "meat_cooked" ); + item D( itype_meat_cooked ); CHECK( D.get_specific_heat_liquid() == 3.7f ); CHECK( D.get_specific_heat_solid() == 2.15f ); @@ -59,8 +62,8 @@ TEST_CASE( "Rate_of_temperature_change", "[temperature]" ) // https://www.researchgate.net/publication/282841499_Study_on_heat_transfer_coefficients_during_cooling_of_PET_bottles_for_food_beverages // Checked with incremental updates and whole time at once - item water1( "water" ); - item water2( "water" ); + item water1( itype_water ); + item water2( itype_water ); set_map_temperature( units::from_fahrenheit( 131 ) ); // 55 C @@ -99,8 +102,8 @@ TEST_CASE( "Rate_of_temperature_change", "[temperature]" ) // 4) Wait two hours then Meat 1 and 2 at 0 C frozen // 5) Wait a bit over hour then Meat 1 and 2 at about -5.2 C - item meat1( "meat_cooked" ); - item meat2( "meat_cooked" ); + item meat1( itype_meat_cooked ); + item meat2( itype_meat_cooked ); set_map_temperature( units::from_fahrenheit( 122 ) ); //50 C @@ -187,8 +190,8 @@ TEST_CASE( "Rate_of_temperature_change", "[temperature]" ) // Process 100 min in different steps // Both meats at about 2.2 C - item meat1( "meat_cooked" ); - item meat2( "meat_cooked" ); + item meat1( itype_meat_cooked ); + item meat2( itype_meat_cooked ); set_map_temperature( units::from_fahrenheit( -4 ) ); // -20 C @@ -264,7 +267,7 @@ TEST_CASE( "Temperature_controlled_location", "[temperature]" ) // Process immediately in heater. Sets temperature to temperatures::normal. // Process water 15 min later. Should still be temperatures::normal. // Process water 2h 3m later. Should still be temperatures::normal. - item water1( "water" ); + item water1( itype_water ); set_map_temperature( units::from_fahrenheit( 0 ) ); // -17 C diff --git a/tests/throw_activation_test.cpp b/tests/throw_activation_test.cpp index d1d46294d1d0a..bf3db25466925 100644 --- a/tests/throw_activation_test.cpp +++ b/tests/throw_activation_test.cpp @@ -5,9 +5,11 @@ static const field_type_str_id field_fd_acid( "fd_acid" ); +static const itype_id itype_acidbomb_test( "acidbomb_test" ); + TEST_CASE( "throw_activation", "[item]" ) { - item acid_bomb( "acidbomb_test" ); + item acid_bomb( itype_acidbomb_test ); SECTION( "acid_bomb_hits_ground" ) { acid_bomb.activate_thrown( tripoint_bub_ms::zero ); diff --git a/tests/throwing_test.cpp b/tests/throwing_test.cpp index b700093b541e1..f3e635e417228 100644 --- a/tests/throwing_test.cpp +++ b/tests/throwing_test.cpp @@ -21,12 +21,17 @@ #include "test_statistics.h" #include "type_id.h" +static const itype_id itype_grenade( "grenade" ); +static const itype_id itype_javelin_iron( "javelin_iron" ); +static const itype_id itype_rock( "rock" ); +static const itype_id itype_throwing_stick( "throwing_stick" ); + static const skill_id skill_throw( "throw" ); TEST_CASE( "throwing_distance_test", "[throwing], [balance]" ) { const standard_npc thrower( "Thrower", { 60, 60, 0 }, {}, 4, 10, 10, 10, 10 ); - item grenade( "grenade" ); + item grenade( itype_grenade ); CHECK( thrower.throw_range( grenade ) >= 30 ); CHECK( thrower.throw_range( grenade ) <= 35 ); } @@ -78,7 +83,7 @@ static constexpr int max_throw_test_iterations = 10000; // tighter thresholds here will increase accuracy but also increase average test // time since more samples are required to get a more accurate test static void test_throwing_player_versus( - Character &you, const std::string &mon_id, const std::string &throw_id, + Character &you, const std::string &mon_id, const itype_id &throw_id, const int range, const throw_test_pstats &pstats, const epsilon_threshold &hit_thresh, const epsilon_threshold &dmg_thresh, const int min_throws = min_throw_test_iterations, @@ -126,7 +131,7 @@ static void test_throwing_player_versus( // hit_thresh_met first } while( !dmg_thresh_met && data.hits.n() < max_throws ); - INFO( "Monster: '" << mon_id << "' Item: '" << throw_id ); + INFO( "Monster: '" << mon_id << "' Item: '" << throw_id.c_str() ); INFO( "Range: " << range << " Pstats: " << pstats ); INFO( "Total throws: " << data.hits.n() ); INFO( "Ratio: " << data.hits.avg() * 100 << "%" ); @@ -149,7 +154,7 @@ static void test_throwing_player_versus( // WARNING: these will take a long time likely /* static void test_throwing_player_versus( - player &p, const std::string &mon_id, const std::string &throw_id, const int range, + player &p, const std::string &mon_id, const itype_id &throw_id, const int range, const throw_test_pstats &pstats ) { test_throwing_player_versus( p, mon_id, throw_id, range, pstats, { 0, 0 }, { 0, 0 }, 5000, 5000 ); @@ -167,42 +172,42 @@ TEST_CASE( "basic_throwing_sanity_tests", "[throwing],[balance]" ) clear_map(); SECTION( "test_player_vs_zombie_rock_basestats" ) { - test_throwing_player_versus( p, "mon_zombie", "rock", 1, lo_skill_base_stats, { 0.78, 0.10 }, { 5, 3 } ); - test_throwing_player_versus( p, "mon_zombie", "rock", 5, lo_skill_base_stats, { 0.07, 0.10 }, { 0.7, 2 } ); - test_throwing_player_versus( p, "mon_zombie", "rock", 10, lo_skill_base_stats, { 0.04, 0.10 }, { 0.5, 2 } ); - test_throwing_player_versus( p, "mon_zombie", "rock", 15, lo_skill_base_stats, { 0.03, 0.10 }, { 0.5, 2 } ); - test_throwing_player_versus( p, "mon_zombie", "rock", 20, lo_skill_base_stats, { 0.03, 0.10 }, { 0.5, 2 } ); - test_throwing_player_versus( p, "mon_zombie", "rock", 25, lo_skill_base_stats, { 0.03, 0.10 }, { 0.5, 2 } ); - test_throwing_player_versus( p, "mon_zombie", "rock", 30, lo_skill_base_stats, { 0.03, 0.10 }, { 0.5, 2 } ); + test_throwing_player_versus( p, "mon_zombie", itype_rock, 1, lo_skill_base_stats, { 0.78, 0.10 }, { 5, 3 } ); + test_throwing_player_versus( p, "mon_zombie", itype_rock, 5, lo_skill_base_stats, { 0.07, 0.10 }, { 0.7, 2 } ); + test_throwing_player_versus( p, "mon_zombie", itype_rock, 10, lo_skill_base_stats, { 0.04, 0.10 }, { 0.5, 2 } ); + test_throwing_player_versus( p, "mon_zombie", itype_rock, 15, lo_skill_base_stats, { 0.03, 0.10 }, { 0.5, 2 } ); + test_throwing_player_versus( p, "mon_zombie", itype_rock, 20, lo_skill_base_stats, { 0.03, 0.10 }, { 0.5, 2 } ); + test_throwing_player_versus( p, "mon_zombie", itype_rock, 25, lo_skill_base_stats, { 0.03, 0.10 }, { 0.5, 2 } ); + test_throwing_player_versus( p, "mon_zombie", itype_rock, 30, lo_skill_base_stats, { 0.03, 0.10 }, { 0.5, 2 } ); } SECTION( "test_player_vs_zombie_javelin_iron_basestats" ) { - test_throwing_player_versus( p, "mon_zombie", "javelin_iron", 1, lo_skill_base_stats, { 0.64, 0.10 }, { 11, 5 } ); - test_throwing_player_versus( p, "mon_zombie", "javelin_iron", 5, lo_skill_base_stats, { 0.05, 0.10 }, { 1.5, 3 } ); - test_throwing_player_versus( p, "mon_zombie", "javelin_iron", 10, lo_skill_base_stats, { 0.04, 0.10 }, { 1.50, 2 } ); - test_throwing_player_versus( p, "mon_zombie", "javelin_iron", 15, lo_skill_base_stats, { 0.03, 0.10 }, { 1.29, 3 } ); - test_throwing_player_versus( p, "mon_zombie", "javelin_iron", 20, lo_skill_base_stats, { 0.03, 0.10 }, { 1.66, 2 } ); - test_throwing_player_versus( p, "mon_zombie", "javelin_iron", 25, lo_skill_base_stats, { 0.03, 0.10 }, { 1.0, 2 } ); + test_throwing_player_versus( p, "mon_zombie", itype_javelin_iron, 1, lo_skill_base_stats, { 0.64, 0.10 }, { 11, 5 } ); + test_throwing_player_versus( p, "mon_zombie", itype_javelin_iron, 5, lo_skill_base_stats, { 0.05, 0.10 }, { 1.5, 3 } ); + test_throwing_player_versus( p, "mon_zombie", itype_javelin_iron, 10, lo_skill_base_stats, { 0.04, 0.10 }, { 1.50, 2 } ); + test_throwing_player_versus( p, "mon_zombie", itype_javelin_iron, 15, lo_skill_base_stats, { 0.03, 0.10 }, { 1.29, 3 } ); + test_throwing_player_versus( p, "mon_zombie", itype_javelin_iron, 20, lo_skill_base_stats, { 0.03, 0.10 }, { 1.66, 2 } ); + test_throwing_player_versus( p, "mon_zombie", itype_javelin_iron, 25, lo_skill_base_stats, { 0.03, 0.10 }, { 1.0, 2 } ); } SECTION( "test_player_vs_zombie_rock_athlete" ) { - test_throwing_player_versus( p, "mon_zombie", "rock", 1, hi_skill_athlete_stats, { 1.00, 0.10 }, { 16.5, 8 } ); - test_throwing_player_versus( p, "mon_zombie", "rock", 5, hi_skill_athlete_stats, { 1.00, 0.10 }, { 16.5, 6 } ); - test_throwing_player_versus( p, "mon_zombie", "rock", 10, hi_skill_athlete_stats, { 1.00, 0.10 }, { 16.27, 6 } ); - test_throwing_player_versus( p, "mon_zombie", "rock", 15, hi_skill_athlete_stats, { 0.97, 0.10 }, { 12.83, 4 } ); - test_throwing_player_versus( p, "mon_zombie", "rock", 20, hi_skill_athlete_stats, { 0.82, 0.10 }, { 9.10, 4 } ); - test_throwing_player_versus( p, "mon_zombie", "rock", 25, hi_skill_athlete_stats, { 0.64, 0.10 }, { 6.54, 4 } ); - test_throwing_player_versus( p, "mon_zombie", "rock", 30, hi_skill_athlete_stats, { 0.47, 0.10 }, { 4.90, 3 } ); + test_throwing_player_versus( p, "mon_zombie", itype_rock, 1, hi_skill_athlete_stats, { 1.00, 0.10 }, { 16.5, 8 } ); + test_throwing_player_versus( p, "mon_zombie", itype_rock, 5, hi_skill_athlete_stats, { 1.00, 0.10 }, { 16.5, 6 } ); + test_throwing_player_versus( p, "mon_zombie", itype_rock, 10, hi_skill_athlete_stats, { 1.00, 0.10 }, { 16.27, 6 } ); + test_throwing_player_versus( p, "mon_zombie", itype_rock, 15, hi_skill_athlete_stats, { 0.97, 0.10 }, { 12.83, 4 } ); + test_throwing_player_versus( p, "mon_zombie", itype_rock, 20, hi_skill_athlete_stats, { 0.82, 0.10 }, { 9.10, 4 } ); + test_throwing_player_versus( p, "mon_zombie", itype_rock, 25, hi_skill_athlete_stats, { 0.64, 0.10 }, { 6.54, 4 } ); + test_throwing_player_versus( p, "mon_zombie", itype_rock, 30, hi_skill_athlete_stats, { 0.47, 0.10 }, { 4.90, 3 } ); } SECTION( "test_player_vs_zombie_javelin_iron_athlete" ) { - test_throwing_player_versus( p, "mon_zombie", "javelin_iron", 1, hi_skill_athlete_stats, { 1.00, 0.10 }, { 34.00, 8 } ); - test_throwing_player_versus( p, "mon_zombie", "javelin_iron", 5, hi_skill_athlete_stats, { 1.00, 0.10 }, { 34.00, 8 } ); - test_throwing_player_versus( p, "mon_zombie", "javelin_iron", 10, hi_skill_athlete_stats, { 1.00, 0.10 }, { 34.16, 8 } ); - test_throwing_player_versus( p, "mon_zombie", "javelin_iron", 15, hi_skill_athlete_stats, { 0.97, 0.10 }, { 25.21, 6 } ); - test_throwing_player_versus( p, "mon_zombie", "javelin_iron", 20, hi_skill_athlete_stats, { 0.82, 0.10 }, { 18.90, 5 } ); - test_throwing_player_versus( p, "mon_zombie", "javelin_iron", 25, hi_skill_athlete_stats, { 0.63, 0.10 }, { 13.59, 5 } ); - test_throwing_player_versus( p, "mon_zombie", "javelin_iron", 30, hi_skill_athlete_stats, { 0.48, 0.10 }, { 10.00, 4 } ); + test_throwing_player_versus( p, "mon_zombie", itype_javelin_iron, 1, hi_skill_athlete_stats, { 1.00, 0.10 }, { 34.00, 8 } ); + test_throwing_player_versus( p, "mon_zombie", itype_javelin_iron, 5, hi_skill_athlete_stats, { 1.00, 0.10 }, { 34.00, 8 } ); + test_throwing_player_versus( p, "mon_zombie", itype_javelin_iron, 10, hi_skill_athlete_stats, { 1.00, 0.10 }, { 34.16, 8 } ); + test_throwing_player_versus( p, "mon_zombie", itype_javelin_iron, 15, hi_skill_athlete_stats, { 0.97, 0.10 }, { 25.21, 6 } ); + test_throwing_player_versus( p, "mon_zombie", itype_javelin_iron, 20, hi_skill_athlete_stats, { 0.82, 0.10 }, { 18.90, 5 } ); + test_throwing_player_versus( p, "mon_zombie", itype_javelin_iron, 25, hi_skill_athlete_stats, { 0.63, 0.10 }, { 13.59, 5 } ); + test_throwing_player_versus( p, "mon_zombie", itype_javelin_iron, 30, hi_skill_athlete_stats, { 0.48, 0.10 }, { 10.00, 4 } ); } } @@ -215,20 +220,20 @@ TEST_CASE( "throwing_skill_impact_test", "[throwing],[balance]" ) // ranges here because what we're really trying to capture is the effect // the throwing skill has while the sanity tests are more explicit. SECTION( "mid_skill_basestats_rock" ) { - test_throwing_player_versus( p, "mon_zombie", "rock", 5, mid_skill_base_stats, { 1.00, 0.10 }, { 12, 6 } ); - test_throwing_player_versus( p, "mon_zombie", "rock", 10, mid_skill_base_stats, { 0.86, 0.10 }, { 7.0, 4 } ); - test_throwing_player_versus( p, "mon_zombie", "rock", 15, mid_skill_base_stats, { 0.52, 0.10 }, { 3, 2 } ); + test_throwing_player_versus( p, "mon_zombie", itype_rock, 5, mid_skill_base_stats, { 1.00, 0.10 }, { 12, 6 } ); + test_throwing_player_versus( p, "mon_zombie", itype_rock, 10, mid_skill_base_stats, { 0.86, 0.10 }, { 7.0, 4 } ); + test_throwing_player_versus( p, "mon_zombie", itype_rock, 15, mid_skill_base_stats, { 0.52, 0.10 }, { 3, 2 } ); } SECTION( "hi_skill_basestats_rock" ) { - test_throwing_player_versus( p, "mon_zombie", "rock", 5, hi_skill_base_stats, { 1.00, 0.10 }, { 18, 5 } ); - test_throwing_player_versus( p, "mon_zombie", "rock", 10, hi_skill_base_stats, { 1.00, 0.10 }, { 14.7, 5 } ); - test_throwing_player_versus( p, "mon_zombie", "rock", 15, hi_skill_base_stats, { 0.97, 0.10 }, { 10.5, 4 } ); + test_throwing_player_versus( p, "mon_zombie", itype_rock, 5, hi_skill_base_stats, { 1.00, 0.10 }, { 18, 5 } ); + test_throwing_player_versus( p, "mon_zombie", itype_rock, 10, hi_skill_base_stats, { 1.00, 0.10 }, { 14.7, 5 } ); + test_throwing_player_versus( p, "mon_zombie", itype_rock, 15, hi_skill_base_stats, { 0.97, 0.10 }, { 10.5, 4 } ); } } static void test_player_kills_monster( - Character &you, const std::string &mon_id, const std::string &item_id, const int range, + Character &you, const std::string &mon_id, const itype_id &item_id, const int range, const int dist_thresh, const throw_test_pstats &pstats, const int iterations ) { const tripoint_bub_ms monster_start = { 30 + range, 30, 0 }; @@ -300,7 +305,7 @@ TEST_CASE( "player_kills_zombie_before_reach", "[throwing],[balance][scenario]" clear_map(); SECTION( "test_player_kills_zombie_with_rock_basestats" ) { - test_player_kills_monster( p, "mon_zombie", "rock", 15, 1, lo_skill_base_stats, 500 ); + test_player_kills_monster( p, "mon_zombie", itype_rock, 15, 1, lo_skill_base_stats, 500 ); } } @@ -309,7 +314,7 @@ TEST_CASE( "time_to_throw_independent_of_number_of_projectiles", "[throwing],[ba Character &you = get_avatar(); clear_avatar(); - item thrown( "throwing_stick", calendar::turn, 10 ); + item thrown( itype_throwing_stick, calendar::turn, 10 ); REQUIRE( thrown.charges > 1 ); you.wield( thrown ); int initial_moves = -1; diff --git a/tests/tool_quality_test.cpp b/tests/tool_quality_test.cpp index 0a7db6bd9a1f0..d184cdc5b9016 100644 --- a/tests/tool_quality_test.cpp +++ b/tests/tool_quality_test.cpp @@ -4,6 +4,16 @@ #include "player_helpers.h" #include "type_id.h" +static const itype_id itype_battery_ups( "battery_ups" ); +static const itype_id itype_debug_backpack( "debug_backpack" ); +static const itype_id itype_heavy_battery_cell( "heavy_battery_cell" ); +static const itype_id itype_medium_battery_cell( "medium_battery_cell" ); +static const itype_id itype_test_can_food( "test_can_food" ); +static const itype_id itype_test_cordless_drill( "test_cordless_drill" ); +static const itype_id itype_test_liquid( "test_liquid" ); +static const itype_id itype_test_sonic_screwdriver( "test_sonic_screwdriver" ); +static const itype_id itype_UPS_ON( "UPS_ON" ); + static const quality_id qual_BOIL( "BOIL" ); static const quality_id qual_DRILL( "DRILL" ); static const quality_id qual_LOCKPICK( "LOCKPICK" ); @@ -25,7 +35,7 @@ static const quality_id qual_WRENCH( "WRENCH" ); TEST_CASE( "get_quality", "[tool][quality]" ) { SECTION( "get_quality returns numeric level of given quality" ) { - item sonic( "test_sonic_screwdriver" ); + item sonic( itype_test_sonic_screwdriver ); CHECK( sonic.get_quality( qual_LOCKPICK ) == 30 ); CHECK( sonic.get_quality( qual_PRY ) == 2 ); CHECK( sonic.get_quality( qual_SCREW ) == 2 ); @@ -36,23 +46,23 @@ TEST_CASE( "get_quality", "[tool][quality]" ) SECTION( "charged_qualities" ) { // Without charges, the cordless drill cannot drill, but with charges, it can drill SECTION( "with 0 charge, get_quality returns 0" ) { - CHECK( tool_with_ammo( "test_cordless_drill", 0 ).get_quality( qual_DRILL ) == 0 ); + CHECK( tool_with_ammo( itype_test_cordless_drill, 0 ).get_quality( qual_DRILL ) == 0 ); } SECTION( "with sufficient charge, get_quality returns quality level" ) { - CHECK( tool_with_ammo( "test_cordless_drill", 20 ).get_quality( qual_DRILL ) == 3 ); + CHECK( tool_with_ammo( itype_test_cordless_drill, 20 ).get_quality( qual_DRILL ) == 3 ); } } SECTION( "BOIL quality" ) { // Tools that can BOIL and have a CONTAINER pocket have BOIL quality only when empty - item tin_can( "test_can_food" ); + item tin_can( itype_test_can_food ); SECTION( "get_quality returns BOIL quality if container is empty" ) { REQUIRE( tin_can.empty_container() ); CHECK( tin_can.get_quality( qual_BOIL ) == 1 ); } SECTION( "get_quality returns INT_MIN for BOIL quality if container is not empty" ) { - item broth( "test_liquid" ); + item broth( itype_test_liquid ); tin_can.put_in( broth, pocket_type::CONTAINER ); REQUIRE_FALSE( tin_can.empty_container() ); @@ -67,8 +77,8 @@ TEST_CASE( "get_quality", "[tool][quality]" ) // that are only available when the item is charged with at least "charges_per_use" charges. TEST_CASE( "battery-powered_tool_qualities", "[tool][battery][quality]" ) { - item drill( "test_cordless_drill" ); - item battery( "medium_battery_cell" ); + item drill( itype_test_cordless_drill ); + item battery( itype_medium_battery_cell ); // This cordless drill is a battery-powered tool needing some charges for each use REQUIRE( drill.is_tool() ); @@ -160,14 +170,14 @@ TEST_CASE( "battery-powered_tool_qualities", "[tool][battery][quality]" ) // Need avatar as "carrier" for the UPS Character &they = get_player_character(); clear_character( they ); - they.worn.wear_item( they, item( "debug_backpack" ), false, false ); + they.worn.wear_item( they, item( itype_debug_backpack ), false, false ); // Use i_add to place everything in the avatar's inventory (backpack) // so the UPS power will be available to the cordless drill after modding - item_location drill = they.i_add( item( "test_cordless_drill" ) ); - item_location bat_cell = they.i_add( item( "heavy_battery_cell" ) ); - item_location ups_mod = they.i_add( item( "battery_ups" ) ); - item_location ups = they.i_add( item( "UPS_ON" ) ); + item_location drill = they.i_add( item( itype_test_cordless_drill ) ); + item_location bat_cell = they.i_add( item( itype_heavy_battery_cell ) ); + item_location ups_mod = they.i_add( item( itype_battery_ups ) ); + item_location ups = they.i_add( item( itype_UPS_ON ) ); GIVEN( "UPS has battery with enough charge, equal to drill's charges_per_use" ) { // Charge the battery diff --git a/tests/unload_naked_test.cpp b/tests/unload_naked_test.cpp index d9985e3b8b136..4c453c786d9eb 100644 --- a/tests/unload_naked_test.cpp +++ b/tests/unload_naked_test.cpp @@ -11,6 +11,8 @@ #include "player_helpers.h" #include "type_id.h" +static const itype_id itype_sw629( "sw629" ); + /** * When a player has no open inventory to place unloaded bullets, but there is room in the gun being * unloaded the bullets are dropped. @@ -26,7 +28,7 @@ TEST_CASE( "unload_revolver_naked_one_bullet", "[unload][nonmagzine]" ) avatar &player_character = get_avatar(); // revolver with only one of six bullets - item revolver( "sw629" ); + item revolver( itype_sw629 ); revolver.ammo_set( revolver.ammo_default(), 1 ); // wield the revolver @@ -61,7 +63,7 @@ TEST_CASE( "unload_revolver_naked_fully_loaded", "[unload][nonmagzine]" ) avatar &player_character = get_avatar(); // revolver fully loaded - item revolver( "sw629" ); + item revolver( itype_sw629 ); revolver.ammo_set( revolver.ammo_default(), revolver.remaining_ammo_capacity() ); // wield the revolver diff --git a/tests/vehicle_interact_test.cpp b/tests/vehicle_interact_test.cpp index e8758a2fbdae7..8a959df6d3b67 100644 --- a/tests/vehicle_interact_test.cpp +++ b/tests/vehicle_interact_test.cpp @@ -21,6 +21,16 @@ #include "veh_type.h" #include "vehicle.h" +static const itype_id itype_battery_ups( "battery_ups" ); +static const itype_id itype_debug_backpack( "debug_backpack" ); +static const itype_id itype_goggles_welding( "goggles_welding" ); +static const itype_id itype_hammer( "hammer" ); +static const itype_id itype_lc_steel_chunk( "lc_steel_chunk" ); +static const itype_id itype_test_storage_battery( "test_storage_battery" ); +static const itype_id itype_UPS_ON( "UPS_ON" ); +static const itype_id itype_welder( "welder" ); +static const itype_id itype_welding_wire_steel( "welding_wire_steel" ); + static const skill_id skill_mechanics( "mechanics" ); static const vpart_id vpart_ap_test_storage_battery( "ap_test_storage_battery" ); @@ -35,11 +45,11 @@ static void test_repair( const std::vector &tools, bool plug_in_tools, boo const tripoint_bub_ms test_origin( 60, 60, 0 ); Character &player_character = get_player_character(); player_character.setpos( test_origin ); - const item debug_backpack( "debug_backpack" ); + const item debug_backpack( itype_debug_backpack ); player_character.wear_item( debug_backpack ); const tripoint_bub_ms battery_pos = test_origin + tripoint::north_west; - std::optional battery_item( "test_storage_battery" ); + std::optional battery_item( itype_test_storage_battery ); place_appliance( battery_pos, vpart_ap_test_storage_battery, player_character, battery_item ); for( const item &gear : tools ) { @@ -89,80 +99,80 @@ TEST_CASE( "repair_vehicle_part", "[vehicle]" ) SECTION( "welder" ) { std::vector tools; - item welder( "welder" ); + item welder( itype_welder ); tools.push_back( welder ); - tools.emplace_back( "goggles_welding" ); - tools.emplace_back( "hammer" ); - tools.insert( tools.end(), 20, item( "lc_steel_chunk" ) ); - tools.insert( tools.end(), 200, item( "welding_wire_steel" ) ); + tools.emplace_back( itype_goggles_welding ); + tools.emplace_back( itype_hammer ); + tools.insert( tools.end(), 20, item( itype_lc_steel_chunk ) ); + tools.insert( tools.end(), 200, item( itype_welding_wire_steel ) ); test_repair( tools, true, true ); } SECTION( "UPS_modded_welder" ) { std::vector tools; - item welder( "welder", calendar::turn_zero, 0 ); - welder.put_in( item( "battery_ups" ), pocket_type::MOD ); + item welder( itype_welder, calendar::turn_zero, 0 ); + welder.put_in( item( itype_battery_ups ), pocket_type::MOD ); tools.push_back( welder ); - item ups( "UPS_ON" ); + item ups( itype_UPS_ON ); item ups_mag( ups.magazine_default() ); ups_mag.ammo_set( ups_mag.ammo_default(), 1000 ); ups.put_in( ups_mag, pocket_type::MAGAZINE_WELL ); tools.push_back( ups ); - tools.emplace_back( "goggles_welding" ); - tools.emplace_back( "hammer" ); - tools.insert( tools.end(), 5, item( "lc_steel_chunk" ) ); - tools.insert( tools.end(), 50, item( "welding_wire_steel" ) ); + tools.emplace_back( itype_goggles_welding ); + tools.emplace_back( itype_hammer ); + tools.insert( tools.end(), 5, item( itype_lc_steel_chunk ) ); + tools.insert( tools.end(), 50, item( itype_welding_wire_steel ) ); test_repair( tools, false, false ); } SECTION( "welder_missing_goggles" ) { std::vector tools; - item welder( "welder" ); + item welder( itype_welder ); tools.push_back( welder ); - tools.emplace_back( "hammer" ); - tools.insert( tools.end(), 5, item( "lc_steel_chunk" ) ); - tools.insert( tools.end(), 50, item( "welding_wire_steel" ) ); + tools.emplace_back( itype_hammer ); + tools.insert( tools.end(), 5, item( itype_lc_steel_chunk ) ); + tools.insert( tools.end(), 50, item( itype_welding_wire_steel ) ); test_repair( tools, true, false ); } SECTION( "welder_missing_charge" ) { std::vector tools; - item welder( "welder" ); + item welder( itype_welder ); tools.push_back( welder ); - tools.emplace_back( "goggles_welding" ); - tools.emplace_back( "hammer" ); - tools.insert( tools.end(), 5, item( "lc_steel_chunk" ) ); - tools.insert( tools.end(), 50, item( "welding_wire_steel" ) ); + tools.emplace_back( itype_goggles_welding ); + tools.emplace_back( itype_hammer ); + tools.insert( tools.end(), 5, item( itype_lc_steel_chunk ) ); + tools.insert( tools.end(), 50, item( itype_welding_wire_steel ) ); test_repair( tools, false, false ); } SECTION( "UPS_modded_welder_missing_charges" ) { std::vector tools; - item welder( "welder", calendar::turn_zero, 0 ); - welder.put_in( item( "battery_ups" ), pocket_type::MOD ); + item welder( itype_welder, calendar::turn_zero, 0 ); + welder.put_in( item( itype_battery_ups ), pocket_type::MOD ); tools.push_back( welder ); - item ups( "UPS_ON" ); + item ups( itype_UPS_ON ); item ups_mag( ups.magazine_default() ); ups_mag.ammo_set( ups_mag.ammo_default(), 500 ); ups.put_in( ups_mag, pocket_type::MAGAZINE_WELL ); tools.push_back( ups ); - tools.emplace_back( "goggles_welding" ); - tools.insert( tools.end(), 5, item( "lc_steel_chunk" ) ); - tools.insert( tools.end(), 50, item( "welding_wire_steel" ) ); + tools.emplace_back( itype_goggles_welding ); + tools.insert( tools.end(), 5, item( itype_lc_steel_chunk ) ); + tools.insert( tools.end(), 50, item( itype_welding_wire_steel ) ); test_repair( tools, false, false ); } SECTION( "welder_missing_consumables" ) { std::vector tools; - item welder( "welder" ); + item welder( itype_welder ); tools.push_back( welder ); - tools.emplace_back( "goggles_welding" ); + tools.emplace_back( itype_goggles_welding ); test_repair( tools, true, false ); } } diff --git a/tests/vehicle_part_test.cpp b/tests/vehicle_part_test.cpp index 8e5efed5aa565..323d0eec48784 100644 --- a/tests/vehicle_part_test.cpp +++ b/tests/vehicle_part_test.cpp @@ -39,6 +39,7 @@ static const ammotype ammo_water( "water" ); static const damage_type_id damage_bash( "bash" ); +static const itype_id itype_backpack( "backpack" ); static const itype_id itype_fridge_test( "fridge_test" ); static const itype_id itype_metal_tank_test( "metal_tank_test" ); static const itype_id itype_oatmeal( "oatmeal" ); @@ -129,7 +130,7 @@ static void test_craft_via_rig( const std::vector &items, int give_battery const tripoint_bub_ms test_origin( 60, 60, 0 ); Character &character = get_player_character(); character.toggle_trait( trait_DEBUG_CNF ); - const item backpack( "backpack" ); + const item backpack( itype_backpack ); character.wear_item( backpack ); for( const item &i : items ) { character.i_add( i ); @@ -208,7 +209,7 @@ TEST_CASE( "faucet_offers_cold_water", "[vehicle][vehicle_parts]" ) const tripoint_bub_ms test_origin( 60, 60, 0 ); const int water_charges = 8; Character &character = get_player_character(); - const item backpack( "backpack" ); + const item backpack( itype_backpack ); character.wear_item( backpack ); get_map().add_vehicle( vehicle_prototype_test_rv, test_origin, -90_degrees, 0, 0 ); const optional_vpart_position ovp = get_map().veh_at( test_origin ); diff --git a/tests/vehicle_power_test.cpp b/tests/vehicle_power_test.cpp index 16d566e38a502..1485913fd5307 100644 --- a/tests/vehicle_power_test.cpp +++ b/tests/vehicle_power_test.cpp @@ -17,6 +17,7 @@ static const efftype_id effect_blind( "blind" ); static const itype_id fuel_type_battery( "battery" ); +static const itype_id itype_test_power_cord_25_loss( "test_power_cord_25_loss" ); static const vpart_id vpart_frame( "frame" ); static const vpart_id vpart_small_storage_battery( "small_storage_battery" ); @@ -49,7 +50,7 @@ TEST_CASE( "power_loss_to_cables", "[vehicle][power]" ) const optional_vpart_position target_vp = here.veh_at( target ); const optional_vpart_position source_vp = here.veh_at( source ); - item cord( "test_power_cord_25_loss" ); + item cord( itype_test_power_cord_25_loss ); cord.set_var( "source_x", source.x() ); cord.set_var( "source_y", source.y() ); cord.set_var( "source_z", source.z() ); diff --git a/tests/vehicle_test.cpp b/tests/vehicle_test.cpp index 4c7f21f43ab75..1d6299a91d7c0 100644 --- a/tests/vehicle_test.cpp +++ b/tests/vehicle_test.cpp @@ -21,13 +21,16 @@ static const damage_type_id damage_pure( "pure" ); +static const itype_id itype_debug_backpack( "debug_backpack" ); static const itype_id itype_folded_bicycle( "folded_bicycle" ); static const itype_id itype_folded_inflatable_boat( "folded_inflatable_boat" ); static const itype_id itype_folded_wheelchair_generic( "folded_wheelchair_generic" ); static const itype_id itype_hand_pump( "hand_pump" ); +static const itype_id itype_jeans( "jeans" ); static const itype_id itype_test_extension_cable( "test_extension_cable" ); static const itype_id itype_test_power_cord( "test_power_cord" ); +static const itype_id itype_test_standing_lamp( "test_standing_lamp" ); static const vpart_id vpart_ap_test_standing_lamp( "ap_test_standing_lamp" ); static const vpart_id vpart_bike_rack( "bike_rack" ); @@ -97,7 +100,7 @@ TEST_CASE( "add_item_to_broken_vehicle_part", "[vehicle]" ) //Now it must be broken REQUIRE( ovp_cargo->part().is_broken() ); //Now part is really broken, adding an item should fail - const item itm2 = item( "jeans" ); + const item itm2 = item( itype_jeans ); REQUIRE( !veh_ptr->add_item( ovp_cargo->part(), itm2 ) ); } @@ -179,7 +182,7 @@ static void unfold_and_check( const vehicle_preset &veh_preset, const damage_pre clear_map(); clear_vehicles( &m ); - u.worn.wear_item( u, item( "debug_backpack" ), false, false ); + u.worn.wear_item( u, item( itype_debug_backpack ), false, false ); item veh_item( veh_preset.vehicle_itype_id ); @@ -321,7 +324,7 @@ static void check_folded_item_to_parts_damage_transfer( const folded_item_damage map &m = get_map(); Character &u = get_player_character(); - u.worn.wear_item( u, item( "debug_backpack" ), false, false ); + u.worn.wear_item( u, item( itype_debug_backpack ), false, false ); item veh_item( preset.folded_vehicle_item ); @@ -444,8 +447,8 @@ TEST_CASE( "power_cable_stretch_disconnect" ) map &m = get_map(); Character &player_character = get_player_character(); const int max_displacement = 50; - const std::optional stand_lamp1( "test_standing_lamp" ); - const std::optional stand_lamp2( "test_standing_lamp" ); + const std::optional stand_lamp1( itype_test_standing_lamp ); + const std::optional stand_lamp2( itype_test_standing_lamp ); const tripoint_bub_ms app1_pos( HALF_MAPSIZE_X + 2, HALF_MAPSIZE_Y + 2, 0 ); const tripoint_bub_ms app2_pos( app1_pos + tripoint( 2, 2, 0 ) ); diff --git a/tests/visitable_remove_test.cpp b/tests/visitable_remove_test.cpp index 06b5d315c8bfc..99e2b50d86096 100644 --- a/tests/visitable_remove_test.cpp +++ b/tests/visitable_remove_test.cpp @@ -27,6 +27,7 @@ #include "visitable.h" #include "vpart_position.h" +static const itype_id itype_backpack( "backpack" ); static const itype_id itype_bone( "bone" ); static const itype_id itype_bottle_plastic( "bottle_plastic" ); static const itype_id itype_flask_hip( "flask_hip" ); @@ -59,8 +60,8 @@ TEST_CASE( "visitable_remove", "[visitable]" ) clear_avatar(); Character &p = get_player_character(); - p.worn.wear_item( p, item( "backpack" ), false, false ); - p.wear_item( item( "backpack" ) ); // so we don't drop anything + p.worn.wear_item( p, item( itype_backpack ), false, false ); + p.wear_item( item( itype_backpack ) ); // so we don't drop anything clear_map(); map &here = get_map(); diff --git a/tests/visitable_test.cpp b/tests/visitable_test.cpp index 3d4a517115ca7..5f7a8dc2aafa6 100644 --- a/tests/visitable_test.cpp +++ b/tests/visitable_test.cpp @@ -7,19 +7,20 @@ #include "ret_val.h" #include "type_id.h" +static const itype_id itype_bottle_plastic( "bottle_plastic" ); static const itype_id itype_water( "water" ); TEST_CASE( "visitable_summation" ) { inventory test_inv; - item bottle_of_water( "bottle_plastic", calendar::turn ); - item water_in_bottle( "water", calendar::turn ); + item bottle_of_water( itype_bottle_plastic, calendar::turn ); + item water_in_bottle( itype_water, calendar::turn ); water_in_bottle.charges = bottle_of_water.get_remaining_capacity_for_liquid( water_in_bottle ); bottle_of_water.put_in( water_in_bottle, pocket_type::CONTAINER ); test_inv.add_item( bottle_of_water ); - const item unlimited_water( "water", calendar::turn_zero, item::INFINITE_CHARGES ); + const item unlimited_water( itype_water, calendar::turn_zero, item::INFINITE_CHARGES ); test_inv.add_item( unlimited_water ); CHECK( test_inv.charges_of( itype_water, item::INFINITE_CHARGES ) > 1 ); diff --git a/tests/water_movement_test.cpp b/tests/water_movement_test.cpp index 74653ea2cf163..63eaa463f63d2 100644 --- a/tests/water_movement_test.cpp +++ b/tests/water_movement_test.cpp @@ -14,6 +14,9 @@ #include "player_helpers.h" #include "type_id.h" +static const itype_id itype_flotation_vest( "flotation_vest" ); +static const itype_id itype_swim_fins( "swim_fins" ); + static void setup_test_lake() { const ter_id t_water_dp( "t_water_dp" ); @@ -165,7 +168,7 @@ struct swimmer_skills { }; struct swimmer_gear { - std::vector worn; + std::vector worn; }; struct swimmer_traits { @@ -227,8 +230,8 @@ static const std::unordered_map skills_map = { static const std::unordered_map gear_map = { {"none", {}}, - {"fins", {{"swim_fins"}}}, - {"flotation vest", {{"flotation_vest"}}}, + {"fins", {{itype_swim_fins}}}, + {"flotation vest", {{itype_flotation_vest}}}, }; static const std::unordered_map traits_map = { @@ -311,7 +314,7 @@ static void configure_swimmer( avatar &swimmer, const move_mode_id move_mode, swimmer.toggle_trait( trait_id( trait ) ); } - for( const std::string &worn : config.gear.worn ) { + for( const itype_id &worn : config.gear.worn ) { swimmer.wear_item( item( worn ), false ); } diff --git a/tests/widget_test.cpp b/tests/widget_test.cpp index 4d436627af1b9..8a2be22a17592 100644 --- a/tests/widget_test.cpp +++ b/tests/widget_test.cpp @@ -40,9 +40,15 @@ static const efftype_id effect_infected( "infected" ); static const flag_id json_flag_SPLINT( "SPLINT" ); const static flag_id json_flag_W_DISABLED_WHEN_EMPTY( "W_DISABLED_WHEN_EMPTY" ); +static const itype_id itype_arm_splint( "arm_splint" ); static const itype_id itype_blindfold( "blindfold" ); static const itype_id itype_ear_plugs( "ear_plugs" ); static const itype_id itype_rad_badge( "rad_badge" ); +static const itype_id itype_sneakers( "sneakers" ); +static const itype_id itype_swim_fins( "swim_fins" ); +static const itype_id itype_test_hazmat_suit( "test_hazmat_suit" ); +static const itype_id itype_test_socks( "test_socks" ); +static const itype_id itype_test_zentai( "test_zentai" ); static const morale_type morale_food_good( "morale_food_good" ); static const morale_type morale_killed_innocent( "morale_killed_innocent" ); @@ -910,14 +916,14 @@ TEST_CASE( "widgets_showing_movement_cost", "[widget][move_cost]" ) } SECTION( "wearing sneakers" ) { // Sneakers eliminate the no-shoes penalty - ava.wear_item( item( "sneakers" ) ); + ava.wear_item( item( itype_sneakers ) ); REQUIRE( ava.is_wearing_shoes() ); REQUIRE( ava.run_cost( 100 ) == 100 ); CHECK( cost_num_w.layout( ava ) == "MOVE COST: 100" ); } SECTION( "wearing swim fins" ) { // Swim fins multiply cost by 1.5 - ava.wear_item( item( "swim_fins" ) ); + ava.wear_item( item( itype_swim_fins ) ); REQUIRE( ava.is_wearing_shoes() ); REQUIRE( ava.run_cost( 100 ) == 167 ); CHECK( cost_num_w.layout( ava ) == "MOVE COST: 167" ); @@ -1374,7 +1380,7 @@ TEST_CASE( "widget_showing_body_part_status_text", "[widget][bp_status]" ) WHEN( "broken and splinted" ) { ava.set_part_hp_cur( arm, 0 ); - ava.wear_item( item( "arm_splint" ) ); + ava.wear_item( item( itype_arm_splint ) ); REQUIRE( ava.is_limb_broken( arm ) ); REQUIRE( ava.worn_with_flag( json_flag_SPLINT, arm ) ); check_bp_has_status( arm_status_w.layout( ava ), @@ -1499,7 +1505,7 @@ TEST_CASE( "compact_bodypart_status_widgets_+_legend", "[widget][bp_status]" ) WHEN( "broken and splinted" ) { ava.set_part_hp_cur( arm, 0 ); - ava.wear_item( item( "arm_splint" ) ); + ava.wear_item( item( itype_arm_splint ) ); REQUIRE( ava.is_limb_broken( arm ) ); REQUIRE( ava.worn_with_flag( json_flag_SPLINT, arm ) ); check_bp_has_status( arm_stat.layout( ava, sidebar_width ), @@ -1580,17 +1586,17 @@ TEST_CASE( "outer_armor_widget", "[widget][armor]" ) CHECK( torso_armor_w.layout( ava ) == "Torso Armor: -" ); // Wearing something covering torso - ava.worn.wear_item( ava, item( "test_zentai" ), false, false ); + ava.worn.wear_item( ava, item( itype_test_zentai ), false, false ); CHECK( torso_armor_w.layout( ava ) == "Torso Armor: ++\u00A0test zentai (poor fit)" ); // Wearing socks doesn't affect the torso - ava.worn.wear_item( ava, item( "test_socks" ), false, false ); + ava.worn.wear_item( ava, item( itype_test_socks ), false, false ); CHECK( torso_armor_w.layout( ava ) == "Torso Armor: ++\u00A0test zentai (poor fit)" ); // Wearing something else on the torso - ava.worn.wear_item( ava, item( "test_hazmat_suit" ), false, false ); + ava.worn.wear_item( ava, item( itype_test_hazmat_suit ), false, false ); CHECK( torso_armor_w.layout( ava ) == "Torso Armor: ++\u00A0TEST hazmat suit (poor fit)" ); } @@ -2442,7 +2448,7 @@ TEST_CASE( "Widget_alignment", "[widget]" ) ava.add_effect( effect_bleed, 1_minutes, torso ); ava.get_effect( effect_bleed, torso ).set_intensity( 5 ); ava.set_part_hp_cur( arm, 0 ); - ava.wear_item( item( "arm_splint" ) ); + ava.wear_item( item( itype_arm_splint ) ); ava.add_effect( effect_bandaged, 1_minutes, arm ); bp_legend._label_align = widget_alignment::LEFT; @@ -2599,7 +2605,7 @@ TEST_CASE( "Clause_conditions_-_pure_JSON_widgets", "[widget][clause][condition] TEST_CASE( "widget_disabled_when_empty", "[widget]" ) { - item blindfold( "blindfold" ); + item blindfold( itype_blindfold ); avatar &ava = get_avatar(); clear_avatar(); diff --git a/tests/wield_times_test.cpp b/tests/wield_times_test.cpp index 6bff32c80d7d0..26d40674f7c79 100644 --- a/tests/wield_times_test.cpp +++ b/tests/wield_times_test.cpp @@ -15,15 +15,20 @@ #include "type_id.h" static const itype_id itype_aspirin( "aspirin" ); +static const itype_id itype_backpack( "backpack" ); +static const itype_id itype_bag_plastic( "bag_plastic" ); static const itype_id itype_knife_combat( "knife_combat" ); +static const itype_id itype_knife_hunting( "knife_hunting" ); static const itype_id itype_metal_tank( "metal_tank" ); +static const itype_id itype_pants_cargo( "pants_cargo" ); +static const itype_id itype_sheath( "sheath" ); static void wield_check_from_inv( avatar &guy, const itype_id &item_name, const int expected_moves ) { guy.remove_weapon(); guy.clear_worn(); item spawned_item( item_name, calendar::turn, 1 ); - item backpack( "backpack" ); + item backpack( itype_backpack ); REQUIRE( backpack.can_contain( spawned_item ).success() ); auto item_iter = guy.worn.wear_item( guy, backpack, false, false ); @@ -58,11 +63,11 @@ TEST_CASE( "Wield_time_test", "[wield]" ) clear_map(); SECTION( "A knife in a sheath in cargo pants in a plastic bag in a backpack" ) { - item backpack( "backpack" ); - item plastic_bag( "bag_plastic" ); - item cargo_pants( "pants_cargo" ); - item sheath( "sheath" ); - item knife( "knife_hunting" ); + item backpack( itype_backpack ); + item plastic_bag( itype_bag_plastic ); + item cargo_pants( itype_pants_cargo ); + item sheath( itype_sheath ); + item knife( itype_knife_hunting ); avatar guy; guy.set_body(); diff --git a/tests/zones_custom_test.cpp b/tests/zones_custom_test.cpp index d8b3c75ab9758..a880600433838 100644 --- a/tests/zones_custom_test.cpp +++ b/tests/zones_custom_test.cpp @@ -3,6 +3,13 @@ #include "map.h" #include "map_helpers.h" +static const itype_id itype_bag_plastic( "bag_plastic" ); +static const itype_id itype_bow_saw( "bow_saw" ); +static const itype_id itype_hammer( "hammer" ); +static const itype_id itype_test_battery_disposable( "test_battery_disposable" ); +static const itype_id itype_test_glaive( "test_glaive" ); +static const itype_id itype_test_pants_fur( "test_pants_fur" ); + static const zone_type_id zone_type_LOOT_CUSTOM( "LOOT_CUSTOM" ); static const zone_type_id zone_type_LOOT_ITEM_GROUP( "LOOT_ITEM_GROUP" ); @@ -19,12 +26,12 @@ TEST_CASE( "zones_custom", "[zones]" ) tripoint_abs_ms const zone_testgroup_end = zone_loc + tripoint::east; tripoint_abs_ms const zone_groupbatt_end = zone_loc + tripoint::west; tripoint_abs_ms const where = m.getglobal( tripoint_bub_ms::zero ); - item hammer( "hammer" ); - item bow_saw( "bow_saw" ); - item pants_fur( "test_pants_fur" ); - item batt( "test_battery_disposable" ); - item bag_plastic( "bag_plastic" ); - item nested_batt( "test_battery_disposable" ); + item hammer( itype_hammer ); + item bow_saw( itype_bow_saw ); + item pants_fur( itype_test_pants_fur ); + item batt( itype_test_battery_disposable ); + item bag_plastic( itype_bag_plastic ); + item nested_batt( itype_test_battery_disposable ); int const num = GENERATE( 1, 2 ); for( int i = 0; i < num; i++ ) { bag_plastic.put_in( nested_batt, pocket_type::CONTAINER ); @@ -48,7 +55,7 @@ TEST_CASE( "zones_custom", "[zones]" ) zone_manager &zmgr = zone_manager::get_manager(); REQUIRE( zmgr.get_near_zone_type_for_item( hammer, where ) == zone_type_LOOT_CUSTOM ); REQUIRE( zmgr.get_near_zone_type_for_item( bow_saw, where ) == zone_type_LOOT_CUSTOM ); - REQUIRE( !zmgr.get_near_zone_type_for_item( item( "test_glaive" ), where ).is_valid() ); + REQUIRE( !zmgr.get_near_zone_type_for_item( item( itype_test_glaive ), where ).is_valid() ); REQUIRE( zmgr.get_near_zone_type_for_item( pants_fur, where ) == zone_type_LOOT_ITEM_GROUP ); REQUIRE( zmgr.get_near_zone_type_for_item( batt, where ) == zone_type_LOOT_ITEM_GROUP ); From 126fad3c7c1880b7adab0b5f87c8bd78e58f887e Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Fri, 10 Jan 2025 15:51:25 +0000 Subject: [PATCH 04/14] Typify consume_drug_iuse::used_up_item and handle_harvest raw strings --- src/activity_actor.cpp | 2 +- src/iexamine.cpp | 28 ++++++++++++++++------------ src/iexamine.h | 2 +- src/iuse_actor.cpp | 9 +++------ src/iuse_actor.h | 2 +- src/map.cpp | 1 - 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/activity_actor.cpp b/src/activity_actor.cpp index cdf88b25a6d79..ece35264613d9 100644 --- a/src/activity_actor.cpp +++ b/src/activity_actor.cpp @@ -4380,7 +4380,7 @@ void harvest_activity_actor::finish( player_activity &act, Character &who ) const int roll = std::min( entry.max, std::round( rng_float( min_num, max_num ) ) ); got_anything = roll > 0; for( int i = 0; i < roll; i++ ) { - iexamine_helper::handle_harvest( who, entry.drop, false ); + iexamine_helper::handle_harvest( who, itype_id( entry.drop ), false ); } } diff --git a/src/iexamine.cpp b/src/iexamine.cpp index e4b0d3b440d67..eeb8f00e48d2a 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -162,10 +162,12 @@ static const itype_id itype_2x4( "2x4" ); static const itype_id itype_arm_splint( "arm_splint" ); static const itype_id itype_bot_broken_cyborg( "bot_broken_cyborg" ); static const itype_id itype_bot_prototype_cyborg( "bot_prototype_cyborg" ); +static const itype_id itype_cactus_pad( "cactus_pad" ); static const itype_id itype_cash_card( "cash_card" ); static const itype_id itype_charcoal( "charcoal" ); static const itype_id itype_chem_carbide( "chem_carbide" ); static const itype_id itype_corpse( "corpse" ); +static const itype_id itype_dahlia_root( "dahlia_root" ); static const itype_id itype_disassembly( "disassembly" ); static const itype_id itype_fake_milling_item( "fake_milling_item" ); static const itype_id itype_fake_smoke_plume( "fake_smoke_plume" ); @@ -185,12 +187,16 @@ static const itype_id itype_nail( "nail" ); static const itype_id itype_nanomaterial( "nanomaterial" ); static const itype_id itype_nectar( "nectar" ); static const itype_id itype_petrified_eye( "petrified_eye" ); +static const itype_id itype_poppy_bud( "poppy_bud" ); static const itype_id itype_poppy_nectar( "poppy_nectar" ); +static const itype_id itype_seed_cactus( "seed_cactus" ); +static const itype_id itype_seed_dahlia( "seed_dahlia" ); static const itype_id itype_sheet( "sheet" ); static const itype_id itype_stick( "stick" ); static const itype_id itype_string_36( "string_36" ); static const itype_id itype_unfinished_cac2( "unfinished_cac2" ); static const itype_id itype_unfinished_charcoal( "unfinished_charcoal" ); +static const itype_id itype_withered( "withered" ); static const json_character_flag json_flag_ATTUNEMENT( "ATTUNEMENT" ); static const json_character_flag json_flag_GLIDE( "GLIDE" ); @@ -2263,11 +2269,9 @@ bool iexamine_helper::drink_nectar( Character &you ) /** * Spawn an item after harvesting the plant */ -//BEFOREMERGE: Change to itype_id &itemid -void iexamine_helper::handle_harvest( Character &you, const std::string &itemid, - bool force_drop ) +void iexamine_helper::handle_harvest( Character &you, const itype_id &itemid, bool force_drop ) { - item harvest = item( itype_id( itemid ) ); + item harvest( itemid ); if( harvest.has_temperature() ) { harvest.set_item_temperature( get_weather().get_temperature( you.pos_bub() ) ); } @@ -2339,8 +2343,8 @@ void iexamine::flower_poppy( Character &you, const tripoint_bub_ms &examp ) here.furn_set( examp, furn_str_id::NULL_ID() ); - iexamine_helper::handle_harvest( you, "poppy_bud", false ); - iexamine_helper::handle_harvest( you, "withered", false ); + iexamine_helper::handle_harvest( you, itype_poppy_bud, false ); + iexamine_helper::handle_harvest( you, itype_withered, false ); } /** @@ -2366,8 +2370,8 @@ void iexamine::flower_cactus( Character &you, const tripoint_bub_ms &examp ) here.furn_set( examp, furn_str_id::NULL_ID() ); - iexamine_helper::handle_harvest( you, "cactus_pad", false ); - iexamine_helper::handle_harvest( you, "seed_cactus", false ); + iexamine_helper::handle_harvest( you, itype_cactus_pad, false ); + iexamine_helper::handle_harvest( you, itype_seed_cactus, false ); } /** @@ -2402,10 +2406,10 @@ void iexamine::flower_dahlia( Character &you, const tripoint_bub_ms &examp ) here.furn_set( examp, furn_str_id::NULL_ID() ); if( can_get_root ) { - iexamine_helper::handle_harvest( you, "dahlia_root", false ); + iexamine_helper::handle_harvest( you, itype_dahlia_root, false ); } - iexamine_helper::handle_harvest( you, "seed_dahlia", false ); - iexamine_helper::handle_harvest( you, "withered", false ); + iexamine_helper::handle_harvest( you, itype_seed_dahlia, false ); + iexamine_helper::handle_harvest( you, itype_withered, false ); // There was a bud and flower spawn here // But those were useless, don't re-add until they get useful } @@ -2515,7 +2519,7 @@ void iexamine::flower_marloss( Character &you, const tripoint_bub_ms &examp ) } here.furn_set( examp, furn_str_id::NULL_ID() ); here.spawn_item( you.pos_bub(), itype_marloss_seed, 1, 3, calendar::turn ); - iexamine_helper::handle_harvest( you, "withered", false ); + iexamine_helper::handle_harvest( you, itype_withered, false ); } /** diff --git a/src/iexamine.h b/src/iexamine.h index 706502a68dbaf..fb7d968e68ac1 100644 --- a/src/iexamine.h +++ b/src/iexamine.h @@ -177,7 +177,7 @@ void practice_survival_while_foraging( Character &who ); namespace iexamine_helper { bool drink_nectar( Character &you ); -void handle_harvest( Character &you, const std::string &itemid, bool force_drop ); +void handle_harvest( Character &you, const itype_id &itemid, bool force_drop ); } // namespace iexamine_helper using iexamine_examine_function = void ( * )( Character &, const tripoint_bub_ms & ); diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 13e396b0a6888..a328739e658bd 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -774,15 +774,13 @@ void consume_drug_iuse::load( const JsonObject &obj, const std::string & ) obj.read( "stat_adjustments", stat_adjustments ); obj.read( "fields_produced", fields_produced ); obj.read( "moves", moves ); + obj.read( "used_up_item", used_up_item ); for( JsonArray vit : obj.get_array( "vitamins" ) ) { int lo = vit.get_int( 1 ); int hi = vit.size() >= 3 ? vit.get_int( 2 ) : lo; vitamins.emplace( vitamin_id( vit.get_string( 0 ) ), std::make_pair( lo, hi ) ); } - - used_up_item = obj.get_string( "used_up_item", used_up_item ); - } void consume_drug_iuse::info( const item &, std::vector &dump ) const @@ -882,9 +880,8 @@ std::optional consume_drug_iuse::use( Character *p, item &it, const tripoin } } - //BEFOREMERGE: Typify raw string consume_drug_iuse::used_up_item - if( !used_up_item.empty() ) { - item used_up( itype_id( used_up_item ), it.birthday() ); + if( !used_up_item.is_null() ) { + item used_up( used_up_item, it.birthday() ); p->i_add_or_drop( used_up ); } diff --git a/src/iuse_actor.h b/src/iuse_actor.h index b5206bc787056..5a3e8319530a9 100644 --- a/src/iuse_actor.h +++ b/src/iuse_actor.h @@ -273,7 +273,7 @@ class consume_drug_iuse : public iuse_actor void info( const item &, std::vector & ) const override; /** Item produced after using drugs. */ - std::string used_up_item; + itype_id used_up_item; }; /** diff --git a/src/map.cpp b/src/map.cpp index 6b744f6cf6095..9f467aac34ad7 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -8748,7 +8748,6 @@ void map::handle_decayed_corpse( const item &it, const tripoint_abs_ms &pnt ) bool anything_left = false; for( const harvest_entry &entry : *dead_monster->decay ) { - //BEFOREMERGE: Typify raw string harvest_entry::drop item harvest = item( itype_id( entry.drop ) ); const float random_decay_modifier = rng_float( 0.0f, static_cast( MAX_SKILL ) ); const float min_num = entry.scale_num.first * random_decay_modifier + entry.base_num.first; From 3cff4aa282c3a92fc27d245a597117af7bdff146 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:28:13 +0000 Subject: [PATCH 05/14] Remove gross hack from receive_item where itype_id gets conditionally treated as a group id --- src/npctalk.cpp | 154 ++++++++++++++++++++++++++---------------------- 1 file changed, 85 insertions(+), 69 deletions(-) diff --git a/src/npctalk.cpp b/src/npctalk.cpp index 59e014dbbaacf..a509d938c3a35 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -3557,92 +3557,95 @@ void map_add_item( item &it, tripoint_abs_ms target_pos ) } } -void receive_item( itype_id &item_name, int count, std::string_view container_name, - const dialogue &d, bool use_item_group, bool suppress_message, +void receive_item( const itype_id &item_id, int count, const itype_id &container_id, + const dialogue &d, bool suppress_message, const std::vector &flags, bool add_talker = true, const tripoint_abs_ms &p = tripoint_abs_ms(), bool force_equip = false ) { - if( use_item_group ) { - item_group::ItemList new_items; - new_items = item_group::items_from( item_group_id( item_name.c_str() ), calendar::turn ); - std::string popup_message; - for( item &new_item : new_items ) { - for( const std::string &flag : flags ) { - new_item.set_flag( flag_id( flag ) ); - } + item new_item = item( item_id, calendar::turn ); + for( const std::string &flag : flags ) { + new_item.set_flag( flag_id( flag ) ); + } + + if( !container_id.is_valid() ) { + if( new_item.count_by_charges() ) { + new_item.charges = count; if( add_talker ) { d.actor( false )->i_add_or_drop( new_item, force_equip ); } else { map_add_item( new_item, p ); } - if( add_talker && !suppress_message && d.has_beta && !d.actor( true )->disp_name().empty() ) { - if( new_item.count() == 1 ) { - //~ %1%s is the NPC name, %2$s is an item - popup_message += string_format( _( "%1$s gives you a %2$s." ), d.actor( true )->disp_name(), - new_item.tname() ) + "\n"; + } else { + for( int i_cnt = 0; i_cnt < count; i_cnt++ ) { + if( !new_item.ammo_default().is_null() ) { + new_item.ammo_set( new_item.ammo_default() ); + } + if( add_talker ) { + d.actor( false )->i_add_or_drop( new_item, force_equip ); } else { - //~ %1%s is the NPC name, %2$d is a number of items, %3$s are items - popup_message += string_format( _( "%1$s gives you %2$d %3$s." ), d.actor( true )->disp_name(), - new_item.count(), new_item.tname() ) + "\n"; + map_add_item( new_item, p ); } } } - if( !popup_message.empty() ) { - popup( popup_message ); + if( add_talker && !suppress_message && d.has_beta && !d.actor( true )->disp_name().empty() ) { + if( count == 1 ) { + //~ %1%s is the NPC name, %2$s is an item + popup( _( "%1$s gives you a %2$s." ), d.actor( true )->disp_name(), new_item.tname() ); + } else { + //~ %1%s is the NPC name, %2$d is a number of items, %3$s are items + popup( _( "%1$s gives you %2$d %3$s." ), d.actor( true )->disp_name(), count, + new_item.tname() ); + } } } else { - item new_item = item( item_name, calendar::turn ); + item container( container_id, calendar::turn ); + new_item.charges = count; + container.put_in( new_item, + pocket_type::CONTAINER ); + if( add_talker ) { + d.actor( false )->i_add_or_drop( container, force_equip ); + } else { + map_add_item( container, p ); + } + if( add_talker && !suppress_message && d.has_beta && !d.actor( true )->disp_name().empty() ) { + //~ %1%s is the NPC name, %2$s is an item + popup( _( "%1$s gives you a %2$s." ), d.actor( true )->disp_name(), container.tname() ); + } + } +} + +void receive_item_group( const item_group_id &group_id, const dialogue &d, bool suppress_message, + const std::vector &flags, bool add_talker = true, + const tripoint_abs_ms &p = tripoint_abs_ms(), bool force_equip = false ) +{ + item_group::ItemList new_items; + new_items = item_group::items_from( group_id, calendar::turn ); + std::string popup_message; + for( item &new_item : new_items ) { for( const std::string &flag : flags ) { new_item.set_flag( flag_id( flag ) ); } - if( container_name.empty() ) { - if( new_item.count_by_charges() ) { - new_item.charges = count; - if( add_talker ) { - d.actor( false )->i_add_or_drop( new_item, force_equip ); - } else { - map_add_item( new_item, p ); - } - } else { - for( int i_cnt = 0; i_cnt < count; i_cnt++ ) { - if( !new_item.ammo_default().is_null() ) { - new_item.ammo_set( new_item.ammo_default() ); - } - if( add_talker ) { - d.actor( false )->i_add_or_drop( new_item, force_equip ); - } else { - map_add_item( new_item, p ); - } - } - } - if( add_talker && !suppress_message && d.has_beta && !d.actor( true )->disp_name().empty() ) { - if( count == 1 ) { - //~ %1%s is the NPC name, %2$s is an item - popup( _( "%1$s gives you a %2$s." ), d.actor( true )->disp_name(), new_item.tname() ); - } else { - //~ %1%s is the NPC name, %2$d is a number of items, %3$s are items - popup( _( "%1$s gives you %2$d %3$s." ), d.actor( true )->disp_name(), count, - new_item.tname() ); - } - } + if( add_talker ) { + d.actor( false )->i_add_or_drop( new_item, force_equip ); } else { - //BEFOREMERGE: See if this can be changed to pass an itype_id - item container( itype_id( container_name ), calendar::turn ); - new_item.charges = count; - container.put_in( new_item, - pocket_type::CONTAINER ); - if( add_talker ) { - d.actor( false )->i_add_or_drop( container, force_equip ); - } else { - map_add_item( container, p ); - } - if( add_talker && !suppress_message && d.has_beta && !d.actor( true )->disp_name().empty() ) { + map_add_item( new_item, p ); + } + if( add_talker && !suppress_message && d.has_beta && !d.actor( true )->disp_name().empty() ) { + if( new_item.count() == 1 ) { //~ %1%s is the NPC name, %2$s is an item - popup( _( "%1$s gives you a %2$s." ), d.actor( true )->disp_name(), container.tname() ); + popup_message += string_format( _( "%1$s gives you a %2$s." ), d.actor( true )->disp_name(), + new_item.tname() ) + "\n"; + } else { + //~ %1%s is the NPC name, %2$d is a number of items, %3$s are items + popup_message += string_format( _( "%1$s gives you %2$d %3$s." ), d.actor( true )->disp_name(), + new_item.count(), new_item.tname() ) + "\n"; } } } + if( !popup_message.empty() ) { + popup( popup_message ); + } } talk_effect_fun_t f_spawn_item( const JsonObject &jo, std::string_view member, @@ -3681,15 +3684,22 @@ talk_effect_fun_t f_spawn_item( const JsonObject &jo, std::string_view member, } talk_effect_fun_t ret( [item_name, count, container_name, use_item_group, suppress_message, add_talker, loc_var, force_equip, flags]( dialogue & d ) { - itype_id iname = itype_id( item_name.evaluate( d ) ); const tripoint_abs_ms target_location = get_tripoint_from_var( loc_var, d, false ); std::vector flags_str; flags_str.reserve( flags.size() ); for( const str_or_var &flat_sov : flags ) { flags_str.emplace_back( flat_sov.evaluate( d ) ); } - receive_item( iname, count.evaluate( d ), container_name.evaluate( d ), d, use_item_group, - suppress_message, flags_str, add_talker, target_location, force_equip ); + if( use_item_group ) { + const item_group_id group_id = item_group_id( item_name.evaluate( d ) ); + receive_item_group( group_id, d, suppress_message, flags_str, add_talker, target_location, + force_equip ); + } else { + const itype_id item_id = itype_id( item_name.evaluate( d ) ); + const itype_id container_id = itype_id( container_name.evaluate( d ) ); + receive_item( item_id, count.evaluate( d ), container_id, d, suppress_message, + flags_str, add_talker, target_location, force_equip ); + } } ); ret.get_likely_rewards().emplace_back( count, item_name ); return ret; @@ -3728,14 +3738,20 @@ talk_effect_fun_t::func f_u_buy_item( const JsonObject &jo, std::string_view mem run_eoc_vector( false_eocs, d ); return; } - itype_id iname = itype_id( item_name.evaluate( d ) ); std::vector flags_str; flags_str.reserve( flags.size() ); for( const str_or_var &flat_sov : flags ) { flags_str.emplace_back( flat_sov.evaluate( d ) ); } - receive_item( iname, count.evaluate( d ), - container_name.evaluate( d ), d, use_item_group, suppress_message, flags_str ); + if( use_item_group ) { + const item_group_id group_id = item_group_id( item_name.evaluate( d ) ); + receive_item_group( group_id, d, suppress_message, flags_str ); + } else { + const itype_id item_id = itype_id( item_name.evaluate( d ) ); + const itype_id container_id = itype_id( container_name.evaluate( d ) ); + receive_item( item_id, count.evaluate( d ), container_id, d, suppress_message, + flags_str ); + } run_eoc_vector( true_eocs, d ); }; } From bd591a89b6a0ed15779fbaf9742dc5e829d3650b Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:43:09 +0000 Subject: [PATCH 06/14] Typify standard_npc constructor raw clothing strings --- src/npc.cpp | 7 +++---- src/npc.h | 2 +- tests/coverage_test.cpp | 4 ++-- tests/melee_test.cpp | 18 ++++++++++++------ tests/ranged_balance_test.cpp | 2 +- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/npc.cpp b/src/npc.cpp index 9071c193daf37..d2730d40203bd 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -270,7 +270,7 @@ npc::npc() } standard_npc::standard_npc( const std::string &name, const tripoint_bub_ms &pos, - const std::vector &clothing, + const std::vector &clothing, int sk_lvl, int s_str, int s_dex, int s_int, int s_per ) { this->name = name; @@ -295,9 +295,8 @@ standard_npc::standard_npc( const std::string &name, const tripoint_bub_ms &pos, set_skill_level( e.ident(), std::max( sk_lvl, 0 ) ); } - //BEFOREMERGE: Change to std::vector - for( const std::string &e : clothing ) { - wear_item( item( itype_id( e ) ), false ); + for( const itype_id &e : clothing ) { + wear_item( item( e ), false ); } worn.set_fitted(); diff --git a/src/npc.h b/src/npc.h index b640d177e7659..36c6110fcacb7 100644 --- a/src/npc.h +++ b/src/npc.h @@ -1472,7 +1472,7 @@ class standard_npc : public npc public: explicit standard_npc( const std::string &name = "", const tripoint_bub_ms &pos = tripoint_bub_ms( HALF_MAPSIZE_X, HALF_MAPSIZE_Y, 0 ), - const std::vector &clothing = {}, + const std::vector &clothing = {}, int sk_lvl = 4, int s_str = 8, int s_dex = 8, int s_int = 8, int s_per = 8 ); }; diff --git a/tests/coverage_test.cpp b/tests/coverage_test.cpp index efdced810edf2..a464c2b1ac889 100644 --- a/tests/coverage_test.cpp +++ b/tests/coverage_test.cpp @@ -139,9 +139,9 @@ static float get_avg_bullet_dmg( const itype_id &clothing_id ) { clear_map(); std::unique_ptr badguy = std::make_unique( "TestBaddie", - badguy_pos, std::vector(), 0, 8, 8, 8, 8 ); + badguy_pos, std::vector(), 0, 8, 8, 8, 8 ); std::unique_ptr dude = std::make_unique( "TestCharacter", - dude_pos, std::vector(), 0, 8, 8, 8, 8 ); + dude_pos, std::vector(), 0, 8, 8, 8, 8 ); item cloth( clothing_id ); projectile proj; proj.speed = 1000; diff --git a/tests/melee_test.cpp b/tests/melee_test.cpp index dbf5c273c4a23..4b0f6b1c5431d 100644 --- a/tests/melee_test.cpp +++ b/tests/melee_test.cpp @@ -21,7 +21,13 @@ static const damage_type_id damage_test_fire( "test_fire" ); static const efftype_id effect_sleep( "sleep" ); static const itype_id itype_2x4( "2x4" ); +static const itype_id itype_hoodie( "hoodie" ); +static const itype_id itype_jeans( "jeans" ); static const itype_id itype_katana( "katana" ); +static const itype_id itype_long_underpants( "long_underpants" ); +static const itype_id itype_long_undertop( "long_undertop" ); +static const itype_id itype_longshirt( "longshirt" ); +static const itype_id itype_survivor_suit( "survivor_suit" ); static const itype_id itype_test_fire_sword( "test_fire_sword" ); static const itype_id itype_test_zentai( "test_zentai" ); static const itype_id itype_test_zentai_immune_test_fire( "test_zentai_immune_test_fire" ); @@ -177,7 +183,7 @@ TEST_CASE( "Zombie_attacking_a_character", "[.melee]" ) SECTION( "10/10/10/10, 3 all skills, good cotton armor" ) { standard_npc dude( "TestCharacter", dude_pos, - { "hoodie", "jeans", "long_underpants", "long_undertop", "longshirt" }, + { itype_hoodie, itype_jeans, itype_long_underpants, itype_long_undertop, itype_longshirt }, 3, 10, 10, 10, 10 ); const float prob = brute_probability( zed, dude, num_iters ); INFO( "Has get_dodge() == " + std::to_string( dude.get_dodge() ) ); @@ -185,7 +191,7 @@ TEST_CASE( "Zombie_attacking_a_character", "[.melee]" ) } SECTION( "10/10/10/10, 8 all skills, survivor suit" ) { - standard_npc dude( "TestCharacter", dude_pos, { "survivor_suit" }, 8, 10, 10, 10, 10 ); + standard_npc dude( "TestCharacter", dude_pos, { itype_survivor_suit }, 8, 10, 10, 10, 10 ); const float prob = brute_probability( zed, dude, num_iters ); INFO( "Has get_dodge() == " + std::to_string( dude.get_dodge() ) ); check_near( prob, 0.025f, 0.0125f ); @@ -211,7 +217,7 @@ TEST_CASE( "Manhack_attacking_a_character", "[.melee]" ) SECTION( "10/10/10/10, 3 all skills, good cotton armor" ) { standard_npc dude( "TestCharacter", dude_pos, - { "hoodie", "jeans", "long_underpants", "long_undertop", "longshirt" }, + { itype_hoodie, itype_jeans, itype_long_underpants, itype_long_undertop, itype_longshirt }, 3, 10, 10, 10, 10 ); const float prob = brute_probability( manhack, dude, num_iters ); INFO( "Has get_dodge() == " + std::to_string( dude.get_dodge() ) ); @@ -219,7 +225,7 @@ TEST_CASE( "Manhack_attacking_a_character", "[.melee]" ) } SECTION( "10/10/10/10, 8 all skills, survivor suit" ) { - standard_npc dude( "TestCharacter", dude_pos, { "survivor_suit" }, 8, 10, 10, 10, 10 ); + standard_npc dude( "TestCharacter", dude_pos, { itype_survivor_suit }, 8, 10, 10, 10, 10 ); const float prob = brute_probability( manhack, dude, num_iters ); INFO( "Has get_dodge() == " + std::to_string( dude.get_dodge() ) ); check_near( prob, 0.25f, 0.05f ); @@ -245,7 +251,7 @@ TEST_CASE( "Hulk_smashing_a_character", "[.], [melee], [monattack]" ) SECTION( "10/10/10/10, 3 all skills, good cotton armor" ) { standard_npc dude( "TestCharacter", dude_pos, - { "hoodie", "jeans", "long_underpants", "long_undertop", "longshirt" }, + { itype_hoodie, itype_jeans, itype_long_underpants, itype_long_undertop, itype_longshirt }, 3, 10, 10, 10, 10 ); const float prob = brute_special_probability( zed, dude, num_iters ); INFO( "Has get_dodge() == " + std::to_string( dude.get_dodge() ) ); @@ -253,7 +259,7 @@ TEST_CASE( "Hulk_smashing_a_character", "[.], [melee], [monattack]" ) } SECTION( "10/10/10/10, 8 all skills, survivor suit" ) { - standard_npc dude( "TestCharacter", dude_pos, { "survivor_suit" }, 8, 10, 10, 10, 10 ); + standard_npc dude( "TestCharacter", dude_pos, { itype_survivor_suit }, 8, 10, 10, 10, 10 ); const float prob = brute_special_probability( zed, dude, num_iters ); INFO( "Has get_dodge() == " + std::to_string( dude.get_dodge() ) ); check_near( prob, 0.2f, 0.05f ); diff --git a/tests/ranged_balance_test.cpp b/tests/ranged_balance_test.cpp index 8e0265267ef49..149048a76092b 100644 --- a/tests/ranged_balance_test.cpp +++ b/tests/ranged_balance_test.cpp @@ -499,7 +499,7 @@ static void shoot_monster( const itype_id &gun_type, const std::vector const tripoint_bub_ms monster_pos = shooter_pos + ( point::east * range ); std::unique_ptr shooter = std::make_unique( "Shooter", shooter_pos, - std::vector(), 5, 10, 10, 10, 10 ); + std::vector(), 5, 10, 10, 10, 10 ); int other_check_success = 0; do { shooter->set_body(); From 4dfd2cfc2cf8d3ba9738937d2d2b6cf75436e9ce Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:43:32 +0000 Subject: [PATCH 07/14] Typify liquid_source_item_id raw string --- src/map.cpp | 13 +++++-------- src/mapdata.h | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/map.cpp b/src/map.cpp index 9f467aac34ad7..e479449ca5730 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2374,9 +2374,9 @@ bool map::ter_set( const tripoint_bub_ms &p, const ter_id &new_terrain, bool avo set_seen_cache_dirty( p ); } - if( !new_t.liquid_source_item_id.empty() && new_t.liquid_source_count != std::make_pair( 0, 0 ) ) { - //BEFOREMERGE: Typify raw string ter_t::liquid_source_item_id - item water( itype_id( new_t.liquid_source_item_id ), calendar::start_of_cataclysm ); + if( new_t.liquid_source_item_id.is_valid() && + new_t.liquid_source_count != std::make_pair( 0, 0 ) ) { + item water( new_t.liquid_source_item_id, calendar::start_of_cataclysm ); water.charges = rng( new_t.liquid_source_count.first, new_t.liquid_source_count.second ); add_item( p, water ); } @@ -5668,12 +5668,9 @@ item map::liquid_from( const tripoint_bub_ms &p ) const weather_manager &weather = get_weather(); ter_t source_terrain = ter( p ).obj(); - if( !source_terrain.liquid_source_item_id.empty() && + if( source_terrain.liquid_source_item_id.is_valid() && source_terrain.liquid_source_count == std::make_pair( 0, 0 ) ) { - - //BEFOREMERGE: Typify raw string ter_t::liquid_source_item_id - item ret( itype_id( source_terrain.liquid_source_item_id ), calendar::turn, - item::INFINITE_CHARGES ); + item ret( source_terrain.liquid_source_item_id, calendar::turn, item::INFINITE_CHARGES ); ret.set_item_temperature( std::max( weather.get_temperature( p ), units::from_celsius( source_terrain.liquid_source_min_temp ) ) ); return ret; diff --git a/src/mapdata.h b/src/mapdata.h index d0bfec3dbf551..509a27c013439 100644 --- a/src/mapdata.h +++ b/src/mapdata.h @@ -539,7 +539,7 @@ struct map_data_common_t { // Maximal volume of items that can be stored in/on this furniture/terrain units::volume max_volume = DEFAULT_TILE_VOLUME; - std::string liquid_source_item_id; // id of a liquid this tile provides + itype_id liquid_source_item_id = itype_id::NULL_ID(); // id of a liquid this tile provides double liquid_source_min_temp = 4; // in centigrades, cold water as default value std::pair liquid_source_count = { 0, 0 }; // charges of liquid, if it's finite source From 63237a5e68a2bf385885054b4930be15e0a0560d Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:46:12 +0000 Subject: [PATCH 08/14] Couple of obvious catches before a proper review --- tests/ranged_balance_test.cpp | 16 ++++++++-------- tests/temp_crafting_inv_test.cpp | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/ranged_balance_test.cpp b/tests/ranged_balance_test.cpp index 149048a76092b..7b4b25b666fac 100644 --- a/tests/ranged_balance_test.cpp +++ b/tests/ranged_balance_test.cpp @@ -39,14 +39,14 @@ character_modifier_ranged_dispersion_manip_mod( "ranged_dispersion_manip_mod" ); static const itype_id itype_556_m855a1( "556_m855a1" ); static const itype_id itype_M24( "M24" ); -static const itype_id itype_armguard_hard( "itype_armguard_hard" ); -static const itype_id itype_armguard_soft( "itype_armguard_soft" ); +static const itype_id itype_armguard_hard( "armguard_hard" ); +static const itype_id itype_armguard_soft( "armguard_soft" ); static const itype_id itype_arrow_cf( "arrow_cf" ); static const itype_id itype_arrow_field_point_fletched( "arrow_field_point_fletched" ); static const itype_id itype_backpack( "backpack" ); static const itype_id itype_balclava( "balclava" ); -static const itype_id itype_bastsandals( "itype_bastsandals" ); -static const itype_id itype_beekeeping_gloves( "itype_beekeeping_gloves" ); +static const itype_id itype_bastsandals( "bastsandals" ); +static const itype_id itype_beekeeping_gloves( "beekeeping_gloves" ); static const itype_id itype_bolt_cf( "bolt_cf" ); static const itype_id itype_bolt_makeshift( "bolt_makeshift" ); static const itype_id itype_bolt_steel( "bolt_steel" ); @@ -57,18 +57,18 @@ static const itype_id itype_cloak_wool( "cloak_wool" ); static const itype_id itype_compbow_high( "compbow_high" ); static const itype_id itype_compcrossbow( "compcrossbow" ); static const itype_id itype_compositecrossbow( "compositecrossbow" ); -static const itype_id itype_cowboy_hat( "itype_cowboy_hat" ); +static const itype_id itype_cowboy_hat( "cowboy_hat" ); static const itype_id itype_crossbow( "crossbow" ); static const itype_id itype_debug_modular_m4_carbine( "debug_modular_m4_carbine" ); static const itype_id itype_fn_p90( "fn_p90" ); static const itype_id itype_footrags_wool( "footrags_wool" ); static const itype_id itype_glasses_safety( "glasses_safety" ); -static const itype_id itype_glock_19( "itype_glock_19" ); +static const itype_id itype_glock_19( "glock_19" ); static const itype_id itype_gloves_wraps_fur( "gloves_wraps_fur" ); static const itype_id itype_hk_mp5( "hk_mp5" ); static const itype_id itype_holo_sight( "holo_sight" ); static const itype_id itype_m14ebr( "m14ebr" ); -static const itype_id itype_mask_guy_fawkes( "itype_mask_guy_fawkes" ); +static const itype_id itype_mask_guy_fawkes( "mask_guy_fawkes" ); static const itype_id itype_mossberg_590( "mossberg_590" ); static const itype_id itype_mossberg_930( "mossberg_930" ); static const itype_id itype_mp40semi( "mp40semi" ); @@ -83,7 +83,7 @@ static const itype_id itype_shotgun_s( "shotgun_s" ); static const itype_id itype_sw629( "sw629" ); static const itype_id itype_sw_619( "sw_619" ); static const itype_id itype_tele_sight( "tele_sight" ); -static const itype_id itype_test_armor_chitin( "itype_test_armor_chitin" ); +static const itype_id itype_test_armor_chitin( "test_armor_chitin" ); static const itype_id itype_test_shot_00_fire_damage( "test_shot_00_fire_damage" ); using firing_statistics = statistics; diff --git a/tests/temp_crafting_inv_test.cpp b/tests/temp_crafting_inv_test.cpp index d25f7be89da30..dc684253f8170 100644 --- a/tests/temp_crafting_inv_test.cpp +++ b/tests/temp_crafting_inv_test.cpp @@ -6,7 +6,7 @@ static const itype_id itype_test_fire_ax( "test_fire_ax" ); static const itype_id itype_test_gum( "test_gum" ); -static const itype_id itype_test_halligan( "itype_test_halligan" ); +static const itype_id itype_test_halligan( "test_halligan" ); static const quality_id qual_AXE( "AXE" ); static const quality_id qual_DIG( "DIG" ); From 020dce728d53dcd6aa4a3953bf05b10950665a25 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Fri, 10 Jan 2025 17:19:45 +0000 Subject: [PATCH 09/14] Post rebase astyle --- tests/archery_damage_test.cpp | 6 ++++-- tests/ranged_balance_test.cpp | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/archery_damage_test.cpp b/tests/archery_damage_test.cpp index 1c05eacd380ee..55be9aa981513 100644 --- a/tests/archery_damage_test.cpp +++ b/tests/archery_damage_test.cpp @@ -125,12 +125,14 @@ TEST_CASE( "archery_damage_thresholds", "[balance],[archery]" ) test_archery_balance( itype_rep_crossbow, itype_bolt_makeshift, "", "test_mon_turkey", true ); // Shortbow can kill turkeys, but not deer test_archery_balance( itype_shortbow, itype_arrow_metal, "test_mon_turkey", "test_mon_deer", true ); - test_archery_balance( itype_hand_crossbow, itype_bolt_steel, "test_mon_turkey", "test_mon_deer", true ); + test_archery_balance( itype_hand_crossbow, itype_bolt_steel, "test_mon_turkey", "test_mon_deer", + true ); // Fiberglass recurve can kill deer with an accurate hit, but not bear test_archery_balance( itype_recurbow, itype_arrow_metal, "", "test_mon_deer", false ); test_archery_balance( itype_compositecrossbow, itype_bolt_steel, "", "test_mon_deer", false ); test_archery_balance( itype_recurbow, itype_arrow_metal, "test_mon_deer", "test_mon_bear", true ); - test_archery_balance( itype_compositecrossbow, itype_bolt_steel, "test_mon_deer", "test_mon_bear", true ); + test_archery_balance( itype_compositecrossbow, itype_bolt_steel, "test_mon_deer", "test_mon_bear", + true ); // Medium setting compound bow can kill Bear test_archery_balance( itype_compbow, itype_arrow_metal, "", "test_mon_bear", false ); test_archery_balance( itype_compbow, itype_arrow_metal, "test_mon_bear", "", true ); diff --git a/tests/ranged_balance_test.cpp b/tests/ranged_balance_test.cpp index 297b0ede5de0e..e24bf92d948a6 100644 --- a/tests/ranged_balance_test.cpp +++ b/tests/ranged_balance_test.cpp @@ -611,10 +611,14 @@ TEST_CASE( "shot_features_with_choke", "[gun]" "[slow]" ) shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_bird, 1, 61, "mon_zombie_brute" ); // Unarmored target - shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 18, 95, "mon_test_shotgun_0_bullet" ); - shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 12, 131, "mon_test_shotgun_0_bullet" ); - shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 5, 185, "mon_test_shotgun_0_bullet" ); - shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 1, 75, "mon_test_shotgun_0_bullet" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 18, 95, + "mon_test_shotgun_0_bullet" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 12, 131, + "mon_test_shotgun_0_bullet" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 5, 185, + "mon_test_shotgun_0_bullet" ); + shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 1, 75, + "mon_test_shotgun_0_bullet" ); // Triviallly armored target (armor_bullet: 1) shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 18, 32, "mon_zombie_tough" ); shoot_monster( itype_shotgun_s, { itype_choke }, itype_shot_00, 12, 61, "mon_zombie_tough" ); From 3353ba8b15a4b4d203eb4d4a7a3fef4a99afc7c9 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Fri, 10 Jan 2025 19:11:38 +0000 Subject: [PATCH 10/14] Make set_var TODO the suggestion I intended it to be and move it to a more appropriate spot --- src/item.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/item.h b/src/item.h index 6e755f5380bc7..133cf499a58d8 100644 --- a/src/item.h +++ b/src/item.h @@ -1939,7 +1939,6 @@ class item : public visitable * */ /*@{*/ - //TODO: Add a set_var( const std::string &name, const cata_variant &id ) overload rather than using raw strings where appropriate void set_var( const std::string &name, int value ); void set_var( const std::string &name, long long value ); // Acceptable to use long as part of overload set @@ -1949,6 +1948,7 @@ class item : public visitable double get_var( const std::string &name, double default_value ) const; void set_var( const std::string &name, const tripoint_abs_omt &value ); tripoint_abs_omt get_var( const std::string &name, const tripoint_abs_omt &default_value ) const; + //TODO: Add cata_variant overload for value here and for get_var rather than using raw strings where appropriate? void set_var( const std::string &name, const std::string &value ); std::string get_var( const std::string &name, const std::string &default_value ) const; /** Get the variable, if it does not exists, returns an empty string. */ From 4c0990e8856e77b05547f6bbc4026e436a346b38 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Fri, 10 Jan 2025 19:35:22 +0000 Subject: [PATCH 11/14] Check against the null id instead bc itype_id s null appears to be valid and isn't being chucked out during the item constructor? --- src/map.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/map.cpp b/src/map.cpp index c7072d77313b3..63a95d76a8ab4 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2299,7 +2299,7 @@ bool map::ter_set( const tripoint_bub_ms &p, const ter_id &new_terrain, bool avo set_seen_cache_dirty( p ); } - if( new_t.liquid_source_item_id.is_valid() && + if( !new_t.liquid_source_item_id.is_null() && new_t.liquid_source_count != std::make_pair( 0, 0 ) ) { item water( new_t.liquid_source_item_id, calendar::start_of_cataclysm ); water.charges = rng( new_t.liquid_source_count.first, new_t.liquid_source_count.second ); @@ -5580,7 +5580,7 @@ item map::liquid_from( const tripoint_bub_ms &p ) const weather_manager &weather = get_weather(); ter_t source_terrain = ter( p ).obj(); - if( source_terrain.liquid_source_item_id.is_valid() && + if( !source_terrain.liquid_source_item_id.is_null() && source_terrain.liquid_source_count == std::make_pair( 0, 0 ) ) { item ret( source_terrain.liquid_source_item_id, calendar::turn, item::INFINITE_CHARGES ); ret.set_item_temperature( std::max( weather.get_temperature( p ), From 183e7f60e5a91c31d823b0c2bb21391792d31035 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Fri, 10 Jan 2025 19:35:46 +0000 Subject: [PATCH 12/14] Explicitly define used_up_item's default --- src/iuse_actor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/iuse_actor.h b/src/iuse_actor.h index 5a3e8319530a9..3b1aa9d016e4f 100644 --- a/src/iuse_actor.h +++ b/src/iuse_actor.h @@ -273,7 +273,7 @@ class consume_drug_iuse : public iuse_actor void info( const item &, std::vector & ) const override; /** Item produced after using drugs. */ - itype_id used_up_item; + itype_id used_up_item = itype_id::NULL_ID(); }; /** From 2a922a6c59f2be6895daa1370ae317276ece897d Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Fri, 10 Jan 2025 20:14:36 +0000 Subject: [PATCH 13/14] Appease our clang overlords Failing to remember Z before a strikes again --- src/character.cpp | 2 +- src/monattack.cpp | 2 +- tests/ammo_set_test.cpp | 2 +- tests/bionics_test.cpp | 4 ++-- tests/clzones_test.cpp | 3 ++- tests/crafting_test.cpp | 4 ++-- tests/encumbrance_test.cpp | 2 +- tests/itemname_test.cpp | 2 +- tests/iuse_test.cpp | 2 +- tests/modify_morale_test.cpp | 2 +- tests/npc_test.cpp | 2 +- tests/tool_quality_test.cpp | 2 +- tests/vehicle_interact_test.cpp | 2 +- tests/water_movement_test.cpp | 19 +++++++++++-------- 14 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/character.cpp b/src/character.cpp index 6152b012f1818..2c3f7850ffefa 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -291,9 +291,9 @@ static const itype_id itype_fire( "fire" ); static const itype_id itype_foodperson_mask( "foodperson_mask" ); static const itype_id itype_foodperson_mask_on( "foodperson_mask_on" ); static const itype_id itype_human_sample( "human_sample" ); +static const itype_id itype_rm13_armor_on( "rm13_armor_on" ); static const itype_id itype_rope_6( "rope_6" ); static const itype_id itype_snare_trigger( "snare_trigger" ); -static const itype_id itype_rm13_armor_on( "rm13_armor_on" ); static const json_character_flag json_flag_ACIDBLOOD( "ACIDBLOOD" ); static const json_character_flag json_flag_ALARMCLOCK( "ALARMCLOCK" ); diff --git a/src/monattack.cpp b/src/monattack.cpp index 287e36c742974..18e2bdb9e664d 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -155,8 +155,8 @@ static const itype_id itype_bot_gasbomb_hack( "bot_gasbomb_hack" ); static const itype_id itype_bot_grenade_hack( "bot_grenade_hack" ); static const itype_id itype_bot_mininuke_hack( "bot_mininuke_hack" ); static const itype_id itype_bot_pacification_hack( "bot_pacification_hack" ); -static const itype_id itype_processor( "processor" ); static const itype_id itype_e_handcuffs( "e_handcuffs" ); +static const itype_id itype_processor( "processor" ); static const itype_id itype_sporeos( "sporeos" ); static const json_character_flag json_flag_BIONIC_LIMB( "BIONIC_LIMB" ); diff --git a/tests/ammo_set_test.cpp b/tests/ammo_set_test.cpp index 2c5d3b19264c3..30bf78ebd7b26 100644 --- a/tests/ammo_set_test.cpp +++ b/tests/ammo_set_test.cpp @@ -13,12 +13,12 @@ #include "type_id.h" #include "value_ptr.h" +static const itype_id itype_M24( "M24" ); static const itype_id itype_box_small( "box_small" ); static const itype_id itype_cz75( "cz75" ); static const itype_id itype_cz75mag_16rd( "cz75mag_16rd" ); static const itype_id itype_cz75mag_20rd( "cz75mag_20rd" ); static const itype_id itype_cz75mag_26rd( "cz75mag_26rd" ); -static const itype_id itype_M24( "M24" ); TEST_CASE( "ammo_set_items_with_MAGAZINE_pockets", "[ammo_set][magazine][ammo]" ) { diff --git a/tests/bionics_test.cpp b/tests/bionics_test.cpp index 8c5b03a08240c..421a224c869c7 100644 --- a/tests/bionics_test.cpp +++ b/tests/bionics_test.cpp @@ -36,14 +36,14 @@ static const bionic_id bio_surgical_razor( "bio_surgical_razor" ); static const flag_id json_flag_PSEUDO( "PSEUDO" ); static const itype_id fuel_type_gasoline( "gasoline" ); +static const itype_id itype_UPS_ON( "UPS_ON" ); static const itype_id itype_backpack( "backpack" ); -static const itype_id itype_light_battery_cell( "light_battery_cell" ); static const itype_id itype_jumper_cable( "jumper_cable" ); +static const itype_id itype_light_battery_cell( "light_battery_cell" ); static const itype_id itype_pants_cargo( "pants_cargo" ); static const itype_id itype_solarpack_on( "solarpack_on" ); static const itype_id itype_splinter( "splinter" ); static const itype_id itype_test_backpack( "test_backpack" ); -static const itype_id itype_UPS_ON( "UPS_ON" ); TEST_CASE( "Bionic_power_capacity", "[bionics] [power]" ) { diff --git a/tests/clzones_test.cpp b/tests/clzones_test.cpp index 6d18152306a1e..9144addcd79c5 100644 --- a/tests/clzones_test.cpp +++ b/tests/clzones_test.cpp @@ -15,13 +15,14 @@ #include "type_id.h" static const activity_id ACT_MOVE_LOOT( "ACT_MOVE_LOOT" ); + static const faction_id faction_your_followers( "your_followers" ); static const itype_id itype_556( "556" ); static const itype_id itype_ammolink223( "ammolink223" ); static const itype_id itype_belt223( "belt223" ); -static const itype_id itype_test_bitter_almond( "test_bitter_almond" ); static const itype_id itype_test_apple( "test_apple" ); +static const itype_id itype_test_bitter_almond( "test_bitter_almond" ); static const itype_id itype_test_milk( "test_milk" ); static const itype_id itype_test_watertight_open_sealed_container_250ml( "test_watertight_open_sealed_container_250ml" ); diff --git a/tests/crafting_test.cpp b/tests/crafting_test.cpp index 8c7aa13b540d0..83a1a557fa90c 100644 --- a/tests/crafting_test.cpp +++ b/tests/crafting_test.cpp @@ -52,6 +52,8 @@ static const flag_id json_flag_USE_UPS( "USE_UPS" ); static const furn_str_id furn_f_smoking_rack( "f_smoking_rack" ); static const itype_id itype_2x4( "2x4" ); +static const itype_id itype_UPS_ON( "UPS_ON" ); +static const itype_id itype_UPS_off( "UPS_off" ); static const itype_id itype_amplifier( "amplifier" ); static const itype_id itype_awl_bone( "awl_bone" ); static const itype_id itype_backpack( "backpack" ); @@ -108,8 +110,6 @@ static const itype_id itype_test_gum( "test_gum" ); static const itype_id itype_test_storage_battery( "test_storage_battery" ); static const itype_id itype_test_ups( "test_ups" ); static const itype_id itype_thread( "thread" ); -static const itype_id itype_UPS_ON( "UPS_ON" ); -static const itype_id itype_UPS_off( "UPS_off" ); static const itype_id itype_vac_mold( "vac_mold" ); static const itype_id itype_water( "water" ); static const itype_id itype_water_clean( "water_clean" ); diff --git a/tests/encumbrance_test.cpp b/tests/encumbrance_test.cpp index 046e21706e748..864a8e4a01fc2 100644 --- a/tests/encumbrance_test.cpp +++ b/tests/encumbrance_test.cpp @@ -13,10 +13,10 @@ static const flag_id json_flag_UNDERSIZE( "UNDERSIZE" ); +static const itype_id itype_holster( "holster" ); static const itype_id itype_test_ballistic_vest( "test_ballistic_vest" ); static const itype_id itype_test_complex_phase( "test_complex_phase" ); static const itype_id itype_test_ghost_vest( "test_ghost_vest" ); -static const itype_id itype_holster( "holster" ); static const itype_id itype_test_jacket_jean( "test_jacket_jean" ); static const itype_id itype_test_load_bearing_vest( "test_load_bearing_vest" ); static const itype_id itype_test_longshirt( "test_longshirt" ); diff --git a/tests/itemname_test.cpp b/tests/itemname_test.cpp index f08fa2ef447db..a02754b625979 100644 --- a/tests/itemname_test.cpp +++ b/tests/itemname_test.cpp @@ -12,9 +12,9 @@ #include "ret_val.h" #include "type_id.h" -static const itype_id itype_butter( "butter" ); static const itype_id itype_bookplate( "bookplate" ); static const itype_id itype_bootsheath( "bootsheath" ); +static const itype_id itype_butter( "butter" ); static const itype_id itype_test_arrow_wood( "test_arrow_wood" ); static const itype_id itype_test_quiver( "test_quiver" ); static const itype_id itype_tunic( "tunic" ); diff --git a/tests/iuse_test.cpp b/tests/iuse_test.cpp index cc7248a30ffb1..419492eeba4eb 100644 --- a/tests/iuse_test.cpp +++ b/tests/iuse_test.cpp @@ -59,8 +59,8 @@ static const itype_id itype_inhaler( "inhaler" ); static const itype_id itype_oxygen( "oxygen" ); static const itype_id itype_oxygen_tank( "oxygen_tank" ); static const itype_id itype_panacea( "panacea" ); -static const itype_id itype_pur_tablets( "pur_tablets" ); static const itype_id itype_prozac( "prozac" ); +static const itype_id itype_pur_tablets( "pur_tablets" ); static const itype_id itype_saline( "saline" ); static const itype_id itype_thorazine( "thorazine" ); static const itype_id itype_towel( "towel" ); diff --git a/tests/modify_morale_test.cpp b/tests/modify_morale_test.cpp index 2cfbe314d6fcb..55f3911bd8061 100644 --- a/tests/modify_morale_test.cpp +++ b/tests/modify_morale_test.cpp @@ -22,8 +22,8 @@ static const itype_id itype_broccoli( "broccoli" ); static const itype_id itype_caff_gum( "caff_gum" ); static const itype_id itype_caffeine( "caffeine" ); static const itype_id itype_cig( "cig" ); -static const itype_id itype_codeine( "codeine" ); static const itype_id itype_cigar( "cigar" ); +static const itype_id itype_codeine( "codeine" ); static const itype_id itype_crack( "crack" ); static const itype_id itype_dayquil( "dayquil" ); static const itype_id itype_disinfectant( "disinfectant" ); diff --git a/tests/npc_test.cpp b/tests/npc_test.cpp index 62e5805cf1617..2dd1b0410f1ed 100644 --- a/tests/npc_test.cpp +++ b/tests/npc_test.cpp @@ -43,8 +43,8 @@ static const efftype_id effect_sleep( "sleep" ); static const item_group_id Item_spawn_data_test_NPC_guns( "test_NPC_guns" ); static const item_group_id Item_spawn_data_trash_forest( "trash_forest" ); -static const itype_id itype_debug_backpack( "debug_backpack" ); static const itype_id itype_M24( "M24" ); +static const itype_id itype_debug_backpack( "debug_backpack" ); static const trait_id trait_WEB_WEAVER( "WEB_WEAVER" ); diff --git a/tests/tool_quality_test.cpp b/tests/tool_quality_test.cpp index d184cdc5b9016..204672af5091f 100644 --- a/tests/tool_quality_test.cpp +++ b/tests/tool_quality_test.cpp @@ -4,6 +4,7 @@ #include "player_helpers.h" #include "type_id.h" +static const itype_id itype_UPS_ON( "UPS_ON" ); static const itype_id itype_battery_ups( "battery_ups" ); static const itype_id itype_debug_backpack( "debug_backpack" ); static const itype_id itype_heavy_battery_cell( "heavy_battery_cell" ); @@ -12,7 +13,6 @@ static const itype_id itype_test_can_food( "test_can_food" ); static const itype_id itype_test_cordless_drill( "test_cordless_drill" ); static const itype_id itype_test_liquid( "test_liquid" ); static const itype_id itype_test_sonic_screwdriver( "test_sonic_screwdriver" ); -static const itype_id itype_UPS_ON( "UPS_ON" ); static const quality_id qual_BOIL( "BOIL" ); static const quality_id qual_DRILL( "DRILL" ); diff --git a/tests/vehicle_interact_test.cpp b/tests/vehicle_interact_test.cpp index 8a959df6d3b67..3d00cc59593b5 100644 --- a/tests/vehicle_interact_test.cpp +++ b/tests/vehicle_interact_test.cpp @@ -21,13 +21,13 @@ #include "veh_type.h" #include "vehicle.h" +static const itype_id itype_UPS_ON( "UPS_ON" ); static const itype_id itype_battery_ups( "battery_ups" ); static const itype_id itype_debug_backpack( "debug_backpack" ); static const itype_id itype_goggles_welding( "goggles_welding" ); static const itype_id itype_hammer( "hammer" ); static const itype_id itype_lc_steel_chunk( "lc_steel_chunk" ); static const itype_id itype_test_storage_battery( "test_storage_battery" ); -static const itype_id itype_UPS_ON( "UPS_ON" ); static const itype_id itype_welder( "welder" ); static const itype_id itype_welding_wire_steel( "welding_wire_steel" ); diff --git a/tests/water_movement_test.cpp b/tests/water_movement_test.cpp index 63eaa463f63d2..0ae9d2637ab7a 100644 --- a/tests/water_movement_test.cpp +++ b/tests/water_movement_test.cpp @@ -14,9 +14,20 @@ #include "player_helpers.h" #include "type_id.h" +static const efftype_id effect_winded( "winded" ); + static const itype_id itype_flotation_vest( "flotation_vest" ); static const itype_id itype_swim_fins( "swim_fins" ); +static const move_mode_id move_mode_crouch( "crouch" ); +static const move_mode_id move_mode_prone( "prone" ); +static const move_mode_id move_mode_run( "run" ); +static const move_mode_id move_mode_walk( "walk" ); + +static const skill_id skill_swimming( "swimming" ); + +static const trait_id trait_DISIMMUNE( "DISIMMUNE" ); + static void setup_test_lake() { const ter_id t_water_dp( "t_water_dp" ); @@ -150,14 +161,6 @@ TEST_CASE( "avatar_diving", "[diving]" ) g->vertical_shift( 0 ); } -static const efftype_id effect_winded( "winded" ); -static const move_mode_id move_mode_crouch( "crouch" ); -static const move_mode_id move_mode_prone( "prone" ); -static const move_mode_id move_mode_run( "run" ); -static const move_mode_id move_mode_walk( "walk" ); -static const skill_id skill_swimming( "swimming" ); -static const trait_id trait_DISIMMUNE( "DISIMMUNE" ); - struct swimmer_stats { int strength = 0; int dexterity = 0; From 049fc35bb91fc670c089747b3d9359c854b3e069 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Fri, 10 Jan 2025 23:41:32 +0000 Subject: [PATCH 14/14] Correct new int id order --- tests/iteminfo_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/iteminfo_test.cpp b/tests/iteminfo_test.cpp index 00d30fd1d1489..9a3db00d2cf49 100644 --- a/tests/iteminfo_test.cpp +++ b/tests/iteminfo_test.cpp @@ -3128,8 +3128,8 @@ TEST_CASE( "final_info", "[iteminfo][final]" ) CHECK( item_info_str( wine_must, brew_products ) == "--\n" - "* Fermenting this will produce yeast.\n" - "* Fermenting this will produce test tennis ball wine.\n" ); + "* Fermenting this will produce test tennis ball wine.\n" + "* Fermenting this will produce yeast.\n" ); } SECTION( "radioactivity" ) {