Skip to content

Commit

Permalink
Add the ability to set the character's age. (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-wolfe authored Apr 19, 2018
1 parent 31bdda7 commit 1d52989
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "this-is-your-life",
"version": "1.3.0",
"version": "1.4.0",
"description": "Generate character backstories based on the Xanathar's Guide to Everything 'This Is Your Life' tables.",
"main": "./src/index.js",
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion src/generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ function alignment(character) {
}

function age(character) {
character.age = Number(character.age) || Life.age();
if (!character.age) {
character.age = Number(character.age) || Life.age();
}
}

function background(character) {
Expand Down
4 changes: 4 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ <h1>This Is Your Life!</h1>
<option value="" selected>Any</option>
</select>
</div>
<div class="form-group">
<label for="age">Age</label>
<input class="form-control" id="age" type="number">
</div>
</div>
</div>
<div class="row">
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ function generateCharacter(e) {
subrace: selectedValue('subrace'),
class: selectedValue('class'),
background: selectedValue('background'),
alignment: selectedValue('alignment')
alignment: selectedValue('alignment'),
age: document.getElementById('age').value
}
const character = Generator(config);
document.getElementById('character').innerHTML = Formatter(character);
Expand Down

0 comments on commit 1d52989

Please sign in to comment.