diff --git a/Icons/0-mana.png b/Icons/0-mana.png deleted file mode 100755 index 9dda72d..0000000 Binary files a/Icons/0-mana.png and /dev/null differ diff --git a/Icons/1-mana.png b/Icons/1-mana.png deleted file mode 100755 index 12b0d64..0000000 Binary files a/Icons/1-mana.png and /dev/null differ diff --git a/Icons/10-mana.png b/Icons/10-mana.png deleted file mode 100755 index 3254473..0000000 Binary files a/Icons/10-mana.png and /dev/null differ diff --git a/Icons/11-mana.png b/Icons/11-mana.png deleted file mode 100755 index 2938a8f..0000000 Binary files a/Icons/11-mana.png and /dev/null differ diff --git a/Icons/12-mana.png b/Icons/12-mana.png deleted file mode 100755 index 6300ebb..0000000 Binary files a/Icons/12-mana.png and /dev/null differ diff --git a/Icons/13-mana.png b/Icons/13-mana.png deleted file mode 100755 index 640add6..0000000 Binary files a/Icons/13-mana.png and /dev/null differ diff --git a/Icons/14-mana.png b/Icons/14-mana.png deleted file mode 100755 index b9188b3..0000000 Binary files a/Icons/14-mana.png and /dev/null differ diff --git a/Icons/15-mana.png b/Icons/15-mana.png deleted file mode 100755 index 6c496ed..0000000 Binary files a/Icons/15-mana.png and /dev/null differ diff --git a/Icons/16-mana.png b/Icons/16-mana.png deleted file mode 100755 index f591218..0000000 Binary files a/Icons/16-mana.png and /dev/null differ diff --git a/Icons/17-mana.png b/Icons/17-mana.png deleted file mode 100755 index 06ead76..0000000 Binary files a/Icons/17-mana.png and /dev/null differ diff --git a/Icons/18-mana.png b/Icons/18-mana.png deleted file mode 100755 index aa7f74f..0000000 Binary files a/Icons/18-mana.png and /dev/null differ diff --git a/Icons/19-mana.png b/Icons/19-mana.png deleted file mode 100755 index d00dd77..0000000 Binary files a/Icons/19-mana.png and /dev/null differ diff --git a/Icons/2-mana.png b/Icons/2-mana.png deleted file mode 100755 index 5846b44..0000000 Binary files a/Icons/2-mana.png and /dev/null differ diff --git a/Icons/20-mana.png b/Icons/20-mana.png deleted file mode 100755 index 9489419..0000000 Binary files a/Icons/20-mana.png and /dev/null differ diff --git a/Icons/3-mana.png b/Icons/3-mana.png deleted file mode 100755 index 489f610..0000000 Binary files a/Icons/3-mana.png and /dev/null differ diff --git a/Icons/4-mana.png b/Icons/4-mana.png deleted file mode 100755 index cbc3ca1..0000000 Binary files a/Icons/4-mana.png and /dev/null differ diff --git a/Icons/5-mana.png b/Icons/5-mana.png deleted file mode 100755 index b1651c9..0000000 Binary files a/Icons/5-mana.png and /dev/null differ diff --git a/Icons/6-mana.png b/Icons/6-mana.png deleted file mode 100755 index 52b6b1b..0000000 Binary files a/Icons/6-mana.png and /dev/null differ diff --git a/Icons/7-mana.png b/Icons/7-mana.png deleted file mode 100755 index fd406d7..0000000 Binary files a/Icons/7-mana.png and /dev/null differ diff --git a/Icons/8-mana.png b/Icons/8-mana.png deleted file mode 100755 index d35d0bb..0000000 Binary files a/Icons/8-mana.png and /dev/null differ diff --git a/Icons/9-mana.png b/Icons/9-mana.png deleted file mode 100755 index 57d8387..0000000 Binary files a/Icons/9-mana.png and /dev/null differ diff --git a/Icons/B-2-mana.png b/Icons/B-2-mana.png deleted file mode 100755 index f8e7f99..0000000 Binary files a/Icons/B-2-mana.png and /dev/null differ diff --git a/Icons/B-G-mana.png b/Icons/B-G-mana.png deleted file mode 100755 index f2c0d5b..0000000 Binary files a/Icons/B-G-mana.png and /dev/null differ diff --git a/Icons/B-P-mana.png b/Icons/B-P-mana.png deleted file mode 100755 index fd4aee4..0000000 Binary files a/Icons/B-P-mana.png and /dev/null differ diff --git a/Icons/B-R-mana.png b/Icons/B-R-mana.png deleted file mode 100755 index 071648e..0000000 Binary files a/Icons/B-R-mana.png and /dev/null differ diff --git a/Icons/B-mana.png b/Icons/B-mana.png deleted file mode 100755 index 6b1acbf..0000000 Binary files a/Icons/B-mana.png and /dev/null differ diff --git a/Icons/G-2-mana.png b/Icons/G-2-mana.png deleted file mode 100755 index c794056..0000000 Binary files a/Icons/G-2-mana.png and /dev/null differ diff --git a/Icons/G-P-mana.png b/Icons/G-P-mana.png deleted file mode 100755 index e66eb3b..0000000 Binary files a/Icons/G-P-mana.png and /dev/null differ diff --git a/Icons/G-U-mana.png b/Icons/G-U-mana.png deleted file mode 100755 index a606055..0000000 Binary files a/Icons/G-U-mana.png and /dev/null differ diff --git a/Icons/G-W-mana.png b/Icons/G-W-mana.png deleted file mode 100755 index 56f748d..0000000 Binary files a/Icons/G-W-mana.png and /dev/null differ diff --git a/Icons/G-mana.png b/Icons/G-mana.png deleted file mode 100755 index a2925b7..0000000 Binary files a/Icons/G-mana.png and /dev/null differ diff --git a/Icons/I-mana.png b/Icons/I-mana.png deleted file mode 100755 index 77a65cf..0000000 Binary files a/Icons/I-mana.png and /dev/null differ diff --git a/Icons/Q-symbol.png b/Icons/Q-symbol.png deleted file mode 100755 index 9006ecd..0000000 Binary files a/Icons/Q-symbol.png and /dev/null differ diff --git a/Icons/R-2-mana.png b/Icons/R-2-mana.png deleted file mode 100755 index f69a07d..0000000 Binary files a/Icons/R-2-mana.png and /dev/null differ diff --git a/Icons/R-G-mana.png b/Icons/R-G-mana.png deleted file mode 100755 index 0c36f79..0000000 Binary files a/Icons/R-G-mana.png and /dev/null differ diff --git a/Icons/R-P-mana.png b/Icons/R-P-mana.png deleted file mode 100755 index 90f0dcd..0000000 Binary files a/Icons/R-P-mana.png and /dev/null differ diff --git a/Icons/R-W-mana.png b/Icons/R-W-mana.png deleted file mode 100755 index da14dba..0000000 Binary files a/Icons/R-W-mana.png and /dev/null differ diff --git a/Icons/R-mana.png b/Icons/R-mana.png deleted file mode 100755 index fbb499d..0000000 Binary files a/Icons/R-mana.png and /dev/null differ diff --git a/Icons/S-mana.png b/Icons/S-mana.png deleted file mode 100755 index 681003b..0000000 Binary files a/Icons/S-mana.png and /dev/null differ diff --git a/Icons/T-symbol.png b/Icons/T-symbol.png deleted file mode 100755 index 0ad0e82..0000000 Binary files a/Icons/T-symbol.png and /dev/null differ diff --git a/Icons/Thumbs.db b/Icons/Thumbs.db deleted file mode 100755 index 2f803fb..0000000 Binary files a/Icons/Thumbs.db and /dev/null differ diff --git a/Icons/U-2-mana.png b/Icons/U-2-mana.png deleted file mode 100755 index cde1756..0000000 Binary files a/Icons/U-2-mana.png and /dev/null differ diff --git a/Icons/U-B-mana.png b/Icons/U-B-mana.png deleted file mode 100755 index 8e4ad19..0000000 Binary files a/Icons/U-B-mana.png and /dev/null differ diff --git a/Icons/U-P-mana.png b/Icons/U-P-mana.png deleted file mode 100755 index 5473151..0000000 Binary files a/Icons/U-P-mana.png and /dev/null differ diff --git a/Icons/U-R-mana.png b/Icons/U-R-mana.png deleted file mode 100755 index 83965c0..0000000 Binary files a/Icons/U-R-mana.png and /dev/null differ diff --git a/Icons/U-mana.png b/Icons/U-mana.png deleted file mode 100755 index a57b225..0000000 Binary files a/Icons/U-mana.png and /dev/null differ diff --git a/Icons/W-2-mana.png b/Icons/W-2-mana.png deleted file mode 100755 index 44a0238..0000000 Binary files a/Icons/W-2-mana.png and /dev/null differ diff --git a/Icons/W-B-mana.png b/Icons/W-B-mana.png deleted file mode 100755 index ec30e70..0000000 Binary files a/Icons/W-B-mana.png and /dev/null differ diff --git a/Icons/W-P-mana.png b/Icons/W-P-mana.png deleted file mode 100755 index c0ef45c..0000000 Binary files a/Icons/W-P-mana.png and /dev/null differ diff --git a/Icons/W-U-mana.png b/Icons/W-U-mana.png deleted file mode 100755 index 5d18cf2..0000000 Binary files a/Icons/W-U-mana.png and /dev/null differ diff --git a/Icons/W-mana.png b/Icons/W-mana.png deleted file mode 100755 index d534442..0000000 Binary files a/Icons/W-mana.png and /dev/null differ diff --git a/Icons/X-mana.png b/Icons/X-mana.png deleted file mode 100755 index 6882f49..0000000 Binary files a/Icons/X-mana.png and /dev/null differ diff --git a/Icons/Y-mana.png b/Icons/Y-mana.png deleted file mode 100755 index 3cdec50..0000000 Binary files a/Icons/Y-mana.png and /dev/null differ diff --git a/Icons/chaos-symbol.png b/Icons/chaos-symbol.png deleted file mode 100755 index 7fc2f3c..0000000 Binary files a/Icons/chaos-symbol.png and /dev/null differ diff --git a/decode.py b/decode.py index 5149e44..67bc364 100755 --- a/decode.py +++ b/decode.py @@ -15,95 +15,35 @@ from namediff import Namediff def exclude_sets(cardset): return cardset == 'Unglued' or cardset == 'Unhinged' or cardset == 'Celebration' -def main(fname, oname = None, verbose = True, +def main(fname, oname = None, verbose = True, encoding = 'std', gatherer = False, for_forum = False, for_mse = False, - creativity = False, norarity = False, vdump = False, for_html = False): - cards = [] - valid = 0 - invalid = 0 - unparsed = 0 + creativity = False, vdump = False, for_html = False): - if norarity: - decode_fields = [ - cardlib.field_name, - cardlib.field_supertypes, - cardlib.field_types, - cardlib.field_loyalty, - cardlib.field_subtypes, - #cardlib.field_rarity, - cardlib.field_pt, - cardlib.field_cost, - cardlib.field_text, - ] + fmt_ordered = cardlib.fmt_ordered_default + + if encoding in ['std']: + pass + elif encoding in ['named']: + fmt_ordered = cardlib.fmt_ordered_named + elif encoding in ['noname']: + fmt_ordered = cardlib.fmt_ordered_noname + elif encoding in ['rfields']: + pass + elif encoding in ['old']: + fmt_ordered = cardlib.fmt_ordered_old + elif encoding in ['norarity']: + fmt_ordered = cardlib.fmt_ordered_norarity + elif encoding in ['vec']: + pass + elif encoding in ['custom']: + ## put custom format decisions here ########################## + + ## end of custom format ###################################### + pass else: - decode_fields = cardlib.fmt_ordered_default + raise ValueError('encode.py: unknown encoding: ' + encoding) - if fname[-5:] == '.json': - if verbose: - print 'This looks like a json file: ' + fname - json_srcs = jdecode.mtg_open_json(fname, verbose) - for json_cardname in sorted(json_srcs): - if len(json_srcs[json_cardname]) > 0: - jcards = json_srcs[json_cardname] - - # look for a normal rarity version, in a set we can use - idx = 0 - card = cardlib.Card(jcards[idx], fmt_ordered = decode_fields) - while (idx < len(jcards) - and (card.rarity == utils.rarity_special_marker - or exclude_sets(jcards[idx][utils.json_field_set_name]))): - idx += 1 - if idx < len(jcards): - card = cardlib.Card(jcards[idx], fmt_ordered = decode_fields) - # if there isn't one, settle with index 0 - if idx >= len(jcards): - idx = 0 - card = cardlib.Card(jcards[idx], fmt_ordered = decode_fields) - # we could go back and look for a card satisfying one of the criteria, - # but eh - - if card.valid: - valid += 1 - elif card.parsed: - invalid += 1 - else: - unparsed += 1 - cards += [card] - - # fall back to opening a normal encoded file - else: - if verbose: - print 'Opening encoded card file: ' + fname - with open(fname, 'rt') as f: - text = f.read() - for card_src in text.split(utils.cardsep): - if card_src: - card = cardlib.Card(card_src, fmt_ordered = decode_fields) - if card.valid: - valid += 1 - elif card.parsed: - invalid += 1 - else: - unparsed += 1 - cards += [card] - - if verbose: - print (str(valid) + ' valid, ' + str(invalid) + ' invalid, ' - + str(unparsed) + ' failed to parse.') - - good_count = 0 - bad_count = 0 - for card in cards: - if not card.parsed and not card.text.text: - bad_count += 1 - else: - good_count += 1 - if good_count + bad_count > 15: - break - # random heuristic - if bad_count > 10: - print 'Saw a bunch of unparsed cards with no text:' - print 'If this is a legacy format, try rerunning with --norarity' + cards = jdecode.mtg_open_file(fname, verbose=verbose, fmt_ordered=fmt_ordered) if creativity: cbow = CBOW() @@ -113,11 +53,11 @@ def main(fname, oname = None, verbose = True, if for_mse: # have to prepend a massive chunk of formatting info writer.write(utils.mse_prepend) - + if for_html: # have to preapend html info - writer.write(utils.html_preapend) - + writer.write(utils.html_prepend) + for card in cards: if for_mse: writer.write(card.to_mse().encode('utf-8')) @@ -128,7 +68,7 @@ def main(fname, oname = None, verbose = True, fstring += 'raw:\n' + card.raw + '\n' fstring += '\n' fstring += card.format(gatherer = gatherer, for_forum = for_forum, - vdump = vdump, for_html = for_html) + vdump = vdump) fstring = fstring.replace('<', '(').replace('>', ')') writer.write(('\n' + fstring[:-1]).replace('\n', '\n\t\t')) else: @@ -160,12 +100,15 @@ def main(fname, oname = None, verbose = True, if for_mse: # more formatting info writer.write('version control:\n\ttype: none\napprentice code: ') - if for_html: # closing the html file - writer.write(utils.html_postapend) + writer.write(utils.html_append) if oname: + if for_html: + print oname + # if ('.html' != oname[-]) + # oname += '.html' if verbose: print 'Writing output to: ' + oname with open(oname, 'w') as ofile: @@ -186,8 +129,6 @@ def main(fname, oname = None, verbose = True, print 'Made an MSE set file called ' + oname + '.mse-set.' # The set file is useless outside the .mse-set, delete it. os.remove('set') - if for_html: - ## not sure what to put here else: writecards(sys.stdout) sys.stdout.flush() @@ -201,6 +142,10 @@ if __name__ == '__main__': help='encoded card file or json corpus to encode') parser.add_argument('outfile', nargs='?', default=None, help='output file, defaults to stdout') + parser.add_argument('-e', '--encoding', default='std', choices=utils.formats, + #help='{' + ','.join(formats) + '}', + help='encoding format to use', + ) parser.add_argument('-g', '--gatherer', action='store_true', help='emulate Gatherer visual spoiler') parser.add_argument('-f', '--forum', action='store_true', @@ -209,16 +154,13 @@ if __name__ == '__main__': help='use CBOW fuzzy matching to check creativity of cards') parser.add_argument('-d', '--dump', action='store_true', help='dump out lots of information about invalid cards') - parser.add_argument('--norarity', action='store_true', - help='the card format has no rarity field; use for legacy input') parser.add_argument('-v', '--verbose', action='store_true', help='verbose output') - parser.add_argument('-mse', '--mse', action='store_true', + parser.add_argument('-mse', '--mse', action='store_true', help='use Magic Set Editor 2 encoding; will output as .mse-set file') parser.add_argument('-html', '--html', action='store_true', help='create a .html file with pretty forum formatting') - args = parser.parse_args() - main(args.infile, args.outfile, verbose = args.verbose, + main(args.infile, args.outfile, verbose = args.verbose, encoding = args.encoding, gatherer = args.gatherer, for_forum = args.forum, for_mse = args.mse, - creativity = args.creativity, norarity = args.norarity, vdump = args.dump, for_html = args.for_html) + creativity = args.creativity, vdump = args.dump, for_html = args.html) exit(0) diff --git a/encode.py b/encode.py index da8520f..e2996f8 100755 --- a/encode.py +++ b/encode.py @@ -10,131 +10,55 @@ import utils import jdecode import cardlib -def exclude_sets(cardset): - return cardset == 'Unglued' or cardset == 'Unhinged' or cardset == 'Celebration' - -def exclude_types(cardtype): - return cardtype in ['conspiracy'] - -def exclude_layouts(layout): - return layout in ['token', 'plane', 'scheme', 'phenomenon', 'vanguard'] - -def main(fname, oname = None, verbose = True, dupes = 0, encoding = 'std', stable = False): +def main(fname, oname = None, verbose = True, encoding = 'std', + nolinetrans = False, randomize = False, nolabel = False, stable = False): fmt_ordered = cardlib.fmt_ordered_default - fmt_labeled = None + fmt_labeled = None if nolabel else cardlib.fmt_labeled_default fieldsep = utils.fieldsep + line_transformations = not nolinetrans randomize_fields = False - randomize_mana = False + randomize_mana = randomize initial_sep = True final_sep = True # set the properties of the encoding - if encoding in ['vec']: + + if encoding in ['std']: pass - elif encoding in ['std']: - if dupes == 0: - dupes = 1 - elif encoding in ['rmana']: - if dupes == 0: - dupes = 1 - randomize_mana = True - elif encoding in ['rmana_dual']: - if dupes == 0: - dupes = 1 - fmt_ordered = fmt_ordered + [cardlib.field_cost] - randomize_mana = True + elif encoding in ['named']: + fmt_ordered = cardlib.fmt_ordered_named + elif encoding in ['noname']: + fmt_ordered = cardlib.fmt_ordered_noname elif encoding in ['rfields']: - if dupes == 0: - dupes = 1 - fmt_labeled = cardlib.fmt_labeled_default randomize_fields = True - #randomize_mana = True final_sep = False + elif encoding in ['old']: + fmt_ordered = cardlib.fmt_ordered_old + elif encoding in ['norarity']: + fmt_ordered = cardlib.fmt_ordered_norarity + elif encoding in ['vec']: + pass + elif encoding in ['custom']: + ## put custom format decisions here ########################## + + ## end of custom format ###################################### + pass else: raise ValueError('encode.py: unknown encoding: ' + encoding) - if dupes <= 0: - dupes = 1 - if verbose: print 'Preparing to encode:' print ' Using encoding ' + repr(encoding) - if dupes > 1: - print ' Duplicating each card ' + str(dupes) + ' times.' if stable: print ' NOT randomizing order of cards.' - + if randomize_mana: + print ' Randomizing order of symobls in manacosts.' + if not fmt_labeled: + print ' NOT labeling fields for this run (may be harder to decode).' + if not line_transformations: + print ' NOT using line reordering transformations' - cards = [] - valid = 0 - skipped = 0 - invalid = 0 - unparsed = 0 - - if fname[-5:] == '.json': - if verbose: - print 'This looks like a json file: ' + fname - json_srcs = jdecode.mtg_open_json(fname, verbose) - # don't worry we randomize later - for json_cardname in sorted(json_srcs): - if len(json_srcs[json_cardname]) > 0: - jcards = json_srcs[json_cardname] - - # look for a normal rarity version, in a set we can use - idx = 0 - card = cardlib.Card(jcards[idx]) - while (idx < len(jcards) - and (card.rarity == utils.rarity_special_marker - or exclude_sets(jcards[idx][utils.json_field_set_name]))): - idx += 1 - if idx < len(jcards): - card = cardlib.Card(jcards[idx]) - # if there isn't one, settle with index 0 - if idx >= len(jcards): - idx = 0 - card = cardlib.Card(jcards[idx]) - # we could go back and look for a card satisfying one of the criteria, - # but eh - - skip = False - if (exclude_sets(jcards[idx][utils.json_field_set_name]) - or exclude_layouts(jcards[idx]['layout'])): - skip = True - for cardtype in card.types: - if exclude_types(cardtype): - skip = True - if skip: - skipped += 1 - continue - - if card.valid: - valid += 1 - cards += [card] * dupes - elif card.parsed: - invalid += 1 - else: - unparsed += 1 - - # fall back to opening a normal encoded file - else: - if verbose: - print 'Opening encoded card file: ' + fname - with open(fname, 'rt') as f: - text = f.read() - for card_src in text.split(utils.cardsep): - if card_src: - card = cardlib.Card(card_src) - if card.valid: - valid += 1 - cards += [card] * dupes - elif card.parsed: - invalid += 1 - else: - unparsed += 1 - - if verbose: - print (str(valid) + ' valid, ' + str(skipped) + ' skipped, ' - + str(invalid) + ' invalid, ' + str(unparsed) + ' failed to parse.') + cards = jdecode.mtg_open_file(fname, verbose=verbose, linetrans=line_transformations) # This should give a random but consistent ordering, to make comparing changes # between the output of different versions easier. @@ -174,17 +98,23 @@ if __name__ == '__main__': help='encoded card file or json corpus to encode') parser.add_argument('outfile', nargs='?', default=None, help='output file, defaults to stdout') - parser.add_argument('-d', '--duplicate', metavar='N', type=int, default=0, - help='number of times to duplicate each card') - parser.add_argument('-e', '--encoding', default='std', - choices=['std', 'rmana', 'rmana_dual', 'rfields', 'vec']) + parser.add_argument('-e', '--encoding', default='std', choices=utils.formats, + #help='{' + ','.join(formats) + '}', + help='encoding format to use', + ) + parser.add_argument('-r', '--randomize', action='store_true', + help='randomize the order of symbols in mana costs') + parser.add_argument('--nolinetrans', action='store_true', + help="don't reorder lines of card text") + parser.add_argument('--nolabel', action='store_true', + help="don't label fields") parser.add_argument('-s', '--stable', action='store_true', help="don't randomize the order of the cards") parser.add_argument('-v', '--verbose', action='store_true', help='verbose output') args = parser.parse_args() - main(args.infile, args.outfile, verbose = args.verbose, dupes = args.duplicate, - encoding = args.encoding, stable = args.stable) + main(args.infile, args.outfile, verbose = args.verbose, encoding = args.encoding, + nolinetrans = args.nolinetrans, randomize = args.randomize, nolabel = args.nolabel, + stable = args.stable) exit(0) - diff --git a/lib/cardlib.py b/lib/cardlib.py index 75dca7f..c452285 100644 --- a/lib/cardlib.py +++ b/lib/cardlib.py @@ -88,7 +88,8 @@ fieldnames = [ field_text, ] -fmt_ordered_default = [ +# legacy +fmt_ordered_old = [ field_name, field_supertypes, field_types, @@ -99,6 +100,52 @@ fmt_ordered_default = [ field_cost, field_text, ] +fmt_ordered_norarity = [ + field_name, + field_supertypes, + field_types, + field_loyalty, + field_subtypes, + field_pt, + field_cost, + field_text, +] + +# standard +fmt_ordered_default = [ + field_types, + field_supertypes, + field_subtypes, + field_loyalty, + field_pt, + field_text, + field_cost, + field_rarity, + field_name, +] + +# minor variations +fmt_ordered_noname = [ + field_types, + field_supertypes, + field_subtypes, + field_loyalty, + field_pt, + field_text, + field_cost, + field_rarity, +] +fmt_ordered_named = [ + field_name, + field_types, + field_supertypes, + field_subtypes, + field_loyalty, + field_pt, + field_text, + field_cost, + field_rarity, +] fmt_labeled_default = { field_name : field_label_name, @@ -176,7 +223,7 @@ def fields_check_valid(fields): # releaseDate - string # starter - boolean -def fields_from_json(src_json): +def fields_from_json(src_json, linetrans = True): parsed = True valid = True fields = {} @@ -254,6 +301,8 @@ def fields_from_json(src_json): text_val = transforms.text_pass_8_equip(text_val) text_val = transforms.text_pass_9_newlines(text_val) text_val = transforms.text_pass_10_symbols(text_val) + if linetrans: + text_val = transforms.text_pass_11_linetrans(text_val) text_val = utils.to_ascii(text_val) text_val = text_val.strip() mtext = Manatext(text_val, fmt = 'json') @@ -340,9 +389,7 @@ def fields_from_format(src_text, fmt_ordered, fmt_labeled, fieldsep): class Card: '''card representation with data''' - def __init__(self, src, fmt_ordered = fmt_ordered_default, - fmt_labeled = fmt_labeled_default, - fieldsep = utils.fieldsep): + def __init__(self, src, fmt_ordered = fmt_ordered_default, fmt_labeled = fmt_labeled_default, fieldsep = utils.fieldsep, linetrans = True): # source fields, exactly one will be set self.json = None self.raw = None @@ -378,8 +425,9 @@ class Card: self.bside = Card(src[utils.json_field_bside], fmt_ordered = fmt_ordered, fmt_labeled = fmt_labeled, - fieldsep = fieldsep) - p_success, v_success, parsed_fields = fields_from_json(src) + fieldsep = fieldsep, + linetrans = linetrans) + p_success, v_success, parsed_fields = fields_from_json(src, linetrans = linetrans) self.parsed = p_success self.valid = v_success self.fields = parsed_fields @@ -391,7 +439,8 @@ class Card: self.bside = Card(utils.bsidesep.join(sides[1:]), fmt_ordered = fmt_ordered, fmt_labeled = fmt_labeled, - fieldsep = fieldsep) + fieldsep = fieldsep, + linetrans = linetrans) p_success, v_success, parsed_fields = fields_from_format(sides[0], fmt_ordered, fmt_labeled, fieldsep) self.parsed = p_success @@ -503,10 +552,7 @@ class Card: # the NN representation, use str() or format() for output intended for human # readers. - def encode(self, fmt_ordered = fmt_ordered_default, - fmt_labeled = None, fieldsep = utils.fieldsep, - randomize_fields = False, randomize_mana = False, - initial_sep = True, final_sep = True): + def encode(self, fmt_ordered = fmt_ordered_default, fmt_labeled = None, fieldsep = utils.fieldsep, randomize_fields = False, randomize_mana = False, initial_sep = True, final_sep = True): outfields = [] for field in fmt_ordered: @@ -608,7 +654,7 @@ class Card: mtext = transforms.text_unpass_2_counters(mtext) #mtext = transforms.text_unpass_3_uncast(mtext) mtext = transforms.text_unpass_4_unary(mtext) - mtext = transforms.text_unpass_5_symbols(mtext, for_forum) + mtext = transforms.text_unpass_5_symbols(mtext, for_forum, for_html) mtext = sentencecase(mtext) mtext = transforms.text_unpass_6_cardname(mtext, cardname) mtext = transforms.text_unpass_7_newlines(mtext) @@ -638,25 +684,27 @@ class Card: outstr += '