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 actorObject = this.actor;
let element = event.currentTarget; let element = event.currentTarget;
let attack = element.parentElement.parentElement.dataset.attack; 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); super.activateListeners(html);

View File

@ -104,19 +104,18 @@ export class OseActor extends Actor {
}); });
} }
rollAttack(attack, options = {}) { rollAttack(attData, options = {}) {
const label = game.i18n.localize(`OSE.${attack}`);
const rollParts = ["1d20"]; const rollParts = ["1d20"];
const data = this.data.data; const data = this.data.data;
if (attack == "Missile") { if (attData.type == "missile") {
rollParts.push( rollParts.push(
"+", "+",
data.scores.dex.mod.toString(), data.scores.dex.mod.toString(),
"+", "+",
data.thac0.mod.missile.toString() data.thac0.mod.missile.toString()
); );
} else if (attack == "Melee") { } else if (attData.type == "melee") {
rollParts.push( rollParts.push(
"+", "+",
data.scores.str.mod.toString(), data.scores.str.mod.toString(),
@ -133,7 +132,7 @@ export class OseActor extends Actor {
...{ ...{
rollData: { rollData: {
type: "Attack", type: "Attack",
stat: attack, stat: attData.type,
scores: data.scores, scores: data.scores,
}, },
}, },
@ -144,8 +143,8 @@ export class OseActor extends Actor {
parts: rollParts, parts: rollParts,
data: rollData, data: rollData,
speaker: ChatMessage.getSpeaker({ actor: this }), speaker: ChatMessage.getSpeaker({ actor: this }),
flavor: `${label} ${game.i18n.localize("OSE.Attack")}`, flavor: `${attData.label} - ${game.i18n.localize("OSE.Attack")}`,
title: `${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 (data.rollData.type == "Attack") {
if (game.settings.get("ose", "ascendingAC")) { if (game.settings.get("ose", "ascendingAC")) {
let bba = data.data.thac0.bba; 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; 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; bba += data.data.thac0.mod.missile + data.rollData.scores.dex.mod;
} }
@ -20,9 +20,9 @@ export class OseDice {
} else { } else {
// B/X Historic THAC0 Calculation // B/X Historic THAC0 Calculation
let thac = data.data.thac0.value; 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; 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; thac -= data.data.thac0.mod.missile + data.rollData.scores.dex.mod;
} }
details = `<div class='roll-result roll-fail'><b>Failure</b> (${thac})</div>`; details = `<div class='roll-result roll-fail'><b>Failure</b> (${thac})</div>`;

View File

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

View File

@ -149,7 +149,7 @@
</div> </div>
<div class="flexrow"> <div class="flexrow">
<ul class="attributes 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'}}"> <h4 class="attribute-name box-title" title="{{localize 'OSE.Melee'}}">
<a>{{localize 'OSE.MeleeShort'}}</a></h4> <a>{{localize 'OSE.MeleeShort'}}</a></h4>
<div class="flexrow"> <div class="flexrow">
@ -189,7 +189,7 @@
</div> </div>
</li> </li>
{{/if}} {{/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'}}"> <h4 class="attribute-name box-title" title="{{localize 'OSE.Missile'}}">
<a>{{localize 'OSE.MissileShort'}}</a></h4> <a>{{localize 'OSE.MissileShort'}}</a></h4>
<div class="flexrow"> <div class="flexrow">

View File

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