Search in sources :

Example 31 with PermanentToken

use of mage.game.permanent.PermanentToken in project mage by magefree.

the class ProgenitorMimicTest method testCloneTriggered.

/**
 * Tests triggers working on both sides after Clone coming onto battlefield
 */
@Test
public void testCloneTriggered() {
    addCard(Zone.BATTLEFIELD, playerA, "Runeclaw Bear", 1);
    addCard(Zone.BATTLEFIELD, playerA, "Forest", 4);
    addCard(Zone.HAND, playerB, "Progenitor Mimic");
    addCard(Zone.BATTLEFIELD, playerB, "Island", 3);
    addCard(Zone.BATTLEFIELD, playerB, "Forest", 3);
    castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Progenitor Mimic");
    setStopAt(4, PhaseStep.END_TURN);
    execute();
    assertLife(playerA, 20);
    assertLife(playerB, 20);
    assertPermanentCount(playerA, "Runeclaw Bear", 1);
    assertPermanentCount(playerB, "Runeclaw Bear", 2);
    int tokens = 0;
    int nonTokens = 0;
    for (Permanent permanent : currentGame.getBattlefield().getAllPermanents()) {
        if (permanent.getControllerId().equals(playerB.getId())) {
            if (permanent.isCreature(currentGame)) {
                if (permanent instanceof PermanentToken) {
                    tokens++;
                } else {
                    nonTokens++;
                }
            }
        }
    }
    Assert.assertEquals("Only one non token permanent ", 1, nonTokens);
    Assert.assertEquals("Only one token permanent ", 1, tokens);
}
Also used : Permanent(mage.game.permanent.Permanent) PermanentToken(mage.game.permanent.PermanentToken) Test(org.junit.Test)

Example 32 with PermanentToken

use of mage.game.permanent.PermanentToken in project mage by magefree.

the class ProgenitorMimicTest method testTwoMimic.

/**
 * If you have Progenitor Mimic copy a creature it gets all of the abilities
 * plus "At the beginning of upkeep if this creature isn't a token, put a
 * token that's a copy of this creature". Up to this point everything works
 * correctly.
 *
 * If you then summon another mimic and have it be a copy of the first mimic
 * it should have "At the beginning of upkeep if this creature isn't a
 * token, put a token that's a copy of this creature" two times. The second
 * mimic would then make two copies and the first mimic would make one copy
 * every turn. Right now the second mimc only makes one copy per turn.
 *
 * 706.9a Some copy effects cause the copy to gain an ability as part of the
 * copying process. This ability becomes part of the copiable values for the
 * copy, along with any other abilities that were copied. Example: Quirion
 * Elves enters the battlefield and an Unstable Shapeshifter copies it. The
 * copiable values of the Shapeshifter now match those of the Elves, except
 * that the Shapeshifter also has the ability “Whenever a creature enters
 * the battlefield, Unstable Shapeshifter becomes a copy of that creature
 * and gains this ability.” Then a Clone enters the battlefield as a copy of
 * the Unstable Shapeshifter. The Clone copies the new copiable values of
 * the Shapeshifter, including the ability that the Shapeshifter gave itself
 * when it copied the Elves.
 */
@Test
public void testTwoMimic() {
    addCard(Zone.BATTLEFIELD, playerA, "Runeclaw Bear", 1);
    addCard(Zone.BATTLEFIELD, playerA, "Plains", 3);
    // Return target permanent you control to its owner's hand. You gain 4 life.
    addCard(Zone.HAND, playerA, "Narrow Escape");
    // You may have Progenitor Mimic enter the battlefield as a copy of any creature on the battlefield except
    // it gains "At the beginning of your upkeep, if this creature isn't a token, put a token onto the battlefield
    // that's a copy of this creature."
    addCard(Zone.HAND, playerB, "Progenitor Mimic", 2);
    addCard(Zone.BATTLEFIELD, playerB, "Island", 3);
    addCard(Zone.BATTLEFIELD, playerB, "Forest", 3);
    castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Progenitor Mimic");
    setChoice(playerB, "Runeclaw Bear");
    castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Narrow Escape", "Runeclaw Bear");
    // Begin of upkeep 1 token added
    castSpell(4, PhaseStep.PRECOMBAT_MAIN, playerB, "Progenitor Mimic");
    setChoice(playerB, "Runeclaw Bear");
    // Begin of upkeep 3 tokens added
    setStopAt(6, PhaseStep.POSTCOMBAT_MAIN);
    execute();
    assertLife(playerA, 24);
    assertLife(playerB, 20);
    assertGraveyardCount(playerA, "Narrow Escape", 1);
    assertPermanentCount(playerA, "Runeclaw Bear", 0);
    assertHandCount(playerA, "Runeclaw Bear", 1);
    assertPermanentCount(playerB, "Runeclaw Bear", 6);
    int tokens = 0;
    int nonTokens = 0;
    for (Permanent permanent : currentGame.getBattlefield().getAllPermanents()) {
        if (permanent.getControllerId().equals(playerB.getId())) {
            if (permanent.isCreature(currentGame)) {
                if (permanent instanceof PermanentToken) {
                    tokens++;
                } else {
                    nonTokens++;
                }
            }
        }
    }
    Assert.assertEquals("Two non token permanents ", 2, nonTokens);
    Assert.assertEquals("Four token permanents", 4, tokens);
}
Also used : Permanent(mage.game.permanent.Permanent) PermanentToken(mage.game.permanent.PermanentToken) Test(org.junit.Test)

