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 inline /act syntax for using actions #12733

Merged

Conversation

nikolaj-a
Copy link
Collaborator

@nikolaj-a nikolaj-a commented Jan 4, 2024

Add support for inline slash-style syntax, specifically /act, for actions.

Also give priority to the action objects instead of the old action functions when using both the old HTML syntax and the new slash syntax.

Examples

[[/act administer-first-aid variant=stop-bleeding dc=25]]

[[/act escape statistic=acrobatics dc=fortitude]]

[[/act grapple]]

Examples

Depends on #13043 and #13047

@nikolaj-a nikolaj-a force-pushed the add-support-for-inline-slash-act-syntax branch 6 times, most recently from fc5d852 to ef9e998 Compare January 4, 2024 01:48
@nikolaj-a nikolaj-a marked this pull request as ready for review January 4, 2024 01:55
@nikolaj-a nikolaj-a force-pushed the add-support-for-inline-slash-act-syntax branch from ef9e998 to f39d328 Compare January 4, 2024 23:39
Copy link
Collaborator

@stwlam stwlam left a comment

Choose a reason for hiding this comment

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

It looks like we'd be better off overriding ChatLog.parse and ChatLog#processMessage

src/global.ts Outdated Show resolved Hide resolved
src/module/apps/sidebar/chat-log.ts Outdated Show resolved Hide resolved
src/module/apps/sidebar/chat-log.ts Outdated Show resolved Hide resolved
src/module/apps/sidebar/chat-log.ts Outdated Show resolved Hide resolved
src/module/apps/sidebar/chat-log.ts Outdated Show resolved Hide resolved
src/module/apps/sidebar/chat-log.ts Outdated Show resolved Hide resolved
@nikolaj-a
Copy link
Collaborator Author

It looks like we'd be better off overriding ChatLog.parse and ChatLog#processMessage

That was my initial attempt. I gave up on that once I basically copied the whole thing and added just another case for the switch in there.

It works, but we’d have to maintain it ourselves since it’s not currently set to be changed in core.

@nikolaj-a nikolaj-a force-pushed the add-support-for-inline-slash-act-syntax branch 2 times, most recently from 1737450 to 8db7a54 Compare January 5, 2024 20:52
@nikolaj-a nikolaj-a changed the title Add support for inline and chat command /act syntax Add support for inline /act syntax for using actions Jan 5, 2024
@nikolaj-a nikolaj-a force-pushed the add-support-for-inline-slash-act-syntax branch 5 times, most recently from aaaefd4 to a256c47 Compare January 6, 2024 09:20
@nikolaj-a
Copy link
Collaborator Author

Rough draft for the Style Guide:

Inline Action Syntax

[[/act action-slug key1=value1 key2=value2]]
[[/act grapple]]
[[/act administer-first-aid variant=stabilize]]
[[/act perform variant=acting difficulty-class=19]]
[[/act escape statistic=acrobatics difficulty-class=fortitude]]

Supported parameters

Parameter Alias Values Examples
difficulty-class dc number or statistic slug 25 or fortitude
statistic stat, skill statistic slug perception
variant variant slug stop-bleeding

What is a "statistic slug"?

A language-agnostic representation of a creature statistic. For most actions the supported statistics are perception, any saving throw, and any skill.

perception
fortitude
reflex
will
acrobatics
arcana
athletics
crafting
deception
diplomacy
intimidation
medicine
nature
occultism
performance
religion
society
stealth
survival
thievery

@nikolaj-a nikolaj-a force-pushed the add-support-for-inline-slash-act-syntax branch 2 times, most recently from 2d71cb5 to ac87d70 Compare January 14, 2024 23:38
@nikolaj-a nikolaj-a requested a review from stwlam January 14, 2024 23:39
@nikolaj-a nikolaj-a force-pushed the add-support-for-inline-slash-act-syntax branch 4 times, most recently from 488b39c to 9c24c96 Compare January 18, 2024 04:10
@nikolaj-a nikolaj-a marked this pull request as draft January 18, 2024 04:13
@nikolaj-a nikolaj-a force-pushed the add-support-for-inline-slash-act-syntax branch 2 times, most recently from 16489cf to a55f5f4 Compare January 19, 2024 02:33
@nikolaj-a nikolaj-a marked this pull request as ready for review January 19, 2024 02:46
element.appendChild(document.createTextNode(" "));

const details = document.createElement("span");
if (dc && showDC && Number.isNumeric(dc)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should have our own helper for this: mind making something like isIntegerString that does a strict regex test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, but I think it's Foundry providing that Number.isNumeric function. Though I guess it's originally from jQuery.

Alternatively, there is something like Number.isInteger(Number("10")).

@nikolaj-a nikolaj-a force-pushed the add-support-for-inline-slash-act-syntax branch from a55f5f4 to e2734e7 Compare January 20, 2024 04:11
Add support for inline slash-style syntax, specifically /act, for actions.
@nikolaj-a nikolaj-a force-pushed the add-support-for-inline-slash-act-syntax branch from e2734e7 to ad0f55c Compare January 20, 2024 04:19
@stwlam stwlam merged commit 66181fc into foundryvtt:master Jan 20, 2024
1 check passed
@nikolaj-a nikolaj-a deleted the add-support-for-inline-slash-act-syntax branch January 20, 2024 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants