mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-16 05:31:07 +01:00
219-fix weapon action damage and display of calculation. (#250)
* fix weapon action damage and display of calculation. * modify weapon data to split formula. * remove unused field
This commit is contained in:
parent
122621a57a
commit
c4448226e0
11 changed files with 36 additions and 29 deletions
|
|
@ -1546,7 +1546,8 @@
|
||||||
"Range": "Range",
|
"Range": "Range",
|
||||||
"Damage": {
|
"Damage": {
|
||||||
"Title": "Damage",
|
"Title": "Damage",
|
||||||
"Value": "Value",
|
"Die": "Die",
|
||||||
|
"Bonus": "Bonus",
|
||||||
"Type": "Type"
|
"Type": "Type"
|
||||||
},
|
},
|
||||||
"Burden": "Burden",
|
"Burden": "Burden",
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static CLEAN_ARRAYS = ["damage.parts", "cost", "effects"];
|
static CLEAN_ARRAYS = ['damage.parts', 'cost', 'effects'];
|
||||||
|
|
||||||
_getTabs() {
|
_getTabs() {
|
||||||
const tabs = {
|
const tabs = {
|
||||||
|
|
@ -69,7 +69,6 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
||||||
context.disableOption = this.disableOption.bind(this);
|
context.disableOption = this.disableOption.bind(this);
|
||||||
context.isNPC = this.action.actor && this.action.actor.type !== 'character';
|
context.isNPC = this.action.actor && this.action.actor.type !== 'character';
|
||||||
context.hasRoll = this.action.hasRoll;
|
context.hasRoll = this.action.hasRoll;
|
||||||
console.log(context)
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,9 +96,9 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) {
|
||||||
|
|
||||||
_prepareSubmitData(event, formData) {
|
_prepareSubmitData(event, formData) {
|
||||||
const submitData = foundry.utils.expandObject(formData.object);
|
const submitData = foundry.utils.expandObject(formData.object);
|
||||||
for ( const keyPath of this.constructor.CLEAN_ARRAYS ) {
|
for (const keyPath of this.constructor.CLEAN_ARRAYS) {
|
||||||
const data = foundry.utils.getProperty(submitData, keyPath);
|
const data = foundry.utils.getProperty(submitData, keyPath);
|
||||||
if ( data ) foundry.utils.setProperty(submitData, keyPath, Object.values(data));
|
if (data) foundry.utils.setProperty(submitData, keyPath, Object.values(data));
|
||||||
}
|
}
|
||||||
return submitData;
|
return submitData;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ export class DHRoll extends Roll {
|
||||||
if (config.dialog.configure !== false) {
|
if (config.dialog.configure !== false) {
|
||||||
// Open Roll Dialog
|
// Open Roll Dialog
|
||||||
const DialogClass = config.dialog?.class ?? this.DefaultDialog;
|
const DialogClass = config.dialog?.class ?? this.DefaultDialog;
|
||||||
console.log(roll, config);
|
|
||||||
const configDialog = await DialogClass.configure(roll, config, message);
|
const configDialog = await DialogClass.configure(roll, config, message);
|
||||||
if (!configDialog) return;
|
if (!configDialog) return;
|
||||||
}
|
}
|
||||||
|
|
@ -124,6 +123,18 @@ export class DHRoll extends Roll {
|
||||||
}
|
}
|
||||||
return (this._formula = this.constructor.getFormula(this.terms));
|
return (this._formula = this.constructor.getFormula(this.terms));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static calculateTotalModifiers(roll, config) {
|
||||||
|
config.roll.modifierTotal = 0;
|
||||||
|
for (let i = 0; i < roll.terms.length; i++) {
|
||||||
|
if (
|
||||||
|
roll.terms[i] instanceof foundry.dice.terms.NumericTerm &&
|
||||||
|
!!roll.terms[i - 1] &&
|
||||||
|
roll.terms[i - 1] instanceof foundry.dice.terms.OperatorTerm
|
||||||
|
)
|
||||||
|
config.roll.modifierTotal += Number(`${roll.terms[i - 1].operator}${roll.terms[i].total}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DualityDie extends foundry.dice.terms.Die {
|
export class DualityDie extends foundry.dice.terms.Die {
|
||||||
|
|
@ -299,15 +310,8 @@ export class D20Roll extends DHRoll {
|
||||||
value: d.total
|
value: d.total
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
config.roll.modifierTotal = 0;
|
|
||||||
for (let i = 0; i < roll.terms.length; i++) {
|
this.calculateTotalModifiers(roll, config);
|
||||||
if (
|
|
||||||
roll.terms[i] instanceof foundry.dice.terms.NumericTerm &&
|
|
||||||
!!roll.terms[i - 1] &&
|
|
||||||
roll.terms[i - 1] instanceof foundry.dice.terms.OperatorTerm
|
|
||||||
)
|
|
||||||
config.roll.modifierTotal += Number(`${roll.terms[i - 1].operator}${roll.terms[i].total}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resetFormula() {
|
resetFormula() {
|
||||||
|
|
@ -468,6 +472,7 @@ export class DamageRoll extends DHRoll {
|
||||||
static async postEvaluate(roll, config = {}) {
|
static async postEvaluate(roll, config = {}) {
|
||||||
super.postEvaluate(roll, config);
|
super.postEvaluate(roll, config);
|
||||||
config.roll.type = config.type;
|
config.roll.type = config.type;
|
||||||
|
this.calculateTotalModifiers(roll, config);
|
||||||
if (config.source?.message) {
|
if (config.source?.message) {
|
||||||
const chatMessage = ui.chat.collection.get(config.source.message);
|
const chatMessage = ui.chat.collection.get(config.source.message);
|
||||||
chatMessage.update({ 'system.damage': config });
|
chatMessage.update({ 'system.damage': config });
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,6 @@ export default class DHAdversarySettings extends HandlebarsApplicationMixin(Appl
|
||||||
context.systemFields = this.actor.system.schema.fields;
|
context.systemFields = this.actor.system.schema.fields;
|
||||||
context.systemFields.attack.fields = this.actor.system.attack.schema.fields;
|
context.systemFields.attack.fields = this.actor.system.attack.schema.fields;
|
||||||
context.isNPC = true;
|
context.isNPC = true;
|
||||||
console.log(context)
|
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -231,6 +231,7 @@ export class DHBaseAction extends foundry.abstract.DataModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasRoll) {
|
if (this.hasRoll) {
|
||||||
|
console.log(config);
|
||||||
const rollConfig = this.prepareRoll(config);
|
const rollConfig = this.prepareRoll(config);
|
||||||
config.roll = rollConfig;
|
config.roll = rollConfig;
|
||||||
config = await this.actor.diceRoll(config);
|
config = await this.actor.diceRoll(config);
|
||||||
|
|
@ -242,7 +243,6 @@ export class DHBaseAction extends foundry.abstract.DataModel {
|
||||||
if(t.hit) {
|
if(t.hit) {
|
||||||
const target = game.canvas.tokens.get(t.id),
|
const target = game.canvas.tokens.get(t.id),
|
||||||
actor = target?.actor;
|
actor = target?.actor;
|
||||||
console.log(actor)
|
|
||||||
if(!actor) return;
|
if(!actor) return;
|
||||||
actor.saveRoll({
|
actor.saveRoll({
|
||||||
event,
|
event,
|
||||||
|
|
@ -629,7 +629,7 @@ export class DHAttackAction extends DHDamageAction {
|
||||||
return {
|
return {
|
||||||
value: {
|
value: {
|
||||||
multiplier: 'prof',
|
multiplier: 'prof',
|
||||||
dice: this.item?.system?.damage.value,
|
dice: this.item?.system?.damage.dice,
|
||||||
bonus: this.item?.system?.damage.bonus ?? 0
|
bonus: this.item?.system?.damage.bonus ?? 0
|
||||||
},
|
},
|
||||||
type: this.item?.system?.damage.type,
|
type: this.item?.system?.damage.type,
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@ export default class DHWeapon extends BaseDataItem {
|
||||||
burden: new fields.StringField({ required: true, choices: SYSTEM.GENERAL.burden, initial: 'oneHanded' }),
|
burden: new fields.StringField({ required: true, choices: SYSTEM.GENERAL.burden, initial: 'oneHanded' }),
|
||||||
//DAMAGE
|
//DAMAGE
|
||||||
damage: new fields.SchemaField({
|
damage: new fields.SchemaField({
|
||||||
value: new FormulaField({ initial: 'd6' }),
|
dice: new fields.StringField({ choices: SYSTEM.GENERAL.diceTypes, initial: 'd6' }),
|
||||||
|
bonus: new fields.NumberField({ nullable: true, initial: null }),
|
||||||
type: new fields.StringField({
|
type: new fields.StringField({
|
||||||
required: true,
|
required: true,
|
||||||
choices: SYSTEM.GENERAL.damageTypes,
|
choices: SYSTEM.GENERAL.damageTypes,
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
this.config.experiences = [];
|
this.config.experiences = [];
|
||||||
|
|
||||||
if (config.source?.action) {
|
if (config.source?.action) {
|
||||||
console.log(config)
|
|
||||||
this.item = config.data.parent.items.get(config.source.item) ?? config.data.parent;
|
this.item = config.data.parent.items.get(config.source.item) ?? config.data.parent;
|
||||||
this.action =
|
this.action =
|
||||||
config.data.attack?._id == config.source.action
|
config.data.attack?._id == config.source.action
|
||||||
|
|
@ -51,7 +50,6 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
};
|
};
|
||||||
|
|
||||||
async _prepareContext(_options) {
|
async _prepareContext(_options) {
|
||||||
console.log(this.config, this.roll)
|
|
||||||
const context = await super._prepareContext(_options);
|
const context = await super._prepareContext(_options);
|
||||||
context.hasRoll = !!this.config.roll;
|
context.hasRoll = !!this.config.roll;
|
||||||
context.roll = this.roll;
|
context.roll = this.roll;
|
||||||
|
|
@ -77,7 +75,7 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
}
|
}
|
||||||
context.extraFormula = this.config.extraFormula;
|
context.extraFormula = this.config.extraFormula;
|
||||||
context.formula = this.roll.constructFormula(this.config);
|
context.formula = this.roll.constructFormula(this.config);
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,10 +85,10 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
this.config.costs = foundry.utils.mergeObject(this.config.costs, rest.costs);
|
this.config.costs = foundry.utils.mergeObject(this.config.costs, rest.costs);
|
||||||
}
|
}
|
||||||
if (this.config.uses) this.config.uses = foundry.utils.mergeObject(this.config.uses, rest.uses);
|
if (this.config.uses) this.config.uses = foundry.utils.mergeObject(this.config.uses, rest.uses);
|
||||||
if(rest.roll?.dice) {
|
if (rest.roll?.dice) {
|
||||||
Object.entries(rest.roll.dice).forEach(([key, value]) => {
|
Object.entries(rest.roll.dice).forEach(([key, value]) => {
|
||||||
this.roll[key] = value;
|
this.roll[key] = value;
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
this.config.extraFormula = rest.extraFormula;
|
this.config.extraFormula = rest.extraFormula;
|
||||||
this.render();
|
this.render();
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@
|
||||||
<div class="dice-result">
|
<div class="dice-result">
|
||||||
<div class="dice-tooltip">
|
<div class="dice-tooltip">
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
{{!-- {{> 'systems/daggerheart/templates/chat/parts/damage-chat.hbs' damage=damage noTitle=true}} --}}
|
{{> 'systems/daggerheart/templates/chat/parts/damage-chat.hbs' damage=damage noTitle=true}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
{{#if damage.roll.modifierTotal}}<div class="duality-modifier">{{#if (gt damage.roll.modifierTotal 0)}}+{{/if}}{{damage.roll.modifierTotal}}</div>{{/if}}
|
||||||
<div class="duality-result">Total: {{damage.roll.total}}</div>
|
<div class="duality-result">Total: {{damage.roll.total}}</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,8 @@
|
||||||
<span>-</span>
|
<span>-</span>
|
||||||
{{localize (concat 'DAGGERHEART.Range.' source.system.range '.name')}}
|
{{localize (concat 'DAGGERHEART.Range.' source.system.range '.name')}}
|
||||||
<span>-</span>
|
<span>-</span>
|
||||||
{{source.system.damage.value}}
|
{{log this}}
|
||||||
|
{{source.system.damage.dice}} + {{source.system.damage.bonus}}
|
||||||
({{localize (concat 'DAGGERHEART.DamageType.' source.system.damage.type '.abbreviation')}})
|
({{localize (concat 'DAGGERHEART.DamageType.' source.system.damage.type '.abbreviation')}})
|
||||||
<span>-</span>
|
<span>-</span>
|
||||||
{{localize (concat 'DAGGERHEART.Burden.' source.system.burden)}}
|
{{localize (concat 'DAGGERHEART.Burden.' source.system.burden)}}
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,10 @@
|
||||||
|
|
||||||
<fieldset class="two-columns">
|
<fieldset class="two-columns">
|
||||||
<legend>{{localize "DAGGERHEART.Sheets.Weapon.Damage.Title"}}</legend>
|
<legend>{{localize "DAGGERHEART.Sheets.Weapon.Damage.Title"}}</legend>
|
||||||
<span>{{localize "DAGGERHEART.Sheets.Weapon.Damage.Value"}}</span>
|
<span>{{localize "DAGGERHEART.Sheets.Weapon.Damage.Die"}}</span>
|
||||||
{{formGroup systemFields.damage.fields.value value=source.system.damage.value}}
|
{{formGroup systemFields.damage.fields.dice value=source.system.damage.dice}}
|
||||||
|
<span>{{localize "DAGGERHEART.Sheets.Weapon.Damage.Bonus"}}</span>
|
||||||
|
{{formGroup systemFields.damage.fields.bonus value=source.system.damage.bonus}}
|
||||||
<span>{{localize "DAGGERHEART.Sheets.Weapon.Damage.Type"}}</span>
|
<span>{{localize "DAGGERHEART.Sheets.Weapon.Damage.Type"}}</span>
|
||||||
{{formGroup systemFields.damage.fields.type value=source.system.damage.type localize=true}}
|
{{formGroup systemFields.damage.fields.type value=source.system.damage.type localize=true}}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue