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

JSONize flag-based modifiers on comestible enjoyability #35813

Merged
merged 6 commits into from
Dec 6, 2019

Conversation

Davi-DeGanne
Copy link
Contributor

Summary

SUMMARY: Infrastructure "JSONize flag-based modifiers on comestible enjoyability"

Purpose of change

There was only a single flag that affected the "fun" value of comestibles (BAD_TASTE) but I want to add more for a water sanitation rework, so rather than hardcoding more, I JSONized the process.

Describe the solution

Adds a new member variable to json_flag objects, "taste_mod", which additively modifies the enjoyability of comestibles. See commit messages for more detailed and technical info.

This also has the side-effect of considering BAD_TASTE and MUSHY effects in places where they weren't before, including but not limited to:

  • Interaction with taste blocker bionic.
  • NPCs making decisions about faction food stocks.
  • NPCs making decisions about whether they personally want food.
  • Scavenging monsters deciding whether to eat food off the ground.

Describe alternatives you've considered

Testing

Additional context

There was only a single flag that affected the "fun" value of
comestibles (BAD_TASTE) but I want to add more for a water sanitation
rework, so rather than hardcoding more, I JSONized the process.

Adds a new member variable to json_flag objects, "taste_mod," which
additively modifies the enjoyability of comestibles.
This is done via a new function, "item::get_comestible_fun". The MUSHY
flag check was moved there from Character::fun_for as well.
"item::get_comestible_fun" is of course called in "Character::fun_for",
so this commit shouldn't have any functional changes.
Anyone trying to query a comestible's "fun" should be using the new
"item::get_comestible_fun" method. This commit is to enforce that.

Of course, that had to be reconciled with the current usage of "fun".
I added "item" and "Item_factory" as friends of "islot_comestible" so
that "item::get_comestible_fun" and the function that sets "fun" still
have access to it.
All other queries of "fun" were instead changed to the new method.
This has the side-effect of applying BAD_TASTE and MUSHY effects in
places where they didn't before, including but not limited to:
- Interaction with taste blocker bionic.
- NPCs making decisions about faction food stocks.
- NPCs making decisions about whether they personally want food.
- Scavenging monsters deciding whether to eat food off the ground.
src/item.cpp Outdated Show resolved Hide resolved
src/item.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 Items: Food / Vitamins Comestibles and drinks Mutations / Traits / Professions/ Hobbies Mutations / Traits / Professions/ Hobbies labels Dec 3, 2019
@ZhilkinSerg ZhilkinSerg merged commit b1cff02 into CleverRaven:master Dec 6, 2019
I-am-Erk pushed a commit to I-am-Erk/Cataclysm-DDA that referenced this pull request Dec 6, 2019
…35813)

* JSONize flag taste modifiers
There was only a single flag that affected the "fun" value of
comestibles (BAD_TASTE) but I want to add more for a water sanitation
rework, so rather than hardcoding more, I JSONized the process.

Adds a new member variable to json_flag objects, "taste_mod," which
additively modifies the enjoyability of comestibles.
This is done via a new function, "item::get_comestible_fun". The MUSHY
flag check was moved there from Character::fun_for as well.
"item::get_comestible_fun" is of course called in "Character::fun_for",
so this commit shouldn't have any functional changes.

* Make "islot_comestible::fun" private
Anyone trying to query a comestible's "fun" should be using the new
"item::get_comestible_fun" method. This commit is to enforce that.

Of course, that had to be reconciled with the current usage of "fun".
I added "item" and "Item_factory" as friends of "islot_comestible" so
that "item::get_comestible_fun" and the function that sets "fun" still
have access to it.
All other queries of "fun" were instead changed to the new method.
This has the side-effect of applying BAD_TASTE and MUSHY effects in
places where they didn't before, including but not limited to:
- Interaction with taste blocker bionic.
- NPCs making decisions about faction food stocks.
- NPCs making decisions about whether they personally want food.
- Scavenging monsters deciding whether to eat food off the ground.

* Apply suggestions from code review

Co-Authored-By: BevapDin <tho_ki@gmx.de>

* Subjugate rogue tab (i.e. astyle)

* Fix merge mistake
@Davi-DeGanne Davi-DeGanne deleted the JSONize-flag-tastiness branch December 6, 2019 23:06
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: Food / Vitamins Comestibles and drinks [JSON] Changes (can be) made in JSON Mutations / Traits / Professions/ Hobbies Mutations / Traits / Professions/ Hobbies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants