Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade reversible recipe property #36872

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions data/json/recipes/recipe_electronics.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] ],
Expand All @@ -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 ] ],
Expand Down
3 changes: 2 additions & 1 deletion doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ],
Expand Down
8 changes: 7 additions & 1 deletion src/recipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>( read_from_json_string<time_duration>( *jo.get_raw( "reversible" ),
time_duration::units ) );
}

if( jo.has_member( "byproducts" ) ) {
if( this->reversible ) {
Expand Down
3 changes: 3 additions & 0 deletions src/recipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
4 changes: 4 additions & 0 deletions src/recipe_dictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down