Cockatrice: Old Cockatrice to new Cockatrice XML help for custom MSE sets

Created on 8 Apr 2020  路  6Comments  路  Source: Cockatrice/Cockatrice

I have created a custom MSE set and found the xml template created by MTGAdvent for converting MSE files into xml. Unfortunately, it is for the old xml cockatrice format. I can and am manually entering the cards into the new format, but am wondering if the developers created a template to convert old xml format to new. This would allow me to get around the tedious process of manually entering 500+ cards.

Most helpful comment

Thanks for doing my work for me. I was just in the process of trying to create a macro to do what you were talking about, but was unfamiliar with what needed to be changed.
I salute you sir!

My most humble thanks.

All 6 comments

Better, we created a converter that loads files in the old (3) format and outputs a file in the new (4) format. You should find an executable named "dbconverter" in the folder where you installed cockatrice.
It runs from the commandline, and the syntax is quite simple:

dbconverter <old file.xml> <new file.xml>

First of all: thank you
Second: do i need to search for the folder extension in cmd or will it autofind?

roag.txt

Apologies. I got it figured out. Now my difficulty springs from the old xml file using wrong element tags. Here's the results:
C:\Program Files\Cockatrice>dbconverter roag.xml roagedh.xml
Loading cards from "C:/Program Files/Cockatrice/roag.xml"
[CockatriceXml4Parser] Trying to parse: "C:/Program Files/Cockatrice/roag.xml"
[CockatriceXml4Parser] Parsing failed: wrong element tag "spoiler"
[CockatriceXml3Parser] Trying to parse: "C:/Program Files/Cockatrice/roag.xml"
[CockatriceXml3Parser] Parsing failed: wrong element tag "spoiler"
[CardDatabase] loadCardDatabase(): Path = "C:/Program Files/Cockatrice/roag.xml" Status = 2 Cards = 0 Sets= 0
Saving cards to "C:/Program Files/Cockatrice/roagedh.xml"
What should I do to the original file to make it compatible with the converter?

I changed the tags to fit the old format ( i.e.



)

The results failed citing 'wrong version 3':

C:\Program Files\Cockatrice>dbconverter roag.xml roagEDH.xml

Loading cards from "C:/Program Files/Cockatrice/roag.xml"
[CockatriceXml4Parser] Trying to parse: "C:/Program Files/Cockatrice/roag.xml"
[CockatriceXml4Parser] Parsing failed: wrong version 3
[CockatriceXml3Parser] Trying to parse: "C:/Program Files/Cockatrice/roag.xml"
[CockatriceXml3Parser] Unknown item "cockatrice_carddatabase" , trying to continue anyway
[CardDatabase] loadCardDatabase(): Path = "C:/Program Files/Cockatrice/roag.xml" Status = 0 Cards = 0 Sets= 0
Saving cards to "C:/Program Files/Cockatrice/roagEDH.xml"

C:\Program Files\Cockatrice>

Looks like the file is using an xml that is not even compatible with cockatrice version 3, but maybe we can figure it out how to fix it.
First, as you noticed, it was missing the root <cockatrice_carddatabase version="3"> tag that needs to be added on top and closed on the bottom of the file.
Then , we need to have a <cards> container; we can replace the <spoiler set=""> with it.
Now, each cards is inside a <card> tag, and that's good, but most of the card properties are in a different format and needs manual adjustment:

  • cost becomes manacost
  • rules becomes text
  • type is split in supertype and subtype, we need to merge them into a single definition
  • power and toughness are split, we need to merge these, too
  • the flavor text, illustrator and collector's number can be removed, since cockatrice v3 doesn't support them
  • we need to add the cards to a set. Using the existing "rarity" tag in cards, we modify it into a set definition.

I made the modifications using search and replace on a text editor.
The original looked like this:

<?xml version="1.0" encoding="UTF-8"?>
<spoiler set="">
  <card>
    <name>Coinspinner</name>
    <cost>11</cost>
    <type>
      <supertype>Legendary Artifact</supertype>
      <subtype>Equipment </subtype>
    </type>
    <rarity>M</rarity>
    <rules>Godly (If a permanent or spell has a lesser converted mana cost it cannot target this card in any zone. Any ability or effect from that source is ignored by this card.)
Coinspinner costs 1 less to cast for each artifact your opponents control.
At the end of your turn, a random player gains control of Coinspinner.
If a spell or ability controlled by an opponent would target or destroy equipped creature, you may redirect it to another target. If it can鈥檛 be redirected, exile that spell or ability instead.
Equip 0</rules>
    <flavor></flavor>
    <stats>
      <power></power>
      <toughness></toughness>
    </stats>
    <illustrator></illustrator>
    <number>1/12</number>
  </card>

The result is something like this:

<?xml version="1.0" encoding="UTF-8"?>
<cockatrice_carddatabase version="3">
<cards>
  <card>
    <name>Coinspinner</name>
    <manacost>11</manacost>
    <type>Legendary Artifact - Equipment </type>
    <set rarity="M">MSE</set>
    <text>Godly (If a permanent or spell has a lesser converted mana cost it cannot target this card in any zone. Any ability or effect from that source is ignored by this card.)
Coinspinner costs 1 less to cast for each artifact your opponents control.
At the end of your turn, a random player gains control of Coinspinner.
If a spell or ability controlled by an opponent would target or destroy equipped creature, you may redirect it to another target. If it can鈥檛 be redirected, exile that spell or ability instead.
Equip 0</text>
  </card>

The dbconverter now seems to digest the file correctly:

> dbconverter roag_v3.xml roag_v4.xml
---------------------------------------------
Loading cards from "roag_v3.xml"
[CockatriceXml4Parser] Trying to parse:  "roag_v3.xml"
[CockatriceXml4Parser] Parsing failed: wrong version 3
[CockatriceXml3Parser] Trying to parse:  "roag_v3.xml"
[CardDatabase] loadCardDatabase(): Path = "roag_v3.xml" Status = 0 Cards = 349 Sets= 1
---------------------------------------------
Saving cards to "roag_v4.xml"
---------------------------------------------

Attached you can find the two resulting files, renamed to .txt to overcome a github limitation.

roag_v3.txt
roag_v4.txt

Thanks for doing my work for me. I was just in the process of trying to create a macro to do what you were talking about, but was unfamiliar with what needed to be changed.
I salute you sir!

My most humble thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

micomicoa picture micomicoa  路  5Comments

tooomm picture tooomm  路  6Comments

Gibidinp picture Gibidinp  路  7Comments

tooomm picture tooomm  路  5Comments

dev-id picture dev-id  路  6Comments