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

New JSON recipe property for overriding inheritance of specified flags #35825

Merged
merged 3 commits into from
Dec 4, 2019

Conversation

Davi-DeGanne
Copy link
Contributor

@Davi-DeGanne Davi-DeGanne commented Dec 3, 2019

Summary

SUMMARY: Infrastructure "New JSON recipe property for overriding inheritance of specified flags"

Purpose of change

My initial incarnation of flag inheritance included an item flag that completely disabled flag inheritance when that item was crafted. In retrospect, that was a poor solution. It is too heavy-handed in practice. For instance, it doesn't allow recipes to inherit one flag as normal, while removing another. This solution should be more practical.

Describe the solution

Adds an optional property to recipes, delete_flags, which is an array of strings. Flags specified there will be removed from the resultant item upon crafting. This will override flag inheritance, but will not delete flags that are part of the item type itself.

Additionally, since this new property does everything that the old "NO_CRAFT_INHERIT" flag did and more, I removed that flag and all usage of it, and translated those usages to the new system.

Describe alternatives you've considered

Testing

  1. Spawn 2 mutant meat, a dehydrator, a mess kit, 2 medium batteries, and 4 bread
  2. Craft 1 cooked mutant meat, and 1 dehydrated meat
  3. Craft 2 meat sandwiches, 1 from each type of processed meat
  4. Compare the meat sandwiches -- one will have the BAD_TASTE flag, one will not

Additional context

My initial incarnation of flag inheritance included an item flag that
completely disabled flag inheritance when that item was crafted.
In retrospect, that was a poor solution. It is too heavy-handed in
practice. For instance, it doesn't allow recipes to inherit one flag as
normal, while removing another. This solution should be more practical.
The new "delete_flags" property of recipes does everything it used to do
and more.
Also replaced all uses of NO_CRAFT_INHERIT with delete_flags property.
@Davi-DeGanne Davi-DeGanne changed the title Recipe flag deletion New JSON recipe property for overriding inheritance of specified flags Dec 3, 2019
src/recipe.cpp Outdated Show resolved Hide resolved
@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Crafting / Construction / Recipes Includes: Uncrafting / Disassembling labels Dec 3, 2019
@ZhilkinSerg ZhilkinSerg merged commit 9f74eae into CleverRaven:master Dec 4, 2019
@Davi-DeGanne Davi-DeGanne deleted the recipe-flag-deletion branch December 4, 2019 09:15
I-am-Erk pushed a commit to I-am-Erk/Cataclysm-DDA that referenced this pull request Dec 6, 2019
CleverRaven#35825)

* Add JSON field to delete flags in recipes
My initial incarnation of flag inheritance included an item flag that
completely disabled flag inheritance when that item was crafted.
In retrospect, that was a poor solution. It is too heavy-handed in
practice. For instance, it doesn't allow recipes to inherit one flag as
normal, while removing another. This solution should be more practical.

* Remove obsolete NO_CRAFT_INHERIT flag
The new "delete_flags" property of recipes does everything it used to do
and more.
Also replaced all uses of NO_CRAFT_INHERIT with delete_flags property.

* Change flags_to_delete from vector to set
As suggested by BevapDin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Crafting / Construction / Recipes Includes: Uncrafting / Disassembling [JSON] Changes (can be) made in JSON
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants