sorting and unscrambling now handle new choice format

This commit is contained in:
billzorn 2015-06-30 23:02:48 -07:00
parent 749c7daea8
commit b63b950955
2 changed files with 24 additions and 2 deletions

View file

@ -58,11 +58,11 @@ def sortcards(cards):
classes['X cards'] += [card] classes['X cards'] += [card]
if 'kick' in card: if 'kick' in card:
classes['kicker cards'] += [card] classes['kicker cards'] += [card]
if '#' in card: if '%' in card:
classes['counter cards'] += [card] classes['counter cards'] += [card]
if 'uncast' in card: if 'uncast' in card:
classes['uncast cards'] += [card] classes['uncast cards'] += [card]
if 'choose one ~' in card or 'choose two ~' in card or '=' in card: if '[' in card or ']' in card or '=' in card:
classes['choice cards'] += [card] classes['choice cards'] += [card]
if '|equipment|' in card or 'equip {' in card: if '|equipment|' in card or 'equip {' in card:
classes['equipment'] += [card] classes['equipment'] += [card]

View file

@ -108,6 +108,27 @@ def unreplace_newlines(s):
return s.replace('\\', '\n') return s.replace('\\', '\n')
def cleanup_choice(s):
openbrackets = re.findall(r'\[[0123456789]+', s)
for openbracket in openbrackets:
number = openbracket[1:]
i = int(number)
if i == 0:
s = s.replace(number, 'choose one or more ~')
elif i == 1:
s = s.replace(number, 'choose one ~')
elif i == 2:
s = s.replace(number, 'choose two ~')
else:
s = s.replace(number, 'choose ' + number + ' ~')
clauses = re.findall(r'\[choose.*\]', s)
for clause in clauses:
newclause = clause.replace('=', '\n=')
s = s.replace(clause, newclause)
return s
def forum_reorder(s): def forum_reorder(s):
fields = s.split('|') fields = s.split('|')
# should see ten of em # should see ten of em
@ -156,6 +177,7 @@ def forum_reorder(s):
def unscramble(s, pretty = False): def unscramble(s, pretty = False):
s = from_unary(s) s = from_unary(s)
s = cleanup_choice(s)
s = cleanup_mana(s, pretty) s = cleanup_mana(s, pretty)
s = unreplace_newlines(s) s = unreplace_newlines(s)
s = forum_reorder(s) s = forum_reorder(s)