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

[#2463] Add configuration for whether to default to true/false for limited uses and templates in AbilityUseDialog #2492

Merged
merged 14 commits into from
Oct 19, 2023
6 changes: 4 additions & 2 deletions module/data/item/templates/activated-effect.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export default class ActivatedEffectTemplate extends SystemDataModel {
value: new foundry.data.fields.NumberField({required: true, min: 0, label: "DND5E.TargetValue"}),
width: new foundry.data.fields.NumberField({required: true, min: 0, label: "DND5E.TargetWidth"}),
units: new foundry.data.fields.StringField({required: true, blank: true, label: "DND5E.TargetUnits"}),
type: new foundry.data.fields.StringField({required: true, blank: true, label: "DND5E.TargetType"})
type: new foundry.data.fields.StringField({required: true, blank: true, label: "DND5E.TargetType"}),
prompt: new foundry.data.fields.BooleanField({initial: true, label: "DND5E.TemplatePrompt"})
}, {label: "DND5E.Target"}),
range: new foundry.data.fields.SchemaField({
value: new foundry.data.fields.NumberField({required: true, min: 0, label: "DND5E.RangeNormal"}),
Expand Down Expand Up @@ -86,7 +87,8 @@ export default class ActivatedEffectTemplate extends SystemDataModel {
per: new foundry.data.fields.StringField({
required: true, nullable: true, blank: false, initial: null, label: "DND5E.LimitedUsesPer"
}),
recovery: new FormulaField({required: true, label: "DND5E.RecoveryFormula"})
recovery: new FormulaField({required: true, label: "DND5E.RecoveryFormula"}),
prompt: new foundry.data.fields.BooleanField({initial: true, label: "DND5E.LimitedUsesPrompt"})
}, extraSchema), options);
}
};
Expand Down
9 changes: 4 additions & 5 deletions module/documents/item.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -935,8 +935,7 @@ export default class Item5e extends Item {
* @returns {ItemUseConfiguration} Configuration data for the roll.
*/
_getUsageConfig() {
const { consume, activation, uses, target, level, preparation } = this.system;
const active = !!activation?.type;
const { consume, uses, target, level, preparation } = this.system;

const config = {
consumeSpellSlot: null,
Expand All @@ -950,13 +949,13 @@ export default class Item5e extends Item {
config.consumeSpellSlot = true;
config.slotLevel = preparation?.mode === "pact" ? "pact" : `spell${level}`;
}
if ( active && this.hasLimitedUses ) config.consumeUsage = true;
if ( active && !!consume?.type && !!consume?.target && (!this.hasAttack || (consume.type !== "ammo")) ) {
if ( this.hasLimitedUses ) config.consumeUsage = uses.prompt;
if ( this.hasResource ) {
config.consumeResource = true;
// Do not suggest consuming your own uses if also consuming them through resources.
if ( consume.target === this.id ) config.consumeUsage = null;
}
if ( active && game.user.can("TEMPLATE_CREATE") && this.hasAreaTarget ) config.createMeasuredTemplate = true;
if ( game.user.can("TEMPLATE_CREATE") && this.hasAreaTarget ) config.createMeasuredTemplate = target.prompt;

return config;
}
Expand Down
7 changes: 0 additions & 7 deletions templates/items/consumable.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,6 @@

{{!-- Item Activation Template --}}
{{> "dnd5e.item-activation"}}
{{#if system.activation.type}}
<div class="form-group">
<label class="checkbox">
<input type="checkbox" name="system.uses.autoDestroy" {{checked system.uses.autoDestroy}}> {{ localize "DND5E.ItemDestroyEmpty" }}
</label>
</div>
{{/if}}

<h3 class="form-header">{{ localize "DND5E.ItemConsumableActivation" }}</h3>

Expand Down
19 changes: 19 additions & 0 deletions templates/items/parts/item-activation.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,23 @@
</select>
</div>
</div>

{{!-- Prompt Configuration --}}
<div class="form-group">
{{#if (eq item.type "consumable")}}
<label class="checkbox">
<input type="checkbox" name="system.uses.autoDestroy" {{checked system.uses.autoDestroy}}> {{ localize "DND5E.ItemDestroyEmpty" }}
krbz999 marked this conversation as resolved.
Show resolved Hide resolved
</label>
{{/if}}
{{#if item.hasAreaTarget}}
<label class="checkbox">
<input type="checkbox" name="system.target.prompt" {{checked system.target.prompt}}> {{ localize "DND5E.TemplatePrompt" }}
krbz999 marked this conversation as resolved.
Show resolved Hide resolved
</label>
{{/if}}
{{#if system.uses.per}}
<label class="checkbox">
<input type="checkbox" name="system.uses.prompt" {{checked system.uses.prompt}}> {{ localize "DND5E.LimitedUsesPrompt" }}
krbz999 marked this conversation as resolved.
Show resolved Hide resolved
</label>
{{/if}}
</div>
{{/if}}