Functions & Dragons – Part 6

Refactor time! I did a huge refactor to cut down on the repetitive nature of the code surrounding Save and Skill Proficiencies. This was immensely satisfying and is probably my favorite thing about Elm. I can refactor with confidence even without a single unit test!

All in all I shrank the codebase by 449 lines, or nearly 37%! And while this did cost me a tiny bit of type goodness (the new code uses Dict which introduces Maybe into the equation) the increased conciseness and flexibility (custom skills, anyone?) is a fair trade in my book.

The new module structure with wrapped messages is also a big win. Check out my new update function:

I also started in on the Basic Info module, but didn’t get very far. That’ll be tomorrow’s project. Stay tuned!

Functions & Dragons – Part 5

Today I added the Other Proficiencies & Languages panel.

I started by taking the same approach of enumerating all the languages and providing a drop-down list, but the user experience was kind of sucky. I eventually decided to simply use a text box and allow any string, which cut way down on code repetition.

I think I’m going to propagate this String based approach to cover Skills and possibly even Abilities as well, not so much for flexibility as to simply cut down on code repetition.

Also, the Languages and Proficiencies sections are basically copy-pasted at this point. I should refactor that.

Anyway, with that, the first column is done! Next time, assuming I don’t get entirely lost in refactor land, I’ll implement the basic character info panel.

Functions & Dragons – Part 4

Quite a lot of visual progress today! I added the Skills and Passive Perception modules. Here’s a side-by-side comparison with a reference character sheet and more repetitive type code:

Honestly the repetition is somewhat bothersome. I had to write the entire list of 18 skills a total of 8 times. That’s 144 lines of mindless copy-paste. It feels wrong, but I can’t seem to come up with a way of doing it better without losing the nice guarantees this system gives me.

Ah well. It’s not a huge problem, but it’s going to nag at me, I’m sure. For now, the first column of the character sheet is mostly complete! Next time I’ll finish it up with the Languages and Other Proficiencies box.

Functions & Dragons – Part 3

Much better progress today compared to yesterday. Fixed the proficiency bonus display (wasn’t actually tied to the model value) and successfully modularized the ability scores type and its related functions. As part of this, I reorganized the code and split it up.

I also realized the abilities record type could easily be genericized to support e.g. Bool for saving throw proficiencies. This feels like a huge design win. It’s just so clean. Although I can’t for the life of me figure out what to do about the repetition here:

update : Abilities a -> Ability -> a -> Abilities a
update abilities ability val =
    case ability of
        Strength ->
          { abilities | str = val }

        Dexterity ->
          { abilities | dex = val }

        Constitution ->
          { abilities | con = val }

        Intelligence ->
          { abilities | int = val }

        Wisdom ->
          { abilities | wis = val }

        Charisma ->
          { abilities | cha = val }

I guess I could redefine Abilities a as List (Ability, a) and have value return Maybe a? I’ll give that a try tomorrow and see how it goes.

Oh, I also implemented the saving throws box, complete with proficiency bonus check boxes and modifier calculation.

Which reminds me. I think it would be a good idea to introduce a viewModel : Model -> ViewModel function and type that computes derived values like saving throw bonuses all in one convenient place.

Functions & Dragons – Part 1

I’ve started working on a D&D app in Elm. I’m starting from the character sheet and plan to grow the project outward over time. Today I built the ability scores block.

Currently you can enter values for each ability score and the modifier will be computed automatically. Scores below 0 or above 24 are rejected.

The code is up on GitHub. Enjoy!

Hex Map

I spent about an hour in Hexographer yesterday tracing over the world map of Delgar and came up with this:

 

 

This exercise reveals some interesting things about the world, which I hadn’t really considered. Specifically, how big is it?

Now obviously, this isn’t the map of an entire world at this point, as much as I tend to think of it as one, because this is the only part of Delgar that has been developed. It’s really a map of one continent about 1400 miles across, roughly the size of Western Europe, based on the “24 miles per hex” rule of thumb I’ve adopted from Matthew Colville.

That makes sense to me. It seems to be about the right scale. It means walking from one end of the continent to the other would take about two months. Enough space for some grand adventure, but not so much space that it would take ages to fill in.

The World Called Delgar

“Plant a thousand seeds in rocky soil, and none will sprout. Yet a single seed tended properly may, in time, feed thousands.”

Dol proverb

I feel I have written this beginning many times. Perhaps I have. My musings lie scattered to the four winds, some collecting in the dark corners of /r/worldbuilding and /r/magicbuilding, others banished to various note-taking apps, poorly maintained wikis, and random scraps of long-discarded paper. I think I even had a Tumblr at one point. Truly, my organizational skills know no bounds. No lower bounds, at any rate.

This is my attempt to collect my thoughts on the world called Delgar. On its people, places, and things. Its history, its customs, and its cultures.

Starting today, for no particular reason beyond there being no time like the present, I am committing to write at least one post about something in this world every week for the next year.

Today’s post is about the world itself, in broad strokes. Enjoy.


The world called Delgar is a place much like any other, save for its inexplicable penchant for the impossible.

It is home to several intelligent Races, sometimes divided among and sometimes united by a multitude of Cultures, which form fuzzy, ever-shifting intersections with the various Nations that vie for power throughout the world.

Delgar is also a world of Magic, expressed via mysterious Runes and powered by the Aether that flows from place to place, shaping the very lands it passes through.

It has two Moons: Sono and Zimaz, which orbit one another as they revolve around the planet, caught in a celestial dance. These moons as well as the Constellations that decorate the night sky play central roles in many of Delgar’s Religions, not to mention its Calendars.

It is a world with a grand History, with its attendant Heroes and Villains and their many Conflicts.

But most of all, Delgar is a world of Stories.