From ee0da6e0de472e912682b03ea61066db5b59ae96 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Tue, 21 Sep 2010 20:16:29 -0400 Subject: [PATCH] Card colors are from casting costs only --- mtg.py | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/mtg.py b/mtg.py index c397565..77dad2b 100644 --- a/mtg.py +++ b/mtg.py @@ -203,29 +203,9 @@ class Card: self.sets = sets self.rarity = rarity self.text = text - self.colors = [color for color, cost in self.cost.mana.mana.iteritems() if cost > 0] self.is_tapped = False self.abilities = [] - # Get color from land type - if 'land' in self.type.split(' '): - if 'mountain' in self.attributes: - self.colors.append('R') - if 'plains' in self.attributes: - self.colors.append('W') - if 'swamp' in self.attributes: - self.colors.append('B') - if 'island' in self.attributes: - self.colors.append('U') - if 'forest' in self.attributes: - self.colors.append('G') - - 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 @@ -242,6 +222,8 @@ class Card: for i in xrange(other): result.append(copy.copy(self)) return result + def colors(self): + return [color for color, cost in ManaCost(self.cost).mana.mana.iteritems() if cost > 0] def store(self): self.__stored = copy.copy(self) def restore(self):