Search in sources :

Example 6 with AdventureCard

use of mage.cards.AdventureCard in project mage by magefree.

the class CopySpellTest method test_SimpleCopy_AdventureCard.

@Test
public void test_SimpleCopy_AdventureCard() {
    AdventureCard sourceCard = (AdventureCard) CardRepository.instance.findCard("Animating Faerie").getCard();
    AdventureCard originalCard = (AdventureCard) CardRepository.instance.findCard("Animating Faerie").getCard();
    prepareZoneAndZCC(originalCard);
    AdventureCard copiedCard = (AdventureCard) currentGame.copyCard(originalCard, null, playerA.getId());
    // main
    Assert.assertNotEquals("main - id must be different", originalCard.getId(), copiedCard.getId());
    Assert.assertEquals("main - rules must be same", originalCard.getRules(), copiedCard.getRules());
    abilitySourceMustBeSame(sourceCard, "main source");
    abilitySourceMustBeSame(originalCard, "main original");
    abilitySourceMustBeSame(copiedCard, "main copied");
    // cardsMustHaveSameZoneAndZCC(originalCard, copiedCard, "main");
    // right (spell)
    Assert.assertNotEquals("right - id must be different", originalCard.getSpellCard().getId(), copiedCard.getSpellCard().getId());
    Assert.assertEquals("right - rules must be same", originalCard.getSpellCard().getRules(), copiedCard.getSpellCard().getRules());
    Assert.assertEquals("right - parent ref", copiedCard.getSpellCard().getParentCard().getId(), copiedCard.getId());
    abilitySourceMustBeSame(originalCard.getSpellCard(), "right original");
    abilitySourceMustBeSame(copiedCard.getSpellCard(), "right copied");
// cardsMustHaveSameZoneAndZCC(originalCard.getSpellCard(), copiedCard.getSpellCard(), "right");
}
Also used : AdventureCard(mage.cards.AdventureCard) Test(org.junit.Test)

Example 7 with AdventureCard

use of mage.cards.AdventureCard in project mage by magefree.

the class WrennAndSixEmblemEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    for (UUID cardId : controller.getGraveyard()) {
        Card card = game.getCard(cardId);
        if (card == null) {
            continue;
        }
        if (card instanceof SplitCard) {
            SplitCardHalf leftHalfCard = ((SplitCard) card).getLeftHalfCard();
            SplitCardHalf rightHalfCard = ((SplitCard) card).getRightHalfCard();
            if (leftHalfCard.isInstantOrSorcery(game)) {
                Ability ability = new RetraceAbility(leftHalfCard);
                ability.setSourceId(cardId);
                ability.setControllerId(leftHalfCard.getOwnerId());
                game.getState().addOtherAbility(leftHalfCard, ability);
            }
            if (rightHalfCard.isInstantOrSorcery(game)) {
                Ability ability = new RetraceAbility(rightHalfCard);
                ability.setSourceId(cardId);
                ability.setControllerId(rightHalfCard.getOwnerId());
                game.getState().addOtherAbility(rightHalfCard, ability);
            }
        }
        if (card instanceof ModalDoubleFacesCard) {
            ModalDoubleFacesCardHalf leftHalfCard = ((ModalDoubleFacesCard) card).getLeftHalfCard();
            ModalDoubleFacesCardHalf rightHalfCard = ((ModalDoubleFacesCard) card).getRightHalfCard();
            if (leftHalfCard.isInstantOrSorcery(game)) {
                Ability ability = new RetraceAbility(leftHalfCard);
                ability.setSourceId(cardId);
                ability.setControllerId(leftHalfCard.getOwnerId());
                game.getState().addOtherAbility(leftHalfCard, ability);
            }
            if (rightHalfCard.isInstantOrSorcery(game)) {
                Ability ability = new RetraceAbility(rightHalfCard);
                ability.setSourceId(cardId);
                ability.setControllerId(rightHalfCard.getOwnerId());
                game.getState().addOtherAbility(rightHalfCard, ability);
            }
        }
        if (card instanceof AdventureCard) {
            // Adventure cards are castable per https://twitter.com/elishffrn/status/1179047911729946624
            card = ((AdventureCard) card).getSpellCard();
        }
        if (!card.isInstantOrSorcery(game)) {
            continue;
        }
        Ability ability = new RetraceAbility(card);
        ability.setSourceId(cardId);
        ability.setControllerId(card.getOwnerId());
        game.getState().addOtherAbility(card, ability);
    }
    return true;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) RetraceAbility(mage.abilities.keyword.RetraceAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) ModalDoubleFacesCard(mage.cards.ModalDoubleFacesCard) RetraceAbility(mage.abilities.keyword.RetraceAbility) ModalDoubleFacesCardHalf(mage.cards.ModalDoubleFacesCardHalf) SplitCardHalf(mage.cards.SplitCardHalf) UUID(java.util.UUID) SplitCard(mage.cards.SplitCard) AdventureCard(mage.cards.AdventureCard) ModalDoubleFacesCard(mage.cards.ModalDoubleFacesCard) AdventureCard(mage.cards.AdventureCard) SplitCard(mage.cards.SplitCard) Card(mage.cards.Card)

Aggregations

AdventureCard (mage.cards.AdventureCard)7 ModalDoubleFacesCard (mage.cards.ModalDoubleFacesCard)5 SplitCard (mage.cards.SplitCard)5 Card (mage.cards.Card)4 Player (mage.players.Player)4 ModalDoubleFacesCardHalf (mage.cards.ModalDoubleFacesCardHalf)3 UUID (java.util.UUID)2 Ability (mage.abilities.Ability)2 SplitCardHalf (mage.cards.SplitCardHalf)2 Test (org.junit.Test)2 ApprovingObject (mage.ApprovingObject)1 MageObjectReference (mage.MageObjectReference)1 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)1 Costs (mage.abilities.costs.Costs)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 FlyingAbility (mage.abilities.keyword.FlyingAbility)1 ForetellAbility (mage.abilities.keyword.ForetellAbility)1 RetraceAbility (mage.abilities.keyword.RetraceAbility)1 CardsImpl (mage.cards.CardsImpl)1 MockCard (mage.cards.mock.MockCard)1