Search in sources :

Example 1 with EscapeAbility

use of mage.abilities.keyword.EscapeAbility in project mage by magefree.

the class EscapesWithEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (permanent == null && source.getAbilityType() == AbilityType.STATIC) {
        permanent = game.getPermanentEntering(source.getSourceId());
    }
    if (permanent == null) {
        return false;
    }
    SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
    if (!(spellAbility instanceof EscapeAbility) || !spellAbility.getSourceId().equals(source.getSourceId()) || permanent.getZoneChangeCounter(game) != spellAbility.getSourceObjectZoneChangeCounter()) {
        return false;
    }
    List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects");
    permanent.addCounters(CounterType.P1P1.createInstance(counter), source.getControllerId(), source, game, appliedEffects);
    if (this.delayedTriggeredAbility != null) {
        game.addDelayedTriggeredAbility(this.delayedTriggeredAbility, source);
    }
    return true;
}
Also used : Permanent(mage.game.permanent.Permanent) ArrayList(java.util.ArrayList) SpellAbility(mage.abilities.SpellAbility) UUID(java.util.UUID) EscapeAbility(mage.abilities.keyword.EscapeAbility)

Example 2 with EscapeAbility

use of mage.abilities.keyword.EscapeAbility in project mage by magefree.

the class TizerusChargerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (permanent == null && source.getAbilityType() == AbilityType.STATIC) {
        permanent = game.getPermanentEntering(source.getSourceId());
    }
    Player player = game.getPlayer(source.getControllerId());
    if (permanent == null || player == null) {
        return false;
    }
    SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
    if (!(spellAbility instanceof EscapeAbility) || !spellAbility.getSourceId().equals(source.getSourceId()) || permanent.getZoneChangeCounter(game) != spellAbility.getSourceObjectZoneChangeCounter()) {
        return false;
    }
    List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects");
    CounterType counterType = player.chooseUse(outcome, "Choose +1/+1 or flying", null, "+1/+1", "Flying", source, game) ? CounterType.P1P1 : CounterType.FLYING;
    permanent.addCounters(counterType.createInstance(), source.getControllerId(), source, game, appliedEffects);
    return true;
}
Also used : Player(mage.players.Player) CounterType(mage.counters.CounterType) Permanent(mage.game.permanent.Permanent) ArrayList(java.util.ArrayList) SpellAbility(mage.abilities.SpellAbility) UUID(java.util.UUID) EscapeAbility(mage.abilities.keyword.EscapeAbility)

Example 3 with EscapeAbility

use of mage.abilities.keyword.EscapeAbility in project mage by magefree.

the class UnderworldBreachEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    controller.getGraveyard().getCards(game).stream().filter(Objects::nonNull).filter(// card must have a mana cost
    card -> !card.getManaCost().getText().isEmpty()).filter(card -> !card.isLand(game)).forEach(card -> {
        Ability ability = new EscapeAbility(card, card.getManaCost().getText(), 3);
        ability.setSourceId(card.getId());
        ability.setControllerId(card.getOwnerId());
        game.getState().addOtherAbility(card, ability);
    });
    return true;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) UUID(java.util.UUID) BeginningOfEndStepTriggeredAbility(mage.abilities.common.BeginningOfEndStepTriggeredAbility) Player(mage.players.Player) CardSetInfo(mage.cards.CardSetInfo) Objects(java.util.Objects) ContinuousEffectImpl(mage.abilities.effects.ContinuousEffectImpl) Game(mage.game.Game) EscapeAbility(mage.abilities.keyword.EscapeAbility) CardImpl(mage.cards.CardImpl) SacrificeSourceEffect(mage.abilities.effects.common.SacrificeSourceEffect) mage.constants(mage.constants) Ability(mage.abilities.Ability) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) BeginningOfEndStepTriggeredAbility(mage.abilities.common.BeginningOfEndStepTriggeredAbility) EscapeAbility(mage.abilities.keyword.EscapeAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) EscapeAbility(mage.abilities.keyword.EscapeAbility)

Example 4 with EscapeAbility

use of mage.abilities.keyword.EscapeAbility in project mage by magefree.

the class PolukranosUnchainedEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (permanent == null && source.getAbilityType() == AbilityType.STATIC) {
        permanent = game.getPermanentEntering(source.getSourceId());
    }
    if (permanent == null) {
        return false;
    }
    SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
    int counters = 12;
    if (!(spellAbility instanceof EscapeAbility) || !spellAbility.getSourceId().equals(source.getSourceId()) || permanent.getZoneChangeCounter(game) != spellAbility.getSourceObjectZoneChangeCounter()) {
        counters = 6;
    }
    List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects");
    permanent.addCounters(CounterType.P1P1.createInstance(counters), source.getControllerId(), source, game, appliedEffects);
    return true;
}
Also used : FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ArrayList(java.util.ArrayList) SpellAbility(mage.abilities.SpellAbility) UUID(java.util.UUID) EscapeAbility(mage.abilities.keyword.EscapeAbility)

Aggregations

UUID (java.util.UUID)4 EscapeAbility (mage.abilities.keyword.EscapeAbility)4 ArrayList (java.util.ArrayList)3 SpellAbility (mage.abilities.SpellAbility)3 Permanent (mage.game.permanent.Permanent)3 Player (mage.players.Player)2 Objects (java.util.Objects)1 Ability (mage.abilities.Ability)1 BeginningOfEndStepTriggeredAbility (mage.abilities.common.BeginningOfEndStepTriggeredAbility)1 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)1 ContinuousEffectImpl (mage.abilities.effects.ContinuousEffectImpl)1 SacrificeSourceEffect (mage.abilities.effects.common.SacrificeSourceEffect)1 CardImpl (mage.cards.CardImpl)1 CardSetInfo (mage.cards.CardSetInfo)1 mage.constants (mage.constants)1 CounterType (mage.counters.CounterType)1 FilterPermanent (mage.filter.FilterPermanent)1 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)1 Game (mage.game.Game)1 TargetPermanent (mage.target.TargetPermanent)1