From 436c635eb2b2a307d24ff9d9f1962fe7957e0339 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Thu, 2 Sep 2010 11:56:42 -0400 Subject: [PATCH 1/6] Bug in mana cost math --- mtg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mtg.py b/mtg.py index e41cd6d..c397565 100644 --- a/mtg.py +++ b/mtg.py @@ -104,9 +104,9 @@ class ManaCost: def __sub__(self, other): result = ManaCost() if isinstance(other, ManaCost): + #TODO: Subtract hybrid symbols result.any = self.any - other.any result.mana = self.mana - other.mana - result.hybrid = self.hybrid - other.hybrid result.snow = self.snow - other.snow return result def __repr__(self): From 4932e7c1fa4b9a12794a18a6c9915daf8458c10d Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Thu, 2 Sep 2010 11:57:00 -0400 Subject: [PATCH 2/6] Support for hybrid symbols in the database loader --- database.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/database.py b/database.py index 6c0285b..9003124 100644 --- a/database.py +++ b/database.py @@ -40,7 +40,7 @@ class TextDB(Database): } elif card and line: # Load the data into the card - if not card['cost'] and re.match('^X?\d*[{0}]*$'.format(' '.join(Mana.types.keys())), line): + if not card['cost'] and re.match('^X?\d*(\((\d+|[{0}])/(\d+|[{0}])\))*[{0}]*$'.format(''.join(Mana.types.keys())), line.upper()): card['cost'] = line continue elif not card['type']: @@ -93,10 +93,5 @@ class WagicDB(Database): if __name__ == '__main__': db = TextDB('db.txt') - deck = Deck() - deck.load('decks/BlackSiege.txt', db) - - wagic = Deck() - w = WagicDB('/home/correlr/Download/wth/PSP/GAME/WTH') - for card in deck: - wagic.append(w.getCard(card.name, card)) + c = db.getCard('Balefire Liege') + print c From daf6a7b50c77f9f586d54f1418e33eb110d590d9 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Thu, 2 Sep 2010 11:59:13 -0400 Subject: [PATCH 3/6] Fire Mill deck --- decks/FireMill.txt | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 decks/FireMill.txt diff --git a/decks/FireMill.txt b/decks/FireMill.txt new file mode 100644 index 0000000..d5bdb13 --- /dev/null +++ b/decks/FireMill.txt @@ -0,0 +1,42 @@ +# Name: Fire Mill +# Colors: Blue / Red +# Created by: Correl Roush + +# Main [60] +## Lands +10 Island +10 Mountain +1 Halimar Depths +1 Magosi, the Waterveil + +## Planeswalkers +1 Chandra Nalaar +1 Jace Beleren + +## Creatures +1 Apprentice Wizard +2 Clone +1 Echo Mage +1 Inferno Titan + +## Enchantments +3 Jace's Erasure +2 Mind Control + +## Sorceries +1 Divination +1 Insurrection +2 Lava Axe +3 Preordain +4 Tome Scour +1 Traumatize + +## Instants +2 Blazing Salvo +2 Comet Storm +1 Counterspell +2 Lightning Bolt +2 Mana Leak +1 Redirect +2 Reverberate +2 Syncopate \ No newline at end of file From 87c61cee6ab4172718dfe84b5341c757d1c3a956 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Thu, 2 Sep 2010 17:43:25 -0400 Subject: [PATCH 4/6] Ajani deck --- decks/Ajani.txt | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 decks/Ajani.txt diff --git a/decks/Ajani.txt b/decks/Ajani.txt new file mode 100644 index 0000000..ee58a0f --- /dev/null +++ b/decks/Ajani.txt @@ -0,0 +1,33 @@ +# Name: Ajani Ascendant +# Colors: White / Green +# Created by: Correl Roush + +## Lands +7 Forest +9 Plains + +## Planeswalkers +1 Ajani Goldmane + +## Creatures +4 Ajani's Pridemate +2 Assault Griffin +1 Birds of Paradise +2 Cloud Crusader +1 Fauna Shaman +3 Goldenglow Moth +2 Prized Unicorn +1 Serra Ascendant + +## Artifacts +2 Angel's Feather +1 Elixir of Immortality +2 Wurm's Tooth + +## Enchantments +4 Ajani's Mantra +3 Primal Cocoon + +## Sorceries +2 Hunters' Feast +3 Nature's Spiral \ No newline at end of file From ee0da6e0de472e912682b03ea61066db5b59ae96 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Tue, 21 Sep 2010 20:16:29 -0400 Subject: [PATCH 5/6] 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): From 352f59288d0f6937824436dccd02e55fb234df66 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Tue, 21 Sep 2010 20:16:47 -0400 Subject: [PATCH 6/6] Support some unicode text --- mtg.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mtg.py b/mtg.py index 77dad2b..be8bb2f 100644 --- a/mtg.py +++ b/mtg.py @@ -26,6 +26,8 @@ class Mana: self.mana = result.mana def __add__(self, other): result = Mana() + if isinstance(other, unicode): + other = str(other) if isinstance(other, str): for m in [c for c in other.upper() if c in Mana.types.keys()]: result.mana[m] = result.mana[m] + 1 @@ -77,6 +79,8 @@ class ManaCost: self.snow = result.snow def __add__(self, other): result = ManaCost() + if isinstance(other, unicode): + other = str(other) if isinstance(other, str): symbols = [] hybrid = re.findall(ManaCost.hybridPattern, other)