The birth of a side project

The first side project I'm going to talk about is writing a chrome extension. This extension enhances a third party web application so that it works a little bit better for my particular use case.

In this blog post I'm going to provide the historical background on what I'm trying to do and why. You can think of it as an extended look at the requirements for this project. I'm going to cover the technical details of actually implementing it in my next post.

So this all started a few weeks ago when I got a chance to start participating in an online role-playing game. For this particular game, we are using Roll20 - a web application that acts as our virtual table top (VTT). Roll20 has a lot of features, but the focus here is on Roll20's dice rolling capabilities.

If you've ever played an RPG (like Dungeons & Dragons), you probably rolled dice. RPGs often use dice as a source of randomness - it would eventually be pretty boring if you just succeeded (or failed) at everything you tried, so you often end up rolling dice to figure out what happens. The details of how each RPG does this, however, vary tremendously. So Roll20 has a flexible system where you can basically type out what dice you're rolling. So you could type in something like this in chat:

/roll d4 + d6 + d8 + d10 + d12

And it would roll 1 4-sided die (d4), one standard six-sided die (d6), ... and so on. It then displays the results of the roll, and adds all the die results up and gives you the total - since that is what you do in a lot of RPGs. Here is what this can look like in the UI:

roll20-default-roll-snapshot.png

Unfortunately, this display is less than ideal for me. For one thing, my game isn't one where you total all the dice up. In particular, we're playing the Marvel Heroic Roleplaying (MHR) game that was published by Margaret Weis Productions a few years back (but not any longer, sadly). The game uses the Cortex Plus system, which has its own unique mechanics for dice rolls. I'll also note that Cortex Plus has been superseded by Cortex Prime . Since that is the system I'm most focused on these days, you'll almost certainly hear more about it from me.

But all I need to note here is that in MHR what we generally do is pick the two highest rolling dice and add their results together for the total. We then pick a third die - and the more sides this die has the better. Lastly, we want to make special note of any die that rolled a one - ones mean (in game terms) trouble for the character of the person that rolled them.

That sounds simple, but I find this kind of thing annoying to do in my head - and I don't find the roll20 display all that easy to interpret. The type of each die in particular is hard for me to see.

While we were playing our first game, I found this both annoying and distracting. And then out of the blue it hit me - I could probably write a chrome extension (chrome is my default browser) to fix this.

Now I've never written a browser extension, but I've certainly used them, and given my interest in RPGs, I knew that people had written extensions to enhance VTTs - roll20 included. So it probably isn't that surprising that this popped into my head. Unfortunately, I really didn't have a clue what it would take to write one.

But I also realized I had an asset that I could use. You see, last year I learned that my favorite RPG convention would be virtual - and they announced this some months in advance indicating that discord would be a tool they would support.

I decided to see if I could write a discord bot for Cortex Prime for a particular game I wanted to run. I thought this would be a good learning project and I had a few unique requirements. I mention this because there is already a great Cortex Prime discord bot, CortexPal that people interested in playing Cortex Prime on Discord should be looking at.

Unfortunately, things got hectic, and I ended up dropping the idea of running a game and the discord bot itself. But I had gotten far enough along that I was displaying dice in a more Cortex Prime friendly manner. Here's a pic:

discordbot-dice-results.png

I should say that this image is just following the conventions used in the Cortex Prime Handbook for how to draw the dice results. But the important point here is that a lot of the code the extension would need (picking the total dice and the effect die, drawing the dice) had already been written. Better still, the code was written in Javascript (I was using discord.js) so I could just use it directly.

So - my initial vision for my extension was that it would somehow "notice" when I rolled some dice, and would look at the output in Roll20 to determine what the result of that roll was. If I could determine that, then I could call my existing code and it would determine the "best" choices for the two total die and the extension die. And lastly I would find a way to "draw" the die in this more Cortex Prime friendly manner into the Roll20 UI. And I could even get it put together before my game the following week - I hoped.

Next post I'll start going over how I implemented the extension - what worked like I hoped - and what didn't.