Merge branch 'master' of /srv/git/mtg
This commit is contained in:
commit
657904c985
4 changed files with 85 additions and 29 deletions
11
database.py
11
database.py
|
@ -40,7 +40,7 @@ class TextDB(Database):
|
||||||
}
|
}
|
||||||
elif card and line:
|
elif card and line:
|
||||||
# Load the data into the card
|
# 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
|
card['cost'] = line
|
||||||
continue
|
continue
|
||||||
elif not card['type']:
|
elif not card['type']:
|
||||||
|
@ -93,10 +93,5 @@ class WagicDB(Database):
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
db = TextDB('db.txt')
|
db = TextDB('db.txt')
|
||||||
deck = Deck()
|
c = db.getCard('Balefire Liege')
|
||||||
deck.load('decks/BlackSiege.txt', db)
|
print c
|
||||||
|
|
||||||
wagic = Deck()
|
|
||||||
w = WagicDB('/home/correlr/Download/wth/PSP/GAME/WTH')
|
|
||||||
for card in deck:
|
|
||||||
wagic.append(w.getCard(card.name, card))
|
|
||||||
|
|
33
decks/Ajani.txt
Normal file
33
decks/Ajani.txt
Normal file
|
@ -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
|
42
decks/FireMill.txt
Normal file
42
decks/FireMill.txt
Normal file
|
@ -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
|
28
mtg.py
28
mtg.py
|
@ -26,6 +26,8 @@ class Mana:
|
||||||
self.mana = result.mana
|
self.mana = result.mana
|
||||||
def __add__(self, other):
|
def __add__(self, other):
|
||||||
result = Mana()
|
result = Mana()
|
||||||
|
if isinstance(other, unicode):
|
||||||
|
other = str(other)
|
||||||
if isinstance(other, str):
|
if isinstance(other, str):
|
||||||
for m in [c for c in other.upper() if c in Mana.types.keys()]:
|
for m in [c for c in other.upper() if c in Mana.types.keys()]:
|
||||||
result.mana[m] = result.mana[m] + 1
|
result.mana[m] = result.mana[m] + 1
|
||||||
|
@ -77,6 +79,8 @@ class ManaCost:
|
||||||
self.snow = result.snow
|
self.snow = result.snow
|
||||||
def __add__(self, other):
|
def __add__(self, other):
|
||||||
result = ManaCost()
|
result = ManaCost()
|
||||||
|
if isinstance(other, unicode):
|
||||||
|
other = str(other)
|
||||||
if isinstance(other, str):
|
if isinstance(other, str):
|
||||||
symbols = []
|
symbols = []
|
||||||
hybrid = re.findall(ManaCost.hybridPattern, other)
|
hybrid = re.findall(ManaCost.hybridPattern, other)
|
||||||
|
@ -104,9 +108,9 @@ class ManaCost:
|
||||||
def __sub__(self, other):
|
def __sub__(self, other):
|
||||||
result = ManaCost()
|
result = ManaCost()
|
||||||
if isinstance(other, ManaCost):
|
if isinstance(other, ManaCost):
|
||||||
|
#TODO: Subtract hybrid symbols
|
||||||
result.any = self.any - other.any
|
result.any = self.any - other.any
|
||||||
result.mana = self.mana - other.mana
|
result.mana = self.mana - other.mana
|
||||||
result.hybrid = self.hybrid - other.hybrid
|
|
||||||
result.snow = self.snow - other.snow
|
result.snow = self.snow - other.snow
|
||||||
return result
|
return result
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
@ -203,29 +207,9 @@ class Card:
|
||||||
self.sets = sets
|
self.sets = sets
|
||||||
self.rarity = rarity
|
self.rarity = rarity
|
||||||
self.text = text
|
self.text = text
|
||||||
self.colors = [color for color, cost in self.cost.mana.mana.iteritems() if cost > 0]
|
|
||||||
self.is_tapped = False
|
self.is_tapped = False
|
||||||
self.abilities = []
|
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.owner = owner
|
||||||
self.zone = None
|
self.zone = None
|
||||||
|
|
||||||
|
@ -242,6 +226,8 @@ class Card:
|
||||||
for i in xrange(other):
|
for i in xrange(other):
|
||||||
result.append(copy.copy(self))
|
result.append(copy.copy(self))
|
||||||
return result
|
return result
|
||||||
|
def colors(self):
|
||||||
|
return [color for color, cost in ManaCost(self.cost).mana.mana.iteritems() if cost > 0]
|
||||||
def store(self):
|
def store(self):
|
||||||
self.__stored = copy.copy(self)
|
self.__stored = copy.copy(self)
|
||||||
def restore(self):
|
def restore(self):
|
||||||
|
|
Loading…
Reference in a new issue