From 4fedb42d446a733390114cdb02cb6e2668dfaeef Mon Sep 17 00:00:00 2001 From: WBHarry Date: Sat, 11 Apr 2026 02:26:01 +0200 Subject: [PATCH] Renamed 'Main Charater' to 'Leader' --- .../applications/dialogs/groupRollDialog.mjs | 80 +++++++++---------- module/applications/sheets/actors/party.mjs | 2 +- module/data/groupRollData.mjs | 4 +- .../{mainCharacter.less => leader.less} | 0 styles/less/dialog/index.less | 2 +- .../dialogs/groupRollDialog/groupRoll.hbs | 2 +- .../groupRollDialog/initialization.hbs | 6 +- ...{groupRollMainCharacter.hbs => leader.hbs} | 12 +-- 8 files changed, 54 insertions(+), 54 deletions(-) rename styles/less/dialog/group-roll-dialog/{mainCharacter.less => leader.less} (100%) rename templates/dialogs/groupRollDialog/{groupRollMainCharacter.hbs => leader.hbs} (94%) diff --git a/module/applications/dialogs/groupRollDialog.mjs b/module/applications/dialogs/groupRollDialog.mjs index 47db04c1..d178a7e4 100644 --- a/module/applications/dialogs/groupRollDialog.mjs +++ b/module/applications/dialogs/groupRollDialog.mjs @@ -19,7 +19,7 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat owned: member.testUserPermission(game.user, CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER) })); - this.mainCharacter = null; + this.leader = null; this.openForAllPlayers = true; this.tabGroups.application = Object.keys(party.system.groupRoll.participants).length @@ -44,9 +44,9 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat makeRoll: this.#makeRoll, removeRoll: this.#removeRoll, rerollDice: this.#rerollDice, - makeMainCharacterRoll: this.#makeMainCharacterRoll, - removeMainCharacterRoll: this.#removeMainCharacterRoll, - rerollMainCharacterDice: this.#rerollMainCharacterDice, + makeLeaderRoll: this.#makeLeaderRoll, + removeLeaderRoll: this.#removeLeaderRoll, + rerollLeaderDice: this.#rerollLeaderDice, markSuccessfull: this.#markSuccessfull, cancelRoll: this.#onCancelRoll, finishRoll: this.#finishRoll @@ -59,9 +59,9 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat id: 'initialization', template: 'systems/daggerheart/templates/dialogs/groupRollDialog/initialization.hbs' }, - mainCharacter: { - id: 'mainCharacter', - template: 'systems/daggerheart/templates/dialogs/groupRollDialog/groupRollMainCharacter.hbs' + leader: { + id: 'leader', + template: 'systems/daggerheart/templates/dialogs/groupRollDialog/leader.hbs' }, groupRoll: { id: 'groupRoll', @@ -85,11 +85,11 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat htmlElement .querySelector('.main-character-field') - ?.addEventListener('input', this.updateMainCharacterField.bind(this)); + ?.addEventListener('input', this.updateLeaderField.bind(this)); } _configureRenderParts(options) { - const { initialization, mainCharacter, groupRoll, footer } = super._configureRenderParts(options); + const { initialization, leader, groupRoll, footer } = super._configureRenderParts(options); const augmentedParts = { initialization }; for (const memberKey of Object.keys(this.party.system.groupRoll.aidingCharacters)) { augmentedParts[memberKey] = { @@ -98,7 +98,7 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat }; } - augmentedParts.mainCharacter = mainCharacter; + augmentedParts.leader = leader; augmentedParts.groupRoll = groupRoll; augmentedParts.footer = footer; @@ -153,20 +153,20 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat const selectedMembers = partContext.memberSelection.filter(x => x.selected); - partContext.selectedMainCharacter = this.mainCharacter; - partContext.selectedMainCharacterOptions = selectedMembers + partContext.selectedLeader = this.leader; + partContext.selectedLeaderOptions = selectedMembers .filter(actor => actor.owned) .map(x => ({ value: x.id, label: x.name })); - partContext.selectedMainCharacterDisabled = !selectedMembers.length; + partContext.selectedLeaderDisabled = !selectedMembers.length; - partContext.canStartGroupRoll = selectedMembers.length > 1 && this.mainCharacter?.memberId; + partContext.canStartGroupRoll = selectedMembers.length > 1 && this.leader?.memberId; partContext.openForAllPlayers = this.openForAllPlayers; break; - case 'mainCharacter': - partContext.mainCharacter = this.getRollCharacterData(this.party.system.groupRoll.mainCharacter); + case 'leader': + partContext.leader = this.getRollCharacterData(this.party.system.groupRoll.leader); break; case 'groupRoll': - const leader = this.party.system.groupRoll.mainCharacter; + const leader = this.party.system.groupRoll.leader; partContext.hasRolled = leader?.rollData || Object.values(this.party.system.groupRoll?.aidingCharacters ?? {}).some( @@ -184,7 +184,7 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat }, { modifierTotal: 0, modifiers: [] } ); - const mainCharacterTotal = leader?.rollData ? leader.roll.total : null; + const leaderTotal = leader?.rollData ? leader.roll.total : null; partContext.groupRoll = { totalLabel: leader?.rollData ? game.i18n.format('DAGGERHEART.GENERAL.withThing', { @@ -192,14 +192,14 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat }) : null, totalDualityClass: leader?.roll?.isCritical ? 'critical' : leader?.roll?.withHope ? 'hope' : 'fear', - total: mainCharacterTotal + modifierTotal, - mainCharacterTotal, + total: leaderTotal + modifierTotal, + leaderTotal: leaderTotal, modifiers }; break; case 'footer': partContext.canFinishRoll = - Boolean(this.party.system.groupRoll.mainCharacter?.rollData) && + Boolean(this.party.system.groupRoll.leader?.rollData) && Object.values(this.party.system.groupRoll.aidingCharacters).every(x => x.successfull !== null); break; } @@ -256,15 +256,15 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat } getUpdatingParts(target) { - const { initialization, mainCharacter, groupRoll, footer } = this.constructor.PARTS; + const { initialization, leader, groupRoll, footer } = this.constructor.PARTS; const isInitialization = this.tabGroups.application === initialization.id; const updatingMember = target.closest('.team-member-container')?.dataset?.memberKey; - const updatingMainCharacter = target.closest('.main-character-outer-container'); + const updatingLeader = target.closest('.main-character-outer-container'); return [ ...(isInitialization ? [initialization.id] : []), ...(updatingMember ? [updatingMember] : []), - ...(updatingMainCharacter ? [mainCharacter.id] : []), + ...(updatingLeader ? [leader.id] : []), ...(!isInitialization ? [groupRoll.id, footer.id] : []) ]; } @@ -307,16 +307,16 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat this.render(); } - updateMainCharacterField(event) { - if (!this.mainCharacter) this.mainCharacter = {}; - this.mainCharacter.memberId = event.target.value; + updateLeaderField(event) { + if (!this.leader) this.leader = {}; + this.leader.memberId = event.target.value; this.render(); } static async #startGroupRoll() { - const mainCharacter = this.partyMembers.find(x => x.id === this.mainCharacter.memberId); + const leader = this.partyMembers.find(x => x.id === this.leader.memberId); const aidingCharacters = this.partyMembers.reduce((acc, curr) => { - if (curr.selected && curr.id !== this.mainCharacter.memberId) + if (curr.selected && curr.id !== this.leader.memberId) acc[curr.id] = { id: curr.id, name: curr.name, img: curr.img }; return acc; @@ -326,7 +326,7 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat 'system.groupRoll': _replace( new game.system.api.data.GroupRollData({ ...this.party.system.groupRoll.toObject(), - mainCharacter: { id: mainCharacter.id, name: mainCharacter.name, img: mainCharacter.img }, + leader: { id: leader.id, name: leader.name, img: leader.img }, aidingCharacters }) ) @@ -373,9 +373,9 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat this.makeRoll(button, character, `system.groupRoll.aidingCharacters.${member}.rollData`); } - static async #makeMainCharacterRoll(_event, button) { - const character = this.party.system.groupRoll.mainCharacter; - this.makeRoll(button, character, 'system.groupRoll.mainCharacter.rollData'); + static async #makeLeaderRoll(_event, button) { + const character = this.party.system.groupRoll.leader; + this.makeRoll(button, character, 'system.groupRoll.leader.rollData'); } async removeRoll(button, path) { @@ -396,8 +396,8 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat this.removeRoll(button, `system.groupRoll.aidingCharacters.${button.dataset.member}`); } - static async #removeMainCharacterRoll(_event, button) { - this.removeRoll(button, 'system.groupRoll.mainCharacter'); + static async #removeLeaderRoll(_event, button) { + this.removeRoll(button, 'system.groupRoll.leader'); } async rerollDice(button, data, path) { @@ -430,8 +430,8 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat ); } - static async #rerollMainCharacterDice(_, button) { - this.rerollDice(button, this.party.system.groupRoll.mainCharacter, `system.groupRoll.mainCharacter.rollData`); + static async #rerollLeaderDice(_, button) { + this.rerollDice(button, this.party.system.groupRoll.leader, `system.groupRoll.leader.rollData`); } static #markSuccessfull(_event, button) { @@ -465,7 +465,7 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat await this.updatePartyData( { 'system.groupRoll': { - mainCharacter: null, + leader: null, aidingCharacters: _replace({}) } }, @@ -481,7 +481,7 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat } static async #finishRoll() { - const totalRoll = this.party.system.groupRoll.mainCharacter.roll; + const totalRoll = this.party.system.groupRoll.leader.roll; for (const character of Object.values(this.party.system.groupRoll.aidingCharacters)) { totalRoll.terms.push(new foundry.dice.terms.OperatorTerm({ operator: character.successfull ? '+' : '-' })); totalRoll.terms.push(new foundry.dice.terms.NumericTerm({ number: 1 })); @@ -490,7 +490,7 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat await totalRoll._evaluate(); const systemData = totalRoll.options; - const actor = game.actors.get(this.party.system.groupRoll.mainCharacter.id); + const actor = game.actors.get(this.party.system.groupRoll.leader.id); const cls = getDocumentClass('ChatMessage'), msgData = { diff --git a/module/applications/sheets/actors/party.mjs b/module/applications/sheets/actors/party.mjs index b7ea9b9f..d4545f63 100644 --- a/module/applications/sheets/actors/party.mjs +++ b/module/applications/sheets/actors/party.mjs @@ -116,7 +116,7 @@ export default class Party extends DHBaseActorSheet { relativeTo: this.document }); context.tagTeamActive = Boolean(this.document.system.tagTeam.initiator); - context.groupRollActive = Boolean(this.document.system.groupRoll.mainCharacter); + context.groupRollActive = Boolean(this.document.system.groupRoll.leader); } async _prepareMembersContext(context, _options) { diff --git a/module/data/groupRollData.mjs b/module/data/groupRollData.mjs index 5047c4e2..78a06b13 100644 --- a/module/data/groupRollData.mjs +++ b/module/data/groupRollData.mjs @@ -3,14 +3,14 @@ export default class GroupRollData extends foundry.abstract.DataModel { const fields = foundry.data.fields; return { - mainCharacter: new fields.EmbeddedDataField(CharacterData, { nullable: true, initial: null }), + leader: new fields.EmbeddedDataField(CharacterData, { nullable: true, initial: null }), aidingCharacters: new fields.TypedObjectField(new fields.EmbeddedDataField(CharacterData)) }; } get participants() { return { - ...(this.mainCharacter ? { [this.mainCharacter.id]: this.mainCharacter } : {}), + ...(this.leader ? { [this.leader.id]: this.leader } : {}), ...this.aidingCharacters }; } diff --git a/styles/less/dialog/group-roll-dialog/mainCharacter.less b/styles/less/dialog/group-roll-dialog/leader.less similarity index 100% rename from styles/less/dialog/group-roll-dialog/mainCharacter.less rename to styles/less/dialog/group-roll-dialog/leader.less diff --git a/styles/less/dialog/index.less b/styles/less/dialog/index.less index fa59d0f5..947142ff 100644 --- a/styles/less/dialog/index.less +++ b/styles/less/dialog/index.less @@ -37,7 +37,7 @@ @import './tag-team-dialog/sheet.less'; @import './group-roll-dialog/initialization.less'; -@import './group-roll-dialog/mainCharacter.less'; +@import './group-roll-dialog/leader.less'; @import './group-roll-dialog/sheet.less'; @import './image-select/sheet.less'; diff --git a/templates/dialogs/groupRollDialog/groupRoll.hbs b/templates/dialogs/groupRollDialog/groupRoll.hbs index 4b28bc30..f33c6ad2 100644 --- a/templates/dialogs/groupRollDialog/groupRoll.hbs +++ b/templates/dialogs/groupRollDialog/groupRoll.hbs @@ -5,7 +5,7 @@
{{#if hasRolled}}{{groupRoll.total}} {{groupRoll.totalLabel}}{{/if}}
- {{#if groupRoll.mainCharacterTotal includeZero=true}}{{groupRoll.mainCharacterTotal}}{{else}}{{localize "DAGGERHEART.APPLICATIONS.GroupRollSelect.leaderRoll"}}{{/if}} + {{#if groupRoll.leaderTotal includeZero=true}}{{groupRoll.leaderTotal}}{{else}}{{localize "DAGGERHEART.APPLICATIONS.GroupRollSelect.leaderRoll"}}{{/if}} {{#each groupRoll.modifiers as |modifier|}} {{#if (gte modifier 0)}}+{{else}}-{{/if}} {{positive modifier}} diff --git a/templates/dialogs/groupRollDialog/initialization.hbs b/templates/dialogs/groupRollDialog/initialization.hbs index 4628c381..a520b8bd 100644 --- a/templates/dialogs/groupRollDialog/initialization.hbs +++ b/templates/dialogs/groupRollDialog/initialization.hbs @@ -11,12 +11,12 @@ {{/each}}
-
+
- + {{selectOptions selectedLeaderOptions selected=selectedLeader.memberId blank="" }}
diff --git a/templates/dialogs/groupRollDialog/groupRollMainCharacter.hbs b/templates/dialogs/groupRollDialog/leader.hbs similarity index 94% rename from templates/dialogs/groupRollDialog/groupRollMainCharacter.hbs rename to templates/dialogs/groupRollDialog/leader.hbs index bf804aa6..78fbcb42 100644 --- a/templates/dialogs/groupRollDialog/groupRollMainCharacter.hbs +++ b/templates/dialogs/groupRollDialog/leader.hbs @@ -1,5 +1,5 @@
- {{#with mainCharacter}} + {{#with leader}}
{{localize "DAGGERHEART.APPLICATIONS.GroupRollSelect.leader"}}
@@ -11,7 +11,7 @@
- {{selectOptions ../traitOptions selected=rollChoice localize=true}}
@@ -26,12 +26,12 @@ {{localize "DAGGERHEART.GENERAL.roll"}}
- + {{#if hasRolled}} - + {{/if}} @@ -42,12 +42,12 @@
{{roll.total}} {{localize "DAGGERHEART.GENERAL.withThing" thing=roll.totalLabel}}