Skip to content

Commit

Permalink
Update CardDB to use the new CardXML API
Browse files Browse the repository at this point in the history
  • Loading branch information
jleclanche committed Dec 5, 2016
1 parent 405cd69 commit f1c805d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion fireplace/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, data):
self.tags.update(data.tags)

def __str__(self):
return self.name
return self.data.name

def __hash__(self):
return self.id.__hash__()
Expand Down
21 changes: 10 additions & 11 deletions fireplace/cards/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@ def __init__(self):
self.initialized = False

@staticmethod
def merge(id, card, carddef=None):
def merge(id, card, cardscript=None):
"""
Find the xmlcard and the card definition of \a id
Then return a merged class of the two
"""
if card is None:
card = cardxml.CardXML()
card.id = id
card = cardxml.CardXML(id)

if carddef is None:
carddef = get_script_definition(id)
if cardscript is None:
cardscript = get_script_definition(id)

if carddef:
card.scripts = type(id, (carddef, ), {})
if cardscript:
card.scripts = type(id, (cardscript, ), {})
else:
card.scripts = type(id, (), {})

Expand Down Expand Up @@ -70,13 +69,13 @@ def merge(id, card, carddef=None):
card.scripts.Hand.update = (card.scripts.Hand.update, )

# Set choose one cards
if hasattr(carddef, "choose"):
card.choose_cards = carddef.choose[:]
if hasattr(cardscript, "choose"):
card.choose_cards = cardscript.choose[:]
else:
card.choose_cards = []

if hasattr(carddef, "tags"):
for tag, value in carddef.tags.items():
if hasattr(cardscript, "tags"):
for tag, value in cardscript.tags.items():
card.tags[tag] = value

# Set some additional events based on the base tags...
Expand Down
2 changes: 1 addition & 1 deletion fireplace/cards/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def custom_card(cls):
raise ValueError("No name provided for custom card %r" % (cls))
db[id] = CardDB.merge(id, None, cls)
# Give the card its fake name
db[id]._localized_tags = {
db[id].strings = {
GameTag.CARDNAME: {"enUS": cls.tags[GameTag.CARDNAME]},
GameTag.CARDTEXT_INHAND: {"enUS": ""}
}
Expand Down

0 comments on commit f1c805d

Please sign in to comment.