First Flatiron Project, a D&D Character Creator

For this project, I decided to make a D&D character creator. I got a bit excited and wanted to include a lot of extra features that weren’t necessary for the assignment which I end up cutting. The final product satisfies the requirements for the project, but I’m not entirely happy with it, as it’s missing a few features yet.

Design

The project is split into two parts, the CLI and the object representations of each of the major components of a D&D character. The CLI is split into three classes, one to handle user input and output, one to handle getting information about the classes, and one for getting information about the races. I’m using this D&D 5e SRD API to populate the class, race, and character information.

I tried to map character attribute concepts to ruby objects. I thought this was a logical approach, since I can then make certain things more flexible with inheritance. An example is a freature, which is inherited from by several other feature classes like RaceFeature:

class CharacterSheetGenerator::RaceFeature < CharacterSheetGenerator::Feature
    def initialize(_name, _description)
        super(_name, _description)
        @source = "Race"
    end
end

The source of the feature is set within each child, and the rest of the parameters are sent to the parent class. I didn’t end up implementing this feature yet, but I think it’s a decent way to think about it.

The source code can be found on GitHub.

Posted on Feb. 16, 2020, 11:23 a.m.

Tagged with: Education Ruby D&D