-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve formatting and styling and output to HTML.
- Loading branch information
Showing
11 changed files
with
165 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
dist | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
module.exports = function (character) { | ||
let output = ''; | ||
|
||
output += '\n<h3>Overview</h3>\n\n'; | ||
|
||
output += `<p>You are a ${character.age} year old ${character.alignment.toLowerCase()} ${character.race.name.toLowerCase()} ${character.background.name.toLowerCase()} adventuring as a ${character.class.name.toLowerCase()}.</p>\n`; | ||
|
||
output += '<p>'; | ||
if (character.backgroundReason) { | ||
output += `You became a ${character.background.name.toLowerCase()} because ${character.backgroundReason}<br>\n`; | ||
} | ||
output += `You became a ${character.class.name.toLowerCase()} because ${character.classReason}`; | ||
output += '</p>\n\n'; | ||
|
||
if (character.raceOther.length > 0) { | ||
output += `<h3>Racial (${character.race.name})</h3>\n\n`; | ||
output += '<p>' + character.raceOther.map(o => `<strong>${o.name}:</strong> ${o.value}`).join('<br>\n') + '</p>\n\n'; | ||
} | ||
|
||
output += `<h3>Background (${character.background.name})</h3>\n\n`; | ||
output += '<p>'; | ||
output += `<strong>Trait:</strong> ${character.backgroundTrait}<br>\n`; | ||
output += `<strong>Ideal:</strong> ${character.backgroundIdeal}<br>\n`; | ||
output += `<strong>Bond:</strong> ${character.backgroundBond}<br>\n`; | ||
output += `<strong>Flaw:</strong> ${character.backgroundFlaw}<br>\n`; | ||
output += character.backgroundOther.map(o => `<strong>${o.name}:</strong> ${o.value}`).join('<br>\n') + '</p>\n\n'; | ||
output += '</p>\n\n'; | ||
|
||
if (character.classOther.length > 0) { | ||
output += `<h3>Class (${character.class.name})</h3>\n\n`; | ||
output += '<p>' + character.classOther.map(o => `<strong>${o.name}:</strong> ${o.value}`).join('<br>\n') + '</p>\n\n'; | ||
} | ||
|
||
output += '<h3>Family</h3>\n\n'; | ||
|
||
const { mother, father } = character.parents; | ||
if (!character.knewParents) { | ||
output += '<p>You don\'t know who your parents are.</p>'; | ||
} else { | ||
if (mother.race === father.race) { | ||
output += `<p>Your mother and father are both ${mother.race.toLowerCase()}s. Your mother ${mother.occupation}, while your father ${father.occupation}.<p>`; | ||
} else { | ||
output += `<p>Your mother is ${mother.race.toLowerCase()} and ${mother.occupation}, but your father is ${father.race.toLowerCase()} and ${father.occupation}.</p>`; | ||
} | ||
} | ||
|
||
const sibCount = character.siblings.length; | ||
if (sibCount === 0) { | ||
output += '<p>You were an only child.</p>\n'; | ||
} else if (character.knewParents) { | ||
output += `<p>You had ${sibCount} sibling${sibCount === 1 ? '' : 's'}.</p>\n`; | ||
output += '<ul>'; | ||
character.siblings.forEach(s => { | ||
output += `<li>a ${s.relativeAge} ${s.relationship} who ${s.occupation}. They are ${s.status} ${s.attitude}</li>\n` | ||
}) | ||
output += '</ul>'; | ||
} else { | ||
output += '<p>You don\'t know if you have any siblings.</p>\n'; | ||
} | ||
|
||
output += '<h3>Upbringing</h3>\n\n'; | ||
|
||
output += `<p>You were born ${character.birthplace}.</p>\n`; | ||
output += `<p>You were raised by ${character.raisedBy.name} and had a ${character.lifestyle.name.toLowerCase()} lifestyle, living ${character.home}.</p>\n`; | ||
|
||
if (mother.absent) { output += `<p>Your mother ${mother.absent}</p>\n`; } | ||
if (father.absent) { output += `<p>Your father ${father.absent}</p>\n`; } | ||
|
||
output += `<h3>Life Events (${character.events.length})</h3>\n\n<ul>`; | ||
character.events.forEach(e => { | ||
output += `<li>${e}</li>\n`; | ||
}); | ||
output += '</ul>\n\n'; | ||
|
||
output += '<h3>Trinket</h3>\n\n'; | ||
output += `<p>Currently in your possession you have ${character.trinket}</p>` | ||
|
||
return output; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,55 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>This Is Your Life</title> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
</head> | ||
<body> | ||
<h1>This Is Your Life</h1> | ||
<div id="character"></div> | ||
</body> | ||
|
||
<head> | ||
<title>This Is Your Life</title> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"> | ||
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"> | ||
</head> | ||
|
||
<body> | ||
<nav class="navbar navbar-dark fixed-top bg-dark"> | ||
<a class="navbar-brand" href="#">This Is Your Life</a> | ||
</nav> | ||
|
||
<main role="main"> | ||
<div class="jumbotron"> | ||
<div class="container"> | ||
<h1>This Is Your Life!</h1> | ||
<p> | ||
This is a simple generator that automates the process of rolling on all the character generation tables that can be found | ||
in the Dungeons & Dragons 5th Edition Player Handbook, Volo's Guide to Monsters, and Xanathar's Guide to Everything. | ||
Click the button below to create a character!</p> | ||
<a id="generate" href="#" class="btn btn-primary" role="button">Roll again! | ||
<i class="fa fa-chevron-right"></i> | ||
</a> | ||
</div> | ||
</div> | ||
<div class="container"> | ||
<div id="character"></div> | ||
<hr> | ||
</div> | ||
</main> | ||
|
||
<footer class="footer"> | ||
<div class="container bt-light mt-4 pt-4 pb-4"> | ||
<div class="text-right"> | ||
<small> | ||
<div>Created by Thomas R. Wolfe</div> | ||
<div>All content owned by | ||
<a href="https://www.wizards.com" target="_blank">Wizards of the Coast</a> | ||
</div> | ||
<div> | ||
<a href="https://github.com/trwolfe13/this-is-your-life/" target="_blank"> | ||
<i class="fa fa-github"></i> View on Github</a> | ||
</div> | ||
</small> | ||
</div> | ||
</div> | ||
</footer> | ||
|
||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
const Generator = require('./generator'); | ||
const Formatter = require('./formatter'); | ||
|
||
console.log(Generator()); | ||
function generateCharacter() { | ||
const character = Generator(); | ||
document.getElementById('character').innerHTML = Formatter(character); | ||
} | ||
|
||
document.getElementById('generate').addEventListener('click', generateCharacter); | ||
generateCharacter(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.jumbotron h1 { | ||
font-size: 3rem; | ||
font-weight: 300; | ||
line-height: 1.2; | ||
} | ||
|
||
h3 { | ||
font-size: 1.25rem; | ||
font-weight: 400; | ||
border-bottom: 1px solid #343a40; | ||
padding-bottom: 8px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters