ENH: Weapon name in attack

master
U~man 2020-07-04 23:12:35 +02:00
parent ebcdcc8465
commit c0efa40725
6 changed files with 18 additions and 22 deletions

View File

@ -122,7 +122,7 @@ export class OseActorSheet extends ActorSheet {
let actorObject = this.actor;
let element = event.currentTarget;
let attack = element.parentElement.parentElement.dataset.attack;
actorObject.rollAttack(attack, { event: event });
actorObject.rollAttack({label: this.actor.name, type: attack}, { event: event });
});
super.activateListeners(html);

View File

@ -104,19 +104,18 @@ export class OseActor extends Actor {
});
}
rollAttack(attack, options = {}) {
const label = game.i18n.localize(`OSE.${attack}`);
rollAttack(attData, options = {}) {
const rollParts = ["1d20"];
const data = this.data.data;
if (attack == "Missile") {
if (attData.type == "missile") {
rollParts.push(
"+",
data.scores.dex.mod.toString(),
"+",
data.thac0.mod.missile.toString()
);
} else if (attack == "Melee") {
} else if (attData.type == "melee") {
rollParts.push(
"+",
data.scores.str.mod.toString(),
@ -133,7 +132,7 @@ export class OseActor extends Actor {
...{
rollData: {
type: "Attack",
stat: attack,
stat: attData.type,
scores: data.scores,
},
},
@ -144,8 +143,8 @@ export class OseActor extends Actor {
parts: rollParts,
data: rollData,
speaker: ChatMessage.getSpeaker({ actor: this }),
flavor: `${label} ${game.i18n.localize("OSE.Attack")}`,
title: `${label} ${game.i18n.localize("OSE.Attack")}`,
flavor: `${attData.label} - ${game.i18n.localize("OSE.Attack")}`,
title: `${attData.label} - ${game.i18n.localize("OSE.Attack")}`,
});
}

View File

@ -6,9 +6,9 @@ export class OseDice {
if (data.rollData.type == "Attack") {
if (game.settings.get("ose", "ascendingAC")) {
let bba = data.data.thac0.bba;
if (data.rollData.stat == "Melee") {
if (data.rollData.stat == "melee") {
bba += data.data.thac0.mod.melee + data.rollData.scores.str.mod;
} else if (data.rollData.stat == "Missile") {
} else if (data.rollData.stat == "missile") {
bba += data.data.thac0.mod.missile + data.rollData.scores.dex.mod;
}
@ -20,9 +20,9 @@ export class OseDice {
} else {
// B/X Historic THAC0 Calculation
let thac = data.data.thac0.value;
if (data.rollData.stat == "Melee") {
if (data.rollData.stat == "melee") {
thac -= data.data.thac0.mod.melee + data.rollData.scores.str.mod;
} else if (data.rollData.stat == "Missile") {
} else if (data.rollData.stat == "missile") {
thac -= data.data.thac0.mod.missile + data.rollData.scores.dex.mod;
}
details = `<div class='roll-result roll-fail'><b>Failure</b> (${thac})</div>`;

View File

@ -49,15 +49,13 @@ export class OseItem extends Item {
rollWeapon() {
if (this.data.data.missile) {
this.actor.rollAttack('Missile');
return true;
this.actor.rollAttack({type: 'missile', label: this.name});
} else if (this.data.data.melee) {
this.actor.rollAttack('Melee');
return true;
this.actor.rollAttack({type: 'melee', label: this.name});
} else {
this.actor.rollAttack();
this.actor.rollAttack({type: 'raw', label: this.name});
}
return false;
return true;
}
async rollFormula(options={}) {
@ -86,7 +84,6 @@ export class OseItem extends Item {
* @return {Promise}
*/
async roll({ configureDialog = true } = {}) {
console.log(this.data);
if (this.data.type == 'weapon') {
if (this.rollWeapon()) return;
}

View File

@ -149,7 +149,7 @@
</div>
<div class="flexrow">
<ul class="attributes flexrow">
<li class="attribute attribute-secondaries attack" data-attack="Melee">
<li class="attribute attribute-secondaries attack" data-attack="melee">
<h4 class="attribute-name box-title" title="{{localize 'OSE.Melee'}}">
<a>{{localize 'OSE.MeleeShort'}}</a></h4>
<div class="flexrow">
@ -189,7 +189,7 @@
</div>
</li>
{{/if}}
<li class="attribute attribute-secondaries attack" data-attack="Missile">
<li class="attribute attribute-secondaries attack" data-attack="missile">
<h4 class="attribute-name box-title" title="{{localize 'OSE.Missile'}}">
<a>{{localize 'OSE.MissileShort'}}</a></h4>
<div class="flexrow">

View File

@ -32,7 +32,7 @@
</div>
{{/if}}
</li>
<li class="attribute attack" data-attack="Attack">
<li class="attribute attack">
{{#if config.ascendingAC}}
<h4 class="attribute-name box-title" title="{{localize 'OSE.AB'}}"><a>{{ localize "OSE.ABShort" }}</a></h4>
<div class="attribute-value">