Search in sources :

Example 21 with EntersTheBattlefieldEvent

use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.

the class FlayerEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent permanent = game.getPermanent(event.getTargetId());
    if (permanent != null && ((EntersTheBattlefieldEvent) event).getFromZone() == Zone.GRAVEYARD && permanent.isOwnedBy(controllerId) && (permanent.isCreature(game) || permanent.getId().equals(getSourceId()))) {
        Effect effect = this.getEffects().get(0);
        effect.setValue("damageSource", event.getTargetId());
        return true;
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) EntersTheBattlefieldEvent(mage.game.events.EntersTheBattlefieldEvent) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect)

Example 22 with EntersTheBattlefieldEvent

use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.

the class GraveBetrayalReplacementEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
    if (creature != null) {
        creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
        ContinuousEffect effect = new BecomesBlackZombieAdditionEffect();
        effect.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game) + 1));
        game.addEffect(effect, source);
    // discard(); why?
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) EntersTheBattlefieldEvent(mage.game.events.EntersTheBattlefieldEvent) BecomesBlackZombieAdditionEffect(mage.abilities.effects.common.continuous.BecomesBlackZombieAdditionEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 23 with EntersTheBattlefieldEvent

use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.

the class RiotReplacementEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
    Player controller = game.getPlayer(source.getControllerId());
    if (creature != null && controller != null) {
        if (controller.chooseUse(outcome, "Have " + creature.getLogName() + " enter the battlefield with a +1/+1 counter on it or with haste?", null, "+1/+1 counter", "Haste", source, game)) {
            game.informPlayers(controller.getLogName() + " choose to put a +1/+1 counter on " + creature.getName());
            creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
        } else {
            game.addEffect(new GainAbilitySourceEffect(HasteAbility.getInstance(), Duration.Custom), source);
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) EntersTheBattlefieldEvent(mage.game.events.EntersTheBattlefieldEvent) GainAbilitySourceEffect(mage.abilities.effects.common.continuous.GainAbilitySourceEffect)

Example 24 with EntersTheBattlefieldEvent

use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.

the class UnleashRestrictionEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
    Player controller = game.getPlayer(source.getControllerId());
    if (creature != null && controller != null) {
        if (controller.chooseUse(outcome, "Unleash " + creature.getLogName() + '?', source, game)) {
            if (!game.isSimulation()) {
                game.informPlayers(controller.getLogName() + " unleashes " + creature.getName());
            }
            creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) EntersTheBattlefieldEvent(mage.game.events.EntersTheBattlefieldEvent)

Example 25 with EntersTheBattlefieldEvent

use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.

the class MetallicMimicReplacementEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    Permanent enteringCreature = ((EntersTheBattlefieldEvent) event).getTarget();
    if (enteringCreature != null && sourcePermanent != null && enteringCreature.isControlledBy(source.getControllerId()) && enteringCreature.isCreature(game) && !event.getTargetId().equals(source.getSourceId())) {
        SubType subType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game);
        return subType != null && enteringCreature.hasSubtype(subType, game);
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) EntersTheBattlefieldEvent(mage.game.events.EntersTheBattlefieldEvent)

Aggregations

EntersTheBattlefieldEvent (mage.game.events.EntersTheBattlefieldEvent)43 Permanent (mage.game.permanent.Permanent)36 Player (mage.players.Player)8 FixedTarget (mage.target.targetpointer.FixedTarget)6 TargetControlledPermanent (mage.target.common.TargetControlledPermanent)5 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)5 ContinuousEffect (mage.abilities.effects.ContinuousEffect)4 FilterPermanent (mage.filter.FilterPermanent)4 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)4 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)4 UUID (java.util.UUID)3 Effect (mage.abilities.effects.Effect)3 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)3 Target (mage.target.Target)3 MageObject (mage.MageObject)2 MageObjectReference (mage.MageObjectReference)2 LoseLifeTargetEffect (mage.abilities.effects.common.LoseLifeTargetEffect)2 SetPowerToughnessSourceEffect (mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect)2 Card (mage.cards.Card)2 GameEvent (mage.game.events.GameEvent)2