-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Make item crafting options include recipes from nearby books #37661
Conversation
To encourage player to memorize more recipes, and/or make it clearer that "You could craft" would appear in this place if more recipes were known. Resolves CleverRaven#37643 Splits the existing `if` condition into two parts, first to check if known recipes are empty, and display this message at the bottom of the item description panel: You don't know anything you could craft with it. Note, unless recipes are listed, this message will be shown for all items, whether or not recipes exist for the item.
I see this change caused a couple failing test cases in Marking this PR as WIP until I can fix those (I've been looking for an excuse to get into the tests anyway). |
Some failed test cases in `tests/iteminfo_test.cpp` made me realize my previous commit should have kept the `DESCRIPTION_APPLICABLE_RECIPES` check, since that is a flag indicating whether the section is applicable to that kind of item, and should be shown at all. Doing that check first made it clear that the preceding block, initializing `tid` and `known_recipes`, could move inside the `if` and avoid being needlessly calculated in some cases. Due to indentation, this looks like a larger diff than it really is, but it's all the same logic as before - if no recipes are known, the section will display "You don't know anything you could craft with it." Verified that all tests in `make check` are passing now, and confirmed in-game that messages are shown as expected.
A misunderstanding on my part regarding the I'm satisfied with how this works, but realize it's a far-reaching change, affecting probably a majority of item descriptions, and ultimately adds very little useful information. Now that I've done it, I am not so sure that it should be accepted and merged. It's kind of a waste of text. So I'm submitting it for consideration and discussion, suggestions of alternatives, criticism, outright ridicule etc. Pros:
Cons:
|
Please see the corresponding issue #37643 (comment). In short, I think the description should match the information available through the crafting menu. |
In discussion with @codemime, determined that `player::get_available_recipes` is suitable for use here in place of `get_learned_recipes`, but my C++fu is weak and I've somehow caused a game crash that doesn't even include this file in the backtrace. Committing to ask for help on what I'm doing wrong.
@codemime In commit 3228bad I tried to use
I can post the full log if it'll help, but I'm betting you could look at my code and immediately know what the problem is. It's been something like 20 years since I did any C++ so my syntax may be awkward... Also, let's just take a moment to appreciate that commit id: |
Avoid ending up with a null pointer refererence from `of_component`. Shorten the "no recipes" message slightly to make it fit without wrapping more often.
Yeah, I suspect that's Linus making fun of our code )). This just gave me an idea. It would be cool to make a generator of commits with funny ids. Some say, SHA-1 was cracked, so there can be something better than the brute-force approach for this. |
I've adjusted the PR summary and description to reflect the new nature of this fix, and added screenshots confirming the consistent behavior I am seeing now between the two UIs. |
Whoops, hold on - that test case isn't working yet. Back in WIP |
Test coverage for modified item info behavior
The test cases are in much better shape now, but I'm still getting semi-random failures in a couple of them; for examine sometimes the crowbar will show up with a bunch of higher-level recipes (foldable-light frame, wheelchair wheels, pipe bomb, nail rifle etc.) instead of the expected level-0 "makeshift crowbar" only. Seems like something is bleeding over from other tests; probably I need to clean up / reset the global user |
Reduced to essential assertions; all passing now
All tests are passing now. Assuming this passes build checks, it should be ready to merge. |
Caught by Travis CI
Summary
SUMMARY: Bugfixes "Make item description consistent with crafting UI for recipe list"
Purpose of change
Resolves #37643
Describe the solution
Instead of showing only memorized recipes at the bottom of the item description panel, show all available recipes (including those from nearby books), so the "You could use it to craft: ..." message is consistent with the recipes found in the main crafting UI for that item.
If no recipes are available (in memorized recipes or nearby books), include this at the bottom of the item description: "You know of nothing you could craft with it."
Describe alternatives you've considered
Considered preserving the original behavior in the item description of only showing learned/memorized recipes, but was persuaded by other players/developers that this was bad and should be changed.
Testing
I tested a variety of ad-hoc use cases, but here's a specific example:
Then compare:
/
to search,c:heating element
: Matches hotplate and coffemakerAdditional context
Screenshots below are cut/pasted to show item description and crafting UI for comparison.
With "What's a Transistor?" nearby, the heating element has two recipes available in both the item description and crafting menu:
Similarly, the amplifier circuit item description and crafting recipes are matching:
With the book too far away, the only recipe I get for the amplifier circuit is the level-0-auto-learned "noise emitter (off)":
And for the heating element, without "What's a Transistor?", there are no known recipes: