diff --git a/data/json/recipes/recipe_electronics.json b/data/json/recipes/recipe_electronics.json index 938417cc885e3..e952994b3f131 100644 --- a/data/json/recipes/recipe_electronics.json +++ b/data/json/recipes/recipe_electronics.json @@ -595,7 +595,7 @@ "skills_required": [ "computer", 1 ], "difficulty": 5, "time": "40 m", - "reversible": true, + "reversible": "5 m", "//": "you might be able to reverse-engineer assembly, but not the music", "book_learn": [ [ "textbook_electronics", 6 ], [ "textbook_robots", 5 ] ], "using": [ [ "soldering_standard", 5 ] ], @@ -611,7 +611,7 @@ "skills_required": [ "computer", 5 ], "difficulty": 8, "time": "1 h", - "reversible": true, + "reversible": "12 m", "//": "as with mp3, no learning how to encode the software from taking it apart", "book_learn": [ [ "textbook_electronics", 7 ], [ "textbook_robots", 6 ] ], "using": [ [ "soldering_standard", 10 ] ], diff --git a/doc/JSON_INFO.md b/doc/JSON_INFO.md index cf639b95e5599..390a21c45ce33 100644 --- a/doc/JSON_INFO.md +++ b/doc/JSON_INFO.md @@ -823,7 +823,8 @@ Mods can modify this via `add:traits` and `remove:traits`. "difficulty": 3, // Difficulty of success check "time": "5 m", // Preferred time to perform recipe, can specify in minutes, hours etc. "time": 5000, // Legacy time to perform recipe (where 1000 ~= 10 turns ~= 10 seconds game time). -"reversible": false, // Can be disassembled. +"reversible": "1 m", // Time to disassemble result. +"reversible": false, // Can be disassembled. Default ("reversible": true) disassemble time is equal to craft time. "autolearn": true, // Automatically learned upon gaining required skills "autolearn" : [ // Automatically learned upon gaining listed skills [ "survival", 2 ], diff --git a/src/recipe.cpp b/src/recipe.cpp index e0ac262b4ddc3..e4287ee81f8b1 100644 --- a/src/recipe.cpp +++ b/src/recipe.cpp @@ -209,7 +209,13 @@ void recipe::load( const JsonObject &jo, const std::string &src ) assign( jo, "category", category, strict ); assign( jo, "subcategory", subcategory, strict ); assign( jo, "description", description, strict ); - assign( jo, "reversible", reversible, strict ); + if( jo.has_bool( "reversible" ) ) { + assign( jo, "reversible", reversible, strict ); + } else if( jo.has_string( "reversible" ) ) { + reversible = true; + uncraft_time = to_moves( read_from_json_string( *jo.get_raw( "reversible" ), + time_duration::units ) ); + } if( jo.has_member( "byproducts" ) ) { if( this->reversible ) { diff --git a/src/recipe.h b/src/recipe.h index 89374a519f572..f37781c48d019 100644 --- a/src/recipe.h +++ b/src/recipe.h @@ -171,6 +171,9 @@ class recipe /** Can recipe be used for disassembly of @ref result via @ref disassembly_requirements */ bool reversible = false; + /** Time to reverse for auto-generated uncraft **/ + int uncraft_time = 0; + /** What does the item spawn contained in? Unset ("null") means default container. */ itype_id container = "null"; diff --git a/src/recipe_dictionary.cpp b/src/recipe_dictionary.cpp index 68efd587926c7..7a59fc275cba6 100644 --- a/src/recipe_dictionary.cpp +++ b/src/recipe_dictionary.cpp @@ -435,6 +435,10 @@ void recipe_dictionary::finalize() // if reversible and no specific uncraft recipe exists use this recipe if( r.is_reversible() && !recipe_dict.uncraft.count( recipe_id( r.result() ) ) ) { recipe_dict.uncraft[ recipe_id( r.result() ) ] = r; + // optional uncraft_time + if( r.uncraft_time ) { + recipe_dict.uncraft[ recipe_id( r.result() ) ].time = r.uncraft_time; + } } }