Improvements

This commit is contained in:
WBHarry 2026-04-11 02:02:32 +02:00
parent 303f2fdae7
commit 154c1c939b
10 changed files with 197 additions and 138 deletions

View file

@ -747,7 +747,8 @@
},
"GroupRollSelect": {
"title": "Group Roll",
"mainCharacter": "Main Character",
"leader": "Leader",
"leaderRoll": "Leader Roll",
"openDialogForAll": "Open Dialog For All",
"startGroupRoll": "Start Group Roll",
"cancelGroupRoll": "Cancel",

View file

@ -1,3 +1,4 @@
import { ResourceUpdateMap } from '../../data/action/baseAction.mjs';
import { emitAsGM, GMUpdateEvent, RefreshType, socketEvent } from '../../systemRegistration/socket.mjs';
import Party from '../sheets/actors/party.mjs';
@ -109,15 +110,19 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat
await super._onRender(context, options);
if (this.element.querySelector('.team-container')) return;
const initializationPart = this.element.querySelector('.initialization-container');
initializationPart.insertAdjacentHTML('afterend', '<div class="team-container"></div>');
initializationPart.insertAdjacentHTML(
'afterend',
`<div class="section-title">${game.i18n.localize('Aiding Characters')}</div>`
);
const teamContainer = this.element.querySelector('.team-container');
for (const memberContainer of this.element.querySelectorAll('.team-member-container'))
teamContainer.appendChild(memberContainer);
if (this.tabGroups.application !== this.constructor.PARTS.initialization.id) {
const initializationPart = this.element.querySelector('.initialization-container');
initializationPart.insertAdjacentHTML('afterend', '<div class="team-container"></div>');
initializationPart.insertAdjacentHTML(
'afterend',
`<div class="section-title">${game.i18n.localize('Aiding Characters')}</div>`
);
const teamContainer = this.element.querySelector('.team-container');
for (const memberContainer of this.element.querySelectorAll('.team-member-container'))
teamContainer.appendChild(memberContainer);
}
}
async _prepareContext(_options) {
@ -161,6 +166,12 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat
partContext.mainCharacter = this.getRollCharacterData(this.party.system.groupRoll.mainCharacter);
break;
case 'groupRoll':
const leader = this.party.system.groupRoll.mainCharacter;
partContext.hasRolled =
leader?.rollData ||
Object.values(this.party.system.groupRoll?.aidingCharacters ?? {}).some(
x => x.successfull !== null
);
const { modifierTotal, modifiers } = Object.values(this.party.system.groupRoll.aidingCharacters).reduce(
(acc, curr) => {
const modifier = curr.successfull === true ? 1 : curr.successfull === false ? -1 : null;
@ -173,15 +184,14 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat
},
{ modifierTotal: 0, modifiers: [] }
);
const mainCharacterTotal = this.party.system.groupRoll.mainCharacter?.rollData
? this.party.system.groupRoll.mainCharacter.roll.total
: null;
const mainCharacterTotal = leader?.rollData ? leader.roll.total : null;
partContext.groupRoll = {
totalLabel: this.party.system.groupRoll.mainCharacter?.rollData
totalLabel: leader?.rollData
? game.i18n.format('DAGGERHEART.GENERAL.withThing', {
thing: this.party.system.groupRoll.mainCharacter.roll.totalLabel
thing: leader.roll.totalLabel
})
: null,
totalDualityClass: leader?.roll?.isCritical ? 'critical' : leader?.roll?.withHope ? 'hope' : 'fear',
total: mainCharacterTotal + modifierTotal,
mainCharacterTotal,
modifiers
@ -333,13 +343,10 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat
}
//#endregion
static async #makeRoll(_event, button) {
const { member } = button.dataset;
const actor = game.actors.find(x => x.id === member);
async makeRoll(button, characterData, path) {
const actor = game.actors.find(x => x.id === characterData.id);
if (!actor) return;
const characterData = this.party.system.groupRoll.aidingCharacters[member];
const result = await actor.rollTrait(characterData.rollChoice, {
skips: {
createMessage: true,
@ -354,36 +361,43 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat
delete rollData.options.messageRoll;
this.updatePartyData(
{
[`system.groupRoll.aidingCharacters.${member}.rollData`]: rollData
[path]: rollData
},
this.getUpdatingParts(button)
);
}
static async #removeRoll(_, button) {
static async #makeRoll(_event, button) {
const { member } = button.dataset;
const character = this.party.system.groupRoll.aidingCharacters[member];
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');
}
async removeRoll(button, path) {
this.updatePartyData(
{
[`system.groupRoll.aidingCharacters.${button.dataset.member}`]: {
[path]: {
rollData: null,
rollChoice: null,
selected: false
selected: false,
successfull: null
}
},
this.getUpdatingParts(button)
);
}
static async #rerollDice(_, button) {
const { member } = button.dataset;
this.rerollDice(
button,
this.party.system.groupRoll.aidingCharacters[member],
`system.groupRoll.aidingCharacters.${member}.rollData`
);
static async #removeRoll(_event, button) {
this.removeRoll(button, `system.groupRoll.aidingCharacters.${button.dataset.member}`);
}
static async #rerollMainCharacterDice(_, button) {
this.rerollDice(button, this.party.system.groupRoll.mainCharacter, `system.groupRoll.mainCharacter.rollData`);
static async #removeMainCharacterRoll(_event, button) {
this.removeRoll(button, 'system.groupRoll.mainCharacter');
}
async rerollDice(button, data, path) {
@ -407,42 +421,17 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat
);
}
static async #makeMainCharacterRoll(_event, button) {
const actor = game.actors.find(x => x.id === this.party.system.groupRoll.mainCharacter.id);
if (!actor) return;
const characterData = this.party.system.groupRoll.mainCharacter;
const result = await actor.rollTrait(characterData.rollChoice, {
skips: {
createMessage: true,
resources: true,
triggers: true
}
});
if (!game.modules.get('dice-so-nice')?.active) foundry.audio.AudioHelper.play({ src: CONFIG.sounds.dice });
const rollData = result.messageRoll.toJSON();
delete rollData.options.messageRoll;
this.updatePartyData(
{
[`system.groupRoll.mainCharacter.rollData`]: rollData
},
this.getUpdatingParts(button)
static async #rerollDice(_, button) {
const { member } = button.dataset;
this.rerollDice(
button,
this.party.system.groupRoll.aidingCharacters[member],
`system.groupRoll.aidingCharacters.${member}.rollData`
);
}
static async #removeMainCharacterRoll(_event, button) {
this.updatePartyData(
{
[`system.groupRoll.mainCharacter`]: {
rollData: null,
rollChoice: null,
selected: false
}
},
this.getUpdatingParts(button)
);
static async #rerollMainCharacterDice(_, button) {
this.rerollDice(button, this.party.system.groupRoll.mainCharacter, `system.groupRoll.mainCharacter.rollData`);
}
static #markSuccessfull(_event, button) {
@ -517,6 +506,20 @@ export default class GroupRollDialog extends HandlebarsApplicationMixin(Applicat
await cls.create(msgData);
const resourceMap = new ResourceUpdateMap(actor);
if (totalRoll.isCritical) {
resourceMap.addResources([
{ key: 'stress', value: -1, total: 1 },
{ key: 'hope', value: 1, total: 1 }
]);
} else if (totalRoll.withHope) {
resourceMap.addResources([{ key: 'hope', value: 1, total: 1 }]);
} else {
resourceMap.addResources([{ key: 'fear', value: 1, total: 1 }]);
}
resourceMap.updateResources();
/* Fin */
this.cancelRoll({ confirm: false });
}

