Manifest abilities - improved combo support for MDF, split and other cards (related to #10803, part of #11873)

This commit is contained in:
Oleg Agafonov 2024-03-02 14:49:17 +04:00
parent 6cd8359fbd
commit 11ddfa0087
5 changed files with 136 additions and 9 deletions

View file

@ -15,6 +15,7 @@ import mage.abilities.effects.common.InfoEffect;
import mage.abilities.keyword.WardAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.ModalDoubleFacedCard;
import mage.cards.repository.TokenInfo;
import mage.cards.repository.TokenRepository;
import mage.constants.*;
@ -31,6 +32,9 @@ import java.util.UUID;
/**
* Support different face down types: morph/manifest and disguise/cloak
* <p>
* WARNING, if you use it custom effect then must create it for left side card,
* not main (see findDefaultCardSideForFaceDown)
*
* <p>
* This effect lets the card be a 2/2 face-down creature, with no text, no name,
@ -334,4 +338,21 @@ public class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl {
}
}
/**
* There are cards with multiple sides like MDFC, but face down must use only main/left side all the time.
* So try to find that side.
*/
public static Card findDefaultCardSideForFaceDown(Game game, Card card) {
// rules example:
// If a double-faced card is manifested, it will be put onto the battlefield face down. While face down,
// it can't transform. If the front face of the card is a creature card, you can turn it face up by paying
// its mana cost. If you do, its front face will be up.
if (card instanceof ModalDoubleFacedCard) {
// only MDFC uses independent card sides on 2024
return ((ModalDoubleFacedCard) card).getLeftHalfCard();
} else {
return card;
}
}
}

View file

@ -58,10 +58,6 @@ import java.util.Set;
* 701.34g TODO: need support it
* If a manifested permanent thats represented by an instant or sorcery card would turn face up, its controller
* reveals it and leaves it face down. Abilities that trigger whenever a permanent is turned face up wont trigger.
* <p>
* 701.34g
* If a manifested permanent thats represented by an instant or sorcery card would turn face up, its controller
* reveals it and leaves it face down. Abilities that trigger whenever a permanent is turned face up wont trigger.
*
* @author LevelX2, JayDi85
*/
@ -123,16 +119,19 @@ public class ManifestEffect extends OneShotEffect {
// prepare face down effect for battlefield permanents
// TODO: need research - why it add effect before move?!
for (Card card : cardsToManifest) {
Card battlefieldCard = BecomesFaceDownCreatureEffect.findDefaultCardSideForFaceDown(game, card);
// search mana cost for a face up ability (look at face side of the double side card)
ManaCosts manaCosts = null;
if (card.isCreature(game)) {
manaCosts = card.getSpellAbility() != null ? card.getSpellAbility().getManaCosts() : null;
if (battlefieldCard.isCreature(game)) {
manaCosts = battlefieldCard.getSpellAbility() != null ? battlefieldCard.getSpellAbility().getManaCosts() : null;
if (manaCosts == null) {
manaCosts = new ManaCostsImpl<>("{0}");
}
}
// zcc + 1 for use case with Rally the Ancestors (see related test)
MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game);
MageObjectReference objectReference = new MageObjectReference(battlefieldCard.getId(), battlefieldCard.getZoneChangeCounter(game) + 1, game);
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
}
@ -140,13 +139,16 @@ public class ManifestEffect extends OneShotEffect {
// TODO: possible buggy for multiple cards, see rule 701.34e - it require manifest one by one (card to check: Omarthis, Ghostfire Initiate)
manifestPlayer.moveCards(cardsToManifest, Zone.BATTLEFIELD, source, game, false, true, false, null);
for (Card card : cardsToManifest) {
Permanent permanent = game.getPermanent(card.getId());
Card battlefieldCard = BecomesFaceDownCreatureEffect.findDefaultCardSideForFaceDown(game, card);
Permanent permanent = game.getPermanent(battlefieldCard.getId());
if (permanent != null) {
// TODO: why it set manifested here (face down effect doesn't work?!)
// TODO: permanent already has manifested status, so code can be deleted later
// TODO: add test with battlefield trigger/watcher (must not see normal card, must not see face down status without manifest)
permanent.setManifested(true);
} else {
// TODO: looks buggy, card can't be moved to battlefield, but face down effect already active
// or it can be face down on another move to battalefield
}
}

View file

@ -56,6 +56,12 @@ public class PermanentCard extends PermanentImpl {
goodForBattlefield = false;
}
}
// face down cards allows in any forms (only face up restricted for non-permanents)
if (card.isFaceDown(game)) {
goodForBattlefield = true;
}
if (!goodForBattlefield) {
throw new IllegalArgumentException("Wrong code usage: can't create permanent card from split or mdf: " + card.getName());
}