set basic hd

This commit is contained in:
Mark
2016-08-06 22:44:32 +02:00
parent c301efed80
commit 9266b7cc2f
2 changed files with 5 additions and 0 deletions
+1
View File
@@ -227,6 +227,7 @@ export class Npc {
const collectionArray = ['hit_dice', 'hit_die'];
for (const key in hd) {
if (hd.hasOwnProperty(key)) {
collectionArray.push(`hd_${key}`);
collectionArray.push(`hd_${key}_max`);
collectionArray.push(`hd_${key}_query`);
collectionArray.push(`hd_${key}_toggle`);
@@ -386,6 +386,7 @@ const updateHD = (v, finalSetAttrs, hd) => {
for (const key in hd) {
if (hd.hasOwnProperty(key)) {
if (hd[key] && hd[key] !== 0) {
finalSetAttrs[`hd_${key}`] = hd[key];
finalSetAttrs[`hd_${key}_max`] = hd[key];
finalSetAttrs[`hd_${key}_query`] = '?{HD';
for (let x = 1; x <= hd[key]; x++) {
@@ -394,6 +395,9 @@ const updateHD = (v, finalSetAttrs, hd) => {
finalSetAttrs[`hd_${key}_query`] += '}';
finalSetAttrs[`hd_${key}_toggle`] = 1;
} else {
if (!isUndefinedOrEmpty(v[`hd_${key}`])) {
finalSetAttrs[`hd_${key}`] = 0;
}
if (!isUndefinedOrEmpty(v[`hd_${key}_max`])) {
finalSetAttrs[`hd_${key}_max`] = 0;
}