Skip to content

Commit

Permalink
Add the definition for bonus crafting speed
Browse files Browse the repository at this point in the history
Currently you need to duplicate recipes to include new tools.
This results in bloated crafting gui and repeated json data
related to CleverRaven#54348 , CleverRaven#42556 , CleverRaven#45157
  • Loading branch information
nopen committed Aug 2, 2022
1 parent ebdbd8e commit a678ebf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/requirements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,18 @@ bool requirement_data::can_make_with_inventory( const read_only_visitable &craft
return retval;
}

float requirement_data::get_tool_bonus_speed_with_inventory( const read_only_visitable
&crafting_inv,
const std::function<bool( const item & )> &filter, int batch, craft_flags flags ) const
{

float tool_bonus = 1.0f;
// has_comps( crafting_inv, components, filter, batch );
// TODO: Iterate reqs and calculate bonus

return tool_bonus;
}

template<typename T>
bool requirement_data::has_comps( const read_only_visitable &crafting_inv,
const std::vector< std::vector<T> > &vec,
Expand Down
8 changes: 8 additions & 0 deletions src/requirements.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,14 @@ struct requirement_data {
bool can_make_with_inventory( const read_only_visitable &crafting_inv,
const std::function<bool( const item & )> &filter, int batch = 1,
craft_flags = craft_flags::none ) const;
/**
* Returns the speed multiplier for optional tools fulfilled by the filtered inventory
* @param filter should be recipe::get_component_filter() if used with a recipe
* or is_crafting_component otherwise.
*/
float get_tool_bonus_speed_with_inventory( const read_only_visitable &crafting_inv,
const std::function<bool( const item & )> &filter, int batch = 1,
craft_flags = craft_flags::none ) const;

/** @param filter see @ref can_make_with_inventory */
std::vector<std::string> get_folded_components_list( int width, nc_color col,
Expand Down

0 comments on commit a678ebf

Please sign in to comment.