I'm trying to write a top-down tactics RPG game in python, and run into the first major decision I can't make with my limited knowledge of RPG fundamentals.
In our game you create a team of characters with mostly typical stats, but they can also have a quirk like "enrage" (gives a chance for a retaliation strike when damage is taken) and can use spells like "deflection" (might negate a physical attack.) The problem is that I can't figure out what order to process events.
In the case of "enrage" the quirk depends on the successful damage dealt to the character; if the character dodges or the enemy misses then there should be no opportunity for such a bonus strike. So the earlier event, the swing and damage, must be resolved before the quirk can react. This would be called "FIFO": first-in first-out, which lends itself to a queue
. In a queue
you can only append to the end of the container and remove elements from the beginning.
In the case of "deflection", it could work like an interruption, a just-in-time spell cast in reaction to the swing / attempt to damage. This makes me think of the Magic the Gathering "interruption stack" where a chain of effects is resolved in reverse chronological order, AKA "LIFO": last-in first-out, which lends itself to a stack
. In a stack
you can only append to the end of the container and remove elements from the same end.
Now there is a third option which could satisfy both requirements: a deque
or double-ended queue
allows you to prepend, append, and remove elements from either end. The problem is then, how do you decide the order to resolve effects/events when both ends of the container are open? When "enrage" and "deflect" are both in play there are dependencies in both directions!
If I had to choose between FIFO and LIFO I think I'd go with the MTG style stack
of effects/events, however it's very hard for me to understand all the implications of that since I'm only so good at MTG and I'm definitely bad at RPG/tactics games. (You might say I have no business developing a game in the genre, I guess I'm just stubbornly optimistic about my abilities to program my way through it.) We don't have a very long list of spells and quirks just yet, but the guy I'm developing with is a serious gamer and he has plans for all kinds of things I can't imagine yet. I don't want to shoot myself in the foot making this a single-ended container just to find out way down the road that we need to rewrite the backbone of the game or we lose out on tons of cool organic interactions.
So please give me a few pointers, there must be loads of games out there that can pull off the deque
design and I'm just too close to the problem.
The only insight I had is that maybe the answer is "none of the above" - maybe you just make events/effects like an arbitrary 'graph' and traverse it along the direction of the dependencies. Or maybe there's a category of events/effects that works like MTG interruptions and its complement works the opposite way. I just don't know.