Move to Cockatrice v4 db style (#255)

* cockatrice xml db v4

* bump to v4

* at least make the style consistent

Co-authored-by: ebbit1q <ebbit1q@gmail.com>
This commit is contained in:
tooomm 2022-02-06 02:46:29 +01:00 committed by GitHub
parent bb7980bec2
commit bd910e37de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -208,7 +208,7 @@ def open_header(card_xml_file: IO[Any]) -> None:
:param card_xml_file: Card file path
"""
card_xml_file.write(
"<cockatrice_carddatabase version='3'>\n"
"<cockatrice_carddatabase version='4'>\n"
+ " <!--\n"
+ " Created At: "
+ datetime.datetime.utcnow().strftime("%a, %b %d %Y, %H:%M:%S")
@ -295,6 +295,11 @@ def write_cards(
else:
pow_tough = ""
if "loyalty" in card.keys() and card["loyalty"]:
loyalty = str(card["loyalty"])
else:
loyalty = ""
if "text" in card.keys():
text = card["text"]
else:
@ -343,12 +348,28 @@ def write_cards(
if card["layout"] == "split" or card["layout"] == "aftermath":
continue
set_name, mana_cost, card_cmc, card_type, pow_tough, table_row, text = map(
set_name, mana_cost, card_cmc, card_type, pow_tough, table_row, text, loyalty = map(
xml_escape,
[set_name, mana_cost, card_cmc, card_type, pow_tough, table_row, text],
[set_name, mana_cost, card_cmc, card_type, pow_tough, table_row, text, loyalty],
)
card_xml_file.write("<card>\n")
card_xml_file.write("<name>" + set_name + "</name>\n")
card_xml_file.write("<text>" + text + "</text>\n")
card_xml_file.write("<prop>\n")
if "colors" in card.keys():
for color in card["colors"]:
card_xml_file.write("<color>" + str(color) + "</color>\n")
card_xml_file.write("<type>" + card_type + "</type>\n")
card_xml_file.write("<cmc>" + card_cmc + "</cmc>\n")
card_xml_file.write("<manacost>" + mana_cost + "</manacost>\n")
if pow_tough:
card_xml_file.write("<pt>" + pow_tough + "</pt>\n")
if loyalty:
card_xml_file.write("<loyalty>" + loyalty + "</loyalty>\n")
card_xml_file.write("</prop>\n")
card_xml_file.write(
'<set rarity="'
+ str(card["rarity"])
@ -358,25 +379,10 @@ def write_cards(
+ str(set_code)
+ "</set>\n"
)
card_xml_file.write("<manacost>" + mana_cost + "</manacost>\n")
card_xml_file.write("<cmc>" + card_cmc + "</cmc>\n")
if "colors" in card.keys():
for color in card["colors"]:
card_xml_file.write("<color>" + str(color) + "</color>\n")
if set_name + " enters the battlefield tapped" in text:
card_xml_file.write("<cipt>1</cipt>\n")
card_xml_file.write("<type>" + card_type + "</type>\n")
if pow_tough:
card_xml_file.write("<pt>" + pow_tough + "</pt>\n")
if "loyalty" in card.keys():
card_xml_file.write("<loyalty>" + str(card["loyalty"]) + "</loyalty>\n")
card_xml_file.write("<tablerow>" + table_row + "</tablerow>\n")
card_xml_file.write("<text>" + text + "</text>\n")
card_xml_file.write("</card>\n")