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

Feat/flat modifiers to attacks 135 #189

Open
wants to merge 16 commits into
base: release-0.2.2
Choose a base branch
from

Conversation

zithith
Copy link
Collaborator

@zithith zithith commented Nov 30, 2024

Type

  • Bug fix
  • Feature
  • Refactor
  • Other (please describe):

Description
This adds a new input box to the item activation form (for skill roll based activations) that allows users to input a formula and that will get added to the attack roll calculations. Using the existing roll data objects, there are a range of @ tags for various modifiers and flat numbers and dice can be included to allow for manually representing global effects.

Related Issue
Closes #135

How Has This Been Tested?
Loaded build into my local server and tested using GM and Player accounts.

  1. Loaded Bridge 9 module into server
  2. For the global item modifiers:
    1. Opened the sheet of any of the pre-gens, switch to the inventory tab
    2. Edited a weapon to include a value in the new field
    3. Rolled the item
      • Confirmed the values show up in the formula display
      • Checked that any dice added appear in DSN animation
      • Confirmed that dice values and flat numbers are shown in the chat card and included in the totalling of the outputted value
    4. repeat ii and iii for various scenarios (dice included, use @mod/@attribute/@skill.rank, use @attr/@skills.<skill>.ranks for any value on the character)
  3. For the situational bonuses:
    1. Open the sheet of a pre-gen
    2. Click on an activation icon for any interaction needing a d20 roll
    3. Enter a value in the Temporary Modifier field
      • Confirmed the formula display updated with the new value
    4. Made the Roll
      • Confirmed the roll still works
      • Confirmed DSN still works
      • Confirmed the values showed up in the chat card
      • Confirmed advantage/disadvantage not broken
      • Confirmed shortcut keys not broken
      • Confirmed Attacks don't double-dip the temporary mods
    5. Repeat for various values (+ve and -ve additions, dice, flat numerics, @ notations, empty field) and for rolls from items as well as weapons and straight skill rolls

Screenshots (if applicable)
Global Mod:

image
(I changed the label text since the screenshot, it is now "Roll Formula Extension")
⬇️
image
⬇️
image
⬇️
image

Temp Mods:

image
⬇️
image
⬇️
image

Checklist:

  • I have commented on my code, particularly in hard-to-understand areas. Happy to add more
  • My changes do not introduce any new warnings or errors.
  • My PR does not contain any copyrighted works that I do not have permission to use.
  • I have tested my changes on Foundry VTT version: 12.331.

@zithith zithith linked an issue Nov 30, 2024 that may be closed by this pull request
1 task
@zithith zithith changed the base branch from main to release-0.2.2 November 30, 2024 02:35
…ula within the roll configuration dialog.

Applied all changes for both global and temp modifiers to attack rolls and general skill rolls.
Also fixed global modifiers for non-attack rolls
@zithith zithith marked this pull request as ready for review December 1, 2024 00:21
@zithith zithith requested review from stanavdb and MangoFVTT December 1, 2024 00:21
@zithith zithith self-assigned this Dec 1, 2024
@zithith zithith added this to the Release 0.2.2 milestone Dec 1, 2024
@zithith
Copy link
Collaborator Author

zithith commented Dec 1, 2024

Also, apologies about pulling in the workflow changes from main. got my target branches a bit confused at one point before I realised I had updated the feature branch. Hopefully we can cherry pick those back out when squashing or just let it lie, as it would need to have been pulled before a release anyhow?

Comment on lines +682 to 683
"AdditionalFormulaDescription": "Input any extra modifiers you wish to add to this item's d20 Skill Roll. This input will be treated as a dice formula, but any die you add won't be available for advantage/disadvantage currently. Paramters you can use: @mod, @attribute & @skill.rank refer to the values of the skills selected here, but the whole list of skills and attributes can be accessed - ask on the discord for help!"
},
Copy link
Collaborator

@MangoFVTT MangoFVTT Dec 2, 2024

Choose a reason for hiding this comment

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

I think it's preferrable for this to be an on-hover tooltip rather than a description that's always visible. It buys us some real estate in the sheet

Copy link
Collaborator Author

@zithith zithith Dec 2, 2024

Choose a reason for hiding this comment

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