View file

@ -116,6 +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);
}
async _prepareMembersContext(context, _options) {

View file

@ -1,3 +1,11 @@
.theme-light .daggerheart.dialog.dh-style.views.group-roll-dialog {
.initialization-container .members-container .member-container {
.member-name {
background-image: url('../assets/parchments/dh-parchment-light.png');
}
}
}
.daggerheart.dialog.dh-style.views.group-roll-dialog {
.initialization-container {
h2 {
@ -20,6 +28,17 @@
.member-name {
position: absolute;
padding: 0 2px;
border: 1px solid;
border-radius: 6px;
margin-top: 4px;
color: light-dark(@dark, @beige);
background-image: url('../assets/parchments/dh-parchment-dark.png');
}
img {
border-radius: 6px;
border: 1px solid light-dark(@dark-blue, @golden);
}
}
}

View file

@ -12,6 +12,11 @@
gap: 8px;
flex: 1;
&.inactive {
opacity: 0.3;
pointer-events: none;
}
.data-container {
display: flex;
flex-direction: column;
@ -59,9 +64,27 @@
align-items: center;
gap: 8px;
&.hope,
&.fear,
&.critical {
color: var(--text-color);
}
&.hope {
--text-color: @golden;
}
&.fear {
--text-color: @chat-blue;
}
&.critical {
--text-color: @chat-purple;
}
&::before,
&::after {
color: light-dark(@dark-blue, @golden);
color: var(--text-color);
content: '';
flex: 1;
height: 2px;

View file

@ -20,6 +20,17 @@
.member-name {
position: absolute;
padding: 0 2px;
border: 1px solid;
border-radius: 6px;
margin-top: 4px;
color: light-dark(@dark, @beige);
background-image: url('../assets/parchments/dh-parchment-dark.png');
}
img {
border-radius: 6px;
border: 1px solid light-dark(@dark-blue, @golden);
}
}
}

View file

@ -3,13 +3,17 @@
<legend>{{localize "Result"}}</legend>
<div class="group-roll-results">
<span class="roll-title">{{groupRoll.total}} {{groupRoll.totalLabel}}</span>
{{#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 "<Main Character Roll>"}}{{/if}}</span>
<span>{{#if groupRoll.mainCharacterTotal includeZero=true}}{{groupRoll.mainCharacterTotal}}{{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>
{{/each}}
{{#unless groupRoll.modifiers.length}}
<span>+</span>
<span>{{localize "DAGGERHEART.GENERAL.Modifier.plural"}}</span>
{{/unless}}
</div>
</div>
</fieldset>

View file

@ -1,71 +1,73 @@
{{#with mainCharacter}}
<div class="main-character-outer-container">
<div class="section-title">{{localize "Main Character"}}</div>
<fieldset>
<div class="main-character-container">
<div class="character-info">
<img src="{{img}}" />
<div class="character-data">
<span>{{name}}</span>
<div class="roll-setup">
<div class="form-group">
<div class="form-fields">
<select name="system.groupRoll.mainCharacter.rollChoice" {{#if hasRolled}}disabled{{/if}}>
{{selectOptions ../traitOptions selected=rollChoice localize=true}}
</select>
<section class="tab {{#if tabs.groupRoll.active}} active{{/if}}" data-group="{{tabs.groupRoll.group}}" data-tab="{{tabs.groupRoll.id}}">
{{#with mainCharacter}}
<div class="main-character-outer-container">
<div class="section-title">{{localize "DAGGERHEART.APPLICATIONS.GroupRollSelect.leader"}}</div>
<fieldset>
<div class="main-character-container">
<div class="character-info">
<img src="{{img}}" />
<div class="character-data">
<span>{{name}}</span>
<div class="roll-setup">
<div class="form-group">
<div class="form-fields">
<select name="system.groupRoll.mainCharacter.rollChoice" {{#if hasRolled}}disabled{{/if}}>
{{selectOptions ../traitOptions selected=rollChoice localize=true}}
</select>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{{#if readyToRoll}}
<div class="roll-container">
<span class="roll-title">
{{localize "DAGGERHEART.GENERAL.roll"}}
<div class="roll-tools">
<a class="roll-button" data-action="makeMainCharacterRoll">
<img src="systems/daggerheart/assets/icons/dice/hope/d12.svg" />
</a>
{{#if readyToRoll}}
<div class="roll-container">
<span class="roll-title">
{{localize "DAGGERHEART.GENERAL.roll"}}
<div class="roll-tools">
<a class="roll-button" data-action="makeMainCharacterRoll">
<img src="systems/daggerheart/assets/icons/dice/hope/d12.svg" />
</a>
{{#if hasRolled}}
<a class="delete-button" data-action="removeMainCharacterRoll">
<i class="fa-solid fa-trash"></i>
</a>
{{/if}}
</div>
</span>
{{#if roll}}
<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">
<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">
<span class="dice-label">{{roll.dFear.total}}</span>
<img src="{{concat "systems/daggerheart/assets/icons/dice/fear/" roll.dFear.denomination ".svg"}}" />
</a>
{{#if roll.advantage.type}}
<span class="roll-operator">{{#if (eq roll.advantage.type 1)}}+{{else}}-{{/if}}</span>
<span class="roll-dice">
<span class="dice-label">{{roll.advantage.value}}</span>
<img src="{{concat "systems/daggerheart/assets/icons/dice/" (ifThen (eq roll.advantage.type 1) "adv/" "disadv/") roll.advantage.dice ".svg"}}" />
</span>
{{#if hasRolled}}
<a class="delete-button" data-action="removeMainCharacterRoll">
<i class="fa-solid fa-trash"></i>
</a>
{{/if}}
<span class="roll-operator">{{#if (gte roll.modifierTotal 0)}}+{{else}}-{{/if}}</span>
<span class="roll-value">{{positive roll.modifierTotal}}</span>
</div>
</div>
{{else}}
<span class="hint">{{localize "DAGGERHEART.APPLICATIONS.TagTeamSelect.makeYourRoll"}}</span>
{{/if}}
</div>
{{/if}}
</fieldset>
</div>
{{/with}}
</span>
{{#if roll}}
<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">
<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">
<span class="dice-label">{{roll.dFear.total}}</span>
<img src="{{concat "systems/daggerheart/assets/icons/dice/fear/" roll.dFear.denomination ".svg"}}" />
</a>
{{#if roll.advantage.type}}
<span class="roll-operator">{{#if (eq roll.advantage.type 1)}}+{{else}}-{{/if}}</span>
<span class="roll-dice">
<span class="dice-label">{{roll.advantage.value}}</span>
<img src="{{concat "systems/daggerheart/assets/icons/dice/" (ifThen (eq roll.advantage.type 1) "adv/" "disadv/") roll.advantage.dice ".svg"}}" />
</span>
{{/if}}
<span class="roll-operator">{{#if (gte roll.modifierTotal 0)}}+{{else}}-{{/if}}</span>
<span class="roll-value">{{positive roll.modifierTotal}}</span>
</div>
</div>
{{else}}
<span class="hint">{{localize "DAGGERHEART.APPLICATIONS.TagTeamSelect.makeYourRoll"}}</span>
{{/if}}
</div>
{{/if}}
</fieldset>
</div>
{{/with}}
</section>

View file

@ -13,7 +13,7 @@
<div class="main-roll {{#if selectedMainCharacterDisabled}}inactive{{/if}}">
<div class="form-group">
<label>{{localize "DAGGERHEART.APPLICATIONS.GroupRollSelect.mainCharacter"}}</label>
<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="" }}

View file

@ -9,15 +9,10 @@
<i class="fa-solid fa-user-group"></i>
<span>Tag Team Roll</span>
</button>
<button data-action="groupRoll">
<button data-action="groupRoll" class="{{#if groupRollActive}}active-action{{/if}}">
<i class="fa-solid fa-users"></i>
<span>Group Roll</span>
</button>
{{!-- NOT YET IMPLEMENTED --}}
{{!-- <button>
<i class="fa-solid fa-handshake-angle"></i>
<span>Help Action</span>
</button> --}}
<button data-action="triggerRest" data-action="triggerRest" data-type="shortRest">
<i class="fa-solid fa-utensils"></i>
<span>{{localize "DAGGERHEART.APPLICATIONS.Downtime.shortRest.title"}}</span>