0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-13 10:52:46 +00:00

Merge branch 'randombrew' into home

This commit is contained in:
Scott Tolksdorf
2017-06-04 22:03:52 -04:00
16 changed files with 1562 additions and 107 deletions

View File

@@ -3,6 +3,7 @@
"description": "Create authentic looking D&D homebrews using only markdown", "description": "Create authentic looking D&D homebrews using only markdown",
"version": "3.0.0", "version": "3.0.0",
"scripts": { "scripts": {
"logs": "heroku logs -t --app=homebrewery",
"dev": "node scripts/dev.js", "dev": "node scripts/dev.js",
"quick": "node scripts/quick.js", "quick": "node scripts/quick.js",
"build": "node scripts/build.js", "build": "node scripts/build.js",
@@ -29,7 +30,6 @@
"jwt-simple": "^0.5.1", "jwt-simple": "^0.5.1",
"lodash": "^4.17.3", "lodash": "^4.17.3",
"loglevel": "^1.4.1", "loglevel": "^1.4.1",
"marked": "^0.3.5",
"moment": "^2.11.0", "moment": "^2.11.0",
"mongoose": "^4.3.3", "mongoose": "^4.3.3",
"nconf": "^0.8.4", "nconf": "^0.8.4",

View File

@@ -5,16 +5,20 @@ const DB = require('../server/db.js');
const BrewData = require('../server/brew.data.js'); const BrewData = require('../server/brew.data.js');
//const BrewGen = require('../tests/brew.gen.js'); //const BrewGen = require('../tests/brew.gen.js');
const BrewGen = require('../shared/homebrewery/snippets/brew/brew.snippet.js');
const BREW_COUNT = 50;
return Promise.resolve() return Promise.resolve()
.then(DB.connect) .then(DB.connect)
.then(BrewData.removeAll) .then(BrewData.removeAll)
.then(() => { .then(() => {
console.log('Adding random brews...'); return _.reduce(_.times(BREW_COUNT, BrewGen.brewModel), (flow, model)=>{
return BrewGen.populateDB(BrewGen.random(50)); return flow.then(()=>BrewData.create(model))
}, Promise.resolve());
}) })
.then(() => { .then(() => {
console.log('Adding specific brews...'); console.log(`Added ${BREW_COUNT} brews`);
return BrewGen.populateDB(BrewGen.static());
}) })
.then(() => { .then(() => {
return DB.close(); return DB.close();

View File

@@ -1,5 +1,6 @@
const _ = require('lodash'); const _ = require('lodash');
const Markdown = require('marked'); //const Markdown = require('marked');
const Markdown = require('./marked.lib.js');
const renderer = new Markdown.Renderer(); const renderer = new Markdown.Renderer();
@@ -10,7 +11,9 @@ renderer.paragraph = function(text){
if(!matches) return `\n<p>${text}</p>\n`; if(!matches) return `\n<p>${text}</p>\n`;
let matchIndex = 0; let matchIndex = 0;
const res = _.reduce(text.split(blockReg), (r, text) => { const res = _.reduce(text.split(blockReg), (r, text) => {
//if(text) r.push(text);
if(text) r.push(Markdown(text, {renderer : renderer, sanitize: true})); if(text) r.push(Markdown(text, {renderer : renderer, sanitize: true}));
const block = matches[matchIndex]; const block = matches[matchIndex];
if(block && block[0] == '{'){ if(block && block[0] == '{'){
r.push(`\n\n<div class="block ${block.substring(2).split(',').join(' ')}">`); r.push(`\n\n<div class="block ${block.substring(2).split(',').join(' ')}">`);
@@ -25,10 +28,14 @@ renderer.paragraph = function(text){
}, []).join('\n'); }, []).join('\n');
return res; return res;
}; };
renderer.image = function(href, title, text){ renderer.image = function(href, title, text){
return `<img src="${href}" class="${text.split(',').join(' ')}"></img>`; return `<img src="${href}" class="${text.split(',').join(' ')}"></img>`;
}; };
renderer.list = function(list, isOrdered, isDef){
if(isDef) return `<ul class='alt'>${list}</ul>`;
if(isOrdered) return `<ol>${list}</ol>`;
return `<ul>${list}</ul>`;
}
module.exports = { module.exports = {
@@ -36,9 +43,12 @@ module.exports = {
render : (rawBrewText)=>{ render : (rawBrewText)=>{
blockCount = 0; blockCount = 0;
rawBrewText = rawBrewText.replace(/\\column/g, '{{columnSplit }}') rawBrewText = rawBrewText.replace(/\\column/g, '{{columnSplit }}');
let html = Markdown(rawBrewText,{renderer : renderer, sanitize: true});
let html = Markdown(rawBrewText, {renderer : renderer, sanitize: true});
//Close all hanging block tags //Close all hanging block tags
html += _.times(blockCount, ()=>{return '</div>'}).join('\n'); html += _.times(blockCount, ()=>{return '</div>'}).join('\n');
return html; return html;

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,7 @@
/////////////////// ///////////////////
.spell{ .spell{
ul:first-of-type{
margin-top : -0.5em;
margin-bottom : 0.5em;
list-style-type : none;
&+p{
text-indent : 0em;
}
}
} }
.monster{ .monster{
.breakAvoid(); .breakAvoid();
@@ -23,10 +15,6 @@
tbody tr { background-color: transparent }; tbody tr { background-color: transparent };
} }
ul:nth-of-type(1),ul:nth-of-type(2){ ul:nth-of-type(1),ul:nth-of-type(2){
list-style: none;
padding-left : 1em;
text-indent : -1em;
margin-bottom : 0.5em;
strong{ strong{
color : @crimson; color : @crimson;
} }
@@ -36,6 +24,7 @@
right : 7px; right : 7px;
bottom : 19px; bottom : 19px;
left : 7px; left : 7px;
//TODO: Swap out to variable color
background-color : #FDF1DC; background-color : #FDF1DC;
border-image-slice : 8; border-image-slice : 8;
border-image-source : @monsterBorder; border-image-source : @monsterBorder;
@@ -43,6 +32,7 @@
} }
&.wide{ &.wide{
column-count : 2; column-count : 2;
column-fill:auto;
} }
} }
.note{ .note{
@@ -104,7 +94,7 @@
z-index : 150; z-index : 150;
width : 200px; width : 200px;
font-size : 0.9em; font-size : 0.9em;
color : @gold; color : @brown;
text-align : right; text-align : right;
} }
//***************************** //*****************************
@@ -161,38 +151,44 @@
} }
.wide{ .wide{
column-span : all; column-span : all;
-webkit-column-span : all; }
-moz-column-span : all; .fullPage, .full{
column-span : all;
height: 100%;
} }
.oneColumn{ .oneColumn{
column-count : 1; column-count : 1;
column-fill:auto;
// column-gap : 1cm; // column-gap : 1cm;
} }
.twoColumn{ .twoColumn{
column-count : 2; column-count : 2;
column-fill:auto;
//column-fill: auto; //column-fill: auto;
////column-gap : 1cm; ////column-gap : 1cm;
} }
.threeColumn{ .threeColumn{
column-count : 3; column-count : 3;
column-fill:auto;
//column-gap : 1cm; //column-gap : 1cm;
} }
.fourColumn{ .fourColumn{
column-count : 4; column-count : 4;
//column-gap : 1cm; //column-gap : 1cm;
column-fill:auto;
} }
.columnSplit{ .columnSplit{
visibility : hidden; visibility : hidden;
-webkit-column-break-bfore : always; -webkit-column-break-bfore : always;
break-before : column; break-before : column;
} }
.brushed{ // .brushed{
border-image-outset : 25px 17px; // border-image-outset : 25px 17px;
border-image-repeat : round; // border-image-repeat : round;
border-image-slice : 1250 1250 1250 1250; // border-image-slice : 1250 1250 1250 1250;
border-image-width : 1250px; // border-image-width : 1250px;
border-image-source : url('http : //i.imgur.com/nzPYZyD.png'); // border-image-source : url('http://i.imgur.com/nzPYZyD.png');
} // }
//basics //basics
.left{ .left{
text-align : left; text-align : left;
@@ -209,3 +205,12 @@
.sansSerif{ .sansSerif{
.useSansSerif(); .useSansSerif();
} }
.dropcap{
p::first-letter{
float : left;
font-family : Solbera;
font-size : 10em;
color : #222;
line-height : 0.8em;
}
}

View File

@@ -1,5 +1,13 @@
//TODO: come up with fun color names //TODO: come up with fun color names
@crimson : #58180D;
@red : #9c2b1b;
@brown : #c9ad6a; //brown?
@green : #e0e5c1;
@yellow : #faf7ea; //same as background?
@teal : blue;
@blue : blue;
@background : #EEE5CE; @background : #EEE5CE;
@noteGreen : #e0e5c1; @noteGreen : #e0e5c1;
@headerUnderline : #c9ad6a; @headerUnderline : #c9ad6a;
@@ -20,13 +28,7 @@
} }
} }
@crimson : #58180D;
@red : #9c2b1b;
@gold : #c9ad6a; //brown?
@green : #e0e5c1;
@yellow : #faf7ea; //same as background?
@teal : blue;
@blue : blue;
//TODO make a color mixin generator //TODO make a color mixin generator
@@ -34,5 +36,6 @@
.blue{ .colorElements(@blue); } .blue{ .colorElements(@blue); }
.green{ .colorElements(@green); } .green{ .colorElements(@green); }
.yellow{ .colorElements(@yellow); } .yellow{ .colorElements(@yellow); }
.gold{ .colorElements(@gold); } .brown{ .colorElements(fade(@brown, 50%)); }
.red{ .colorElements(@red); } .red{ .colorElements(fade(@red, 25%)); }
.crimson{ .colorElements(fade(@crimson, 20%)); }

View File

@@ -1,15 +1,14 @@
pre{ pre{
font-family : monospace; padding : 12px;
background-color : @yellow; background-color : @yellow;
padding : 12px; font-family : monospace;
border: 1px solid #bfbfbf; color : #333;
white-space: pre-wrap; border : 1px solid #bfbfbf;
color : #333; white-space : pre-wrap;
-webkit-column-break-inside : avoid; -webkit-column-break-inside : avoid;
column-break-inside : avoid; column-break-inside : avoid;
} }
hr{ hr{
visibility : visible; visibility : visible;
height : 6px; height : 6px;
@@ -18,8 +17,6 @@ hr{
background-size : 100% 100%; background-size : 100% 100%;
border : none; border : none;
} }
p{ p{
padding-bottom : 0.8em; padding-bottom : 0.8em;
line-height : 1.3em; line-height : 1.3em;
@@ -27,35 +24,42 @@ p{
margin-top : -0.8em; margin-top : -0.8em;
} }
} }
blockquote{ blockquote{
font-style : italic; font-style : italic;
&>p{ &>p{
line-height: 1.8em; line-height : 1.8em;
//Why did I do this?
&:first-child::first-line{ &:first-child::first-line{
font-family : ScalySansSmallCaps;
//TODO: Find the right font for block quotes //TODO: Find the right font for block quotes
font-style: normal; font-style : normal;
font-family: ScalySansSmallCaps;
} }
} }
.cite{ .cite{
font-style: normal; font-style : normal;
text-align: right; text-align : right;
}
}
// IMAGE
img{
display : block;
z-index : -1;
mix-blend-mode : multiply;
&.center{
margin-right : auto;
margin-left : auto;
}
&.noBlend{
mix-blend-mode : normal;
}
&.bg, &.background{
position : absolute;
} }
} }
//Indents after p or lists //Indents after p or lists
p+p, ul+p, ol+p{ p+p, ul+p, ol+p{
text-indent : 1em; text-indent : 1em;
} }
img{
z-index : -1;
}
strong{ strong{
font-weight : bold; font-weight : bold;
letter-spacing : 0.03em; letter-spacing : 0.03em;
@@ -88,13 +92,6 @@ h1{
font-size : 0.987cm; font-size : 0.987cm;
-webkit-column-span : all; -webkit-column-span : all;
-moz-column-span : all; -moz-column-span : all;
&+p::first-letter{
float : left;
font-family : Solbera;
font-size : 10em;
color : #222;
line-height : 0.8em;
}
} }
h2{ h2{
font-size : 0.705cm; font-size : 0.705cm;
@@ -113,8 +110,6 @@ h5{
font-size : 0.423cm; font-size : 0.423cm;
font-weight : 900; font-weight : 900;
} }
//****************************** //******************************
// LISTS // LISTS
//****************************** //******************************
@@ -141,7 +136,19 @@ ol{
list-style-type : decimal; list-style-type : decimal;
} }
p+ul.alt{
margin-top : -0.5em;
}
ul.alt{
margin-bottom : 0.5em;
padding-left : 0em;
list-style-position : outside;
list-style-type : none;
list-style-type : none;
&+p{
text-indent : 0em;
}
}
//***************************** //*****************************
// * TABLE // * TABLE
// *****************************/ // *****************************/
@@ -150,6 +157,7 @@ table{
width : 100%; width : 100%;
margin-bottom : 1em; margin-bottom : 1em;
font-size : 10pt; font-size : 10pt;
break-inside : avoid-column;
thead{ thead{
font-weight : 800; font-weight : 800;
th{ th{

View File

@@ -57,7 +57,7 @@
background-size : cover; background-size : cover;
padding: 28px 63px; padding: 28px 63px;
box-sizing: border-box; box-sizing: border-box;
color : lighten(@gold, 0%); color : lighten(@brown, 0%);
font-size: 0.7em; font-size: 0.7em;
} }
&:nth-child(even){ &:nth-child(even){
@@ -81,7 +81,7 @@
bottom : 22px; bottom : 22px;
width : 50px; width : 50px;
font-size : 0.9em; font-size : 0.9em;
color : @gold; color : @brown;
text-align : center; text-align : center;
} }

View File

@@ -0,0 +1,74 @@
const _ = require('lodash');
const Data = require('./random.data.js');
const Snips = _.merge(
require('./spell.snippet.js'),
require('./table.snippet.js'),
require('./class.snippet.js'),
require('./note.snippet.js'),
require('./monster.snippet.js')
);
const BrewSnippets = {
brewModel : ()=>{
return {
title : Data.rand(Data.titles),
description : Data.rand(Data.subtitles),
text : BrewSnippets.brew(),
authors : _.sampleSize(['userA','userB','userC','userD'], _.random(0, 3)),
systems : _.sampleSize(['5e', '4e', '3.5e', 'Pathfinder'], _.random(0,2)),
views : _.random(0,1000),
published : !!_.random(0,1)
}
},
brew : ()=>{
return _.times(_.random(1,10), ()=>_.sample([
BrewSnippets.page1,
BrewSnippets.page2
])()).join('\n\n\\page\n\n');
},
page1 : ()=>{
return BrewSnippets.filler(_.random(10, 15), [Snips.monster, Snips.table]);
},
page2 : ()=>{
const title = '# ' + Data.rand('titles');
let table = Snips.noncasterTable();
if(Data.chance(3)){
table = Snips.casterTable();
if(Data.chance(2)) table = Snips.halfcasterTable();
return `${title}\n\n${table}\n\n${BrewSnippets.paragraph(true)}\n\n${BrewSnippets.filler(3)}`;
}
return `${title}\n\n${table}\n\n${BrewSnippets.paragraph(true)}\n\n${BrewSnippets.filler(5)}`;
},
filler : (count = 1, additional = [])=>{
const base = _.concat([
BrewSnippets.paragraph, BrewSnippets.paragraph, BrewSnippets.paragraph, BrewSnippets.paragraph,
BrewSnippets.paragraph, BrewSnippets.paragraph, BrewSnippets.paragraph, BrewSnippets.paragraph,
Snips.table,
Snips.note, Snips.note, Snips.altnote
], additional);
return _.times(count, ()=>{
let res = _.sample(base)();
if(Data.chance(8)) res = BrewSnippets.title() + '\n\n' + res;
return res;
}).join('\n\n');
},
paragraph : (dropcap = false)=>{
let res = Data.rand(Data.sentences, 6, 3).join(' ');
if(dropcap || Data.chance(20)) res = `{{dropcap\n${res}\n}}`;
return res;
},
title : ()=>{
return _.sample(['##', '###', '##', '###','####', '#####']) + ' ' + Data.rand('titles');
}
}
module.exports = BrewSnippets;

View File

@@ -11,6 +11,52 @@ const getFeature = (level)=>{
return res.join(', '); return res.join(', ');
}; };
const spellLevels = [
[2,'―','―','―','―','―','―','―','―'],
[3,'―','―','―','―','―','―','―','―'],
[4, 2 ,'―','―','―','―','―','―','―'],
[4, 3 ,'―','―','―','―','―','―','―'],
[4, 3 , 2 ,'―','―','―','―','―','―'],
[4, 3 , 3 ,'―','―','―','―','―','―'],
[4, 3 , 3 , 1 ,'―','―','―','―','―'],
[4, 3 , 3 , 2 ,'―','―','―','―','―'],
[4, 3 , 3 , 3 , 1 ,'―','―','―','―'],
[4, 3 , 3 , 3 , 2 ,'―','―','―','―'],
[4, 3 , 3 , 3 , 2 , 1 ,'―','―','―'],
[4, 3 , 3 , 3 , 2 , 1 ,'―','―','―'],
[4, 3 , 3 , 3 , 2 , 1 , 1 ,'―','―'],
[4, 3 , 3 , 3 , 2 , 1 , 1 ,'―','―'],
[4, 3 , 3 , 3 , 2 , 1 , 1 , 1 ,'―'],
[4, 3 , 3 , 3 , 2 , 1 , 1 , 1 ,'―'],
[4, 3 , 3 , 3 , 2 , 1 , 1 , 1 , 1 ],
[4, 3 , 3 , 3 , 3 , 1 , 1 , 1 , 1 ],
[4, 3 , 3 , 3 , 3 , 2 , 1 , 1 , 1 ],
[4, 3 , 3 , 3 , 3 , 2 , 2 , 1 , 1 ]
];
const halfspellLevels = [
['―','―','―','―','―'],
[ 2 ,'―','―','―','―'],
[ 3 ,'―','―','―','―'],
[ 3 ,'―','―','―','―'],
[ 4 , 2 ,'―','―','―'],
[ 4 , 2 ,'―','―','―'],
[ 4 , 3 ,'―','―','―'],
[ 4 , 3 ,'―','―','―'],
[ 4 , 3 , 2 ,'―','―'],
[ 4 , 3 , 2 ,'―','―'],
[ 4 , 3 , 3 ,'―','―'],
[ 4 , 3 , 3 ,'―','―'],
[ 4 , 3 , 3 , 1 ,'―'],
[ 4 , 3 , 3 , 1 ,'―'],
[ 4 , 3 , 3 , 2 ,'―'],
[ 4 , 3 , 3 , 2 ,'―'],
[ 4 , 3 , 3 , 3 , 1 ],
[ 4 , 3 , 3 , 3 , 1 ],
[ 4 , 3 , 3 , 3 , 2 ],
[ 4 , 3 , 3 , 3 , 2 ]
];
module.exports = { module.exports = {
@@ -23,13 +69,15 @@ module.exports = {
lvlText, lvlText,
'+'+Math.floor(level/4 + 2), '+'+Math.floor(level/4 + 2),
getFeature(level), getFeature(level),
'+'+featureScore '??'
].join(' | ') + ' |'; ].join(' | ') + ' | ' +
spellLevels[level].join(' | ')
+ ' |';
}).join('\n'); }).join('\n');
return `{{frame,wide return `{{frame,wide
##### ${Data.rand('classes')} ##### ${Data.rand('classes')}
| Level | Proficiency Bonus | Features | Cantrips Known | Spells Known | 1st | 2nd | 3rd | 4th | 5th | 6th | 7th | 8th | 9th | | Level | Proficiency Bonus | Features | Spells Known | 1st | 2nd | 3rd | 4th | 5th | 6th | 7th | 8th | 9th |
|:---:|:---:|:---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:| |:---:|:---:|:---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
${rows} ${rows}
}}`; }}`;
@@ -43,9 +91,10 @@ ${rows}
return '| ' + [ return '| ' + [
lvlText, lvlText,
'+'+Math.floor(level/4 + 2), '+'+Math.floor(level/4 + 2),
getFeature(level), getFeature(level)
'+'+featureScore ].join(' | ') + ' | ' +
].join(' | ') + ' |'; halfspellLevels[level].join(' | ')
+ ' |'
}).join('\n'); }).join('\n');

View File

@@ -8,7 +8,8 @@ module.exports = _.merge(
require('./monster.snippet.js'), require('./monster.snippet.js'),
require('./toc.snippet.js'), require('./toc.snippet.js'),
require('./random.brew.js') //require('./random.brew.js')
require('./brew.snippet.js')

View File

@@ -12,13 +12,10 @@ const getStats = function(){
const getAttributes = ()=>{ const getAttributes = ()=>{
return ` return `
- **Saving Throws** - **Saving Throws**
- **Condition Immunities** " + genList(["groggy", "swagged", "weak-kneed", "buzzed", "groovy", "melancholy", "drunk"], 3), - **Condition Immunities** ${Data.rand(["groggy", "swagged", "weak-kneed", "buzzed", "groovy", "melancholy", "drunk"], 3).join(', ')},
- **Senses** passive Perception " + _.random(3, 20), - **Senses** passive Perception " ${_.random(3, 20)},
- **Languages** ${Data.rand(["Common", "Pottymouth", "Gibberish", "Latin", "Jive"], 2).join(', ')} - **Languages** ${Data.rand(["Common", "Pottymouth", "Gibberish", "Latin", "Jive"], 2).join(', ')}
- **Challenge** ${_.random(0, 15)} (${_.random(10,10000)} XP) - **Challenge** ${_.random(0, 15)} (${_.random(10,10000)} XP)
`; `;
@@ -45,23 +42,16 @@ module.exports = {
*${Data.rand('sizes')}, ${Data.rand('alignments')}* *${Data.rand('sizes')}, ${Data.rand('alignments')}*
--- ---
- **Armor Class** ${_.random(10,20)} - **Armor Class** ${_.random(10,20)}
- **Hit Points** ${_.random(1, 150)} (1d4 + 5) - **Hit Points** ${_.random(1, 150)} (1d4 + 5)
- **Speed** ${ _.random(0,50)} ft - **Speed** ${ _.random(0,50)} ft
--- ---
|STR|DEX|CON|INT|WIS|CHA| |STR|DEX|CON|INT|WIS|CHA|
|:---:|:---:|:---:|:---:|:---:|:---:| |:---:|:---:|:---:|:---:|:---:|:---:|
${getStats()} ${getStats()}
--- ---
${getAttributes()} ${getAttributes()}
--- ---
Abilities Abilities

View File

@@ -4,7 +4,7 @@ const Data = require('./random.data.js');
module.exports = { module.exports = {
note : ()=>{ note : ()=>{
return `{{note return `{{note,red
##### ${Data.rand('abilities')} ##### ${Data.rand('abilities')}
${Data.rand('sentences', 6, 4).join(' ')} ${Data.rand('sentences', 6, 4).join(' ')}
}}` }}`

View File

@@ -5,7 +5,9 @@ const Data = {
const data = (Data[name] ? Data[name] : name); const data = (Data[name] ? Data[name] : name);
return _.sampleSize(data, _.random(min, max)); return _.sampleSize(data, _.random(min, max));
}, },
//Boolean of 1 in n chance
chance : (max = 20)=>_.random(1,max)== 1,
mix : (list, max = 1, min = 1)=>_.times(_.random(min, max), ()=>_.sample(list)),
titles : [ titles : [
`The Burning Gallows`, `The Burning Gallows`,
`The Ring of Nenlast`, `The Ring of Nenlast`,

View File

@@ -26,7 +26,7 @@ module.exports = {
const description = Data.rand('effects', 2).concat(Data.rand('effects2')).join(' '); const description = Data.rand('effects', 2).concat(Data.rand('effects2')).join(' ');
return `{{spell return `
#### ${_.sample(Data.spellNames)} #### ${_.sample(Data.spellNames)}
*${_.sample(levels)}-level ${_.sample(schools)}* *${_.sample(levels)}-level ${_.sample(schools)}*
- **Casting Time:** ${_.sample(['1 action', 'Reaction', '10 minutes', '1 hour'])} - **Casting Time:** ${_.sample(['1 action', 'Reaction', '10 minutes', '1 hour'])}
@@ -34,8 +34,18 @@ module.exports = {
- **Components:** ${components} - **Components:** ${components}
- **Duration:** ${duration} - **Duration:** ${duration}
${description} ${description}`;
}}`;
},
spellList : ()=>{
const levels = ['Cantrips (0 Level)', '2nd Level', '3rd Level', '4th Level', '5th Level', '6th Level', '7th Level', '8th Level', '9th Level'];
const content = _.map(levels, (level)=>{
const spells = _.map(Data.rand('spellNames', 15, 5), (spell)=>`- ${spell}`).join('\n');
return `##### ${level} \n${spells} \n`;
}).join('\n');
return `{{fourColumn,fullPage,sansSerif\n${content}\n}}`;
} }
} }

View File

@@ -43,15 +43,26 @@ const columns = {
module.exports = { module.exports = {
table : () => { table : () => {
let title = '';
if(Data.chance(5)) title = `##### ${Data.rand(Data.abilities)}\n`;
const rows = _.sample([4,6,8,10]); const rows = _.sample([4,6,8,10]);
const cols = [ let fns = [];
columns.roll(rows), if(Data.chance(3)) fns.push(columns.roll);
columns.level(rows),
columns.gear(rows)
];
return _.times(rows + 2, (i)=>{ fns = _.concat(fns, Data.rand([
columns.level,
columns.spell,
columns.cost,
columns.gear
], 3, 2 - fns.length))
const cols = _.map(fns, (fn)=>fn(rows));
return title + _.times(rows + 2, (i)=>{
if(i==1){ if(i==1){
return '|' + _.map(cols, (col)=>col[i]).join('|') + '|'; return '|' + _.map(cols, (col)=>col[i]).join('|') + '|';
}else{ }else{