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

[#2479, #2232] Prevent resource objects from being mutated #2510

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions module/applications/actor/character-sheet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ export default class ActorSheet5eCharacter extends ActorSheet5e {

// Resources
context.resources = ["primary", "secondary", "tertiary"].reduce((arr, r) => {
const res = context.actor.system.resources[r] || {};
res.name = r;
res.placeholder = game.i18n.localize(`DND5E.Resource${r.titleCase()}`);
if (res && res.value === 0) delete res.value;
if (res && res.max === 0) delete res.max;
krbz999 marked this conversation as resolved.
Show resolved Hide resolved
const res = foundry.utils.mergeObject(context.actor.system.resources[r] || {}, {
name: r,
placeholder: game.i18n.localize(`DND5E.Resource${r.titleCase()}`)
}, {inplace: false});
if ( res.value === 0 ) delete res.value;
if ( res.max === 0 ) delete res.max;
return arr.concat([res]);
}, []);

Expand Down