Search in sources :

Example 6 with PermanentToken

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

the class GyomeMasterChefWatcher method watch.

@Override
public void watch(GameEvent event, Game game) {
    if (event.getType() != GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
        return;
    }
    Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
    if (permanent == null || permanent instanceof PermanentToken || !permanent.isCreature(game)) {
        return;
    }
    playerMap.compute(event.getPlayerId(), CardUtil::setOrIncrementValue);
}
Also used : FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) EntersTheBattlefieldEvent(mage.game.events.EntersTheBattlefieldEvent) PermanentToken(mage.game.permanent.PermanentToken) CardUtil(mage.util.CardUtil)

Example 7 with PermanentToken

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

the class GutterGrimeEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    UUID targetId = event.getTargetId();
    MageObject card = game.getLastKnownInformation(targetId, Zone.BATTLEFIELD);
    if (card instanceof Permanent && !(card instanceof PermanentToken)) {
        Permanent permanent = (Permanent) card;
        ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
        if (zEvent.isDiesEvent() && permanent.isControlledBy(this.controllerId) && (targetId.equals(this.getSourceId()) || (permanent.isCreature(game) && !(permanent instanceof PermanentToken)))) {
            return true;
        }
    }
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Permanent(mage.game.permanent.Permanent) MageObject(mage.MageObject) PermanentToken(mage.game.permanent.PermanentToken) UUID(java.util.UUID)

Example 8 with PermanentToken

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

the class ProwlingGeistcatcherReturnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Card card = game.getCard(getTargetPointer().getFirst(game, source));
    if (player != null && card != null) {
        player.moveCardsToExile(card, source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
    }
    Permanent exiled = (Permanent) getValue("sacrificedPermanent");
    Permanent permanent = source.getSourcePermanentIfItStillExists(game);
    if (exiled instanceof PermanentToken && permanent != null) {
        permanent.addCounters(CounterType.P1P1.createInstance(), source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) PermanentToken(mage.game.permanent.PermanentToken) Card(mage.cards.Card)

Example 9 with PermanentToken

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

the class SkullSkaabTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent exploiter = game.getPermanentOrLKIBattlefield(event.getSourceId());
    Permanent exploited = game.getPermanentOrLKIBattlefield(event.getTargetId());
    return exploiter != null && exploited != null && exploiter.isCreature(game) && exploited.isCreature(game) && exploiter.isControlledBy(getControllerId()) && !(exploited instanceof PermanentToken);
}
Also used : Permanent(mage.game.permanent.Permanent) PermanentToken(mage.game.permanent.PermanentToken)

Example 10 with PermanentToken

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

the class GarthOneEyeTest method testShivanDragon.

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

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