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 "forbidden traits" to professions #36074

Merged
merged 7 commits into from
Mar 16, 2020

Conversation

np-vortex
Copy link
Contributor

@np-vortex np-vortex commented Dec 13, 2019

Summary

SUMMARY: Features "Enable defining forbidden traits in profession .json configuration"

Purpose of change

To allow for more complex combination of scenario and professions configuration in regards to locked and forbidden traits.

Describe the solution

Adds handling of "forbidden_traits" in professions json config.
Adds logic to filter out professions whose traits conflict with traits for the scenario.
Adds a debug message on scenario select if scenario has an explicitly configured profession but there is a conflict in trait configuration between the scenario and a profession.
Debug message would appear if:

  • scenario has a locked trait that is also a forbidden trait for a profession for that scenario
  • scenario has a forbidden trait that is also a locked trait for a profession for that scenario
  • scenario has a locked trait that conflicts with a locked trait for a profession for that scenario

I would like to add checks for traits that override or cancel each other, basically what is done in player::has_conflicting_trait, but that would mean I should take that logic outside of src/player.cpp and make it reusable.

I have added the extra checks. Should I attempt to refactor player::has_conflicting_trait to use more generic code to check for conflicts in traits?

Describe alternatives you've considered

Do not throw a debug message in game.
Do not check for conflicting traits at the moment of scenario selection or anywhere else in game, but do it outside of game by parsing json files and detecting conflicting configuration, maybe even during running of tests.
Instead of removing a profession from menu in game, make it greyed out and display a message if it is clicked on with an explanation of why the player can not choose this profession. This is more complex.

Testing

Chose a scenario Y that has profession profession Z enabled. Added a trait X as a locked trait to a scenario Y, added trait X as a forbidden trait to a profession Z, started a new game, picked scenario Y, observed debug message about conflict in trait configuration between scenario Y and profession Z.

Additional context

Even before this change it was possible that scenario and profession trait configuration was conflicting, as a scenario could have had a forbidden trait that was a locked trait for a profession for that scenario. I assume this was avoided by paying attention to not create such conflicts in the first place. Because I see no checks in the code that look for such conflicts, I am not sure If I should even attempt to create them.

This feature was probably suggested before, but I first observed it in #34808 (comment)

src/scenario.cpp Outdated Show resolved Hide resolved
@np-vortex np-vortex changed the title [WIP] Add "forbidden traits" to professions Add "forbidden traits" to professions Dec 14, 2019
src/mutation.cpp Outdated Show resolved Hide resolved
Co-Authored-By: anothersimulacrum <[email protected]>
@kevingranade
Copy link
Member

Needs astyling.

@ZhilkinSerg ZhilkinSerg changed the base branch from master to dev March 16, 2020 20:33
@ZhilkinSerg ZhilkinSerg merged commit 89f1afd into CleverRaven:dev Mar 16, 2020
@ZhilkinSerg ZhilkinSerg mentioned this pull request Mar 16, 2020
13 tasks
@ZhilkinSerg
Copy link
Contributor

Needs some json example - maybe add some trait restrictions to a challenge?

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` Mutations / Traits / Professions/ Hobbies Mutations / Traits / Professions/ Hobbies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants