Search in sources :

Example 26 with PermanentToken

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

the class GarthOneEyeTest method testBlackLotus.

@Test
public void testBlackLotus() {
    addCard(Zone.BATTLEFIELD, playerA, garth);
    setChoice(playerA, lotus);
    activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Choose");
    setStopAt(1, PhaseStep.END_TURN);
    execute();
    assertAllCommandsUsed();
    assertTapped(garth, true);
    Permanent permanent = getPermanent(lotus);
    Assert.assertNotNull(lotus + " should be on the battlefield", permanent);
    Assert.assertTrue(lotus + " should be a token", permanent instanceof PermanentToken);
}
Also used : Permanent(mage.game.permanent.Permanent) PermanentToken(mage.game.permanent.PermanentToken) Test(org.junit.Test)

Example 27 with PermanentToken

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

the class MillicentRestlessRevenantTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent permanent;
    switch(event.getType()) {
        case ZONE_CHANGE:
            ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
            if (!zEvent.isDiesEvent()) {
                return false;
            }
            permanent = zEvent.getTarget();
            break;
        case DAMAGED_PLAYER:
            if (!((DamagedEvent) event).isCombatDamage()) {
                return false;
            }
            permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
            break;
        default:
            return false;
    }
    if (permanent == null) {
        return false;
    }
    return permanent.getId().equals(this.getSourceId()) || (!(permanent instanceof PermanentToken) && permanent.hasSubtype(SubType.SPIRIT, game));
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) FilterPermanent(mage.filter.FilterPermanent) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) PermanentToken(mage.game.permanent.PermanentToken)

Example 28 with PermanentToken

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

the class EmbalmedThisTurnWatcher method apply.

@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
    for (Permanent entering : game.getPermanentsEntering().values()) {
        if (!entering.getId().equals(copyToObjectId) || !(entering instanceof PermanentToken)) {
            continue;
        }
        UUID originalCardId = ((PermanentToken) entering).getToken().getCopySourceCard().getId();
        EmbalmedThisTurnWatcher watcher = game.getState().getWatcher(EmbalmedThisTurnWatcher.class);
        if (watcher == null) {
            continue;
        }
        for (MageObjectReference mor : watcher.getEmbalmedThisTurnCards()) {
            if (!Objects.equals(mor.getSourceId(), originalCardId) || game.getState().getZoneChangeCounter(originalCardId) != mor.getZoneChangeCounter()) {
                continue;
            }
            blueprint.getManaCost().clear();
            if (!blueprint.getSubtype().contains(SubType.ZOMBIE)) {
                blueprint.getSubtype().add(SubType.ZOMBIE);
            }
            blueprint.getColor().setColor(ObjectColor.WHITE);
        }
    }
    return true;
}
Also used : Permanent(mage.game.permanent.Permanent) PermanentToken(mage.game.permanent.PermanentToken) UUID(java.util.UUID) MageObjectReference(mage.MageObjectReference)

Example 29 with PermanentToken

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

the class VileRedeemerNonTokenCreaturesDiedWatcher method watch.

@Override
public void watch(GameEvent event, Game game) {
    if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
        ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
        if (zEvent.isDiesEvent() && zEvent.getTarget() != null && zEvent.getTarget().isCreature(game) && !(zEvent.getTarget() instanceof PermanentToken)) {
            int count = getAmountOfNontokenCreatureDiedThisTurn(zEvent.getTargetId());
            amountOfCreaturesThatDied.put(zEvent.getTarget().getControllerId(), ++count);
        }
    }
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) PermanentToken(mage.game.permanent.PermanentToken)

Example 30 with PermanentToken

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

the class WorldgorgerDragonLeavesEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller != null && sourceObject != null) {
        int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() - 1;
        ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter));
        if (exile != null) {
            return controller.moveCards(exile.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null);
        }
    }
    return false;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) ExileZone(mage.game.ExileZone) 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