Merge pull request #16 from Foundryborne/irk/sheet-rolling

Fix Attribute rolling. Updated some depreciated values based on warni…
This commit is contained in:
WBHarry 2025-05-23 07:29:01 +02:00 committed by GitHub
commit 76e261680c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 15 additions and 14 deletions

View file

@ -1,7 +1,7 @@
export default class DhpChatMesssage extends ChatMessage {
async renderHTML() {
if(this.type === 'dualityRoll' || this.type === 'adversaryRoll' || this.type === 'abilityUse'){
this.content = await renderTemplate(this.content, this.system);
this.content = await foundry.applications.handlebars.renderTemplate(this.content, this.system);
}
return super.renderHTML();

View file

@ -331,11 +331,11 @@ export default class PCSheet extends DaggerheartSheet(ActorSheetV2) {
this.render();
}
static async rollAttribute(_, event){
const { roll, hope, fear, advantage, disadvantage, modifiers } = await this.document.dualityRoll({ title: 'Attribute Bonus', value: event.currentTarget.dataset.value }, event.shiftKey);
static async rollAttribute(event, target) {
const { roll, hope, fear, advantage, disadvantage, modifiers } = await this.document.dualityRoll({ title: 'Attribute Bonus', value: event.target.dataset.value }, event.shiftKey);
const cls = getDocumentClass("ChatMessage");
const msg = new cls({
const msgData = {
type: 'dualityRoll',
system: {
roll: roll._formula,
@ -348,9 +348,9 @@ export default class PCSheet extends DaggerheartSheet(ActorSheetV2) {
user: game.user.id,
content: "systems/daggerheart/templates/chat/duality-roll.hbs",
rolls: [roll]
});
};
await cls.create(msg.toObject());
await cls.create(msgData);
}
static async toggleMarks(_, button){

View file

@ -87,9 +87,10 @@ export default class DhpActor extends Actor {
async dualityRoll(modifier, shiftKey, bonusDamage=[]){
let hopeDice = 'd12', fearDice = 'd12', advantageDice = null, disadvantageDice = null, bonusDamageString = "";
const modifiers = [
{
value: Number.parseInt(modifier.value),
value: modifier.value ? Number.parseInt(modifier.value) : 0,
label: modifier.value >= 0 ? `+${modifier.value}` : `-${modifier.value}`,
title: modifier.title,
}
@ -104,11 +105,11 @@ export default class DhpActor extends Actor {
bonusDamageString = result.bonusDamage;
const automateHope = await game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Automation.Hope);
if(automateHope && result.hopeUsed){
await this.update({ "system.resources.hope.value": this.system.resources.hope.value - result.hopeUsed });
}
}
const roll = new Roll(`1${hopeDice} + 1${fearDice}${advantageDice ? ` + 1${advantageDice}` : disadvantageDice ? ` - 1${disadvantageDice}` : ''} ${modifiers.map(x => `+ ${x.value}`).join(' ')}`);
let rollResult = await roll.evaluate();
rollResult.dice[0].options.appearance = {