magefree / mage

Magic Another Game Engine
http://xmage.today
MIT License
1.9k stars 773 forks source link

[I am wrong] card Double Header - code looks wrong #12472

Closed tiera3 closed 4 months ago

tiera3 commented 4 months ago

I was looking at the code for Double Header.

// When Double Header enters the battlefield, you may return target permanent with a two-word name to its owner’s hand.

And looking at the code to filter for permanents with two-word names, I realised that MDFCs might return false positives.

} else if (input instanceof ModalDoubleFacedCard) { return hasTwoWords(((ModalDoubleFacedCard) input).getLeftHalfCard().getName()) || hasTwoWords(((ModalDoubleFacedCard) input).getRightHalfCard().getName());

It looks like it checks both sides and includes in the filter if either side has Two Words. It should only be checking the side that is currently present on the battlefield. For example, I would expect "Agadeem, the Undercrypt" to return a false positive because "Agadeem's Awakening" is two words. Similarly, I would expect "Cosima, God of the Voyage" to return a false positive because "The Omenkeel" is two words. (However, since "The Omenkeel" is a permanent, it should return a positive when the NightCard side is on the battlefield.)

Also, is all the code for SplitCard redundant since split cards are non-permanents? Or is this needed because a non-permanent card may be put on the battlefield facedown as a morph - but in that case doesn't it have no name, not the name of the actual card? I am not aware of any cards that allow animating an Instant or Sorcery to make it a creature or other permanent.

github-actions[bot] commented 4 months ago

Unable to retrieve information for "(ModalDoubleFacedCard) input).getLeftHalfCard().getName("

Unable to retrieve information for "(ModalDoubleFacedCard) input).getRightHalfCard().getName("

tiera3 commented 4 months ago

Ran a test with Agadeem's Awakening, Barkchannel Pathway // Tidechannel Pathway, and Garruk Relentless // Garruk, the Veil-Cursed and it worked correctly.

JayDi85 commented 4 months ago

It looks like it checks both sides and includes in the filter if either side has Two Words

MDF cards on battlefield are single side by ModalDoubleFacedCardHalf. So input instanceof ModalDoubleFacedCard can catch MDFC in hand and other non-battlefield zone.