Skip to content
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

Re-add missing '/' separator in <pt> after b282df2e27 #4747

Merged
merged 1 commit into from
Feb 8, 2023

Conversation

Elarnon
Copy link
Contributor

@Elarnon Elarnon commented Feb 8, 2023

Related Ticket(s)

Short roundup of the initial problem

In b282df2 (#4728) the logic for creating values was updated to avoid adding a final slash after an existing power value and missing toughness value. This works by setting the ptSeparator to an empty string when either the power or the toughness is undefined. However, due to the ptSeparator variable being scoped out of the for loop, this causes all remaining cards to have an empty string as a separator, ending up with values of e.g. 21 instead of 2/1.

Moreover, the implementation from #4728 is ambiguous in the case of a card having a toughness value but no power value: in that situation, it creates a entry with the toughness value and no separator, which is not a good idea since it is not possible to know if 2 means power 2 and no toughness, or no power and toughness 2 (Cockatrice takes the first interpretation).

What will change with this Pull Request?

Oracle no longer generates incorrect values with a missing separator. The value is now one of the following:

  1. A regular P/T value when the card has power and toughness
  2. A simplified P value when the card has power but no toughness
  3. A simplified /T value when the card has toughness but no power
  4. Absent when the card has neither power nor toughness

Note that, as far as I can tell, Cockatrice seems to (incorrectly, IMO) ignore the initial slash if present in Player::parsePT, and treat /T as a power value. However that is a separate issue: this patch is concerned with Oracle and ensuring proper values in cards.xml, not with how Cockatrice interprets those values.

In b282df2 (Cockatrice#4728) the logic for
creating <pt> values was updated to avoid adding a final slash after an
existing power value and missing toughness value. This works by setting
the ptSeparator to an empty string when either the power or the
toughness is undefined. However, due to the ptSeparator variable being
scoped out of the `for` loop, this causes all remaining cards to have an
empty string as a separator, ending up with <pt> values of e.g. 21
instead of 2/1.

Moreover, the implementation from Cockatrice#4728 is ambiguous in the case of a
card having a toughness value but no power value: in that situation, it
creates a <pt> entry with the toughness value and no separator, which is
not a good idea since it is not possible to know if <pt>2</pt> means
power 2 and no toughness, or no power and toughness 2 (Cockatrice takes
the first interpretation).

To avoid ambiguities, the <pt> value is now one of:

 1. A regular P/T value when the card has power and toughness
 2. A simplified P value when the card has power but no toughness
 3. A simplified /T value when the card has toughness but no power
 4. Absent when the card has neither power nor toughness

Note that, as far as I can tell, Cockatrice seems to (incorrectly, IMO)
ignore the initial slash if present in Player::parsePT, and treat /T as
a power value. However that is a separate issue: this patch is concerned
with Oracle and ensuring proper values in cards.xml, not with how
Cockatrice interprets those values.
Copy link
Member

@ebbit1q ebbit1q left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was actually planning to simply revert that commit but this is better, thanks.

@ebbit1q ebbit1q merged commit ef38a8b into Cockatrice:master Feb 8, 2023
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.

None yet

2 participants