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

Make item pockets smarter #54812

Merged
merged 9 commits into from
Feb 3, 2022
Merged

Conversation

matshou
Copy link
Contributor

@matshou matshou commented Jan 26, 2022

Summary

Features "Made item pockets smarter"

Purpose of change

I was always bothered by the fact that pocket autopickup rules did not apply to container content. The inability of pockets to look inside containers when deciding whether an item can be stored inside makes the pocket autopickup feature much less useful.

I was also never happy with how the filtering system was limited to either using rules defined in whitelist or blacklist without being able to use both. Currently the most advanced way to filter is to either whitelist items and blacklist categories or the other way around. However without consideration for container content there is no need to expand the filtering functionality.

Resolves #54104

Describe the solution

This feature makes pocket smarter by making the pocket autopickup system recognize container content. Similar to the system being introduced with #54408 pockets will now factor in item content when deciding whether an item can be stored in them.

In addition to this, pocket favorite settings now allow mixed whitelist and blacklist rules for both items and categories. This means that players can include different items in whitelist and blacklist at the same time. Previously they had to choose whether they want to filter items with the use of a whitelist or blacklist.

The new system allows players to express: "In this pocket I only want these items and I also do not want to see any of these items". That second part might seem superfluous, however containers are now allowed to enter a pocket without expressly being included in the whitelist (even when the whitelist has been defined) as long as it's content is accepted by pocket autopickup settings. Now we can use the blacklist to filter containers and the whitelist to filter items.

Describe alternatives you've considered

No alternatives considered.

Testing

Unit tested with 118 assertions in 2 test cases.

Click on this line to reveal in-game test information.
  • Pocket 1:

    • Priority: 2
    • Item Whitelist: aspirin
    • Item Blacklist: small cardboard box
  • Pocket 2:

    • Priority: 1
    • Item Whitelist: aspirin
    • Item Blacklist: [x]
  • Pocket 3:

    • Priority: 0
    • Item Whitelist: aspirin and matchbook
    • Item Blacklist: [x]

Picking up the following items from the ground:

  • small cardboard box

    • matchbook (20/20 match)
    • plastic prescription bottle > aspirin (cold)
  • small cardboard box

    • plastic prescription bottle > aspirin (cold)

Contents of rucksack pockets after picking up items from the ground:

  • Pocket 1:

    • This pocket is empty
  • Pocket 2:

    • small cardboard box > plastic prescription bottle > 1 item
  • Pocket 3:

    • small cardboard box > 2 items

Additional context

Click on this line to reveal short in-game test videos.
cataclysm-tiles_LwyrHwK28x.mp4
cataclysm-tiles_B1N9445NlE.mp4
cataclysm-tiles_1TCCFOPnNW.mp4

@github-actions github-actions bot added json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Jan 26, 2022
@NetSysFire NetSysFire added <Enhancement / Feature> New features, or enhancements on existing [C++] Changes (can be) made in C++. Previously named `Code` Items: Containers Things that hold other things labels Jan 26, 2022
src/item_pocket.cpp Outdated Show resolved Hide resolved
src/item_pocket.h Outdated Show resolved Hide resolved
@matshou matshou requested a review from BrettDong January 27, 2022 18:10
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Jan 27, 2022
@kevingranade kevingranade merged commit 0d88094 into CleverRaven:master Feb 3, 2022
@matshou matshou deleted the feat/pocket-fav branch February 4, 2022 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` <Enhancement / Feature> New features, or enhancements on existing Items: Containers Things that hold other things json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Items/liquids in bottles ignore pocket autopickup setting
4 participants