Get a card's color from its abilities if it has no cost (i.e. special lands)

This commit is contained in:
Correl Roush 2010-07-01 18:05:01 -04:00
parent 0dc2e4e794
commit f93d674b8f

6
mtg.py
View file

@ -184,6 +184,12 @@ class Card:
self.is_tapped = False
self.abilities = []
if not self.colors:
# Try to determine the card's color based on its abilities. Not ideal, but maybe it'll help for now
for line in self.text:
for m in [ManaCost(c) for c in re.findall('{(\d*[WURGB]*)}',line)]:
self.colors.extend([color for color, c in m.mana.mana.iteritems() if c > 0 and color not in self.colors])
self.owner = owner
self.zone = None