void mission_type::load( JsonObject &jo, const std::string & ) { mandatory( jo, was_loaded, "name", name, translated_string_reader ); mandatory( jo, was_loaded, "difficulty", difficulty ); mandatory( jo, was_loaded, "value", value ); auto djo = jo.get_object( "dialogue" ); // @todo There should be a cleaner way to do it mandatory( djo, was_loaded, "describe", dialogue[ "describe" ] ); mandatory( djo, was_loaded, "offer", dialogue[ "offer" ] ); mandatory( djo, was_loaded, "accepted", dialogue[ "accepted" ] ); mandatory( djo, was_loaded, "rejected", dialogue[ "rejected" ] ); mandatory( djo, was_loaded, "advice", dialogue[ "advice" ] ); mandatory( djo, was_loaded, "inquire", dialogue[ "inquire" ] ); mandatory( djo, was_loaded, "success", dialogue[ "success" ] ); mandatory( djo, was_loaded, "success_lie", dialogue[ "success_lie" ] ); mandatory( djo, was_loaded, "failure", dialogue[ "failure" ] ); optional( jo, was_loaded, "urgent", urgent ); optional( jo, was_loaded, "item", item_id ); optional( jo, was_loaded, "count", item_count, 1 ); goal = jo.get_enum_value<decltype(goal)>( "goal" ); assign_function( jo, "place", place, tripoint_function_map ); assign_function( jo, "start", start, mission_function_map ); assign_function( jo, "end", end, mission_function_map ); assign_function( jo, "fail", fail, mission_function_map ); if( jo.has_int( "deadline_low" ) ) { deadline_low = DAYS( jo.get_int( "deadline_low" ) ); } if( jo.has_int( "deadline_high" ) ) { deadline_high = DAYS( jo.get_int( "deadline_high" ) ); } if( jo.has_member( "origins" ) ) { origins.clear(); for( auto &m : jo.get_tags( "origins" ) ) { origins.emplace_back( io::string_to_enum_look_up( io::origin_map, m ) ); } } if( jo.has_member( "followup" ) ) { follow_up = mission_type_id( jo.get_string( "followup" ) ); } if( jo.has_member( "destination" ) ) { target_id = oter_id( jo.get_string( "destination" ) ); } }
void mission_type::load( JsonObject &jo, const std::string &src ) { const bool strict = src == "dda"; mandatory( jo, was_loaded, "name", name ); mandatory( jo, was_loaded, "difficulty", difficulty ); mandatory( jo, was_loaded, "value", value ); if( jo.has_member( "origins" ) ) { origins.clear(); for( auto &m : jo.get_tags( "origins" ) ) { origins.emplace_back( io::string_to_enum_look_up( io::origin_map, m ) ); } } if( std::any_of( origins.begin(), origins.end(), []( mission_origin origin ) { return origin == ORIGIN_ANY_NPC || origin == ORIGIN_OPENER_NPC || origin == ORIGIN_SECONDARY; } ) ) { auto djo = jo.get_object( "dialogue" ); // TODO: There should be a cleaner way to do it mandatory( djo, was_loaded, "describe", dialogue[ "describe" ] ); mandatory( djo, was_loaded, "offer", dialogue[ "offer" ] ); mandatory( djo, was_loaded, "accepted", dialogue[ "accepted" ] ); mandatory( djo, was_loaded, "rejected", dialogue[ "rejected" ] ); mandatory( djo, was_loaded, "advice", dialogue[ "advice" ] ); mandatory( djo, was_loaded, "inquire", dialogue[ "inquire" ] ); mandatory( djo, was_loaded, "success", dialogue[ "success" ] ); mandatory( djo, was_loaded, "success_lie", dialogue[ "success_lie" ] ); mandatory( djo, was_loaded, "failure", dialogue[ "failure" ] ); } optional( jo, was_loaded, "urgent", urgent ); optional( jo, was_loaded, "item", item_id ); optional( jo, was_loaded, "count", item_count, 1 ); goal = jo.get_enum_value<decltype( goal )>( "goal" ); assign_function( jo, "place", place, tripoint_function_map ); if( jo.has_string( "start" ) ) { assign_function( jo, "start", start, mission_function_map ); } else if( jo.has_member( "start" ) ) { JsonObject j_start = jo.get_object( "start" ); parse_start( j_start ); } assign_function( jo, "end", end, mission_function_map ); assign_function( jo, "fail", fail, mission_function_map ); assign( jo, "deadline_low", deadline_low, false, 1_days ); assign( jo, "deadline_high", deadline_high, false, 1_days ); if( jo.has_member( "followup" ) ) { follow_up = mission_type_id( jo.get_string( "followup" ) ); } if( jo.has_member( "monster_species" ) ) { monster_species = species_id( jo.get_string( "monster_species" ) ); } if( jo.has_member( "monster_type" ) ) { monster_type = mtype_id( jo.get_string( "monster_type" ) ); } if( jo.has_member( "monster_kill_goal" ) ) { monster_kill_goal = jo.get_int( "monster_kill_goal" ); } assign( jo, "destination", target_id, strict ); }