Project 1 - Lore Generators
Published on: May 03, 2021Filed under: Technology
As I previously noted, I’m looking to both grow my developer skillset and create a slew of little products that I would hopefully use. This weekend I started working on the first of those - a Lore generator - a simple system for creating names, places, and even characters.
This is actually a bit of a throwback for me, as one of the first programs I built with Python was a D&D character creator that went beyond mere stats, and included things like names, personal goals, and biases.
As the idea was inspired by a friend’s post on Twitter, I started using the various names for Wheel of Time’s dark god as the seed. My first step was to take all of those names and break them down into groups. What I came away with was Titles (names consisting of more than 1 word, starting with some sort of honorific) and Nicknames (compound words typically consisting of a Good Noun followed by a bad verb).
Once I had an idea of what I was constructing, I was able to create a working prototype in Python in roughly 5 minutes. It was a basic thing, values stored in Lists, picked at random, and concatenated together based on whether I was generating a Title or a Nickname.
Turning that into something I could a working Django page took quite a bit longer than I anticipated. For one, when things got tough, I would often drift into messing with the layout - as that was an easier muscle to stretch than growing my dev skills. Eventually, I did come around, starting with the most basic model possible - a single CharField - and then growing that into three fields:
- name_piece - the actual string
- position - the order the string will arrange in the concatenated string
- name_type - whether the concatenated string will be a Nickname or Title
The biggest piece of learning, aside from getting more comfortable in Bootstrap, was building the logic for how to query the pieces, concatenate them, and then finally send them into the template as an object.
There’s a fair amount of “Add Small Details” around this in a lot of the research I did, and if you’re wondering where to perform query logic in a Django app, I did it in the View.
It was a productive weekend, and as usually seems to be the case with these things, learning one thing showed me that I don’t know how to do at least one other - in this instance, how to best store and then reference images within a model, and how to upload model data via a CSV.
The next few steps on this project are to add few more generators - I’m thinking a Kind and Light God to balance out the evil one, and then a bigger and more sophisticated NPC generator. Maybe a tavern name generator and a mysterious location generator.
After that, there’s a bunch of front-end polish. Maybe I can get this one deployed next weekend.