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

Add infrastructure for restricting clothing mods #34705

Merged
merged 4 commits into from
Oct 22, 2019

Conversation

Davi-DeGanne
Copy link
Contributor

Summary

SUMMARY: Infrastructure "Can set up clothing mods to be valid only for certain items"

Purpose of change

Allows more granularity for clothing mods.

Required infrastructure for #34593

Describe the solution

  • Added the boolean field "restricted" to clothing mod JSONs (defaults to false)
  • Added the vector<string> field "valid_mods" to armor JSONs (defaults to empty list)
  • Made it so clothing mods with "restricted": true can only be applied to armor which lists that clothing mod's ID in "valid_mods"
  • To make it clear to the user why mods were not applicable in this case, I had to shuffle things around a bit, and while doing so, it only made sense to explain why a mod couldn't be applied in the other instances as well; appropriate messages now display in the clothing modification menu not only when the new restrictions make a modification impossible, but also when the player doesn't have enough material or thread.
  • Added documentation to JSON_INFO.md detailing the new properties.

Describe alternatives you've considered

Discussed in #34593, this seemed the best solution.

Testing

  • Temporarily add "restricted": true to one of the clothing mods (I'll use kevlar_padded as an example).
  • Temporarily add "valid_mods": ["kevlar_padded"] to any clothing item(s).
  • Load the game and spawn in a tailor's kit, 100 Kevlar plates, and the clothing item(s) you modified.
  • Observe that the clothing item(s) you modified can be padded with Kevlar, but all other clothing cannot.

Additional context

NB: Does not affect existing clothing modifications (as of yet), since "restricted" defaults to false.

Screenshot of UI changes:
image

@snipercup
Copy link
Contributor

I also tested it. Works as designed:
image

I'll start making a whitelist for the upcoming steel padded mod.

@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Items / Item Actions / Item Qualities Items and how they work and interact labels Oct 13, 2019
src/iuse_actor.cpp Outdated Show resolved Hide resolved
src/iuse_actor.cpp Outdated Show resolved Hide resolved
src/iuse_actor.cpp Outdated Show resolved Hide resolved
src/iuse_actor.cpp Outdated Show resolved Hide resolved
@Fris0uman
Copy link
Contributor

Do you really need the bool? You could just use valid_mods to get the same results: if the item has a valid_mods entry then it is restricted.

src/iuse_actor.cpp Outdated Show resolved Hide resolved
@Davi-DeGanne
Copy link
Contributor Author

Davi-DeGanne commented Oct 14, 2019

Do you really need the bool? You could just use valid_mods to get the same results: if the item has a valid_mods entry then it is restricted.

Well, this was created with #34593 in mind. Doing it this way, snipercup doesn't have to add ["leather_padded", "kevlar_padded", "furred", "wooled"] to every single armor item besides the handful of items he wants to allow steel reinforcement for; instead, only ["steel_padded"] has to be added to said handful of items. This way seems more intuitive for JSON editors in general, and means the new item additions (and existing mods, for that matter) will have steel_padded disabled by default unless they specify otherwise, which is desirable imho.

Co-Authored-By: Jianxiang Wang (王健翔) <[email protected]>
@kevingranade kevingranade merged commit 7825679 into CleverRaven:master Oct 22, 2019
va5h pushed a commit to va5h/Cataclysm-DDA that referenced this pull request Oct 23, 2019
@Davi-DeGanne Davi-DeGanne deleted the restrict-clothing-mods branch October 25, 2019 05:39
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 Items / Item Actions / Item Qualities Items and how they work and interact
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants