Skip to content
08 Jun 2022

Programming Project: Card Draw Simulator part 1

I'm working on improving my JavaScript knowledge and want to ramble about my process/progress writing an RPG-adjacent tool for randomising prompts. Here's an overview and plans to start.

I’ve been looking for an idea for a little programming project, and settled on implementing part of a game in JavaScript. I’ll be sharing the planning and implementation process in case it’s useful for people getting into web development.

Motivation

Where does the idea come from? Short answer: The solo journalling RPG Apothecaria by Anna Blackwell. The premise is that you take over the job of local witch in the village of High Rannoc and gather ingredients to brew potions that heal the people from illnesses, injuries, and curses. You also explore the area and build relationships, writing about it all in your journal.

The main mechanism to randomise things is a deck of regular playing cards. For example, at the start of an in-game week you draw a card, and look up in the Ailments table which problem someone wants you to solve. After deciding what Reagents you need to brew a potion that heals it, you decide in which Location (forest, lake, mountain, dungeon) best to look for the first one, draw a card, and look up on the events table for that location what happens — you meet the local druid, or get targeted by thieving gull-drakes or fairies, or whatever.

Now, the problem I want to solve is that Anna Blackwell has added more Ailments and Events in game expansions and little extras. I’d like to just add them to the pool that gets drawn from, but the randomisation via regular playing card values means that you can only have 13 options per list.

A way to fix this is to not use a deck of standard playing cards for randomisation, but to make dedicated cards with the text currently listed in tables printed on them. You would need one deck of cards per table in the original game, meaning one for Ailments and one per Location. (Actually multiple for Ailments, depending on your Reputation.)

I’ve tried making physical cards by designing them in a graphics program and printing them, but I got frustrated because I did not manage to cut them to exactly the same size, so, a programming project it is.

Why not just make bigger tables and use a random number generator to pick your option?

A (simulated) card deck has the advantage that you can control repetition.

With a random number generator (like a die in real life), it can happen that you get the same result multiple times in a row.

With a deck of cards you can prevent repetition like that by not shuffling a drawn card back into the deck immediately, but leaving drawn cards out of the deck before the next draw.

OK, so much for context, now on to actual planning.

What should the program do?

It must present a list of available decks, and allow the player to select which one they draw from.

It must enable the player to draw a random card from the selected deck, and display that card. This must be repeatable, so the player can draw multiple cards one by one.

It must keep track of which cards have already been drawn, and which are still in the deck, so that cards that have already been drawn are not drawn again. Optionally it may display the cards that have already been drawn.

It must present an option for the player to shuffle a deck, that is, to return already drawn cards to the deck so they can be drawn again.

It should remember which cards from which deck have been drawn even when the player switches between different decks.

Is that all?

The list above is not features for a full game, just for a tool to aid playing a tabletop game.

Some things that could be added to the program:

Choice of expansions. Let the player pick which material to include.

Timers. Some Ailments must be cured in a given time (measured in Event cards drawn, Location changes, affected by special events).

Saving and loading game state. If anything more long-term than timers gets tracked, this is a must, since these games can last long.

Changing cards. Some events are written as “The first time you draw this card, A happens. The second time, B happens”, or “If you have not yet done X, A happens. If you have, B happens”. We could display only A or only B if we kept track of the condition.

Reputation. Can raise or fall depending on success or failure curing Ailments, as well as other events.

Locked/unlocked Ailment decks. You will not see all Ailments at the start of the game. More difficult to heal ones will only be unlocked after your Reputation reaches a certain level.

Locked/unlocked Locations. Some Locations can only be visited after a condition is met.

Reagents List. Displaying a list of reagents in the program, ideally filtered to show only those useful for healing a certain ailment.

Calendar. Most reagents are easier to find in some seasons than others. If we tracked passing in-game time, we could display only the reagent information relevant now.

Inventory and money tracking.

Apothecaria also has a lot more features, including familiars, buying ingredients, items that grant bonuses, upgrades to the witch house that let you visit additional locations, and quests.

So yeah, if I want to add more later, there’s a lot to pick from!

But for a start, the listed features are sufficient. The program will be useful with only these features, and it’s not an overwhelming goal. If I were to try to build everything at once, it would get chaotic and too much and hard to focus on.

Tags:
Content tagged "Year 2022"
edit
I agree with the Privacy Terms

no comments yet