Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mse version: 0.3.8
- short name: Cockatrice
- full name: Cockatrice Exporter
- position hint: 006
- icon: icon.png
- version: 2013-01-27
- installer group: magic/Export/cockatrice
- depends on:
- package: magic.mse-game
- version: 2009-07-23
- game: magic
- file type: *.xml|*.xml|*.*|*.*
- # By LtEntropy
- # Written by modifying the forum export template
- # Modified code which was based on code by Idle Muse, Innuendo and Seeonee
- option field:
- type: text
- name: setcode
- description: Enter the setcode (ie SOM, DKA, RTR etc)
- option field:
- type: text
- name: longname
- description: Enter the set name (ie Scars of Mirrodin, Return to Ravnica etc)
- script:
- # Formats rules text w/ only italic tags.
- forum_rules_filter_plain := replace@(match:"[(]", replace:"[i](")+
- replace@(match:"[)]", replace: ")[/i]")
- # Count the number of paragraphs to detect number of walker abilities.
- paragraph_count := replace@(match:"\n", replace:"•")+
- filter_text@(match:"•")
- write_normal := {
- "\n\<card>"
- +"\n\<name>"+card.name+"\</name>"
- +"\n\<set>"+options.setcode+"\</set>"
- +"\n\<manacost>"+card.casting_cost+"\</manacost>"
- +"\n\<type>"+card.type+"\</type>"
- +"\n\<pt>"+card.pt+"\</pt>"
- +"\n\<tablerow>1\</tablerow>"
- +"\n\<text>"+card.rule_text+"\</text>"
- +"\n\</card>\n"
- }
- write_walker := {
- "\n\<card>"
- +"\n\<name>"+card.name+"\</name>"
- +"\n\<set>"+options.setcode+"\</set>"
- +"\n\<manacost>"+card.casting_cost+"\</manacost>"
- +"\n\<type>"+card.type+"\</type>"
- +"\n\<pt>"+card.pt+"\</pt>"
- +"\n\<tablerow>1\</tablerow>"
- +"\n\<loyalty>"+card.loyalty+"\</loyalty>"
- +"\n\<text>"
- # The First Ability
- +"\n"+card.loyalty_cost_1
- +(if card.loyalty_cost_1 !="" then ": ")
- +forum_rules_filter_plain(split_text(match:"\n", card.rule_text).0)
- # The Second Ability
- +(if contains(paragraph_count(card.rule_text), match:"•") then "\n")
- +card.loyalty_cost_2
- +(if card.loyalty_cost_2 !="" then ": ")
- +(if contains(paragraph_count(card.rule_text), match:"•") then forum_rules_filter_plain(split_text(match:"\n", card.rule_text).1))
- # The Third Ability
- +(if contains(paragraph_count(card.rule_text), match:"••") then "\n")
- +card.loyalty_cost_3
- +(if card.loyalty_cost_3 !="" then ": ")
- +(if contains(paragraph_count(card.rule_text), match:"••") then forum_rules_filter_plain(split_text(match:"\n", card.rule_text).2))
- # The Fourth Ability
- +(if contains(paragraph_count(card.rule_text), match:"•••") then "\n")
- +card.loyalty_cost_4
- +(if card.loyalty_cost_4 !="" then ": ")
- +(if contains(paragraph_count(card.rule_text), match:"•••") then forum_rules_filter_plain(split_text(match:"\n", card.rule_text).3))
- +"\n\</text>"
- +"\n\</card>\n"
- }
- write_leveler := {
- "\n\<card>"
- +"\n\<name>"+card.name+"\</name>"
- +"\n\<set>"+options.setcode+"\</set>"
- +"\n\<manacost>"+card.casting_cost+"\</manacost>"
- +"\n\<type>"+card.type+"\</type>"
- +"\n\<pt>"+card.pt+"\</pt>"
- +"\n\<tablerow>1\</tablerow>"
- +"\n\<text>"
- # The First Textbox
- +"\n"+forum_rules_filter_plain(card.rule_text)
- +(if card.pt !="" then " (")+card.pt+")"
- # The Second Textbox
- +"\n[LEVEL "+card.level_1+"]: "
- +forum_rules_filter_plain(card.rule_text_2)
- +(if card.pt_2 !="" then " (")+card.pt_2+")"
- # The Third Textbox
- +"\n"+(if card.level_2 !="" then "[LEVEL "+card.level_2+"]: ")
- +forum_rules_filter_plain(card.rule_text_3)
- +(if card.pt_3 !="" then " (")+card.pt_3+")"
- +"\n\</text>"
- +"\n\</card>\n"
- }
- write_split := {
- "\n\<card>"
- +"\n\<name>"+card.name+" // "+card.name_2+"\</name>"
- +"\n\<set>"+options.setcode+"\</set>"
- +"\n\<manacost>"+card.casting_cost+"\</manacost>"
- +"\n\<type>"+card.type+"\</type>"
- +"\n\<pt>"+card.pt+"\</pt>"
- +"\n\<tablerow>1\</tablerow>"
- +"\n\<text>"+card.rule_text_2+"\n---\n"+card.rule_text_2+"\</text>"
- +"\n\</card>\n"
- }
- write_flip := {
- "\n\<card>"
- +"\n\<name>"+card.name+"\</name>"
- +"\n\<set>"+options.setcode+"\</set>"
- +"\n\<manacost>"+card.casting_cost+"\</manacost>"
- +"\n\<type>"+card.type+"\</type>"
- +"\n\<pt>"+card.pt+"\</pt>"
- +"\n\<tablerow>1\</tablerow>"
- +"\n\<text>"+card.rule_text+"\n---\n"+card.rule_text_2+"\</text>"
- +"\n\</card>\n"
- +"\n\<card>"
- +"\n\<name>"+card.name_2+"\</name>"
- +"\n\<set>"+options.setcode+"\</set>"
- +"\n\<manacost>"+card.casting_cost_2+"\</manacost>"
- +"\n\<type>"+card.type_2+"\</type>"
- +"\n\<pt>"+card.pt_2+"\</pt>"
- +"\n\<tablerow>1\</tablerow>"
- +"\n\<text>"+card.rule_text_2+"\n---\n"+card.rule_text+"\</text>"
- +"\n\</card>\n"
- }
- write_card := { if contains(card.shape, match:"token") or contains(card.shape, match:"rulestip") then ""
- else if contains(card.shape, match:"split") then write_split()
- else if card.name_2 != "" then write_flip()
- else if card.loyalty != "" then write_walker()
- else if contains(card.shape, match:"leveler") then write_leveler()
- else write_normal()
- }
- write_cards := to_text(for each card in sort_list(cards, order_by: {input.card_number}) do write_card())
- to_string("<?xml version='1.0' encoding='UTF-8'?>\n"
- +"<cockatrice_carddatabase version='2'>\n"
- +"<sets>\n"
- +"<set>\n"
- +"<name>"+options.setcode+"</name>\n"
- +"<longname>"+options.longname+"</longname>\n"
- +"</set>\n"
- +"</sets>\n"
- +"<cards>\n"+write_cards+"\n"
- +"</cards>\n"
- +"</cockatrice_carddatabase>\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement