mse version: 2.0.0 short name: LackeyBot full name: LackeyBot Exporter position hint: 003 icon: icon.png version: 2024-01-28 installer group: magic/Export/lackeybot depends on: package: magic.mse-game version: 2009-07-23 game: magic create directory: true file type: *.txt|*.txt|*.*|*.* # By Cajun option field: type: text name: set code description: The set code for the set option field: type: choice name: export images choice: no choice: full size choice: lackey size option field: type: choice name: image name choice: name choice: card number choice: dfc name option field: type: text name: default designer description: The default or head designer for this set. option field: type: boolean name: check designers description: check the textbox by card # for designer credit? option field: type: text name: v mana replacement description: exports V mana as a replacement text string option field: type: choice name: special usage choice: promo choice: bonus script: public := true export_me := { if options.update or else false then contains(card.notes, match:"!update") else true } fix_tm := replace@(match:"™", replace:"TM") fixed_set_code := {fix_tm(options.set_code)} dfc_splitter_name := { name := card_name() second := if contains(card.shape, match:"double faced") then remove_tags(card.name_2) else "" if options.image_name == "dfc name" and second != "" then name + "_" + second else name } pull_designer_1 := { design_command := designer_name_grabber(designer_name_filter(card.notes)) design_credit := card.card_code_text != "" and not match(card.card_code_text, match:"^(Story Spotlight|FT(:| ?[-—]| by| from| written))") if design_command != "" then design_command else if options.check_designers and design_credit then card.card_code_text else if public then options.default_designer else options.default_designer } pull_designer := { trim(pull_designer_1()) } a_lackey_image_export_width := { if contains(card.shape, match:"split") then "445" else if contains(card.shape, match:"double faced") then "626" else "312" } a_lackey_image_export_height := { if contains(card.shape, match:"split") then "312" else "445" } image_export_width := { if options.export_images == "lackey size" then if contains(card.shape, match:"split") then "445" else if contains(card.shape, match:"double faced") then "626" else "312" else if contains(card.shape, match:"split") then 523 else if contains(card.shape, match:"double faced") then 752 else 375 } image_export_height := { if options.export_images == "lackey size" then if contains(card.shape, match:"split") then "312" else "445" else if contains(card.shape, match:"split") then 375 else 523 } remove_commas := replace@(match:":", replace:"")+ replace@(match:"<(/|\\\\)?i>", replace:"")+ replace@(match:"[\<>:\\\\/\"\\*\\?\\|]", replace:"") token_export := {contains(card.shape, match:"token") or contains(card.shape, match:"emblem") or contains(card.shape, match:"rulestip")} v_rep := { if input != "V" then input else if options.v_mana_replacement == "" then input else options.v_mana_replacement } exporter_name_filter := filter_text@(match:"!exporte?r?name [^\n!]+") exporter_name_grabber := replace@(match:"!exporte?r?name ", replace:"") hidden_name_filter := filter_text@(match:"!hiddenname [^\n!]+") hidden_name_grabber := replace@(match:"!hiddenname ", replace:"") hidden_tag_filter := filter_text@(match:"!hidetag [^\n!]+") hidden_tag_grabber := replace@(match:"!hidetag ", replace:"") hidden_name := { name := hidden_name_grabber(hidden_name_filter(card.notes)) tag := hidden_tag_grabber(hidden_tag_filter(card.notes)) if tag != "" then name := card.name + " " + tag name } patch_note_filter := filter_text@(match:"!update [^\n!]+") patch_note_grabber := replace@(match:"!update ", replace:"") patch_note := {patch_note_grabber(patch_note_filter(card.notes))} card_name := { if exporter_name_grabber(exporter_name_filter(card.notes)) != "" then exporter_name_grabber(exporter_name_filter(card.notes)) else remove_tags(card.name) } notes_filter := filter_text@(match:"!notes? [^\n!]+") notes_grabber := replace@(match:"!notes? ", replace:"") +replace@(match:"([^,]+)", replace:{"\"" + _1 + "\""}) +replace@(match:"italics", replace:"italic") card_note_array := { "[" + (if notes_grabber(notes_filter(card.notes)) != "" then notes_grabber(notes_filter(card.notes)) else "") + "]" } exporter_num_filter := filter_text@(match:"!num [^\n!]+") exporter_num_grabber := replace@(match:"!num ", replace:"") lackey_script_filter := filter_text@(match:"!script [^\n]+") lackey_script_grabber := replace@(match:"!script ", replace:"") designer_name_filter := filter_text@(match:"!designe?r? [^\n]+") designer_name_grabber := replace@(match:"!designe?r? ", replace:"") link_filter := filter_text@(match:"!link [^\n]+") link_grabber := replace@(match:"!link ", replace:"") link_name := { if link_grabber(link_filter(card.notes)) != "" then link_grabber(link_filter(card.notes)) else "" } is_revived := { if contains(card.notes, match:"!revivetoken") then "Revived " else ""} database_name := { if exporter_name_grabber(exporter_name_filter(card.notes)) != "" then exporter_name_grabber(exporter_name_filter(card.notes)) else if contains(card.shape, match: "split") or contains(card.shape, match:"double") or contains(card.shape, match:"adventure") then remove_tags(card.name) + "//" + remove_tags(card.name_2) else is_revived() + remove_tags(card.name) } forced_script := { if lackey_script_grabber(lackey_script_filter(card.notes)) != "" then "[" + lackey_script_grabber(lackey_script_filter(card.notes)) + "]" else "\"\""} type_trim := replace@(match:"Basic ", replace:"")+ replace@(match:"Legendary", replace:"")+ replace@(match:"Snow ", replace:"")+ replace@(match:"World ", replace:"")+ replace@(match:"Token ", replace:"") ####### Script that converts the card's mana cost lackey_bot_rule_filter := replace@(match:"’", replace:"'")+ replace@(match:"\n", replace:"\\\\n")+ replace@(match:"[(]", replace:"*(")+ replace@(match:"[)]", replace: ")*")+ replace@(match:"\"", replace:"”") quote_replace := replace@(match:"\"", replace:"\\\\\"") break_cleaner := replace@(match:"\n", replace:"") mana_script := replace@(match:"(2|H|W|U|B|R|G|S|C)/(W|U|B|R|G|S|C)", replace:{"\{"+_1+"/"+_2+"\}"})+ replace@(match:"(X|Y|Z|W|U|B|R|G|S|C)", in_context:"(?", replace:{"\{"+_1+"\}"})+ replace@(match:"([1-9][0-9])", in_context:"(?", replace:{"\{"+_1+"\}"})+ replace@(match:"([0-9])", in_context:"(?(?!})", replace:{"\{"+_1+"\}"})+ replace@(match:"V", replace:{"\{"+v_rep("V")+"\}"}) lackey_bot_mana_filter := replace@(match:"([0-9WUBRGCSHEQTXYZEDV/]+)", replace:{"\{"+_2+"}"})+ replace@(match:"([0-9HSCWUBRGXYZEDV/])", in_context:"\{[0-9HSCWUBRGXYZEDV/]*[0-9HSCWUBRGXYZEDV/]*}", replace:{"\{"+v_rep(_1)+"}"})+ replace@(match:"}\{/}\{", replace:"/")+ replace@(match:"\{([0-9])}\{([0-9])}", replace:{"\{"+_1+_2+"}"})+ replace@(match:"\{\{", replace:"\{")+ replace@(match:"}}", replace:"}") color_condense := replace@(match:"(, )?(artifact|multicolor|land|hybrid|horizontal|vertical|radial|overlay)", replace: "") indicator_color_name := { cond := color_condense(input) if cond == "white" then "\{White\} " else if cond == "blue" then "\{Blue\} " else if cond == "black" then "\{Black\} " else if cond == "red" then "\{Red\} " else if cond == "green" then "\{Green\} " else if cond == "white, blue" then "\{White/Blue\} " else if cond == "blue, black" then "\{Blue/Black\} " else if cond == "black, red" then "\{Black/Red\} " else if cond == "red, green" then "\{Red/Green\} " else if cond == "white, green" then "\{Green/White\} " else if cond == "white, black" then "\{White/Black\} " else if cond == "blue, red" then "\{Blue/Red\} " else if cond == "black, green" then "\{Black/Green\} " else if cond == "white, red" then "\{Red/White\} " else if cond == "blue, green" then "\{Green/Blue\} " else if cond == "white, black, red" then "\{White/Black/Red\} " else if cond == "blue, red, green" then "\{Blue/Red/Green\} " else if cond == "white, black, green" then "\{Black/Green/White\} " else if cond == "white, blue, red" then "\{Red/White/Blue\} " else if cond == "blue, black, green" then "\{Green/Blue/Black\} " else if cond == "white, blue, black" then "\{White/Blue/Black\} " else if cond == "blue, black, red" then "\{Blue/Black/Red\} " else if cond == "black, red, green" then "\{Black/Red/Green\} " else if cond == "white, red, green" then "\{Red/Green/White\} " else if cond == "white, blue, green" then "\{Green/White/Blue\} " else "" } trim_zeroes := replace@(match: "^00?", replace: "")+ replace@(match: "a?/[0-9b]+", replace: "") corrected_card_number := { if exporter_num_grabber(exporter_num_filter(card.notes)) != "" then exporter_num_grabber(exporter_num_filter(card.notes)) else if card.custom_card_number != "" then trim_zeroes(card.custom_card_number) else card_number() } lackey_bot_flavor := {"*" + input + "*" } apos_filter := replace@(match:"’", replace:"'") paragraph_count := replace@(match:"\n", replace:"~")+ filter_text@(match:"~") text_script := { replace( remove_tags(input) + (if card.rule_text_3 != "" then "\\n" + card.rule_text_3 else ""), match:"[ ][ ]+•", replace: "\\n•" ) } leveler_text := { card.rule_text + "\\n" + "[PROGRESS " + card.level_1 + "] " + card.rule_text_2 + "\\n" + "[PROGRESS " + card.level_2 + "] " + card.rule_text_3 + "\\n" } flavor_script := { if input == "" then "" else replace(italic_filter(input), match:"\n", replace:"\\\\n") + "\\n" } italic_filter := replace@(match:"", replace:"*")+ replace@(match:" *", replace:"*")+ replace@(match:" ", replace:"* ")+ replace@(match:" ", replace:"* ")+ replace@(match:" ", replace:"* ")+ replace@(match:"", replace:"*")+ replace@(match:"", replace:"*")+ replace@(match:"", replace:"*")+ replace@(match:" ", replace:" *")+ replace@(match:" ", replace:" *")+ replace@(match:" ", replace:" *")+ replace@(match:"", replace:"*")+ replace@(match:"", replace:"*")+ replace@(match:"", replace:"*")+ replace@(match:"\\*\\*+", replace:"") walker_text := { lackey_bot_mana_filter(lackey_bot_rule_filter((if card.loyalty_cost_1 != "" then "[" + card.loyalty_cost_1 + "]: ") +(if card.level_1_text != "" then card.level_1_text else split_text(match:"\n", card.rule_text).0)+"\\n" + "[" + card.loyalty_cost_2 + "]" +(if card.loyalty_cost_2 !="" then ": ") +(if card.level_2_text != "" then card.level_2_text+"\\n" else if contains(paragraph_count(card.rule_text), match:"~") then split_text(match:"\n", card.rule_text).1+"\\n") + "[" + card.loyalty_cost_3 + "]" +(if card.loyalty_cost_3 !="" then ": ") +(if card.level_3_text != "" then card.level_3_text+"\\n" else if contains(paragraph_count(card.rule_text), match:"~~") then split_text(match:"\n", card.rule_text).2+"\\n") + ( if card.loyalty_cost_4 != "" then "[" + card.loyalty_cost_4 + "]" +": ") +(if card.level_4_text != "" then card.level_4_text+"\\n" else if contains(paragraph_count(card.rule_text), match:"~~~") then split_text(match:"\n", card.rule_text).3+"\\n"))) } walker_text_2 := { lackey_bot_mana_filter(lackey_bot_rule_filter((if card.loyalty_cost_5 != "" then "[" + card.loyalty_cost_5 + "]: ") +(if card.loyalty_cost_5 !="" then ": ") +(if card.level_5_text != "" then card.level_5_text+"\\n" else split_text(match:"\n", card.rule_text_2).0)+"\\n" + "[" + card.loyalty_cost_6 + "]" +(if card.loyalty_cost_6 !="" then ": ") +(if card.level_6_text != "" then card.level_6_text+"\\n" else if contains(paragraph_count(card.rule_text_2), match:"~") then split_text(match:"\n", card.rule_text_2).1+"\\n") + "[" + card.loyalty_cost_7 + "]" +(if card.loyalty_cost_7 !="" then ": ") +(if card.level_7_text != "" then card.level_7_text+"\\n" else if contains(paragraph_count(card.rule_text_2), match:"~~") then split_text(match:"\n", card.rule_text_2).2+"\\n") + ( if card.loyalty_cost_8 != "" then "[" + card.loyalty_cost_8 + "]" +": ") +(if card.level_8_text != "" then card.level_8_text+"\\n" else if contains(paragraph_count(card.rule_text_2), match:"~~~") then split_text(match:"\n", card.rule_text_2).3+"\\n"))) } apos_fix := replace@(match:"’", replace:"'") use_token := { contains(card.shape, match:"token") or contains(card.shape, match:"emblem") } search_code := { (if card.rarity == "masterpiece" then "MPS_" else if card.rarity == "special" and not use_bonus() then "PRO_" else if use_token() then "TKN_" else "") + fixed_set_code() } use_bonus := {card.rarity == "special" and options.special_usage == "bonus" } rarity_name := { if contains(fixed_set_code(), match:"MPS") or card.rarity == "masterpiece" then "Masterpiece" else if use_bonus() then "Bonus" else if card.rarity == "special" then "Promo" else if use_token() then "Token" else if card.rarity == "mythic rare" then "M" else if card.rarity == "rare" then "R" else if card.rarity == "uncommon" then "U" else if card.rarity == "common" then "C" else "L" } lb_rarity_code := { if use_token() or fixed_set_code() != "MPS_MSE" then "*" + fixed_set_code() + " " + rarity_name() + "*" else "*MSEM Champion*" } add_token_filter := filter_text@(match:"!addtoken [^\n!]+") add_token_grabber := replace@(match:"!addtoken ", replace:"") replace_token_filter := filter_text@(match:"!replacetoken [^\n!]+") replace_token_grabber := replace@(match:"!replacetoken ", replace:"") token_tag_filter := filter_text@(match:"!tokentag [^\n!]+") token_tag_grabber := replace@(match:"!tokentag ", replace:"") token_scripts := { add_token_argument := add_token_grabber(add_token_filter(card.notes)) replace_token_argument := replace_token_grabber(replace_token_filter(card.notes)) token_tag_argument := token_tag_grabber(token_tag_filter(card.notes)) output := "" if add_token_argument != "" then output := output + "\"aa\": \"" + add_token_argument + "\"" + (if replace_token_argument != "" or token_tag_argument != "" then ", " else "") if replace_token_argument != "" then output := output + "\"rr\": \"" + replace_token_argument + "\"" + (if token_tag_argument != "" then ", " else "") if token_tag_argument != "" then output := output + "\"t\": \"" + token_tag_argument + "\"" if output != "" then output := "\"tokenscripts\": \{" + output + "\}, " output } write_normal:= {" \"" + (if hidden_name() != "" then hidden_name() else break_cleaner(apos_fix(database_name()))) + "_" + search_code() + "\": \{" + "\"fullName\": \"" + break_cleaner(apos_fix(database_name())) + "\", " + ( if card.alias != "" then "\"cardName\": \"" + break_cleaner(card.alias) + "\", " + "\"alias\": \"" + break_cleaner(remove_tags(card.name)) + "\", " else "\"cardName\": \"" + break_cleaner(remove_tags(card.name)) + "\", " ) + "\"manaCost\": \"" + mana_script(card.casting_cost) + "\", " + "\"typeLine\": \"" + break_cleaner(card.type) + "\", " + "\"rarityLine\": \"" + lb_rarity_code() + "\", " + "\"rulesText\": \"" + (if card.special_text != "" then lackey_bot_rule_filter(text_script(lackey_bot_mana_filter(card.special_text))) else if card.shape == "leveler" then lackey_bot_mana_filter(lackey_bot_rule_filter(leveler_text())) else if card.loyalty != "" then walker_text() else lackey_bot_rule_filter(text_script(lackey_bot_mana_filter(card.rule_text)))) + "\", " + "\"flavorText\": \"" + flavor_script(card.flavor_text) + "\", " + "\"power\": " + (if card.power == "*" then "\"★\"" else if card.power == "" then "\"\"" else if (to_number(card.power) or else false != card.power) then "\"" + card.power + "\"" else card.power) + ", " + "\"toughness\": " + (if card.toughness == "*" then "\"★\"" else if card.toughness == "" then "\"\"" else if (to_number(card.toughness) or else false != card.toughness) then "\"" + card.toughness + "\"" else card.toughness) + ", " + "\"loyalty\": " + (if (to_number(card.loyalty) or else false != card.loyalty) then "\"" + card.loyalty + "\"" else card.loyalty) + ", " + "\"color\": \"" + (if contains(card.super_type, match:"Land") then "" else indicator_color_name(card.card_color)) + "\", " + "\"cmc\": " + cmc(card.casting_cost) + ", " + "\"cardType\": \"" + type_trim(card.super_type) + "\", " + (if contains(card.shape, match: "split") or contains(card.shape, match:"double") or contains(card.shape, match:"adventure") or contains(card.shape, match:"aftermath") then secondCard()) + "\"rarity\": \"" + (if rarity_name() == "Token" then "token" else if rarity_name() == "Bonus" then "bonus" else if rarity_name() == "Masterpiece" then "masterpiece" else card.rarity) + "\", " + "\"shape\": \"" + (if contains(card.shape, match: "adventure") then "adventure" else if contains(card.shape, match: "aftermath") or contains(card.shape, match: "split") then "split" else if contains(card.shape, match:"double") then "doubleface" else "normal") + "\", " + "\"setID\": \"" + (if use_token() then "tokens" else fixed_set_code()) + "\", " + "\"cardID\": \"" + (if use_token() then fixed_set_code() else "") + corrected_card_number() + "\", " + "\"designer\": \"" + pull_designer() + "\", " + "\"script\": " + forced_script() + ", " + "\"notes\": " + card_note_array() + ", " + token_scripts() + (if hidden_name() != "" then "\"hidden\": \"" + hidden_name() + "\"," else "") + (if link_name() != "" then "\"link\": \"" + link_name() + "\"," else "") + (if patch_note() != "" then "\"patchNote\": \"" + patch_note() + "\"," else "") + "\"artist\": \"" + break_cleaner(quote_replace(card.illustrator)) + (if contains(card.shape, match: "split") or contains(card.shape, match:"double") and card.illustrator != card.illustrator_2 and card.illustrator_2 != "" then "\", \"artist2\": \"" + quote_replace(break_cleaner(card.illustrator_2))) + "\"\},\n" } write_command:= {" \"" + apos_fix(database_name()) + "_" + search_code() + "\": \{" + "\"fullName\": \"" + apos_fix(database_name()) + "\", " + "\"cardName\": \"" + remove_tags(card.name) + "\", " + "\"manaCost\": \"\", " + "\"typeLine\": \"\", " + "\"rarityLine\": \"\", " + "\"rulesText\": \"" + (if card.loyalty != "" then walker_text() else lackey_bot_rule_filter(text_script(lackey_bot_mana_filter(card.rule_text)))) + "\", " + "\"flavorText\": \"\", " + "\"power\": \"\", " + "\"toughness\": \"\", " + "\"loyalty\": \"\", " + "\"color\": \"\", " + "\"cmc\": \"\", " + "\"cardType\": \"\", " + "\"rarity\": \"\", " + "\"shape\": \"normal\", " + "\"setID\": \"BOT\", " + "\"cardID\": \"\"\},\n" } secondCard := { ( if card.alias_2 != "" then "\"cardName2\": \"" + break_cleaner(card.alias_2) + "\", " + "\"alias2\": \"" + break_cleaner(remove_tags(card.name_2)) + "\", " else "\"cardName2\": \"" + break_cleaner(remove_tags(card.name_2)) + "\", " ) + "\"manaCost2\": \"" + mana_script(card.casting_cost_2) + "\", " + "\"typeLine2\": \"" + break_cleaner(card.type_2) + "\", " + "\"rarityLine2\": \"" + lb_rarity_code() + "\", " + "\"rulesText2\": \"" + (if card.special_text_2 != "" then lackey_bot_rule_filter(text_script(lackey_bot_mana_filter(card.special_text_2))) else if card.loyalty_2 != "" then walker_text_2() else lackey_bot_rule_filter(text_script(lackey_bot_mana_filter(card.rule_text_2)))) + "\", " + "\"flavorText2\": \"" + flavor_script(card.flavor_text_2) + "\", " + "\"power2\": " + (if card.power_2 == "*" then "\"★\"" else if card.power_2 == "" then "\"\"" else if (to_number(card.power_2) or else false != card.power_2) then "\"" + card.power_2 + "\"" else card.power_2) + ", " + "\"toughness2\": " + (if card.toughness_2 == "*" then "\"★\"" else if card.toughness_2 == "" then "\"\"" else if (to_number(card.toughness_2) or else false != card.toughness_2) then "\"" + card.toughness_2 + "\"" else card.toughness_2) + ", " + "\"loyalty2\": " + (if (to_number(card.loyalty_2) or else false != card.loyalty_2) then "\"" + card.loyalty_2 + "\"" else card.loyalty_2) + ", " + "\"color2\": \"" + (if contains(card.super_type, match:"Land") then "" else indicator_color_name(card.card_color_2)) + "\", " + "\"cmc2\": " + cmc(card.casting_cost_2) + ", " + "\"cardType2\": \"" + type_trim(card.super_type_2) + "\", " } write_update := { if not export_me() then "" else write_normal() } ####################################write_update := { if options.update and not contains(card.notes, match:"!alter") then "" else write_normal() } write_cards := to_text(for each card in cards do write_update()) clean_cards := replace@(match:",\n$", replace: "\n") +replace@(match:"’", replace:"'") ####################################to_string("\{\n"+clean_cards(write_cards+"THATSALLF0LKS") +"}") file_name := { if options.image_name == "card number" then (if token_export() or fixed_set_code() == "MSEMAR" or card_name() == "Glory Counter" or card_name() == "Idol" or card_name() == "Morph" or card_name() == "Manifest" or card_name() == "Shimmer" or card_name() == "Submerge" then fixed_set_code()+corrected_card_number() else corrected_card_number() ) +".jpg" else dfc_splitter_name()+".jpg" } write_images := if options.export_images == "no" then "" else for each card in cards do if not export_me() then "" else write_image_file(card, directory: "{fixed_set_code()}", file:file_name(), width: image_export_width(), height: image_export_height()) to_string("\{\n"+clean_cards(write_cards) +"}")