diff options
| author | Jan Tuomi <jan.tuomi@eficode.com> | 2019-07-02 20:59:32 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan.tuomi@eficode.com> | 2019-07-02 20:59:32 +0300 |
| commit | 05d8a2876fed9eb189264103eaad69c41f6836cb (patch) | |
| tree | e422181f8dc8763ea193739ff87d06d62c7fc4c4 /index.js | |
| parent | 4d8cd954747096024eeb4fab78211717e433ac10 (diff) | |
Minor fixes
Diffstat (limited to 'index.js')
| -rwxr-xr-x[-rw-r--r--] | index.js | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -1,3 +1,5 @@ +#!/usr/bin/env node + const builder = require('xmlbuilder'); const fs = require('fs'); @@ -14,6 +16,11 @@ const inputData = JSON.parse(inputString); const printableNumber = n => (n > 0) ? "+" + n : n; +const capitalize = (s) => { + if (typeof s !== 'string') return '' + return s.charAt(0).toUpperCase() + s.slice(1) +}; + const replaceSpecialValuesInActionText = (text) => { text = text.replace(/\{@hit (\d+?)\}/g, (match, p1) => printableNumber(p1)) text = text.replace(/\{@h\}(\d+?)/g, '$1'); @@ -21,6 +28,8 @@ const replaceSpecialValuesInActionText = (text) => { text = text.replace(/\{@dc (\d+?)\}/g, 'DC $1'); text = text.replace(/\{@condition (\w+)\}/g, '$1'); text = text.replace(/\{@skill (\w+)\}/g, '$1'); + text = text.replace(/\{@dice (.+?)\}/g, '$1'); + text = text.replace(/\{@spell (.+?)\}/g, (match, p1) => capitalize(p1)); text = text.replace(/\{@atk (.+?)\}/g, (match, p1) => { p1 = p1.replace(/mw/g, 'Melee Weapon Attack'); p1 = p1.replace(/ms/g, 'Melee Spell Attack'); @@ -72,7 +81,7 @@ const parseToXML = (obj) => { }).join(', ')); monster.ele('save', obj.save && Object.keys(obj.save).map((key) => { - return `${type} ${obj.save[key]}`; + return `${key} ${obj.save[key]}`; }).join(', ')); monster.ele('skill', obj.skill && Object.keys(obj.skill).map((key) => { |
