DEV Community

Ephriam Henderson
Ephriam Henderson

Posted on

Day 5 [D&D Character Sheets]

Thanks

Thanks to everyone who comments, reacts or does anything that lets me know you're out there! Knowing people are watching even a little bit keeps me honest and is motivation to keep going!

Report

Today I created a simple test view for my character sheet. First I had to write the initial schema for the character classes and races, then I created a test character to display.

// router/characters/index.js
router.get("/create-test", async (req, res) => {
    let race = await req.context.models.Race.create({
        name: "Test",
        stats: {
            abilityMods: {
                strength: 0,
                dexterity: 1,
                constitution: 0,
                intelligence: 1,
                wisdom: 0,
                charisma: 0
            },
            speed: 30,
            size: "medium"
        }
    });

    let player = await req.context.models.Player.findOne({
        email: "test@ephriamhenderson.dev"
    });

    let charClass = await req.context.models.Class.create({
        name: "test",
        stats: {
            abilityMods: {
                strength: 2,
                dexterity: 0,
                constitution: 0,
                intelligence: 0,
                wisdom: 0,
                charisma: 0
            }
        }
    });

    let character = await req.context.models.Character.create({
        shortName: "Zii",
        longName: "Zii",
        race: race.id,
        class: charClass.id,
        player: player.id,
        Description: "Zii",
        urlSlug: "",
        stats: {
            abilities: {
                strength: 8,
                dexterity: 8,
                constitution: 8,
                intelligence: 8,
                wisdom: 8,
                charisma: 8
            },
            speed: 30,
            proficiencyBonus: 2
        }
    });
});

Next I wrote a very basic view showing the name and ability scores of a character.

// router/characters/index.js
router.get("/:id", async (req, res) => {
    console.log(req.params.id);
    req.context.models.Character.findOne({ _id: req.params.id }).then(
        async result => {
            if (result == null) res.redirect("/404");
            console.log(result);
            res.render("characterSheet", {
                data: {
                    character: result,
                    player: await req.context.models.Player.findOne({
                        _id: result.player
                    })
                }
            });
        }
    );
});
// views/characterSheet.ejs
<h1><%= data.character.longName %></h1>
<h2><%= data.player.username %></h2>

<h3>Strength</h3>
<p><%= data.character.stats.abilities.strength %></p>
<h3>Dexterity</h3>
<p><%= data.character.stats.abilities.dexterity %></p>
<h3>Consitution</h3>
<p><%= data.character.stats.abilities.constitution %></p>
<h3>Intelligence</h3>
<p><%= data.character.stats.abilities.intelligence %></p>
<h3>Wisdom</h3>
<p><%= data.character.stats.abilities.wisdom %></p>
<h3>Charisma</h3>
<p><%= data.character.stats.abilities.charisma %><

It feels great to to finally see some data populate to the screen, even on this simple view!

Project

[100days] The DND Character Sheet App

This is the first project of my 100 days of coding This is an app to keep D&D character sheets.

Stack

I'll be using Node.js and building a full-stack Express app with MongoDB.

Requirements

Minimum Viable

  • Present a D&D Character Sheet
    • The sheet should display all the same info as the first page of the 5e Official sheet.
  • Users should be able to log in and create player-characters.
  • Users should be able to edit character sheets.
  • Users should be able to organize character sheets into groups (parties/tables)
  • Sheets should auto calculate basic stats like ability modifiers
    • Support Proficiency Bonuses

Cake

  • Extend character creation to allow the user to use any of the three common stat gen methods
    • Point Buy
    • Standard Array
    • Roll
  • Extend the character sheet to all the info in the 5e official sheet.
  • Allow for image uploads for character portraits.
  • Allow for…

The First project will be an app to keep D&D character sheets.

Stack

I'll be using Node.js and building a full-stack Express app with MongoDB.

Requirements

Minimum Viable

  • [ ] Present a D&D Character Sheet
    • [ ] The sheet should display all the same info as the first page of the 5e Official sheet.
  • [ ] Users should be able to log in and create player-characters.
  • [ ] Users should be able to edit character sheets.
  • [ ] Users should be able to organize character sheets into groups (parties/tables)
  • [ ] Sheets should auto calculate basic stats like ability modifiers.
    • [ ] Support Proficiency Bonuses

Cake

  • [ ] Extend character creation to allow the user to use any of the three common stat gen methods.
    • [ ] Point Buy
    • [ ] Standard Array
    • [ ] Roll
  • [ ] Extend the character sheet to all the info in the 5e official sheet.
  • [ ] Allow for image uploads for character portraits.
  • [ ] Allow for extended descriptions/backstories.
    • [ ] Characters should have nice full page backstories.
    • [ ] Preferably use a markdown editor.

Top comments (0)