mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-19 00:19:03 +01:00
Action Refactor Part #2
This commit is contained in:
parent
479e147640
commit
9da6a13009
20 changed files with 324 additions and 340 deletions
|
|
@ -13,4 +13,27 @@ export default class UsesField extends fields.SchemaField {
|
|||
};
|
||||
super(usesFields, options, context);
|
||||
}
|
||||
|
||||
static prepareConfig(config) {
|
||||
const uses = this.uses?.max ? foundry.utils.deepClone(this.uses) : null;
|
||||
if (uses && !uses.value) uses.value = 0;
|
||||
config.uses = uses;
|
||||
const hasUses = UsesField.hasUses.call(this, config.uses);
|
||||
if(config.isFastForward && !hasUses)
|
||||
return ui.notifications.warn("That action doesn't have remaining uses.");
|
||||
return hasUses;
|
||||
}
|
||||
|
||||
static calcUses(uses) {
|
||||
if (!uses) return null;
|
||||
return {
|
||||
...uses,
|
||||
enabled: uses.hasOwnProperty('enabled') ? uses.enabled : true
|
||||
};
|
||||
}
|
||||
|
||||
static hasUses(uses) {
|
||||
if (!uses) return true;
|
||||
return (uses.hasOwnProperty('enabled') && !uses.enabled) || uses.value + 1 <= uses.max;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue