module/npc-parser.js
/** Parse out a attack string into fields
 * @param {string} attackString  Full weapon string for a single attack
 * @param {string} damageString  Damage string for blocks with damage separate
 */
Parse out a attack string into fields
@param {string} attackString  Full weapon string for a single attack
@param {string} damageString  Damage string for blocks with damage separate
Parse out a attack string into fields @param { string } attackString Full weapon string for a single attack @param { string } damageString Damage string for blocks with damage separate
function _parseAttack(attackString, damageString) {
    let attack = {}
    attack.name = attackString.replace(/(.*?) [+-].*/, "$1");
    attack.toHit = attackString.replace(/.*? ([+-].*?) .*/, "$1");
    attack.special = "";
    attack.damage = "";
    attack.type = "melee";
    if (attackString.includes("ranged")) attack.type = "ranged";
    if (damageString) {
        attack.damage = damageString;
    } else {
        if (attackString.match(/.*\(\w+ (.*)\).*/)) attack.special = attackString.replace(/.*\(\w+ (.*)\).*/, "$1");
        attack.damage = attackString.replace(/.*\((\w+).*\).*/, "$1");
    }
    return attack;
}
function _parseAttack ( attackString , damageString ) { let attack = { } attack . name = attackString . replace ( / (.*?) [+-].* / , "$1" ) ; attack . toHit = attackString . replace ( / .*? ([+-].*?) .* / , "$1" ) ; attack . special = "" ; attack . damage = "" ; attack . type = "melee" ; if ( attackString . includes ( "ranged" ) ) attack . type = "ranged" ; if ( damageString ) { attack . damage = damageString ; } else { if ( attackString . match ( / .*\(\w+ (.*)\).* / ) ) attack . special = attackString . replace ( / .*\(\w+ (.*)\).* / , "$1" ) ; attack . damage = attackString . replace ( / .*\((\w+).*\).* / , "$1" ) ; } return attack ; }
Parse out a attack string into fields
 @param {string} attackString  Full weapon string for a single attack
 @param {string} damageString  Damage string for blocks with damage separate
Parse out a attack string into fields @param { string } attackString Full weapon string for a single attack @param { string } damageString Damage string for blocks with damage separate