Hey TFM. I've gotten back around to expanding the generator's coding ability. I'm currently tackling abilities that are the same on all cards but differ slightly because they use the card's name, e.g. "
Akoum Refuge enters the battlefield tapped."
I replace the card's name in the ability text with "ENGLISHCARDNAME". This standardizes the ability text, making the dictionary approach used on other abilities possible. The dictionary doesn't contain the localized text, though, since it differs from card to card. Instead, each ability with the card name has "<!--LOCALIZEDTEXT-->", instead. Then, it returns the ability like normal if it doesn't have the placeholder localized text. If it does contain it, it replaces that placeholder with the localized text extracted from the card (like when it can't find the ability at all).
It currently only adds "enters the battlefield tapped", "can't be countered (by spells and abilities)", "can't block", and "can't be blocked". Can you (or anyone else seeing this) think of similar abilities?
Also, I've got an issue with Outlast that I can't quite figure out. I've added outlast to the list of abilities, but it uses the <!--LOCALIZEDTEXT--> placeholder from above as well as <!--COST--> so I can insert the cost. It works, but ONLY if I remove the '$' from the search pattern. In other words, this doesn't match Outlast:
- Code: Select all
# search for simple templates
for sPattern, sTemplate in dicSimpleTemplates.iteritems():
moMatch = re.search('^' + sPattern + '$', sEnglishText)
if moMatch:
but this does
- Code: Select all
# search for simple templates
for sPattern, sTemplate in dicSimpleTemplates.iteritems():
moMatch = re.search('^' + sPattern, sEnglishText)
if moMatch:
Outlast's entry in the dictionary is this:
- Code: Select all
(r'Outlast\W',
r"""<ACTIVATED_ABILITY>
<!--LOCALIZEDTEXT--> <AVAILABILITY sorcery_time="1" />
<!--COST--> <RESOLUTION_TIME_ACTION>
if EffectSource() ~= nil then
EffectSource():AddCounters( MTG():PlusOnePlusOneCounters(), 1)
end
</RESOLUTION_TIME_ACTION>
</ACTIVATED_ABILITY>""")
This is an entry in the simple templates dictionary (the one with the other normal abilities). This means that I can't just remove '$' without allowing it to possibly incorrectly match abilities in other circumstances. Do you know of a way to alter Outlast's dictionary entry such that
- Code: Select all
re.search('^' + sPattern + '$', sEnglishText)
will match it? I tried making its dictionary entry
- Code: Select all
r'Outlast\W' + '$'
and
r'Outlast\W$'
but neither one worked. I don't know enough about python's strings to get it to work. I looked into it, but obviously I haven't found a solution. At worst, I can repeat the search in a completely different section of code, leaving the bit that matches endlines alone, but it would be much simpler to just do it all at once (assuming there's a way to make outlast match '^' + sPattern + '$').