Renamed 'Main Charater' to 'Leader'

This commit is contained in:
WBHarry 2026-04-11 02:26:01 +02:00
parent 94f9a7a0d2
commit 4fedb42d44
8 changed files with 54 additions and 54 deletions

View file

@ -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 = {

View file

@ -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) {

View file

@ -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
};
}

View file

@ -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';

View file

@ -5,7 +5,7 @@
<div class="group-roll-results">
{{#if hasRolled}}<span class="roll-title {{groupRoll.totalDualityClass}}">{{groupRoll.total}} {{groupRoll.totalLabel}}</span>{{/if}}
<div class="group-roll-container">
<span>{{#if groupRoll.mainCharacterTotal includeZero=true}}{{groupRoll.mainCharacterTotal}}{{else}}{{localize "DAGGERHEART.APPLICATIONS.GroupRollSelect.leaderRoll"}}{{/if}}</span>
<span>{{#if groupRoll.leaderTotal includeZero=true}}{{groupRoll.leaderTotal}}{{else}}{{localize "DAGGERHEART.APPLICATIONS.GroupRollSelect.leaderRoll"}}{{/if}}</span>
{{#each groupRoll.modifiers as |modifier|}}
<span>{{#if (gte modifier 0)}}+{{else}}-{{/if}}</span>
<span>{{positive modifier}}</span>

View file

@ -11,12 +11,12 @@
{{/each}}
</div>
<div class="main-roll {{#if selectedMainCharacterDisabled}}inactive{{/if}}">
<div class="main-roll {{#if selectedLeaderDisabled}}inactive{{/if}}">
<div class="form-group">
<label>{{localize "DAGGERHEART.APPLICATIONS.GroupRollSelect.leader"}}</label>
<div class="form-fields">
<select class="main-character-field" {{#if selectedMainCharacterDisabled}}disabled{{/if}}>
{{selectOptions selectedMainCharacterOptions selected=selectedMainCharacter.memberId blank="" }}
<select class="main-character-field" {{#if selectedLeaderDisabled}}disabled{{/if}}>
{{selectOptions selectedLeaderOptions selected=selectedLeader.memberId blank="" }}
</select>
</div>
</div>

View file

@ -1,5 +1,5 @@
<section class="tab {{#if tabs.groupRoll.active}} active{{/if}}" data-group="{{tabs.groupRoll.group}}" data-tab="{{tabs.groupRoll.id}}">
{{#with mainCharacter}}
{{#with leader}}
<div class="main-character-outer-container">
<div class="section-title">{{localize "DAGGERHEART.APPLICATIONS.GroupRollSelect.leader"}}</div>
<fieldset>
@ -11,7 +11,7 @@
<div class="roll-setup">
<div class="form-group">
<div class="form-fields">
<select name="system.groupRoll.mainCharacter.rollChoice" {{#if hasRolled}}disabled{{/if}}>
<select name="system.groupRoll.leader.rollChoice" {{#if hasRolled}}disabled{{/if}}>
{{selectOptions ../traitOptions selected=rollChoice localize=true}}
</select>
</div>
@ -26,12 +26,12 @@
<span class="roll-title">
{{localize "DAGGERHEART.GENERAL.roll"}}
<div class="roll-tools">
<a class="roll-button" data-action="makeMainCharacterRoll">
<a class="roll-button" data-action="makeLeaderRoll">
<img src="systems/daggerheart/assets/icons/dice/hope/d12.svg" />
</a>
{{#if hasRolled}}
<a class="delete-button" data-action="removeMainCharacterRoll">
<a class="delete-button" data-action="removeLeaderRoll">
<i class="fa-solid fa-trash"></i>
</a>
{{/if}}
@ -42,12 +42,12 @@
<div class="roll-data {{#if roll.withHope}}hope{{else if roll.withFear}}fear{{else}}critical{{/if}}">
<div class="duality-label">{{roll.total}} {{localize "DAGGERHEART.GENERAL.withThing" thing=roll.totalLabel}}</div>
<div class="roll-dice-container">
<a class="roll-dice" data-action="rerollMainCharacterDice" data-dice-type="hope">
<a class="roll-dice" data-action="rerollLeaderDice" data-dice-type="hope">
<span class="dice-label">{{roll.dHope.total}}</span>
<img src="{{concat "systems/daggerheart/assets/icons/dice/hope/" roll.dHope.denomination ".svg"}}" />
</a>
<span class="roll-operator">+</span>
<a class="roll-dice" data-action="rerollMainCharacterDice" data-dice-type="fear">
<a class="roll-dice" data-action="rerollLeaderDice" data-dice-type="fear">
<span class="dice-label">{{roll.dFear.total}}</span>
<img src="{{concat "systems/daggerheart/assets/icons/dice/fear/" roll.dFear.denomination ".svg"}}" />
</a>