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 support for expressions in the inline chat commands #183

Merged

Conversation

Azurelol
Copy link
Collaborator

@Azurelol Azurelol commented Dec 12, 2024

Adds support for evaluating expressions provided in the Expressions module, property referencing and function invocation in the inline chat commands such as @DMG, @HEAL, @GAIN, @LOSS

It adds support for the following:

  • @item|actor.<property>
  • $<variable> : These would be shorthands for very common usages like item level, which would be $il, can also support alias $sl
  • &<macro>: for custom functions that the system can provide. The most beneficial one to provide would be the one that picks a value based on the character's level. I went with &step(40,50,60) .
  • minor|heavy|massive effect: Using the level of the actor to calculate the amount

@KSops
Copy link
Collaborator

KSops commented Dec 12, 2024

Implementing this specifically for inline effects is fine for now, but I think eventually being able to handle dynamic expressions in other places will be beneficial and having a standardized DSL for the entire project would help.
So a utility module/class for dynamic evaluation that takes a string to parse and evaluate against a given context. And that way consumers can simply call an exposed interface call like evaluate(value: string, context: object)
That way we can refence this common module for how the DSL works instead of worrying about specific contexts in which evaluation happens.

@Azurelol
Copy link
Collaborator Author

Implementing this specifically for inline effects is fine for now, but I think eventually being able to handle dynamic expressions in other places will be beneficial and having a standardized DSL for the entire project would help.
So a utility module/class for dynamic evaluation that takes a string to parse and evaluate against a given context. And that way consumers can simply call an exposed interface call like evaluate(value: string, context: object)
That way we can refence this common module for how the DSL works instead of worrying about specific contexts in which evaluation happens.

Oh yeah, I definitely agree with providing a standard API for handling expression evaluation for the DSL in the system. I will go ahead and factor that out into its own class.

@Azurelol
Copy link
Collaborator Author

It's been factored out and a bit simpler to reason about now that it's on its own module.

@Azurelol Azurelol marked this pull request as ready for review December 13, 2024 19:33
@Azurelol
Copy link
Collaborator Author

Azurelol commented Dec 13, 2024

One last question for the time being is to decide whether to use a different symbol for executing functions (atm $) or use the same one as property referencing @. If we use different ones then we can invoke functions from referenced properties without having to deal with scoping issues.

It may also be good to think of a symbol for short-hand syntactic sugar for things such as item level, character level, target count.

Examples: $sl, &il, etc..

@Azurelol
Copy link
Collaborator Author

After the latest round of changes I believe it's in a good state. I will await your review.

@Azurelol Azurelol requested a review from KSops December 16, 2024 19:14
Copy link
Collaborator

@KSops KSops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didnt look too deeply on testing it so if it works it works :)

@spyrella spyrella merged commit c0293bb into League-of-Fabulous-Developers:dev Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants