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 explicit what fields should and should not be modified by temp #140

Open
Ruin0x11 opened this issue Feb 24, 2021 · 0 comments
Open
Labels
documentation Improvements or additions to documentation standardization Concerns conventions that should be strongly followed in mods undecided Issues for which there are multiple potential solutions/none decided yet.

Comments

@Ruin0x11
Copy link
Owner

Ruin0x11 commented Feb 24, 2021

This is an implicit design encoded in the engine: some fields shouldn't generally be modified by temp.

As a rule, this includes things that can be added to or subtracted from in quantities. Examples include HP and current gold. I'm not sure it would make sense to have a temporary amount of gold or HP.

As a result, code that touches fields like these are acted on with base values (chara.gold = chara.gold + 100) as opposed to temporary values (chara:mod("gold", 100, "add") This encoding of what fields act like this is entirely implicit and not documented anywhere. I just tend to remember in an ad-hoc fashion, "oh, this modifies gold, so we'll use base values here."

Related to #135, when the schema inevitably gets codified we should add a flag or note for these fields. This would not be an engine behavior sort of flag, it would be a developer contract. You'd be free to use gold as a temporary value anyways, but the engine would be designed to obey this implicit contract, so ultimately it would not be applied when e.g. buying items. The code that does the gold subtraction in those cases would use base values, as an explicit design choice.

Or maybe, to prevent unexpected behavior, we could instead throw an error if trying to access or modify a temporary value for those fields. That would at least make the problem more explicit.

@Ruin0x11 Ruin0x11 added documentation Improvements or additions to documentation standardization Concerns conventions that should be strongly followed in mods undecided Issues for which there are multiple potential solutions/none decided yet. labels Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation standardization Concerns conventions that should be strongly followed in mods undecided Issues for which there are multiple potential solutions/none decided yet.
Projects
None yet
Development

No branches or pull requests

1 participant