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

Loyalty filter added #3087

Merged

Conversation

Vafthrudnir
Copy link
Contributor

@Vafthrudnir Vafthrudnir commented Feb 6, 2018

Related Ticket(s)

Short roundup of the initial problem

"Loyalty" was missing from the possible options for card filter.

Screenshots

loyalty_filter

Copy link
Member

@tooomm tooomm left a comment

Choose a reason for hiding this comment

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

  • Works as a normal digit filter ✔️
  • Utilizes new relative filter, too ✔️
  • Placed at correct alphabetical position in filter list ✔️

But I have a problem with using <= and <... ❌
>, >=, =, == and only digits are working!

Copy link
Member

@ZeldaZach ZeldaZach left a comment

Choose a reason for hiding this comment

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

So loyalty is technically a string, as there are cards with "X" loyalty. If you want to convert "X" => 0, that's fine with me.

@Vafthrudnir
Copy link
Contributor Author

Vafthrudnir commented Feb 6, 2018

Loyalty is stored as an int value in the code, and what caused this problem is that all non-planeswalker cards are indistinguishable from those with 0 or X loyalty (both are stored as 0).
As I see it there are two ways to solve this problem:

  • Either apply type filtering automatically to planeswalker whenever loyalty is set,
  • or set the default loyalty of all cards to -1, which is updated when a valid loyalty value is read from the cardlist xml

I'd rather choose the second solution due to the runtime we can spare by not having to compare the type of each card to the "Planeswalker" string when loyalty filter is used. What are your opinions?

@ZeldaZach
Copy link
Member

I'd prefer the 2nd option as planeswalker is tied to magic. If the field doensn't exist it should be easy to say it's a negative.

@tooomm
Copy link
Member

tooomm commented Feb 6, 2018

Hmm, we handle X loyalty planeswalkers wrong right now - they are tagged as 0 loyalty:

        <card>
            <name>Nissa, Steward of Elements</name>
            <set rarity="Mythic Rare" muId="426906" num="204">AKH</set>
            <color>U</color>
            <color>G</color>
            <manacost>XGU</manacost>
            <cmc>2</cmc>
            <type>Legendary Planeswalker — Nissa</type>
            <tablerow>1</tablerow>
            <text>+2: Scry 2.
0: Look at the top card of your library. If it's a land card or a creature card with converted mana cost less than or equal to the number of loyalty counters on Nissa, Steward of Elements, you may put that card onto the battlefield.
−6: Untap up to two target lands you control. They become 5/5 Elemental creatures with flying and haste until end of turn. They're still lands.</text>
            <loyalty>0</loyalty>
        </card>

The root issue is from upstream: mtgjson/mtgjson#320

I prefer to not do any shenanigans here. Can we make the loyalty filters support strings already?
That way once mtgjson fixes things, it'll work in all clients immediately.
It would return no result if somebody searches for Loyalty = X right now, that shouldn't be too bad?
There is only one single X-loyalty planeswalker as of now...

@Vafthrudnir
Copy link
Contributor Author

Vafthrudnir commented Feb 7, 2018

If we don't do any shenanigans here, three planeswalkers will be left out when we filter to loyalty=0:

  • Arlinn, Embraced by the Moon
  • Garruk, the Veil-Cursed
  • Nissa, Steward of Elements

I think it would be nice to remain consistent with the handling of X values: if they mean 0 in CMC, they should mean 0 here as well - or is it totally different?
Regarding the other two, they probably really shouldn't show up in this query, since their loyalty is technically not 0 but undefined.

@ZeldaZach
Copy link
Member

I'm happy with this PR as-is. When MTGJSON v4 is released, I'll give ample notice to put a change in. Maybe we can leave a TODO alert to update this when that happens.

@tooomm
Copy link
Member

tooomm commented Feb 7, 2018

I think it would be nice to remain consistent with the handling of X values: if they mean 0 in CMC, they should mean 0 here as well - or is it totally different?

Planeswalker with Loyalty = 0 don't/can't exist 😉
But I understand your point.

For the back-sides of the transform-planeswalkers (Arlinn, Embraced by the Moon and Garruk, the Veil-Cursed) shouldn't they have no Loyalty at all rules wise?
mtgjson has that right btw - so this should end up in a new oracle parsing issue maybe.
But maybe we just add that key to every planeswalker card? And these are planeswalkers on both sides... unlike these DFC planeswalkers from Origins.
For Kytheon, Hero of Akros we corractly have no loyalty value in cards.xml

@Vafthrudnir
Copy link
Contributor Author

Vafthrudnir commented Feb 7, 2018

Ok, I made loyalty into a string, to handle X values whenever we'll have any.
I also checked the mtgjson database, and it indeed shows no loyalty value for the two back-sided planeswalkers, and shows null instead of 0 for Nissa - I think the parsing itself should be modified to transform this to X as a separate issue.
If you agree I'd leave this PR as is, and leave the rest to the json parsing issue.

Copy link
Member

@tooomm tooomm left a comment

Choose a reason for hiding this comment

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

Looks good now. The <= etc. work again for me, too.

If we do nothing on our end and mtgjson changes their value from "loyalty": null to "loyalty": "X", Oracle then parses that correctly and stores the X as <loyalty>X</loyalty>.
Just simulated that. 👍

Only issue: relative filtering wouldn't work to find Nissa yet.
You have to filter loyalty for exactly x or X.

Copy link
Member

@ZeldaZach ZeldaZach left a comment

Choose a reason for hiding this comment

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

I'm good here

@ZeldaZach ZeldaZach merged commit a0d6a34 into Cockatrice:master Feb 7, 2018
@Vafthrudnir Vafthrudnir deleted the feature/3084_loyalty_filter branch February 7, 2018 16:33
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

3 participants