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

Resource value is deleted when set to 0 #2232

Closed
sgsabbage opened this issue Mar 9, 2023 · 2 comments
Closed

Resource value is deleted when set to 0 #2232

sgsabbage opened this issue Mar 9, 2023 · 2 comments
Labels
bug Functionality which is not working as intended nonrepro Issues which have not been reproduced
Milestone

Comments

@sgsabbage
Copy link

Hi folks,

I've noticed a weird issue where if a feature pulls from one of the primary/secondary/tertiary resources on the sheet, if the value of that resource is 0, rather than being told the resource is out of charges, it says that the attribute no longer exists.

This has a separate knock-on effect if you edit a feature on a character while the resource is 0, which is that the attribute disappears from the list, e.g:
character with resource at 0:
image
attribute options:
image

Which means if you happen to edit a feature while its linked resource is 0, it immediately delinks the resource even if you make no other changes.

I believe this is down to this line of code: https://github.com/foundryvtt/dnd5e/blob/master/module/applications/actor/character-sheet.mjs#L30 where the value is deleted if the resource exists and the value is 0 - though if the resource is unconfigured, it returns a null instead, e.g:

{
    "primary": {
        "max": 10,
        "sr": false,
        "lr": false,
        "label": "Psychic",
        "name": "primary",
        "placeholder": "Resource 1"
    },
    "secondary": {
        "value": null,
        "max": null,
        "sr": false,
        "lr": false,
        "label": "",
        "name": "secondary",
        "placeholder": "Resource 2"
    },
    "tertiary": {
        "value": null,
        "max": null,
        "sr": false,
        "lr": false,
        "label": "",
        "name": "tertiary",
        "placeholder": "Resource 3"
    }
}

I'm happy to raise a PR to either remove that line of code or replace it with a null, but as I have no other experience with the module, I don't know what this has the potential to break.

@LukasPrism
Copy link

FWIW this issue screws up Monk’s Token Bar if that is set to display resources and they drop to 0. Perhaps Monk will circumvent it at his end.

@Fyorl Fyorl added bug Functionality which is not working as intended nonrepro Issues which have not been reproduced labels Jul 3, 2023
@krbz999
Copy link
Contributor

krbz999 commented Sep 9, 2023

This seems to be the same issue as #2165.

@Fyorl Fyorl added this to the D&D5E 2.4.0 milestone Oct 19, 2023
krbz999 pushed a commit to krbz999/dnd5e that referenced this issue Oct 22, 2023
Fyorl pushed a commit that referenced this issue Oct 26, 2023
Co-authored-by: Zhell <zhellqol@gmail.com>
@Fyorl Fyorl closed this as completed Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality which is not working as intended nonrepro Issues which have not been reproduced
Projects
None yet
Development

No branches or pull requests

4 participants