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

math_parser: evaluate variables in diag. functions #65467

Merged
merged 1 commit into from
May 19, 2023

Conversation

andrei8l
Copy link
Contributor

@andrei8l andrei8l commented May 4, 2023

Summary

None

Purpose of change

Allow dialogue functions in math to evaluate their parameters from dialogue variables.

So something like

"condition": { "u_has_skill": { "skill": { "global_val": "myvar" }, "level": 5 } },

can be fully ported to

"condition": { "math": [ "u_skill(myvar)", ">=", "5" ] }

where myvar gets evaluated inside u_skill.

Describe the solution

Expand the math parser to include this use case

TODO:

  • figure out validation: ez pz; I was overthinking it

Describe alternatives you've considered

Third party parser

Testing

New test units

Additional context

This includes a tiny bit of code from #65465 so that the tests work.

This will stay in draft until #65298 and #65465 get merged to spare myself some conflict resolution.

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON Code: Tests Measurement, self-control, statistics, balancing. astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions labels May 4, 2023
@andrei8l andrei8l force-pushed the math_parser-diag-func-vars branch from 168933f to 5169f34 Compare May 4, 2023 09:18
tests/math_parser_test.cpp Outdated Show resolved Hide resolved
@github-actions github-actions bot added BasicBuildPassed This PR builds correctly, label assigned by github actions and removed astyled astyled PR, label is assigned by github actions labels May 4, 2023
@andrei8l andrei8l marked this pull request as ready for review May 11, 2023 05:12
@andrei8l andrei8l force-pushed the math_parser-diag-func-vars branch from 5169f34 to 205ed3f Compare May 11, 2023 05:12
@github-actions github-actions bot added <Documentation> Design documents, internal info, guides and help. [Markdown] Markdown issues and PRs NPC / Factions NPCs, AI, Speech, Factions, Ownership astyled astyled PR, label is assigned by github actions labels May 11, 2023
@andrei8l andrei8l force-pushed the math_parser-diag-func-vars branch 2 times, most recently from cbe3722 to e9eed74 Compare May 19, 2023 02:26
@andrei8l andrei8l force-pushed the math_parser-diag-func-vars branch from e9eed74 to 6617eb6 Compare May 19, 2023 02:35
@dseguin dseguin merged commit aa3b581 into CleverRaven:master May 19, 2023
@andrei8l
Copy link
Contributor Author

Thanks for merging!

@andrei8l andrei8l deleted the math_parser-diag-func-vars branch May 19, 2023 04:25
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` Code: Tests Measurement, self-control, statistics, balancing. <Documentation> Design documents, internal info, guides and help. [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions [Markdown] Markdown issues and PRs NPC / Factions NPCs, AI, Speech, Factions, Ownership
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants