mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 15:39:02 +01:00
Added difficulty support in rollDialog/rollMessage and [[/dr]]
This commit is contained in:
parent
867947c2c5
commit
2616ff59be
6 changed files with 37 additions and 8 deletions
|
|
@ -1170,6 +1170,7 @@
|
||||||
},
|
},
|
||||||
"Roll": {
|
"Roll": {
|
||||||
"attack": "Attack Roll",
|
"attack": "Attack Roll",
|
||||||
|
"difficulty": "Roll (Difficulty {difficulty})",
|
||||||
"primaryWeaponAttack": "Primary Weapon Attack Roll",
|
"primaryWeaponAttack": "Primary Weapon Attack Roll",
|
||||||
"secondaryWeaponAttack": "Secondary Weapon Attack Roll",
|
"secondaryWeaponAttack": "Secondary Weapon Attack Roll",
|
||||||
"spellcast": "Spellcast Roll",
|
"spellcast": "Spellcast Roll",
|
||||||
|
|
@ -1274,6 +1275,7 @@
|
||||||
"single": "Experience",
|
"single": "Experience",
|
||||||
"plural": "Experiences"
|
"plural": "Experiences"
|
||||||
},
|
},
|
||||||
|
"failure": "Failure",
|
||||||
"fear": "Fear",
|
"fear": "Fear",
|
||||||
"features": "Features",
|
"features": "Features",
|
||||||
"formula": "Formula",
|
"formula": "Formula",
|
||||||
|
|
@ -1309,6 +1311,7 @@
|
||||||
"scalable": "Scalable",
|
"scalable": "Scalable",
|
||||||
"situationalBonus": "Situational Bonus",
|
"situationalBonus": "Situational Bonus",
|
||||||
"stress": "Stress",
|
"stress": "Stress",
|
||||||
|
"success": "Success",
|
||||||
"take": "Take",
|
"take": "Take",
|
||||||
"Target": {
|
"Target": {
|
||||||
"single": "Target",
|
"single": "Target",
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
||||||
async renderHTML() {
|
async renderHTML() {
|
||||||
if (this.system.messageTemplate)
|
if (this.system.messageTemplate)
|
||||||
this.content = await foundry.applications.handlebars.renderTemplate(
|
this.content = await foundry.applications.handlebars.renderTemplate(this.system.messageTemplate, {
|
||||||
this.system.messageTemplate,
|
...this.system,
|
||||||
this.system
|
_source: this.system._source
|
||||||
);
|
});
|
||||||
|
|
||||||
/* We can change to fully implementing the renderHTML function if needed, instead of augmenting it. */
|
/* We can change to fully implementing the renderHTML function if needed, instead of augmenting it. */
|
||||||
const html = await super.renderHTML();
|
const html = await super.renderHTML();
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,14 @@ export function getDualityMessage(roll) {
|
||||||
data-label="${dataLabel}"
|
data-label="${dataLabel}"
|
||||||
data-hope="${roll.hope ?? 'd12'}"
|
data-hope="${roll.hope ?? 'd12'}"
|
||||||
data-fear="${roll.fear ?? 'd12'}"
|
data-fear="${roll.fear ?? 'd12'}"
|
||||||
|
${roll.difficulty ? `data-difficulty="${roll.difficulty}"` : ''}
|
||||||
${roll.trait && abilities[roll.trait] ? `data-trait="${roll.trait}"` : ''}
|
${roll.trait && abilities[roll.trait] ? `data-trait="${roll.trait}"` : ''}
|
||||||
${roll.advantage ? 'data-advantage="true"' : ''}
|
${roll.advantage ? 'data-advantage="true"' : ''}
|
||||||
${roll.disadvantage ? 'data-disadvantage="true"' : ''}
|
${roll.disadvantage ? 'data-disadvantage="true"' : ''}
|
||||||
>
|
>
|
||||||
<i class="fa-solid fa-circle-half-stroke"></i>
|
<i class="fa-solid fa-circle-half-stroke"></i>
|
||||||
${label}
|
${label}
|
||||||
|
${roll.difficulty ? `(${roll.difficulty})` : ''}
|
||||||
</button>
|
</button>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
@ -43,7 +45,8 @@ export function getDualityMessage(roll) {
|
||||||
export const renderDualityButton = async event => {
|
export const renderDualityButton = async event => {
|
||||||
const button = event.currentTarget,
|
const button = event.currentTarget,
|
||||||
traitValue = button.dataset.trait?.toLowerCase(),
|
traitValue = button.dataset.trait?.toLowerCase(),
|
||||||
target = getCommandTarget();
|
target = getCommandTarget(),
|
||||||
|
difficulty = button.dataset.difficulty;
|
||||||
if (!target) return;
|
if (!target) return;
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
|
|
@ -52,6 +55,7 @@ export const renderDualityButton = async event => {
|
||||||
roll: {
|
roll: {
|
||||||
modifier: traitValue ? target.system.traits[traitValue].value : null,
|
modifier: traitValue ? target.system.traits[traitValue].value : null,
|
||||||
label: button.dataset.label,
|
label: button.dataset.label,
|
||||||
|
difficulty: difficulty,
|
||||||
type: button.dataset.actionType ?? null // Need check
|
type: button.dataset.actionType ?? null // Need check
|
||||||
},
|
},
|
||||||
chatMessage: {
|
chatMessage: {
|
||||||
|
|
|
||||||
|
|
@ -131,13 +131,17 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 16px;
|
gap: 16px;
|
||||||
|
height: 32px;
|
||||||
|
|
||||||
.roll-mode-select {
|
.roll-mode-select {
|
||||||
width: min-content;
|
width: min-content;
|
||||||
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
height: 100%;
|
||||||
|
font-family: @font-body;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -136,14 +136,22 @@
|
||||||
<input type="text" value="{{extraFormula}}" name="extraFormula" placeholder="{{#if (eq @root.rollType 'DualityRoll')}}Ex: 1d6 + 5{{else}}Situational Bonus{{/if}}">
|
<input type="text" value="{{extraFormula}}" name="extraFormula" placeholder="{{#if (eq @root.rollType 'DualityRoll')}}Ex: 1d6 + 5{{else}}Situational Bonus{{/if}}">
|
||||||
</fieldset>
|
</fieldset>
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
|
||||||
<span class="formula-label"><b>{{localize "DAGGERHEART.GENERAL.formula"}}:</b> {{@root.formula}}</span>
|
<span class="formula-label"><b>{{localize "DAGGERHEART.GENERAL.formula"}}:</b> {{@root.formula}}</span>
|
||||||
|
|
||||||
<div class="roll-dialog-controls">
|
<div class="roll-dialog-controls">
|
||||||
<select class="roll-mode-select" name="selectedRollMode">
|
<select class="roll-mode-select" name="selectedRollMode">
|
||||||
{{selectOptions rollModes selected=selectedRollMode valueAttr="action" labelAttr="label" localize=true}}
|
{{selectOptions rollModes selected=selectedRollMode valueAttr="action" labelAttr="label" localize=true}}
|
||||||
</select>
|
</select>
|
||||||
<button class="sunmit-btn" data-action="submitRoll"{{#unless canRoll}} disabled{{/unless}}>
|
<button class="sunmit-btn" data-action="submitRoll"{{#unless canRoll}} disabled{{/unless}}>
|
||||||
<i class="fa-solid fa-dice"></i>
|
<i class="fa-solid fa-dice"></i>
|
||||||
<span class="label">{{localize "DAGGERHEART.GENERAL.roll"}}</span>
|
<span class="label">
|
||||||
|
{{#if @root.rollConfig.roll.difficulty}}
|
||||||
|
{{localize "DAGGERHEART.GENERAL.Roll.difficulty" difficulty=@root.rollConfig.roll.difficulty}}
|
||||||
|
{{else}}
|
||||||
|
{{localize "DAGGERHEART.GENERAL.roll"}}
|
||||||
|
{{/if}}
|
||||||
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,17 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="dice-total duality {{#if (eq roll.result.duality 1)}}hope{{else}}{{#if (eq roll.result.duality -1)}}fear{{else}}critical{{/if}}{{/if}}">
|
<div class="dice-total duality {{#if (eq roll.result.duality 1)}}hope{{else}}{{#if (eq roll.result.duality -1)}}fear{{else}}critical{{/if}}{{/if}}">
|
||||||
<div class="dice-total-label">{{roll.result.label}}</div>
|
<div class="dice-total-label">
|
||||||
|
{{#unless (eq _source.roll.success undefined)}}
|
||||||
|
{{#if _source.roll.success}}
|
||||||
|
{{localize "DAGGERHEART.GENERAL.success"}} {{localize "DAGGERHEART.GENERAL.withThing" thing=roll.result.label}}
|
||||||
|
{{else}}
|
||||||
|
{{localize "DAGGERHEART.GENERAL.failure"}} {{localize "DAGGERHEART.GENERAL.withThing" thing=roll.result.label}}
|
||||||
|
{{/if}}
|
||||||
|
{{else}}
|
||||||
|
{{roll.result.label}}
|
||||||
|
{{/unless}}
|
||||||
|
</div>
|
||||||
<div class="dice-total-value">
|
<div class="dice-total-value">
|
||||||
{{roll.total}}
|
{{roll.total}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue