mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-16 13:41:07 +01:00
before main merge
This commit is contained in:
parent
1695c80388
commit
e52d9e4d8c
5 changed files with 14 additions and 94 deletions
|
|
@ -240,7 +240,6 @@ export class DHBaseAction extends foundry.abstract.DataModel {
|
||||||
config = {
|
config = {
|
||||||
...config,
|
...config,
|
||||||
roll: {
|
roll: {
|
||||||
// modifier: modifierValue,
|
|
||||||
modifiers: [],
|
modifiers: [],
|
||||||
trait: this.roll?.trait,
|
trait: this.roll?.trait,
|
||||||
label: game.i18n.localize(abilities[this.roll.trait].label),
|
label: game.i18n.localize(abilities[this.roll.trait].label),
|
||||||
|
|
@ -290,6 +289,14 @@ export class DHBaseAction extends foundry.abstract.DataModel {
|
||||||
}
|
}
|
||||||
/* COST */
|
/* COST */
|
||||||
|
|
||||||
|
/* USES */
|
||||||
|
async spendUses(config) {
|
||||||
|
if(!this.uses.max) return;
|
||||||
|
|
||||||
|
}
|
||||||
|
/* USES */
|
||||||
|
|
||||||
|
|
||||||
/* TARGET */
|
/* TARGET */
|
||||||
async getTarget(config) {
|
async getTarget(config) {
|
||||||
if(this.target?.type === SYSTEM.ACTIONS.targetTypes.self.id) return this.formatTarget(this.actor.token ?? this.actor.prototypeToken);
|
if(this.target?.type === SYSTEM.ACTIONS.targetTypes.self.id) return this.formatTarget(this.actor.token ?? this.actor.prototypeToken);
|
||||||
|
|
@ -397,62 +404,6 @@ export class DHDamageAction extends DHBaseAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
roll = CONFIG.Dice.daggerheart.DamageRoll.build(config)
|
roll = CONFIG.Dice.daggerheart.DamageRoll.build(config)
|
||||||
|
|
||||||
/* if (!event.shiftKey) {
|
|
||||||
const dialogClosed = new Promise((resolve, _) => {
|
|
||||||
new DamageSelectionDialog(formula, bonusDamage, resolve).render(true);
|
|
||||||
});
|
|
||||||
const result = await dialogClosed;
|
|
||||||
bonusDamage = result.bonusDamage;
|
|
||||||
formula = result.rollString;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isNaN(formula)) {
|
|
||||||
roll = await new Roll(formula, this.getRollData()).evaluate();
|
|
||||||
}
|
|
||||||
if(!roll) return;
|
|
||||||
const dice = [],
|
|
||||||
modifiers = [];
|
|
||||||
for (var i = 0; i < roll.terms.length; i++) {
|
|
||||||
const term = roll.terms[i];
|
|
||||||
if (term.faces) {
|
|
||||||
dice.push({
|
|
||||||
type: `d${term.faces}`,
|
|
||||||
rolls: term.results.map(x => x.result),
|
|
||||||
total: term.results.reduce((acc, x) => acc + x.result, 0)
|
|
||||||
});
|
|
||||||
} else if (term.operator) {
|
|
||||||
} else if (term.number) {
|
|
||||||
const operator = i === 0 ? '' : roll.terms[i - 1].operator;
|
|
||||||
modifiers.push({ value: term.number, operator: operator });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const cls = getDocumentClass('ChatMessage'),
|
|
||||||
systemData = {
|
|
||||||
title: game.i18n.format('DAGGERHEART.Chat.DamageRoll.Title', { damage: this.name }),
|
|
||||||
roll: formula,
|
|
||||||
damage: {
|
|
||||||
total: roll.total,
|
|
||||||
type: this.damage.parts[0].type // Handle multiple type damage
|
|
||||||
},
|
|
||||||
dice: dice,
|
|
||||||
modifiers: modifiers,
|
|
||||||
targets: (data.system?.targets ?? data.targets).map(x => ({ id: x.id, name: x.name, img: x.img, hit: true }))
|
|
||||||
},
|
|
||||||
msg = new cls({
|
|
||||||
type: 'damageRoll',
|
|
||||||
user: game.user.id,
|
|
||||||
sound: CONFIG.sounds.dice,
|
|
||||||
system: systemData,
|
|
||||||
content: await foundry.applications.handlebars.renderTemplate(
|
|
||||||
'systems/daggerheart/templates/chat/damage-roll.hbs',
|
|
||||||
systemData
|
|
||||||
),
|
|
||||||
rolls: [roll]
|
|
||||||
});
|
|
||||||
|
|
||||||
cls.create(msg.toObject()); */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -502,25 +453,6 @@ export class DHHealingAction extends DHBaseAction {
|
||||||
return await this.rollHealing(event, config);
|
return await this.rollHealing(event, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* async use(event, ...args) {
|
|
||||||
const config = await super.use(event, args);
|
|
||||||
if(['error', 'warning'].includes(config.type)) return;
|
|
||||||
const roll = await this.rollHealing(),
|
|
||||||
cls = getDocumentClass('ChatMessage'),
|
|
||||||
msg = new cls({
|
|
||||||
user: game.user.id,
|
|
||||||
content: await foundry.applications.handlebars.renderTemplate(
|
|
||||||
this.chatTemplate,
|
|
||||||
{
|
|
||||||
...roll,
|
|
||||||
...config
|
|
||||||
}
|
|
||||||
)
|
|
||||||
});
|
|
||||||
|
|
||||||
cls.create(msg.toObject());
|
|
||||||
} */
|
|
||||||
|
|
||||||
async rollHealing(event, data) {
|
async rollHealing(event, data) {
|
||||||
console.log(event, data)
|
console.log(event, data)
|
||||||
let formula = this.healing.value.getFormula(this.actor);
|
let formula = this.healing.value.getFormula(this.actor);
|
||||||
|
|
@ -536,20 +468,7 @@ export class DHHealingAction extends DHBaseAction {
|
||||||
messageTemplate: 'systems/daggerheart/templates/chat/healing-roll.hbs'
|
messageTemplate: 'systems/daggerheart/templates/chat/healing-roll.hbs'
|
||||||
}
|
}
|
||||||
|
|
||||||
roll = CONFIG.Dice.daggerheart.DamageRoll.build(config)
|
roll = CONFIG.Dice.daggerheart.DamageRoll.build(config);
|
||||||
/* const formula = this.healing.value.getFormula(this.actor);
|
|
||||||
if (!formula || formula == '') return;
|
|
||||||
|
|
||||||
let roll = { formula: formula, total: formula };
|
|
||||||
if (isNaN(formula)) {
|
|
||||||
roll = await new Roll(formula, this.getRollData()).evaluate();
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
roll: roll.formula,
|
|
||||||
total: roll.total,
|
|
||||||
dice: roll.dice,
|
|
||||||
type: this.healing.type
|
|
||||||
} */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get chatTemplate() {
|
get chatTemplate() {
|
||||||
|
|
@ -586,7 +505,6 @@ export class DHEffectAction extends DHBaseAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
async chatApplyEffects(event, data) {
|
async chatApplyEffects(event, data) {
|
||||||
// console.log(data, this.effects, this.effectsDetails)
|
|
||||||
const cls = getDocumentClass('ChatMessage'),
|
const cls = getDocumentClass('ChatMessage'),
|
||||||
systemData = {
|
systemData = {
|
||||||
title: game.i18n.format('DAGGERHEART.Chat.ApplyEffect.Title', { name: this.name }),
|
title: game.i18n.format('DAGGERHEART.Chat.ApplyEffect.Title', { name: this.name }),
|
||||||
|
|
|
||||||
|
|
@ -50,11 +50,12 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
context.selectedExperiences = this.config.experiences;
|
context.selectedExperiences = this.config.experiences;
|
||||||
context.advantage = this.config.advantage;
|
context.advantage = this.config.advantage;
|
||||||
/* context.diceOptions = this.diceOptions; */
|
/* context.diceOptions = this.diceOptions; */
|
||||||
|
context.canRoll = true;
|
||||||
if(this.config.costs?.length) {
|
if(this.config.costs?.length) {
|
||||||
const updatedCosts = this.config.action.calcCosts(this.config.costs);
|
const updatedCosts = this.config.action.calcCosts(this.config.costs);
|
||||||
context.costs = updatedCosts
|
context.costs = updatedCosts
|
||||||
context.canRoll = this.config.action.getRealCosts(updatedCosts)?.hasCost;
|
context.canRoll = this.config.action.getRealCosts(updatedCosts)?.hasCost;
|
||||||
} else context.canRoll = true;
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
|
||||||
|
|
||||||
async _prepareContext(_options) {
|
async _prepareContext(_options) {
|
||||||
const context = await super._prepareContext(_options);
|
const context = await super._prepareContext(_options);
|
||||||
|
context.title = this.config.title;
|
||||||
context.formula = this.config.formula;
|
context.formula = this.config.formula;
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<div class="dice-actions{{#unless (or hasDamage hasEffect)}} duality-alone{{/unless}}">
|
<div class="dice-actions{{#unless (or hasDamage hasHealing)}} duality-alone{{/unless}}">
|
||||||
{{#if hasDamage}}
|
{{#if hasDamage}}
|
||||||
<button class="duality-action duality-action-damage" data-value="{{roll.total}}"><span>{{localize "DAGGERHEART.Chat.AttackRoll.RollDamage"}}</span></button>
|
<button class="duality-action duality-action-damage" data-value="{{roll.total}}"><span>{{localize "DAGGERHEART.Chat.AttackRoll.RollDamage"}}</span></button>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<div>
|
<div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label><strong>Total Damage</strong></label>
|
<label><strong>{{title}}</strong></label>
|
||||||
<div class="form-fields">
|
<div class="form-fields">
|
||||||
<input type="text" value="{{formula}}" disabled />
|
<input type="text" value="{{formula}}" disabled />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue