aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Tuomi <jan.tuomi@eficode.com>2019-07-02 20:59:32 +0300
committerJan Tuomi <jan.tuomi@eficode.com>2019-07-02 20:59:32 +0300
commit05d8a2876fed9eb189264103eaad69c41f6836cb (patch)
treee422181f8dc8763ea193739ff87d06d62c7fc4c4
parent4d8cd954747096024eeb4fab78211717e433ac10 (diff)
Minor fixes
-rwxr-xr-x[-rw-r--r--]index.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/index.js b/index.js
index 7c46c84..6699975 100644..100755
--- a/index.js
+++ b/index.js
@@ -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) => {