-
Notifications
You must be signed in to change notification settings - Fork 16
remove unused token relations #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
That's cool stuff! Did you also check for doubled entries that are not necessarily next to each other for some reason? |
|
because all entries have been sorted they would always be next to each other, so I did not |
|
Wait, why is |
|
I moved the internal token relations to be |
I saw your description in commit 67b20ab regarding that: While we never agreed on a specific way in earlier discussions about related/reverse-related, I like this. Downside is that users can no longer look at the file or a specific token in there and learn about or see all creators at a glance, Now, e.g. an emblem creating tokens will not be listed at the resulting token anymore, but the token will be listed at the emblem. But yeah, as related/reverse-related was not a strict pattern for internal links before... one could not be sure either. In order to describe this kind of information completely in tokens.xml, including both directions of internal relations like the token creating emblem example, doubled information would be needed: Anyway, should be good as is. 👍 |
reverse-related is assumed to only be used for external references to
the xml
related tags should be used for internal links to make this easier and
to avoid certain errors eg the Phyrexian Insect here
the following lazy bash has been used to find these:
\#!/bin/bash
relationrx='<reverse-related([^>]*)>([^<]*)</reverse-related>'
while read -r line; do
if [[ $line =~ $relationrx ]]; then
name="${BASH_REMATCH[2]}"
#args="${BASH_REMATCH[1]}"
if ! grep -F "$name" "$HOME/.local/share/Cockatrice/Cockatrice/cards.xml" -q; then
echo "$name"
fi
fi
done <tokens.xml
the following relations are affected:
Domri, Chaos Bringer (Emblem) is related internally, moved
Ajani, Adversary of Tyrants (Emblem) is related internally, moved
Chief Jim Hopper became Sophina, Spearsage Deserter, moved
Max, the Daredevil became Elmar, Ulvenwald Informant, moved
Will the Wise became Wernog, Rider's Chaplain, moved
"Big Boy Forest Crusher" was a spoiler placeholder, deleted
"Destoroyah, Perfect Lifeform" is called Everquill Phoenix, deleted
"What's Kraken" was a spoiler placeholder, deleted
Liliana, the Last Hope (Emblem) is related internally, moved
Insect Token has been renamed to Phyrexian Insect token before and had its Poison Counter relationship lost, moved
`Snake Token ` is related internally, moved
Obsessed Astronomer was probably a spoiler placeholder?, deleted
"Obosh, With The Leggies" was a spoiler placeholder, deleted
"Gigan, Cyberclaw Terror" is called Gyruda, Doom of Depths, deleted
less lazy script but still bash:
\#!/bin/bash
tag="reverse-related"
relationrx="<$tag([^>]*)>([^<]*)</$tag>"
numberrx='[0-9]+'
declare -A list # associative array
while IFS= read -r line; do
if [[ $line =~ $relationrx ]]; then
yes=1
name="${BASH_REMATCH[2]}"
args="${BASH_REMATCH[1]}"
if [[ $args =~ $numberrx ]]; then
args="$(printf "%03d" "${BASH_REMATCH[0]}")$args"
fi
list[ "$name$args"]="$line"
keys+="
$name$args"
elif [[ $yes ]]; then
# LC_ALL=C determines the sort behavior!
<<<"${keys:1}" LC_ALL=C sort --ignore-case | while read -r key; do
echo "${list[ $key]}"
done
yes=""
list=()
keys=""
echo "$line"
else
echo "$line"
fi
done <tokens.xml | sponge tokens.xml
this also needed a script, because why not:
\#!/bin/bash
while IFS= read -r line; do
if [[ $line == "$last" ]]; then
echo "$line"
fi
last="$line"
done <tokens.xml
fixes #161
I've automated some of the menial tasks in the xml, see the individual commits
most of the changes are purely cosmetic, the only noticeable result to the user is that the phyrexian insect now creates poison counter tokens again