I don't disagree, I just don't know if we use tooltips for providing info like that elsewhere in any of the sheets yet, do we?
This is where something like a set of the tutorials/walkthroughs ( #149 ) or a wiki would reduce the need for wordy hints like this and we could take a review and set a standardised approach to such things

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm all for moving any hint infos to tooltips wherever we can. It's just cleaner UI with less overwhelming amounts of text

src/system/applications/dialogs/roll-configuration.ts Outdated Show resolved Hide resolved
src/system/config.ts Outdated Show resolved Hide resolved
zithith and others added 2 commits December 3, 2024 20:13
@zithith
Copy link
Collaborator Author

zithith commented Dec 8, 2024

Regarding the "Noneable" stuff, feel free to suggest another name. I wanted to use Nullable but that feels like it's inaccurate and also likely to clash with potential future 3rd party libraries.
If you guys are happy with it, I'll raise another issue/PR to go through and standardise the use of "none" where appropriate.

Copy link
Collaborator

@stanavdb stanavdb left a comment

Choose a reason for hiding this comment

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

Is there a reason to step away from using null to represent none selections and move to explicit 'none'?

Noneable is useful within the applications that make the selection. But beyond that context I feel null is a cleaner solution.

Copy link
Collaborator

@stanavdb stanavdb left a comment

Choose a reason for hiding this comment

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

Setting the skill to None for any skill test (or attack), causes the activation to no longer work as both the rollAttack and the roll function on the item document explicitly check for skill.

@zithith
Copy link
Collaborator Author

zithith commented Dec 9, 2024

Setting the skill to None for any skill test (or attack), causes the activation to no longer work as both the rollAttack and the roll function on the item document explicitly check for skill.

Ok, I'll go back and check that, been focussing on the attribute for the last few sessions. TBF I don't think I changed any of the logic for skill selection as it seemed like that was already handled. Might just have to go in and add belt and braces around it.

@zithith
Copy link
Collaborator Author

zithith commented Dec 9, 2024

Is there a reason to step away from using null to represent none selections and move to explicit 'none'?

Noneable is useful within the applications that make the selection. But beyond that context I feel null is a cleaner solution.

That was partly my reason for mentioning/bringing attention to it in my earlier comments.
I don't know for sure. Mostly I was following the approach that the Skills and other dropdowns already had in place for selecting a "No Value" option.

The model value is still set to null (see base item line 134). This is mostly for handling where the select option value is handed around the application.

There is probably some way that this could be converted to a null, but technically speaking I'm not sure if using explicit null is good practice in TS and that having a separate value to identify when the user has actively selected a No Value might be cleaner. I'll have to check some articles/ask my work colleagues.

src/system/dice/index.ts Outdated Show resolved Hide resolved
…ll was selected (no-skill rolls are now possible).

Switched from "none" to null in the code for ease.
Refactored some common code into generic functions.
@zithith
Copy link
Collaborator Author

zithith commented Dec 14, 2024

OK, so I've gone in and updated to what could be the final approach?
I see why the rolling was failing on no-skill. We were short-circuiting the roll functions and using the "none" option as a sort of "this is unconfigured" flag. Removed as that would invalidate some of the idea for this feature.

Enabling no-skill rolls highlighted that the use of "none" as a string value was causing some problems buried deep in some of the object assignments so instead of trying to go round the houses I've switched it to rely on nulls from the earliest opportunity. I think there could be some discussion had to align our use of null vs. undefined in places, but for now happy to take this route.

Word of note: Would be good to get more testing in. There seems to be a bit of flakiness to when the rolls pick up @ variables properly in the current build. flat numbers seem to work across the board for global mods and for temporary ones, but the variables seem to sometimes read as 0 in the calculations despite reading their correct values in the config dialog.

Copy link
Collaborator

@stanavdb stanavdb left a comment

Choose a reason for hiding this comment

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

Left a couple of small comments. Haven't tested yet but looks like we're pretty much there.

src/system/applications/dialogs/attack-configuration.ts Outdated Show resolved Hide resolved
src/system/applications/dialogs/attack-configuration.ts Outdated Show resolved Hide resolved
src/system/documents/item.ts Show resolved Hide resolved
Comment on lines +10 to +11
// Simple utility type for easier null definitions, but general rule: only use it when you have one type that is nullable (i.e. prefer X | Y | null over Nullable<X | Y>)
export type Nullable<T> = T | null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason to use this over Type | null? Not opposed to this, more questioning for consistency

Copy link
Collaborator Author

@zithith zithith Dec 15, 2024

Choose a reason for hiding this comment

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

None technically, I did look it up.
I prefer it here for the simple fact it seems like it's closer to following the Generic Utility approach kinda like Omit/Pick. We're saying here that this is something of X type or it could be null, and is readable to someone who is less confident with raw Union types. And it seems a little neater in source that having a bunch of | nulls around imo.

Again this is caveated though by what input in the comment, once you've got a few things in the list of potential types, switch back to a straight Union as it is clearer than either Nullbale<X | Y> or Nullable<X> | Nullable<Y>

But it's totally a team preference thing. If we're happy using this going forward, I'd happily just raise a separate PR doing the grunt work to refactor any existing situations where it occurs (along with swapping 'none' literals for the constant I made)

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.

Add flat modifiers to attacks
3 participants