FIX: attacks, raw attacks

master
U~man 2020-07-29 21:37:25 +02:00
parent 8af8a0f635
commit 6459321493
6 changed files with 38 additions and 19 deletions

View File

@ -164,7 +164,11 @@ export class OseActorSheet extends ActorSheet {
let actorObject = this.actor;
let element = event.currentTarget;
let attack = element.parentElement.parentElement.dataset.attack;
actorObject.rollAttack({roll: {}}, { type: attack, skipDialog: ev.ctrlKey });
const rollData = {
actor: this.data,
roll: {}
}
actorObject.targetAttack(rollData, attack, {type: attack, skipDialog: ev.ctrlKey});
});
html.find(".spells .item-reset").click((ev) => {

View File

@ -105,6 +105,7 @@ export class OseActor extends Actor {
let roll = new Roll(this.data.data.hp.hd).roll();
return this.update({
data: {
actor: this.data,
hp: {
max: roll.total,
value: roll.total,
@ -144,6 +145,7 @@ export class OseActor extends Actor {
const rollParts = ["2d6"];
const data = {
actor: this.data,
roll: {
type: "below",
target: this.data.data.details.morale,
@ -167,6 +169,7 @@ export class OseActor extends Actor {
const rollParts = ["2d6"];
const data = {
actor: this.data,
roll: {
type: "below",
target: this.data.data.retainer.loyalty,
@ -189,6 +192,7 @@ export class OseActor extends Actor {
const rollParts = ["2d6"];
const data = {
actor: this.data,
roll: {
type: "table",
table: {
@ -230,6 +234,7 @@ export class OseActor extends Actor {
const rollParts = ["1d20"];
const data = {
actor: this.data,
roll: {
type: "check",
target: this.data.data.scores[score].value,
@ -262,6 +267,7 @@ export class OseActor extends Actor {
}
const data = {
actor: this.data,
roll: {
type: "hitdice",
},
@ -290,6 +296,7 @@ export class OseActor extends Actor {
label = "(1)";
}
const data = {
actor: this.data,
roll: {
type: {
type: "appearing",
@ -314,6 +321,7 @@ export class OseActor extends Actor {
const rollParts = ["1d6"];
const data = {
actor: this.data,
roll: {
type: "below",
target: this.data.data.exploration[expl],
@ -372,6 +380,17 @@ export class OseActor extends Actor {
});
}
async targetAttack(data, type, options) {
if (game.user.targets.size > 0) {
for (let t of game.user.targets.values()) {
data.roll.target = t;
await this.rollAttack(data, { type: type, skipDialog: options.skipDialog });
}
} else {
this.rollAttack(data, { type: type, skipDialog: options.skipDialog });
}
}
rollAttack(attData, options = {}) {
const data = this.data.data;
const rollParts = ["1d20"];

View File

@ -79,18 +79,6 @@ export class OseItem extends Item {
}
};
// rollAttack to target helper
const rollAttack = async (type) => {
if (game.user.targets.size > 0) {
for (let t of game.user.targets.values()) {
rollData.roll.target = t;
await this.actor.rollAttack(rollData, { type: type, skipDialog: options.skipDialog });
}
} else {
this.actor.rollAttack(rollData, { type: type, skipDialog: options.skipDialog });
}
};
if (data.missile && data.melee && !isNPC) {
// Dialog
new Dialog({
@ -101,14 +89,14 @@ export class OseItem extends Item {
icon: '<i class="fas fa-fist-raised"></i>',
label: "Melee",
callback: () => {
rollAttack("melee");
this.targetAttack(rollData, "melee", options);
},
},
missile: {
icon: '<i class="fas fa-bullseye"></i>',
label: "Missile",
callback: () => {
rollAttack("missile");
this.targetAttack(rollData, "missile", options);
},
},
},
@ -118,7 +106,7 @@ export class OseItem extends Item {
} else if (data.missile && !isNPC) {
type = "missile";
}
rollAttack(type);
this.targetAttack(rollData, type, options);
return true;
}

View File

@ -5,7 +5,11 @@
<div class="chat-title">
<h2>{{title}}</h2>
</div>
<div class="chat-img" style="background-image:url('{{data.img}}')"></div>
{{#if data.item}}
<div class="chat-img" style="background-image:url('{{data.item.img}}')"></div>
{{else}}
<div class="chat-img" style="background-image:url('{{data.actor.img}}')"></div>
{{/if}}
</div>
{{#if result.victim}}
<div class="chat-target">

View File

@ -2,7 +2,7 @@
<div class="ose chat-block">
<div class="flexrow chat-header">
<div class="chat-title"><h2>{{title}}</h2></div>
<div class="chat-img" style="background-image:url('{{data.img}}')"></div>
<div class="chat-img" style="background-image:url('{{data.actor.img}}')"></div>
</div>
<div class="flexrow">
<ol class="flex2">

View File

@ -2,7 +2,11 @@
<div class="ose chat-block">
<div class="flexrow chat-header">
<div class="chat-title"><h2>{{title}}</h2></div>
<div class="chat-img" style="background-image:url('{{data.img}}')"></div>
{{#if data.item}}
<div class="chat-img" style="background-image:url('{{data.item.img}}')"></div>
{{else}}
<div class="chat-img" style="background-image:url('{{data.actor.img}}')"></div>
{{/if}}
</div>
{{#if result.details}}<div class="chat-details">{{{result.details}}}</div>{{/if}}
{{#if result.isFailure}}<div class='roll-result roll-fail'><b>{{localize 'OSE.Failure'}}</b> ({{result.target}})