Wagic deck export
This commit is contained in:
parent
8f38aaf09b
commit
445cb66282
1 changed files with 15 additions and 0 deletions
15
mtg.py
15
mtg.py
|
@ -295,3 +295,18 @@ class Deck(CardList):
|
|||
# TODO: The database should log an error
|
||||
continue
|
||||
self.extend(card * count)
|
||||
def exportWagic(self, filename, name=None):
|
||||
cards = {}
|
||||
for card in self:
|
||||
cards[card] = cards[card] + 1 if card in cards.keys() else 1
|
||||
lines = [
|
||||
'#NAME:{0}\n'.format(name if name else filename),
|
||||
'#DESC: Exported deck\n\n',
|
||||
]
|
||||
for card, count in cards.iteritems():
|
||||
sets = card.sets
|
||||
line = '{0} ({1}) *{2}\n'.format(card.name, card.sets[-1], count)
|
||||
lines.append(line)
|
||||
with open(filename, 'w') as f:
|
||||
f.writelines(lines)
|
||||
f.close()
|
||||
|
|
Loading…
Reference in a new issue