0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-27 20:12:40 +00:00

Clean up duplicate code in snippet generator

This commit is contained in:
Trevor Buckner
2021-04-04 16:22:50 -04:00
parent ea9ba84dc2
commit c186b6677b
3 changed files with 13 additions and 67 deletions

View File

@@ -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')}
}}`;
}
};

View File

@@ -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',

View File

@@ -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;