New fields for weapons
This commit is contained in:
@ -105,7 +105,12 @@ export class BoLRoll {
|
||||
rollData.id = randomID(16)
|
||||
|
||||
// Weapon mode specific management
|
||||
rollData.weaponModifier = 0
|
||||
rollData.attackBonusDice = false
|
||||
if (rollData.mode == "weapon") {
|
||||
//console.log("WEAPON", rollData.weapon)
|
||||
rollData.weaponModifier = rollData.weapon.data.data.properties.attackModifiers?? 0;
|
||||
rollData.attackBonusDice = rollData.weapon.data.data.properties.attackBonusDice
|
||||
if (rollData.defender) { // If target is selected
|
||||
rollData.defence = rollData.defender.defenseValue,
|
||||
rollData.shieldBlock = 'none'
|
||||
@ -118,8 +123,6 @@ export class BoLRoll {
|
||||
}
|
||||
}
|
||||
|
||||
console.log("ROL1", rollData)
|
||||
|
||||
const rollOptionContent = await renderTemplate(rollOptionTpl, rollData);
|
||||
let d = new Dialog({
|
||||
title: rollData.label,
|
||||
@ -154,12 +157,13 @@ export class BoLRoll {
|
||||
}
|
||||
|
||||
const isMalus = rollData.adv.includes('M');
|
||||
const dicePool = __adv2dice[rollData.adv]
|
||||
let dicePool = __adv2dice[rollData.adv]
|
||||
dicePool += (rollData.attackBonusDice) ? 1 : 0
|
||||
//// const dicePool = (isMalus) ? 2 - parseInt(rollData.adv) : 2 + parseInt(rollData.adv);
|
||||
const attrValue = (rollData.attrKey) && eval(`rollData.actor.data.data.attributes.${rollData.attrKey}.value`) || 0;
|
||||
const aptValue = (rollData.aptKey) && eval(`rollData.actor.data.data.aptitudes.${rollData.aptKey}.value`) || 0
|
||||
|
||||
const modifiers = parseInt(attrValue) + parseInt(aptValue) + parseInt(rollData.mod) + parseInt(rollData.career) - rollData.defence - shieldMalus;
|
||||
const modifiers = rollData.weaponModifier + parseInt(attrValue) + parseInt(aptValue) + parseInt(rollData.mod) + parseInt(rollData.career) - rollData.defence - shieldMalus;
|
||||
const formula = (isMalus) ? dicePool + "d6kl2 + " + modifiers : dicePool + "d6kh2 + " + modifiers;
|
||||
rollData.formula = formula;
|
||||
rollData.modifiers = modifiers
|
||||
@ -177,6 +181,7 @@ export class BoLRoll {
|
||||
}
|
||||
|
||||
export class BoLDefaultRoll {
|
||||
|
||||
constructor(rollData) {
|
||||
BoLUtility.storeRoll(rollData)
|
||||
this.rollData = rollData
|
||||
|
@ -381,24 +381,28 @@ export class BoLUtility {
|
||||
static getDamageFormula(damageString, modifier=0, multiplier = 1) {
|
||||
if (damageString[0] == 'd') { damageString = "1" + damageString } // Help parsing
|
||||
if (modifier == null) modifier = 0;
|
||||
var myReg = new RegExp('(\\d+)[dD]([\\d]+)([MB]*)?([\\+\\d]*)?', 'g');
|
||||
let res = myReg.exec(damageString);
|
||||
let nbDice = parseInt(res[1]);
|
||||
let postForm = 'kh' + nbDice;
|
||||
let modIndex = 3;
|
||||
if (res[3]) {
|
||||
if (res[3] == 'M') {
|
||||
postForm = 'kl' + nbDice;
|
||||
nbDice++;
|
||||
modIndex = 4;
|
||||
}
|
||||
if (res[3] == 'B') {
|
||||
postForm = 'kh' + nbDice;
|
||||
nbDice++;
|
||||
modIndex = 4;
|
||||
|
||||
let formula = damageString
|
||||
if ( damageString.includes("d") || damageString.includes("D")) {
|
||||
var myReg = new RegExp('(\\d+)[dD]([\\d]+)([MB]*)?([\\+\\d]*)?', 'g');
|
||||
let res = myReg.exec(damageString);
|
||||
let nbDice = parseInt(res[1]);
|
||||
let postForm = 'kh' + nbDice;
|
||||
let modIndex = 3;
|
||||
if (res[3]) {
|
||||
if (res[3] == 'M') {
|
||||
postForm = 'kl' + nbDice;
|
||||
nbDice++;
|
||||
modIndex = 4;
|
||||
}
|
||||
if (res[3] == 'B') {
|
||||
postForm = 'kh' + nbDice;
|
||||
nbDice++;
|
||||
modIndex = 4;
|
||||
}
|
||||
}
|
||||
formula = "(" + nbDice + "d" + res[2] + postForm + "+" + modifier +") *" + multiplier;
|
||||
}
|
||||
let formula = "(" + nbDice + "d" + res[2] + postForm + "+" + modifier +") *" + multiplier;
|
||||
return formula;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
|
@ -10,6 +10,9 @@ System.debugMode = true;
|
||||
export const BOL = {};
|
||||
|
||||
BOL.damageValues = {
|
||||
"1": "1",
|
||||
"2": "2",
|
||||
"3": "3",
|
||||
"d3" : "d3",
|
||||
"d6M" : "d6M (Malus)",
|
||||
"d6" : "d6",
|
||||
|
Reference in New Issue
Block a user