55 lines
2.6 KiB
Bash
Executable File
55 lines
2.6 KiB
Bash
Executable File
# Only really need to remove sets.*. head/cards get reinitialised anyway, 05 only gets written once so always reinits, and pics basically doesn't change unless it's broken.
|
|
rm -r head.xml cards.xml sets.csv sets.xml 05.ga.xml pics
|
|
|
|
echo '<?xml version="1.0" encoding="UTF-8"?>
|
|
<cockatrice_carddatabase version="4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
<info>
|
|
<author>Zergling_man</author>
|
|
<createdAt>'"`date -Iseconds`"'</createdAt>
|
|
<sourceUrl>https://github.com/ItsSilvie/img.silvie.org/</sourceUrl>
|
|
<sourceVersion>'"`git log | head -n 1 | awk '{ print $2 }'`"'</sourceVersion>
|
|
</info>
|
|
<sets>' > head.xml
|
|
echo '</sets>
|
|
<cards>' > cards.xml
|
|
|
|
for id in `jq -r '.[]|.u' < search.json`; do
|
|
jq -r '" <card>
|
|
<name>"+.name+"</name>
|
|
<text>"+.effect_raw+"</text>
|
|
<prop>"+if .power==null and (.life//.durability)==null then "" else "
|
|
<pt>"+(.power//""|tostring)+"/"+((.life//.durability//"")|tostring)+"</pt>" end+"
|
|
<type>"+({"null":"","false":"Slow ","true":"Fast "}[.speed|tostring])+(.types|join(" "))+" - "+(.subtypes|join(" "))+"</type>
|
|
<maintype>"+.types[0]+"</maintype>
|
|
<cmc>"+((.cost_reserve//.cost_memory)|tostring)+"</cmc>
|
|
<manacost>"+((.cost_reserve//.cost_memory)|tostring)+"</manacost>"+if .elements==["NORM"] then "" else "
|
|
<colors>"+(.elements|map({"NORM":"","WATER":"U","FIRE":"R","WIND":"G","EXALTED":"W","ARCANE":"B","ASTRA":"B","CRUX":"B","EXIA":"B","LUXEM":"B","NEOS":"B","TERA":"B","UMBRA":"B"}[.])|join(""))+"</colors>
|
|
<coloridentity>"+(.elements|map({"NORM":"","WATER":"U","FIRE":"R","WIND":"G","EXALTED":"W","ARCANE":"B","ASTRA":"B","CRUX":"B","EXIA":"B","LUXEM":"B","NEOS":"B","TERA":"B","UMBRA":"B"}[.])|join(""))+"</coloridentity>" end+"
|
|
</prop>
|
|
"+(.editions|map("<set rarity=\""+["common","uncommon","rare","mythic","special","bonus","mythic","mythic","mythic"][.rarity-1]+"\">"+.set.prefix+"</set>")|join("
|
|
"))+"
|
|
<tablerow>"+if (.cost_memory != null) then "1" else "2" end+"</tablerow>
|
|
</card>"' < $id.json >> cards.xml
|
|
IFS=, read set name <<< "`jq -r '.editions[0].set.prefix+","+.name' < $id.json`"
|
|
install -d "pics/$set"
|
|
cp $id.jpg "pics/$set/$name.jpg"
|
|
jq -r '.editions[]|.set|.prefix+","+.name+","+.release_date' < $id.json >> sets.csv
|
|
done
|
|
|
|
cat sets.csv | sort | uniq > sets2.csv
|
|
mv sets2.csv sets.csv
|
|
|
|
while read line; do
|
|
IFS=, read pfx name date <<< "$line"
|
|
echo '<set>
|
|
<name>'"$pfx"'</name>
|
|
<longname>'"$name"'</longname>
|
|
<settype>Grand Archive</settype>
|
|
<releasedate>'"`date -d $date -I`"'</releasedate>
|
|
</set>' >> sets.xml
|
|
done < sets.csv
|
|
|
|
echo '</cards>
|
|
</cockatrice_carddatabase>' >> cards.xml
|
|
|
|
cat head.xml sets.xml cards.xml > 05.ga.xml |