Example 33 with PermanentToken

use of mage.game.permanent.PermanentToken in project mage by magefree.

the class KikiJikiMirrorBreakerTest method testCopyBodyDouble.

/**
 * Kiki-Jiki, Mirror Breaker tokens are not entering with haste...
 *
 * I just tried to reproduce this but I was not able--
 *
 * In the game in question I used a card (Body Double) to target a card in a
 * graveyard (don't remember the name) and copy it
 *
 * I then used Kiki to copy Body Double that copied a graveyard card of my
 * opponent---that copy did not have haste...
 */
@Test
public void testCopyBodyDouble() {
    addCard(Zone.GRAVEYARD, playerA, "Silvercoat Lion", 1);
    addCard(Zone.BATTLEFIELD, playerB, "Island", 5);
    addCard(Zone.BATTLEFIELD, playerB, "Kiki-Jiki, Mirror Breaker", 1);
    // You may have Body Double enter the battlefield as a copy of any creature card in a graveyard.
    // {4}{U}
    addCard(Zone.HAND, playerB, "Body Double", 1);
    castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Body Double");
    setChoice(playerB, "Silvercoat Lion");
    activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerB, "{T}: Create a token that's a copy of target nonlegendary creature you control, except it has haste. Sacrifice it at the beginning of the next end step.");
    attack(2, playerB, "Silvercoat Lion");
    setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
    execute();
    assertGraveyardCount(playerA, "Silvercoat Lion", 1);
    // one from Body Double and one from Kiki
    assertPermanentCount(playerB, "Silvercoat Lion", 2);
    Permanent kikiCopy = null;
    for (Permanent permanent : currentGame.getState().getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, currentGame)) {
        if (permanent.getName().equals("Silvercoat Lion") && (permanent instanceof PermanentToken)) {
            kikiCopy = permanent;
            break;
        }
    }
    if (kikiCopy != null) {
        Assert.assertEquals("Has to have haste", kikiCopy.getAbilities(currentGame).containsClass(HasteAbility.class), true);
    } else {
        Assert.assertEquals("Silvercoat Lion copied by Kiki is missing", kikiCopy != null, true);
    }
    assertLife(playerA, 18);
    assertLife(playerB, 20);
}
Also used : HasteAbility(mage.abilities.keyword.HasteAbility) Permanent(mage.game.permanent.Permanent) PermanentToken(mage.game.permanent.PermanentToken) Test(org.junit.Test)

Example 34 with PermanentToken

use of mage.game.permanent.PermanentToken in project mage by magefree.

the class ZonesHandler method cast.

public static boolean cast(ZoneChangeInfo info, Game game, Ability source) {
    if (maybeRemoveFromSourceZone(info, game, source)) {
        placeInDestinationZone(info, game, 0);
        // create a group zone change event if a card is moved to stack for casting (it's always only one card, but some effects check for group events (one or more xxx))
        Set<Card> cards = new HashSet<>();
        Set<PermanentToken> tokens = new HashSet<>();
        Card targetCard = getTargetCard(game, info.event.getTargetId());
        if (targetCard instanceof PermanentToken) {
            tokens.add((PermanentToken) targetCard);
        } else {
            cards.add(targetCard);
        }
        game.fireEvent(new ZoneChangeGroupEvent(cards, tokens, info.event.getSourceId(), info.event.getSource(), info.event.getPlayerId(), info.event.getFromZone(), info.event.getToZone()));
        // normal movement
        game.fireEvent(info.event);
        return true;
    }
    return false;
}
Also used : PermanentToken(mage.game.permanent.PermanentToken) ZoneChangeGroupEvent(mage.game.events.ZoneChangeGroupEvent) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard) PermanentCard(mage.game.permanent.PermanentCard)

Example 35 with PermanentToken

use of mage.game.permanent.PermanentToken in project mage by magefree.

the class TheoreticalDuplicationTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    EntersTheBattlefieldEvent eEvent = (EntersTheBattlefieldEvent) event;
    if (!eEvent.getTarget().isCreature(game) || eEvent.getTarget() instanceof PermanentToken || !game.getOpponents(getControllerId()).contains(eEvent.getTarget().getControllerId())) {
        return false;
    }
    getEffects().setTargetPointer(new FixedTarget(eEvent.getTarget(), game));
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) EntersTheBattlefieldEvent(mage.game.events.EntersTheBattlefieldEvent) PermanentToken(mage.game.permanent.PermanentToken)

Aggregations

PermanentToken (mage.game.permanent.PermanentToken)40 Permanent (mage.game.permanent.Permanent)30 Player (mage.players.Player)14 ZoneChangeEvent (mage.game.events.ZoneChangeEvent)8 Test (org.junit.Test)8 UUID (java.util.UUID)7 MageObject (mage.MageObject)7 Card (mage.cards.Card)7 PermanentCard (mage.game.permanent.PermanentCard)6 Ability (mage.abilities.Ability)5 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)4 FixedTarget (mage.target.targetpointer.FixedTarget)4 Cards (mage.cards.Cards)3 CardsImpl (mage.cards.CardsImpl)3 CardType (mage.constants.CardType)3 Outcome (mage.constants.Outcome)3 Zone (mage.constants.Zone)3 Counters (mage.counters.Counters)3 FilterCard (mage.filter.FilterCard)3 ExileZone (mage.game.ExileZone)3