Skip to content

Conversation

@ebbit1q
Copy link
Member

@ebbit1q ebbit1q commented Jun 16, 2022

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

@tooomm
Copy link
Contributor

tooomm commented Jun 16, 2022

That's cool stuff!
Looks like you tackled #161 in here as well.

Did you also check for doubled entries that are not necessarily next to each other for some reason?

@ebbit1q
Copy link
Member Author

ebbit1q commented Jun 16, 2022

because all entries have been sorted they would always be next to each other, so I did not

@Psithief
Copy link
Contributor

Psithief commented Jun 25, 2022

Wait, why is <related> for the RG Beast preferred over the <reverse-related> on the emblem? I'd have preferred not to repeat the spaces in the Beast token's name more than once in the file.

@ebbit1q
Copy link
Member Author

ebbit1q commented Jun 26, 2022

I moved the internal token relations to be <related> instead of <reverse-related> for consistency, this way all <reverse-related> tags refer to the cards.xml

@tooomm
Copy link
Contributor

tooomm commented Jun 29, 2022

I moved the internal token relations to be <related> instead of <reverse-related> for consistency, this way all <reverse-related> tags refer to the cards.xml

I saw your description in commit 67b20ab regarding that:

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

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:
Emblem (related) --> Token // Token (reverse-related) --> Emblem

Anyway, should be good as is. 👍

ebbit1q added 4 commits July 1, 2022 20:23
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
@ebbit1q ebbit1q merged commit 589b278 into Cockatrice:master Jul 1, 2022
@ebbit1q ebbit1q deleted the bikeshedding branch July 1, 2022 18:24
@ebbit1q ebbit1q mentioned this pull request Jul 4, 2022
@tooomm tooomm mentioned this pull request Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Funny alternative names

3 participants