From c186b6677b6293820376fddb9ebaddb42aa0936e Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Sun, 4 Apr 2021 16:22:50 -0400 Subject: [PATCH] Clean up duplicate code in snippet generator --- .../snippetbar/snippets/monsterblock.gen.js | 66 ++----------------- .../editor/snippetbar/snippets/snippets.js | 6 +- client/homebrew/phbStyle/phb.style.less | 8 +-- 3 files changed, 13 insertions(+), 67 deletions(-) diff --git a/client/homebrew/editor/snippetbar/snippets/monsterblock.gen.js b/client/homebrew/editor/snippetbar/snippets/monsterblock.gen.js index dcd8b379a..522596e16 100644 --- a/client/homebrew/editor/snippetbar/snippets/monsterblock.gen.js +++ b/client/homebrew/editor/snippetbar/snippets/monsterblock.gen.js @@ -96,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.', + '***Pack Tactics.*** These guys work together like peanut butter and jelly.', '***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.', + '***Big Jerk.*** Whenever this creature makes an attack, it starts telling you how much cooler it is than you.', ]); }; @@ -140,9 +140,9 @@ const genAction = function(){ module.exports = { - full : function(){ + monster : function(classes, genLines){ return dedent` - {{monster,frame,wide + {{${classes} ## ${getMonsterName()} *${getType()}, ${getAlignment()}* ___ @@ -160,64 +160,10 @@ module.exports = { : **Challenge** : ${_.random(0, 15)} (${_.random(10, 10000)} XP) ___ : - ${_.times(_.random(3, 6), function(){return genAbilities();}).join('\n\t\t\t\n\t\t\t')} + ${_.times(_.random(genLines, genLines + 2), function(){return genAbilities();}).join('\n\t\t\t\n\t\t\t')} : ### Actions - ${_.times(_.random(4, 6), function(){return genAction();}).join('\n\t\t\t\n\t\t\t')} - }}`; - }, - - half : function(){ - 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')} - }}`; - }, - - unframed : function(){ - return dedent` - {{monster - ## ${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')} + ${_.times(_.random(genLines, genLines + 2), function(){return genAction();}).join('\n\t\t\t\n\t\t\t')} }}`; } }; diff --git a/client/homebrew/editor/snippetbar/snippets/snippets.js b/client/homebrew/editor/snippetbar/snippets/snippets.js index 9e577a8a3..6a0345381 100644 --- a/client/homebrew/editor/snippetbar/snippets/snippets.js +++ b/client/homebrew/editor/snippetbar/snippets/snippets.js @@ -154,17 +154,17 @@ module.exports = [ { name : 'Monster Stat Block (unframed)', icon : 'fas fa-paw', - gen : MonsterBlockGen.unframed, + gen : MonsterBlockGen.monster('monster', 2), }, { name : 'Monster Stat Block', icon : 'fas fa-spider', - gen : MonsterBlockGen.half, + gen : MonsterBlockGen.monster('monster,frame', 2), }, { name : 'Wide Monster Stat Block', icon : 'fas fa-dragon', - gen : MonsterBlockGen.full, + gen : MonsterBlockGen.monster('monster,frame,wide', 4), }, { name : 'Cover Page', diff --git a/client/homebrew/phbStyle/phb.style.less b/client/homebrew/phbStyle/phb.style.less index ed9f754b9..50b17b71f 100644 --- a/client/homebrew/phbStyle/phb.style.less +++ b/client/homebrew/phbStyle/phb.style.less @@ -229,12 +229,12 @@ body { box-shadow : 1px 4px 14px #888; padding : 4px 2px; margin : 0px -6px 1em; - -webkit-transform : translateZ(0); //Prevents shadows from breaking across columns } .useSansSerif(); - position : relative; - padding : 0px; - margin-bottom : 1em; + -webkit-transform : translateZ(0); //Prevents shadows from breaking across columns + position : relative; + padding : 0px; + margin-bottom : 1em; p{ margin-bottom : 0;