Expert Guide: Calling and Recursion

## Normal Casting

Before talking about how spells are copied, let’s talk about how they’re normally cast. A normal cast always happens through draw - either when the wand draws a spell, or a spell draws another spell. In either case, there’s a whole routine that the game goes through as part of the draw process.

When a draw is initiated, the game takes the first spell off the top of the deck and holds it. It doesn’t immediately go to the hand - first, it’s checked to see if the wand has enough mana to cast it and that it’s not out of charges. If either of those things make it so the spell can’t be cast, the card goes to the discard instead of the hand, and the game takes the next spell off the top of the deck and tries again.

When this process succeeds, then the spell’s mana drain is deducted from the wand’s mana bar, the spell is moved to the hand, and the spell is “called”. To “call” a spell means to perform the spell’s “function” - the main thing that the spell does.

The “function” of the spell is an important concept. A way of thinking about it is that it’s what the spell itself does, rather than what other spells or mechanisms of the game do when interacting with that spell.

For instance, the mana drain and uses remaining of a spell are not part of a spell’s function, because the spell itself doesn’t interact with those values - as we saw before, the drawing mechanism looks at those properties of the spell and does the appropriate things on its own. Only after that’s over is the spell called and its function performed.

Here are two examples of the function of spells:

The function of Damage Plus is: “Add +10 projectile damage and +0.08s cast delay to the cast state.“

The function of Black Hole is: “Add a Black Hole projectile and +1.33s cast delay to the cast state”

Neither of these functions include mana cost or uses remaining, and that is because those values are “properties” of the spell. A spell’s properties is our second to last new term for now, and it basically refers to all of the miscellaneous things about a spell except for its function. This includes how rare it is and where it can be found, the type of the spell, whether or not the spell is tagged as “recursive”, which we’ll get to soon, and other various and less relevant things. And, of course, mana cost and uses remaining.

The thing in common about properties is that if they are to come into play, another mechanism of the game must be the one doing it. Properties do not do anything on their own, as we see with mana cost. Either another spell or the function of the spell must interact with the properties of the spell for them to be relevant.

With all that background out of the way, let’s get on to the meat of it: copying.

## Copying

Copying a spell, at its most basic, simply calls that spell. It invokes the function of a spell without taking into consideration any of its properties. The function of Gamma, for instance, is this:

“Add +0.25s cast delay to the cast state. Find the spell that’s last in the deck, or if the deck is empty, the spell that’s last in the hand. Call that spell.” (A line is omitted for simplicity - we’ll talk about it soon.)

Note that there is no mention of the mana cost or uses remaining of the target spell in Gamma’s function - the function of the spell is evoked directly with none of the trimmings that the draw process has. That’s why you can cast a 0 charge Black Hole for only 30 mana (Gamma’s cost) by using Gamma. However, since the added cast delay of a spell is always part of the spell’s function, you still have to deal with the cast delay of Black Hole if you call it with Gamma.

However, the function of some spells add back some of the trimmings that are present in the draw process. The Divide spells, for instance, check and deduct from the uses remaining of their target spell as part of their function. There is no standard process for what all spells that copy do - most of them do various things differently, which is the point of this guide. All of them, however, call their target spell to produce their function. That’s the baseline.

## Recursion

Before getting into the specifics of how each spell copies, we need to understand the recursion limit, because all spells that copy other spells reference it in some way.

The first thing to know is that some spells are labelled “recursive”. Whether or not a spell is recursive is one of its properties, and it’s the property that determines how the recursion level of each instance of a spell is calculated. Here’s how it works:

* If a spell is drawn and cast that way, its recursion level is 0.
* If a spell calls a non-recursive spell, the called spell’s recursion level is the same as the caller.
* If a spell calls a recursive spell, the called spell’s recursion level is 1 plus the caller’s level.
* If a spell’s recursion level is higher than the recursion limit, it cannot be cast.
* The recursion limit is 2.

This is the general procedure for checking recursion: getting the recursion level of a spell to be called, and determining if it is over the limit or not. All of the spells we’re about to talk about use this logic to limit recursion.

Time for an example to demonstrate!

## Tau Example

The function of Tau is to memorize the top two spells on the deck, check the recursion level of each, and call them if they are not over the limit.

With that in mind, this is how the above example is evaluated:

* The wand draws Tau. Since it was drawn by normal means, this Tau's recursion counter is 0.
* Tau (rec = 0) memorizes the top two spells in the the deck: Tau and Spark Bolt
* Tau (rec = 0) calls Tau. This Tau's recursion level is 0 + 1, since Tau is a recursive spell.
	+ Tau (rec = 1) memorizes the top two spells of the deck. These are still Tau and Spark Bolt
	+ Tau (rec = 1) calls Tau (rec = 2)
		- Tau (rec = 2) memorizes the top two spells of the deck, Tau and Spark Bolt
		- Tau (rec = 2) tries to call Tau (rec = 3), but cannot, because the recursion limit is exceeded. Instead, nothing happens.
		- Tau (rec = 2) calls Spark Bolt (rec = 2). This succeeds.
	+ Tau (rec = 1) calls Spark Bolt (rec = 1)
* Tau (rec = 0) calls Spark Bolt (rec = 0)

In the end, three Spark Bolts are produced, and the Cast Delay from three separate Taus is added. After this is over, the deck still contains the second Tau and Spark Bolt.

## Omega example

Omega's function (and this is not intuitive!) is to cast all spells, in order, in the discard, then all spells that are NOT recursive in the hand, and then all spells in the deck. Normally, this functionality of not casting recursive spells in the hand works to make it so that Omega does not cast Omega, but things work a little differently when we do it like above. Additionally, Omega has a special case, which is that it will never call Wand Refresh in any situation. Knowing all of that, how many Spark Bolts do you think the above example will cast?

Let's see how it goes:

* Gamma (rec = 0) calls the last spell in the deck, which is Omega (rec = 1)
	+ Omega (rec = 1) calls all spells in the discard, in order. No spells are in the discard, so nothing happens.
	+ Omega (rec = 1) calls all spells in the hand, skipping recursive ones. The only spell in the hand is Gamma, so nothing happens.
	+ Omega (rec = 1) calls all spells in the deck, in order:
	+ Omega (rec = 1) skips Wand Refresh
	+ Omega (rec = 1) calls Spark Bolt (rec = 1)
	+ Omega (rec = 1) calls the first Omega, (rec = 2)
		- Omega (rec = 2) skips Gamma and Wand Refresh
		- Omega (rec = 2) calls Spark Bolt (rec = 2)
		- Omega (rec = 2) also skips both Omegas, since they would have rec = 3.
	+ Omega (rec = 1) calls the second Omega, (rec = 2)
		- Same as above; this version of Omega only calls a single Spark Bolt

So, we find that this setup casts 3 copies of Spark Bolt. Very efficient!

## What spells are recursive?

Here's the list:

* All Greek Letter Spells
* Spell Duplication
* Wand Refresh
* Random Spell, Random Projectile, Random Modifier, Random Static Projectile
* Copy Random Spell, Copy Random Spell x3, Copy Three Random Spells

Notably, the Divide By spells are not recursive. As such, a Divide spell's recursion level is the same as that of its caller.

## Conclusion

Hopefully you understand how the recursion limit works now! :) At this point, if you've also read and understand the Draw guide, you know all of the general mechanics of wandcrafting. What's left is learning the specific details of every spell, which in some cases (like Omega, as seen here) can be quite strange or unintuitive. For that, check out the Expert Guide on Advanced Spell Specifics. Other than that, have fun crafting some obscure wands!

Written by Zoldort