forked from public/bol
Attack process path
This commit is contained in:
@ -31,12 +31,7 @@ export class BoLRoll {
|
||||
// const elt = $(event.currentTarget)[0];
|
||||
// let key = elt.attributes["data-rolling"].value;
|
||||
let target = BoLUtility.getTarget()
|
||||
if ( !target) {
|
||||
ui.notifications.warn("No target selected for attack !");
|
||||
return;
|
||||
}
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
console.log("ITEM", target);
|
||||
const weapon = actor.items.get(li.data("item-id"));
|
||||
if (!weapon) {
|
||||
ui.notifications.warn("Unable to find weapon !");
|
||||
@ -50,7 +45,7 @@ export class BoLRoll {
|
||||
weapon :weapon,
|
||||
mod: 0,
|
||||
target : target,
|
||||
defender: game.actors.get(target.data.actorId),
|
||||
defender: (target) ? game.actors.get(target.data.actorId) : undefined,
|
||||
adv :dataset.adv || 0,
|
||||
attribute : eval(`actor.data.data.attributes.${weaponData.properties.attackAttribute}`),
|
||||
aptitude : eval(`actor.data.data.aptitudes.${weaponData.properties.attackAptitude}`),
|
||||
@ -123,7 +118,7 @@ export class BoLRoll {
|
||||
careers: attackDef.attackerData.features.careers,
|
||||
boons: attackDef.attackerData.features.boons,
|
||||
flaws: attackDef.attackerData.features.flaws,
|
||||
defence: attackDef.defender.defenseValue,
|
||||
defence: (attackDef.defender) ? attackDef.defender.defenseValue : 0,
|
||||
};
|
||||
const rollOptionContent = await renderTemplate(rollOptionTpl, dialogData);
|
||||
let d = new Dialog({
|
||||
@ -270,7 +265,7 @@ export class BoLAttackRoll {
|
||||
|
||||
async roll(){
|
||||
const r = new Roll(this.attackDef.formula);
|
||||
await r.roll({"async": true});
|
||||
await r.roll({"async": false});
|
||||
const activeDice = r.terms[0].results.filter(r => r.active);
|
||||
const diceTotal = activeDice.map(r => r.result).reduce((a, b) => a + b);
|
||||
this._isSuccess = (r.total >= 9);
|
||||
@ -290,17 +285,30 @@ export class BoLAttackRoll {
|
||||
let weaponFormula = BoLUtility.getDamageFormula(this.attackDef.weapon.data.data.properties.damage)
|
||||
let damageFormula = weaponFormula + "+" + this.attackDef.attacker.data.data.attributes[attrDamage].value;
|
||||
this.damageRoll = new Roll(damageFormula);
|
||||
await this.damageRoll.roll({"async": true});
|
||||
await this.damageRoll.roll({"async": false});
|
||||
// Update attackDef object
|
||||
this.attackDef.damageFormula = damageFormula;
|
||||
this.attackDef.damageRoll = this.damageRoll;
|
||||
|
||||
this._buildDamageChatMessage(this.attackDef.attacker, this.attackDef.weapon, this.damageRoll.total).then(msgFlavor => {
|
||||
this.damageRoll.toMessage({
|
||||
user: game.user.id,
|
||||
flavor: msgFlavor,
|
||||
speaker: ChatMessage.getSpeaker({actor: this.attackDef.attacker}),
|
||||
flags : {msgType : "default"}
|
||||
}).then( result => {
|
||||
if (this.attackDef.target) {
|
||||
// Broadcast to GM or process it directly in case of GM defense
|
||||
if ( !game.user.isGM) {
|
||||
game.socket.emit("system.bol", { msg: "msg_attack_success", data: this.attackDef });
|
||||
} else {
|
||||
BoLUtility.processAttackSuccess( this.attackDef);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_buildDamageChatMessage(actor, weapon, total) {
|
||||
const rollMessageTpl = 'systems/bol/templates/chat/rolls/damage-roll-card.hbs';
|
||||
|
Reference in New Issue
Block a user