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

Detect and warn about crafting with rotten food #36610

Merged
merged 1 commit into from
Jan 2, 2020

Conversation

jbytheway
Copy link
Contributor

@jbytheway jbytheway commented Jan 1, 2020

Summary

SUMMARY: Interface "Detect and warn about crafting with rotten food"

Purpose of change

Partial solution to #33385.

To deal with the long-standing issue of accidentally using rotting food in crafting (especially when crafting a large batch) and thus wasting time and materials.

Describe the solution

Based on idea of @ifreund.

Allow a recipe filter to exclude rotten components.

Use this new feature when selecting items for crafting to prefer non-rotten ones. When non-rotten ones do not suffice, warn the player of this fact before proceeding.

In the crafting GUI, mark crafts in brown when they can only be crafted with rotten ingredients.

Describe alternatives you've considered

The brown text might be difficult to read; if so, suggested alternatives are welcome.

This only catches the case where the ingredients are rotten when you start the craft. There is also the situation where things start non-rotten, but become rotten while you craft. This change does not attempt to handle that, but it could now be handled by a localized change in recipe::get_component_filter.

It would be nice for the specific rotten ingredients to be highlighted in the crafting GUI, but that would require fairly invasive changes elsewhere, and certainly shouldn't be part of this PR. One issue that arises with the current implementation is that the GUI might suggest you have (say) two options to choose from, but if one is rotten then it will pick the other automatically without asking you, which might be surprising.

It would be nice to have unit tests for this, but the player interactivity aspects make that difficult.

Testing

Ran unit tests.

In-game experiments with milk crafting.

Additional context

See how crafts are listed in brown when they require rotten ingredients:
rotten-crafting-gui-normal
And when crafting beyond a particular number of batches requires rotten ingredients the higher numbers are brown similarly:
rotten-crafting-gui-batch
If you go ahead and craft, you get this warning:
rotten-craft-warning
And there's a similar warning for continuing an interrupted craft:
rotten-continue-warning

@Morat2255
Copy link
Contributor

Does this apply to things like Lamp Oil that intentionally allow for rotten ingredients for a non-rotten product? That could get annoying, and in some cases confusing.

@Lamandus
Copy link
Contributor

Lamandus commented Jan 1, 2020

Does this apply to things like Lamp Oil that intentionally allow for rotten ingredients for a non-rotten product? That could get annoying, and in some cases confusing.

there I would like to see the opposite! I want to use the rotten stuff, so I don't loose the "fresh" one, which I would use for food cooking.
Something like "prefer rotten components"

@ghost
Copy link

ghost commented Jan 1, 2020

there I would like to see the opposite! I want to use the rotten stuff, so I don't loose the "fresh" one, which I would use for food cooking.
Something like "prefer rotten components"

+1
Probably could be done in crafting logic, something like - if craft allows rotten and result is food prioritize not rotten / warn and if its not food prefer rotten.

@jbytheway
Copy link
Contributor Author

Does this apply to things like Lamp Oil that intentionally allow for rotten ingredients for a non-rotten product? That could get annoying, and in some cases confusing.

Yes, this is handled correctly, in that it doesn't warn you about it. There's no prioritization of ingredient choice based on age for any crafting. That might indeed be a useful thing, but I don't want to tackle it in this PR.

rotten-fat
rotten-lamp-oil

Copy link
Contributor

@ifreund ifreund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great to me. I like the idea of the recipe_filter_flags enum you introduced, it makes the filtering code a good deal cleaner and more extensible than what I was initially picturing.

src/recipe.cpp Outdated Show resolved Hide resolved
src/recipe.cpp Outdated Show resolved Hide resolved
@ifreund ifreund added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Crafting / Construction / Recipes Includes: Uncrafting / Disassembling labels Jan 1, 2020
To deal with the long-standing issue of accidentally using rotting food
in crafting (especially when crafting a large batch) and thus wasting
time and materials.

Allow a recipe filter to exclude rotten components.

Use this new feature when selecting items for crafting to prefer
non-rotten ones.  When non-rotten ones do not suffice, warn the player
of this fact before proceeding.

In the crafting GUI, mark crafts in brown when they can only be crafted
with rotten ingredients.

If the result doesn't care about rottenness, as with e.g. lamp oil, then
no warnings or marking of the recipes is done.

This only catches the case where the ingredients are rotten when you
start the craft.  There is also the situation where things start
non-rotten, but become rotten while you craft.  This change does not
attempt to handle that, but it could now be handled by a localized
change in recipe::get_component_filter.
@snipercup
Copy link
Contributor

Oops, I actually referenced this PR instead of #36611 about 34 times

@snipercup snipercup mentioned this pull request Feb 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Crafting / Construction / Recipes Includes: Uncrafting / Disassembling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants