|    .  ___  __   __   ___ .  __      __   __        __   __   __      
|    | |__  |__) |__) |__  ' /__`    /__` /  \  /\  |__) |__) /  \ \_/ 
|___ | |___ |  \ |  \ |___   .__/    .__/ \__/ /~~\ |    |__) \__/ / \ 
⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∽⋅∼⋅∽⋅∽⋅∽⋅∽⋅

home

Cairn Realmify log 5

previously (gemlink)
previously (http link)

Abstract

I want to automate the Cairn second edition map creation guide[0] to produce pure text maps, to integrate with my table top role playing game (TTRPG) preparation notes easily.

I've decided to write a python package that automate the procedure I've been exploring in previous logs[1] and I'm documenting the progress, one log at the time.

Log

Been a while, but I really want to finish this one way or the other. Last time we had the coloration of the map. I would like to do the associated legend now. Actually, I had forgotten to push the last commit to the remote, which meant I had to redo the little thing we did last time as I did this from another setup. A bit awkward but alright. Live and learn.

I'll handle this as a simple string addition. And maybe play with some decorations. Adding the legend itself is no big deal. Just parsing the territory once more and formatting its content and appending them to the render. Done, commited and pushed.

Let's decorate. For that I have to make sure the logic is line length based and that we have a prefix/suffix system.

Let's maybe start with that, with empty suffixes and verify that the test still stands. Then add the border decorations.

Doing so, I notice that my test should be more informative, therefore I improved the comparison check. I now do line by line then a full one, to catch newline errors as the line by line one is blind to "\n" due to the split used.

Great, things are green again. Let's tackle those border decorations. Logic should be pretty simple.

Now that I have lines, I can get their max length and do what is needed. Let's write some test first though to guide us.

One thing that becomes obvious is that the legend is more difficult to encase in borders than the map itself as we do not control the width there, it depends on the legend content. I can't just add characters, I need to know the length of the longest entry first.

The territory holds the config, which holds the legend. We can have a method on the territory looping over the config and telling us just that. Done.

Alright. Now we can produce the border decoration method. As always, we first need the test. Let's therefore do a mockup by generating the test map, then decorate it with a border manually. We'll then be able to test it as expected output.

┌────────────────────┐
│aaaaaaabbbbbbbbbbbbb│  
│aaaaaaabbbbbbbbbbbbb│   
│aaaaaaabbbbbbbbbbbbb│   
│aaaaaaabbbbbbBbbbbbb│   
│aAaaaaaabbbbbbbbbbbb│   
│aaaaaaaabbbbbbbbbbbb│   
│aaaaaaaacccccccccccc│   
│aaaaaaaccccccccccccc│   
│aaaaaaaccccccCcccccc│   
│aaaaaaaccccccccccccc│   
│aaaaaacccccccccccccc│   
└────────────────────┘
┌───────────────────┐
│A: Silver_Face     │
│B: Broken_Sundial  │
│C: Great_Waterwheel│
└───────────────────┘

Great. Test written, method parameter mocked, test red let's actually implement it now.

Ah. Made a fault in the get length test, of all things. I need to do the rendered version, not the dict version. Had also an annoying newline error, so I added a newline counter to the method I use to compare expected realm versus produced realm.

Hmm. And now comes yet another error. How I wish I had a git diff of the string error instead. Leaned about the built-in difflib. Made the diff print out. And what a surprise,

Made an error in the many aaa and bbb in the expected value... Fixed and pushed.

Great, now we have basic map generation with legend addition plus border decorations. It's not as nice as the nice layout we made by hand but it's a serviceable start.

Next time, I would like to write a random territory generator. Let's see how it goes.

References

[0] The Setting Seed/Ream creation procedure
[1] the previous dev blog.
[2] the repository in which I publicly store the code

⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∼⋅∽⋅∽⋅∼⋅∽⋅∽⋅

home
posts
about