Added an enable/disable checkbox for TagTeamRoll hope cost

This commit is contained in:
WBHarry 2026-06-20 23:19:26 +02:00
parent 9eeadba046
commit de7c08ed64
3 changed files with 51 additions and 13 deletions

View file

@ -9,6 +9,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
constructor(party) { constructor(party) {
super({ id: `TagTeamDialog-${party.id}` }); super({ id: `TagTeamDialog-${party.id}` });
this.usesTagTeamHopeCost = true;
this.party = party; this.party = party;
this.partyMembers = party.system.partyMembers this.partyMembers = party.system.partyMembers
.filter(x => Party.DICE_ROLL_ACTOR_TYPES.includes(x.type)) .filter(x => Party.DICE_ROLL_ACTOR_TYPES.includes(x.type))
@ -20,7 +21,9 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
owned: member.testUserPermission(game.user, CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER) owned: member.testUserPermission(game.user, CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER)
})); }));
this.initiator = { cost: 3 }; this.initiator = { cost:
this.party.system.schema.fields.tagTeam.fields.initiator.fields.cost.initial
};
this.openForAllPlayers = true; this.openForAllPlayers = true;
this.tabGroups.application = Object.keys(party.system.tagTeam.members).length this.tabGroups.application = Object.keys(party.system.tagTeam.members).length
@ -94,9 +97,13 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
?.addEventListener('input', this.updateInitiatorMemberField.bind(this)); ?.addEventListener('input', this.updateInitiatorMemberField.bind(this));
htmlElement htmlElement
.querySelector('.initiator-cost-field') .querySelector('.initiator-cost-input')
?.addEventListener('input', this.updateInitiatorCostField.bind(this)); ?.addEventListener('input', this.updateInitiatorCostField.bind(this));
htmlElement
.querySelector('.initiator-cost-enabled-checkbox')
?.addEventListener('change', this.toggleInitiatorCostEnabled.bind(this));
htmlElement htmlElement
.querySelector('.openforall-field') .querySelector('.openforall-field')
?.addEventListener('change', this.updateOpenForAllField.bind(this)); ?.addEventListener('change', this.updateOpenForAllField.bind(this));
@ -156,6 +163,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
.map(x => ({ value: x.id, label: x.name })); .map(x => ({ value: x.id, label: x.name }));
partContext.initiatorDisabled = !selectedMembers.length; partContext.initiatorDisabled = !selectedMembers.length;
partContext.openForAllPlayers = this.openForAllPlayers; partContext.openForAllPlayers = this.openForAllPlayers;
partContext.usesTagTeamHopeCost = this.usesTagTeamHopeCost;
break; break;
case 'tagTeamRoll': case 'tagTeamRoll':
@ -397,6 +405,13 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
this.render(); this.render();
} }
toggleInitiatorCostEnabled(_event) {
this.usesTagTeamHopeCost = !this.usesTagTeamHopeCost;
this.initiator.cost = this.usesTagTeamHopeCost ?
this.party.system.schema.fields.tagTeam.fields.initiator.fields.cost.initial : 0;
this.render();
}
updateOpenForAllField(event) { updateOpenForAllField(event) {
this.openForAllPlayers = event.target.checked; this.openForAllPlayers = event.target.checked;
this.render(); this.render();
@ -751,9 +766,10 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
await cls.create(msgData); await cls.create(msgData);
/* Handle resource updates from the finished TagTeamRoll */ /* Handle resource updates from the finished TagTeamRoll */
const tagTeamData = this.party.system.tagTeam;
const fearUpdate = { key: 'fear', value: null, total: null, enabled: true };
if (shouldUseHopeFearAutomation({ gmAsPlayer: true })) { if (shouldUseHopeFearAutomation({ gmAsPlayer: true })) {
const tagTeamData = this.party.system.tagTeam;
const fearUpdate = { key: 'fear', value: null, total: null, enabled: true };
for (let memberId in tagTeamData.members) { for (let memberId in tagTeamData.members) {
const resourceUpdates = []; const resourceUpdates = [];
const rollGivesHope = finalRoll.isCritical || finalRoll.withHope; const rollGivesHope = finalRoll.isCritical || finalRoll.withHope;
@ -775,12 +791,17 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
game.actors.get(memberId).modifyResource(resourceUpdates); game.actors.get(memberId).modifyResource(resourceUpdates);
} }
}
if (fearUpdate.value) { /* Even with Hope/Fear automation off, the hope cost of performing the TagTeamRoll can still optionally be subtracted */
mainActor.modifyResource([fearUpdate]); else if (tagTeamData.initiator.cost) {
} const initiatingActor = game.actors.get(tagTeamData.initiator.memberId);
initiatingActor.modifyResource([{ key: 'hope', value: -tagTeamData.initiator.cost, total: tagTeamData.initiator.cost, enabled: true }]);
} }
if (fearUpdate.value) {
mainActor.modifyResource([fearUpdate]);
}
/* Fin */ /* Fin */
this.cancelRoll({ confirm: false }); this.cancelRoll({ confirm: false });
} }

View file

@ -88,9 +88,21 @@
grid-template-columns: 1fr 1fr; grid-template-columns: 1fr 1fr;
gap: 8px; gap: 8px;
&.inactive { .inactive {
opacity: 0.4; opacity: 0.4;
} }
.initiator-cost-fields {
display: flex;
flex-direction: column;
align-items: flex-start;
.initiator-cost-inputs {
display: grid;
grid-template-columns: auto 1fr;
align-items: center;
}
}
} }
footer { footer {

View file

@ -26,11 +26,16 @@
</select> </select>
</div> </div>
</div> </div>
<div class="form-group"> <div class="initiator-cost-fields">
<label>{{localize "DAGGERHEART.APPLICATIONS.TagTeamSelect.FIELDS.initiator.cost.label"}}</label> <label>{{localize "DAGGERHEART.APPLICATIONS.TagTeamSelect.FIELDS.initiator.cost.label"}}</label>
<div class="form-fields"> <div class="initiator-cost-inputs">
<input type="text" data-dtype="Number" value="{{initiator.cost}}" class="initiator-cost-field" {{#if initiatorDisabled}}disabled{{/if}} /> <input type="checkbox" class="initiator-cost-enabled-checkbox {{#if initiatorDisabled}}inactive{{/if}}" {{checked usesTagTeamHopeCost}} {{#if initiatorDisabled}}disabled{{/if}} />
</div> <input
type="text" data-dtype="Number" value="{{initiator.cost}}"
class="initiator-cost-input {{#if (or initiatorDisabled (not usesTagTeamHopeCost))}}inactive{{/if}}"
{{#if (or initiatorDisabled (not usesTagTeamHopeCost))}}disabled{{/if}}
/>
</div>
</div> </div>
</div> </div>