-
Notifications
You must be signed in to change notification settings - Fork 23
Action Queue
Slay the Spire's combat works based on an action queue.
Anything that happens adds actions to the queue, which will take place in order.
When you play a card, it adds some actions to the bottom of the queue. When you end your turn, enemies queue their own actions.
When a relic triggers, it adds actions to the queue.
Using the queue is important to ensure things trigger in the correct order.
As an example, here's what would happen if you played the card Bash. (Deal 8 damage. Apply 2 Vulnerable.)
First, the card's use
method would be called. This will queue two actions, a DamageAction
and an ApplyPowerAction
, to apply the vulnerable. In addition, a UseCardAction
is queued after that, which will move the card to the discard pile (Exhaust pile for cards that Exhaust).
These three actions will be processed in order, first dealing damage, then applying vulnerable, and moving the card to the discard pile.
There are two ways of adding to the queue: adding to the bottom, and adding to the top.
Adding to the bottom is adding on to the end of the queue. Anything added to the bottom will happen after anything already in the queue. Adding to the top is adding to the front of the queue. This will happen right away, before any other actions already in the queue.
For a general rule:
In a card's use: add to bottom. In an action's update: add to top. Not sure? add to bottom.
For powers and relics, it really depends, but it's usually addToBottom.
An example of a power that uses addToTop would be Thorns. When a multi-hit is used against thorns, such as the byrds attacking a player with Bronze Scales, each hit of thorns is added to top, which causes it to take place before the next hit of the attack happens. This just makes more sense than an enemy hitting you 6 times and then taking damage 6 times after it finishes attacking you.
Like anything else, look for an example of something similar first if you're not sure, and if you really have no idea, try asking in #modding-technical.