My mother likes playing scrabble – she usually forces my teenaged nephew to play during family visits (which he reluctantly enjoys). So I wanted to find a way to play scrabble with her while we’re in lockdown, and we can’t visit her in person anymore.

My first thought was to search the Apple app. store for a multiplayer scrabble game she could play on her iPad. I would have been happy to pay for something that just acts as a smart board – keeping track of letters and adding up scores. But, there doesn’t seem to be any official scrabble app. for IOS – presumably Mattel are being colossal dicks vigorously defending their intellectual property and utterly clueless about have yet to decide their mobile strategy.

The two multiplayer candidates I could find are “Scrabble Go,” and “Words With Friends 2” by Zynga. Both of these are multiplayer scrabble clones, but they both have very visually noisy interfaces, with horribly intrusive and annoying popups clamouring for you to upgrade/challenge friends/click on this prize you just earned…you get the idea.

Scrabble Go app. store image
Words With Friends 2 app. store image

I found both of them incredibly annoying when I tried them out, and I can guarantee my mother would find them confusing, frustrating and completely unusable. There’s also the problem of unwanted chat from strangers – everything from dick pics to 419 scammers. The user reviews on the app. store make for quite depressing reading.

As a software developer, my next thought was naturally to write my own. After all, how hard can it be? A bit of websockets, some nice HTML5 drag and drop, maybe a bit of React. Ooh, how about building the whole thing in Elixir Phoenix with LiveView!?

But, as a technical architect, I then started to think about how long it would take me to get to an MVP, and is that really how I want to spend my time? The objective is to let my mum play scrabble with her family and friends, not start yet another software project that I’ll probably never finish.

Next step, search GitHub for scrabble projects. As I’m fond of saying to my team; My second favourite kind of work is work that someone else has already done (my favourite being work that doesn’t need to be done at all – you’d be surprised how much work falls into that category).

There were a few projects that looked interesting, but the best I found was this one;

Screenshot of hanshuebner/html-scrabble

It’s very simple to install and run, and it wouldn’t take long to set up a cheap virtual machine (VM) on a hosting service and host multiplayer games.

What I really want though is something that can easily be spun up on Heroku. My team and I spend enough time managing infrastructure at work. I don’t really want to be doing that in my free time as well.

There’s a small problem though – the app. uses the “node-dirty” library to use a local file as a quick and dirty (hence the name) datastore. That works fine on my laptop, and it would work equally well on a hosted VM, but it won’t work on Heroku.

Heroku applications run on ‘dynos’ which are ephemeral. Every time your dyno goes to sleep and wakes up again, you get a fresh dyno with its own filesystem, so storing the game data that way won’t work. Any changes to the file which holds your games data will just disappear when the dyno goes to sleep.

Heroku offers several persistent data storage options, of which Redis is the easiest for this kind of application. Unfortunately, Redis isn’t a drop-in replacement for node-dirty because you can only communicate with the redis server asynchronously, whereas the app. as written uses synchronous filesystem calls to save and retrieve data. So there was a bit of work to do to get the app. into the state I wanted it.

I forked someone else’s fork of the original project because they’d already tweaked it to make it easier to deploy to Heroku (I’m really not kidding about preferring work that other people have done). Then I made some changes to replace node-dirty with Redis.

Although async redis calls aren’t a drop-in replacement for synchronous filesystem calls, it works fine the other way around, so you can still run the project as before, without Redis (just don’t specify a REDIS_URL environment variable), and it will use node-dirty perfectly happily, just like before.

Here is my fork of the project, and there are some instructions in the README for how you can deploy it to Heroku.

You will need to configure the mailgun addon to send the email invitations to players, but you don’t actually need those to play. You can just visit the root URL of your application on Heroku, and you’ll see a list of all the games in progress. Click on your player name and you’ll be playing in that game as that player.

Game list view – click on your player name to join/resume a game

I hope this is of use to other people who are unable to visit scrabble-playing friends or relatives.

Enjoy, and stay safe in these difficult times.

Update: 2020-05-04

Happy Star Wars day!

Hans, the maintainer of the project I forked, has kindly merged my changes into the main project, so you should be able to just use that, now.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s