From 7ae419716a9d393e4bfb609a1e3c525ec24d3450 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Fri, 2 Apr 2021 11:02:19 -0400 Subject: [PATCH] Monster snippet added --- .../snippetbar/snippets/monsterblock.gen.js | 67 +++++++++---------- package-lock.json | 5 ++ package.json | 1 + 3 files changed, 39 insertions(+), 34 deletions(-) diff --git a/client/homebrew/editor/snippetbar/snippets/monsterblock.gen.js b/client/homebrew/editor/snippetbar/snippets/monsterblock.gen.js index 1e8a0eebd..e512c7d64 100644 --- a/client/homebrew/editor/snippetbar/snippets/monsterblock.gen.js +++ b/client/homebrew/editor/snippetbar/snippets/monsterblock.gen.js @@ -1,4 +1,5 @@ const _ = require('lodash'); +const dedent = require('dedent-tabs').default; const genList = function(list, max){ return _.sampleSize(list, _.random(0, max)).join(', ') || 'None'; @@ -86,7 +87,7 @@ const getAlignment = function(){ }; const getStats = function(){ - return `>|${_.times(6, function(){ + return `|${_.times(6, function(){ const num = _.random(1, 20); const mod = Math.ceil(num/2 - 5); return `${num} (${mod >= 0 ? `+${mod}` : mod})`; @@ -95,12 +96,12 @@ const getStats = function(){ const genAbilities = function(){ return _.sample([ - '> ***Pack Tactics.*** These guys work together. Like super well, you don\'t even know.', - '> ***Fowl Appearance.*** While the creature remains motionless, it is indistinguishable from a normal chicken.', - '> ***Onion Stench.*** Any creatures within 5 feet of this thing develops an irrational craving for onion rings.', - '> ***Enormous Nose.*** This creature gains advantage on any check involving putting things in its nose.', - '> ***Sassiness.*** When questioned, this creature will talk back instead of answering.', - '> ***Big Jerk.*** Thinks he is just *waaaay* better than you.', + '***Pack Tactics.*** These guys work together. Like super well, you don\'t even know.', + '***Fowl Appearance.*** While the creature remains motionless, it is indistinguishable from a normal chicken.', + '***Onion Stench.*** Any creatures within 5 feet of this thing develops an irrational craving for onion rings.', + '***Enormous Nose.*** This creature gains advantage on any check involving putting things in its nose.', + '***Sassiness.*** When questioned, this creature will talk back instead of answering.', + '***Big Jerk.*** Thinks he is just *waaaay* better than you.', ]); }; @@ -133,7 +134,7 @@ const genAction = function(){ 'Turnbuckle Roll' ]); - return `> ***${name}.*** *Melee Weapon Attack:* +4 to hit, reach 5ft., one target. *Hit* 5 (1d6 + 2) `; + return `***${name}.*** *Melee Weapon Attack:* +4 to hit, reach 5ft., one target. *Hit* 5 (1d6 + 2) `; }; @@ -170,31 +171,29 @@ module.exports = { }, half : function(){ - return `${[ - '___', - `> ## ${getMonsterName()}`, - `>*${getType()}, ${getAlignment()}*`, - '> ___', - `> - **Armor Class** ${_.random(10, 20)}`, - `> - **Hit Points** ${_.random(1, 150)}(1d4 + 5)`, - `> - **Speed** ${_.random(0, 50)}ft.`, - '>___', - '>|STR|DEX|CON|INT|WIS|CHA|', - '>|:---:|:---:|:---:|:---:|:---:|:---:|', - getStats(), - '>___', - `> - **Condition Immunities** ${genList(['groggy', 'swagged', 'weak-kneed', 'buzzed', 'groovy', 'melancholy', 'drunk'], 3)}`, - `> - **Senses** passive Perception ${_.random(3, 20)}`, - `> - **Languages** ${genList(['Common', 'Pottymouth', 'Gibberish', 'Latin', 'Jive'], 2)}`, - `> - **Challenge** ${_.random(0, 15)} (${_.random(10, 10000)} XP)`, - '> ___', - _.times(_.random(2, 3), function(){ - return genAbilities(); - }).join('\n>\n'), - '> ### Actions', - _.times(_.random(1, 2), function(){ - return genAction(); - }).join('\n>\n'), - ].join('\n')}\n\n\n`; + return dedent` + {{monster,frame + ## ${getMonsterName()} + *${getType()}, ${getAlignment()}* + ___ + : **Armor Class** : ${_.random(10, 20)} (chain mail, shield) + : **Hit Points** : ${_.random(1, 150)}(1d4 + 5) + : **Speed** : ${_.random(0, 50)}ft. + ___ + | STR | DEX | CON | INT | WIS | CHA | + |:-----:|:-----:|:-----:|:-----:|:-----:|:-----:| + ${getStats()} + ___ + : **Condition Immunities** : ${genList(['groggy', 'swagged', 'weak-kneed', 'buzzed', 'groovy', 'melancholy', 'drunk'], 3)} + : **Senses** : darkvision 60 ft., passive Perception ${_.random(3, 20)} + : **Languages** : ${genList(['Common', 'Pottymouth', 'Gibberish', 'Latin', 'Jive'], 2)} + : **Challenge** : ${_.random(0, 15)} (${_.random(10, 10000)} XP) + ___ + : + ${_.times(_.random(2, 3), function(){return genAbilities();}).join('\n\t\t\t\n\t\t\t')} + : + ### Actions + ${_.times(_.random(2, 3), function(){return genAction();}).join('\n\t\t\t\n\t\t\t')} + }}`; } }; diff --git a/package-lock.json b/package-lock.json index 8f1e65e49..c1e3f6595 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3187,6 +3187,11 @@ "mimic-response": "^1.0.0" } }, + "dedent-tabs": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/dedent-tabs/-/dedent-tabs-0.9.0.tgz", + "integrity": "sha512-XpJr3b3pX6XHK0MDE9/hF2AxAIqzeBhBWqQ22PlzEZFqR31N8x44+e/iML76cwVvhjVqk1BqZeTBS9BrccMJlA==" + }, "deep-extend": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", diff --git a/package.json b/package.json index fa4beba36..bbed7256e 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "codemirror": "^5.59.4", "cookie-parser": "^1.4.5", "create-react-class": "^15.7.0", + "dedent-tabs": "^0.9.0", "express": "^4.17.1", "express-async-handler": "^1.1.4", "express-static-gzip": "2.1.1",