Magi-Nation search    simple advanced expert [version 0.7 -- under construction]
help credits

Examples

The following examples demonstrate how to use Python expressions to query the database. Even if you don't know Python, you should be able to change these expressions without much trouble.

Searching by name

This is perhaps the most common search type, which is already covered (mostly) by simple and advanced search.

# look for the card named Gia
card.name == "Gia"

# find all cards with 'quor' in the name
card.name.like("quor")

However, these queries can be more refined as well:

# find all cards whose names start with 'q'
card.name.startswith("q")

# find all cards with a name exactly 4 characters long 
# (ok, maybe not so useful...)
len(card.name) == 4

Card types

Magi-Nation has four types of cards: Creature, Magi, Relic, and Spell. To find a specific type, just compare the card.type attribute:

# show all Magi cards
card.type == 'Magi'

Some cards have a subtype. For example, Arderial Shadow Geyser has subtype "Shadow Geyser", while Drahkar has "Illusion" and Yaromant has "Arctic". To work with this, just check card.subtype:

# list all cards that have a subtype
card.subtype

# find all Arctic cards
card.subtype == 'Arctic'

Regions

Magi-Nation has 12 regions (13 if you count Universal). The simplest way to find cards from a specific region is to compare card.region with that region's name:

card.region == 'Orothe'

However, some cards belong to multiple regions. In that case, it's better to use card.has_region:

# find all cards that belong to Kybar's Teeth (dual region or otherwise)
card.has_region("Kybar's Teeth")

# find cards that belong to Orothe *and* Cald
card.has_region("Orothe") and card.has_region("Cald")

There's also an attribute card.regions, which is a list of all regions the card belongs to. We can use this to find all cards with dual regions:

len(card.regions) > 1

or single regions:

len(card.regions) == 1

Energy / cost

The card.cost attribute holds the casting cost of Creatures, Spells and Relics. For Magis, it has the starting energy. Since this is almost always a number, we can use it in comparisons like:

# find all Magi with starting energy of 11 or less
card.type == "Magi" and card.cost <= 11

# find all Magi with starting energy greater than 18
card.type == "Magi" and card.cost > 18

# find all 1-energy creatures
card.type == "Creature" and card.cost == 1

Some cards have a cost of "X":

card.cost == "X"

Sets

There are two attributes that contain expansion set information: card.set contains a two-letter abbreviation of the set's name, while card.set_long has the full name.

So these are equivalent:

card.set == 'AW'
# or:
card.set_long = "Awakening"

Powers and effects

To find cards that have powers or effects, simply use card.powers and card.effects.

card.powers       # all cards with one or more powers
card.effects      # all cards with one or more effects

These attributes are actually Python dictionaries, so we can take the length to find cards that have two or more powers:

len(card.powers) > 1    # ditto for effects

If we want to look for a certain power/effect, we can use card.has_power and card.has_effect:

card.has_effect("Weave")

Rarity

The card.rarity attribute can take one of four values: R (rare), U (uncommon), C (common), and P (promo).

# find rare Arderial cards
card.rarity == 'R' and card.has_region("Arderial")

General text

...under construction...

Other attributes

Regular expressions