Search in sources :

Example 1 with GainAbilityAllEffect

use of mage.abilities.effects.common.continuous.GainAbilityAllEffect in project mage by magefree.

the class HellishRebukeTriggeredAbility method apply.

@Override
public boolean apply(Game game, Ability source) {
    MageObject mageObject = source.getSourceObject(game);
    game.addEffect(new GainAbilityAllEffect(new HellishRebukeTriggeredAbility(source, game), Duration.EndOfTurn, StaticFilters.FILTER_OPPONENTS_PERMANENT), source);
    return true;
}
Also used : MageObject(mage.MageObject) GainAbilityAllEffect(mage.abilities.effects.common.continuous.GainAbilityAllEffect)

Example 2 with GainAbilityAllEffect

use of mage.abilities.effects.common.continuous.GainAbilityAllEffect in project mage by magefree.

the class ReinsOfPowerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    UUID opponentId = this.getTargetPointer().getFirst(game, source);
    if (opponentId != null) {
        // Untap all creatures you control and all creatures target opponent controls.
        FilterCreaturePermanent filter = new FilterCreaturePermanent();
        filter.add(Predicates.or(new ControllerIdPredicate(source.getControllerId()), new ControllerIdPredicate(opponentId)));
        new UntapAllEffect(filter).apply(game, source);
        // You and that opponent each gain control of all creatures the other controls until end of turn.
        Set<UUID> yourCreatures = new HashSet<>();
        Set<UUID> opponentCreatures = new HashSet<>();
        for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), source.getControllerId(), source.getSourceId(), game)) {
            yourCreatures.add(permanent.getId());
        }
        FilterCreaturePermanent filterOpponent = new FilterCreaturePermanent();
        filterOpponent.add(new ControllerIdPredicate(opponentId));
        for (Permanent permanent : game.getBattlefield().getActivePermanents(filterOpponent, source.getControllerId(), source.getSourceId(), game)) {
            opponentCreatures.add(permanent.getId());
        }
        for (UUID creatureId : yourCreatures) {
            ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfTurn, opponentId);
            effect.setTargetPointer(new FixedTarget(creatureId, game));
            game.addEffect(effect, source);
        }
        for (UUID creatureId : opponentCreatures) {
            ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfTurn);
            effect.setTargetPointer(new FixedTarget(creatureId, game));
            game.addEffect(effect, source);
        }
        // Those creatures gain haste until end of turn.
        game.addEffect(new GainAbilityAllEffect(HasteAbility.getInstance(), Duration.EndOfTurn, filter), source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID) UntapAllEffect(mage.abilities.effects.common.UntapAllEffect) GainAbilityAllEffect(mage.abilities.effects.common.continuous.GainAbilityAllEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect) HashSet(java.util.HashSet)

Example 3 with GainAbilityAllEffect

use of mage.abilities.effects.common.continuous.GainAbilityAllEffect in project mage by magefree.

the class TorrentOfSoulsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetedPlayer = game.getPlayer(source.getTargets().get(1).getFirstTarget());
    if (targetedPlayer != null) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent();
        filter.add(new ControllerIdPredicate(targetedPlayer.getId()));
        ContinuousEffect boostEffect = new BoostAllEffect(2, 0, Duration.EndOfTurn, filter, true);
        ContinuousEffect gainAbilityEffect = new GainAbilityAllEffect(HasteAbility.getInstance(), Duration.EndOfTurn, filter);
        game.addEffect(boostEffect, source);
        game.addEffect(gainAbilityEffect, source);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) TargetPlayer(mage.target.TargetPlayer) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) ContinuousEffect(mage.abilities.effects.ContinuousEffect) BoostAllEffect(mage.abilities.effects.common.continuous.BoostAllEffect) GainAbilityAllEffect(mage.abilities.effects.common.continuous.GainAbilityAllEffect)

Example 4 with GainAbilityAllEffect

use of mage.abilities.effects.common.continuous.GainAbilityAllEffect in project mage by magefree.

the class GainAbilityDependenciesTest method test_GenerationByFilters.

@Test
public void test_GenerationByFilters() {
    // auto-dependency must find subtype predicate and add dependecy on it
    FilterPermanent filterEmpty = new FilterPermanent("empty");
    FilterPermanent filterSubtype = new FilterPermanent(SubType.HUMAN, "single");
    FilterPermanent filterOr = new FilterPermanent("or");
    filterOr.add(Predicates.or(SubType.HUMAN.getPredicate(), SubType.ORC.getPredicate()));
    FilterPermanent filterTree = new FilterPermanent("tree");
    filterTree.add(Predicates.and(new NamePredicate("test"), Predicates.or(SubType.HUMAN.getPredicate(), SubType.ORC.getPredicate())));
    FilterPermanent filterNotTree = new FilterPermanent("tree");
    filterNotTree.add(Predicates.not(Predicates.or(SubType.HUMAN.getPredicate(), SubType.ORC.getPredicate())));
    ContinuousEffectImpl effectEmpty = new GainAbilityAllEffect(HasteAbility.getInstance(), Duration.EndOfTurn, filterEmpty);
    ContinuousEffectImpl effectSubtype = new GainAbilityAllEffect(HasteAbility.getInstance(), Duration.EndOfTurn, filterSubtype);
    ContinuousEffectImpl effectOr = new GainAbilityAllEffect(HasteAbility.getInstance(), Duration.EndOfTurn, filterOr);
    ContinuousEffectImpl effectTree = new GainAbilityAllEffect(HasteAbility.getInstance(), Duration.EndOfTurn, filterTree);
    ContinuousEffectImpl effectNotTree = new GainAbilityAllEffect(HasteAbility.getInstance(), Duration.EndOfTurn, filterNotTree);
    Assert.assertFalse("must haven't depends with empty filter", effectEmpty.getDependedToTypes().contains(DependencyType.AddingCreatureType));
    Assert.assertTrue("must have depend from subtype predicate", effectSubtype.getDependedToTypes().contains(DependencyType.AddingCreatureType));
    Assert.assertTrue("must have depend from or predicate", effectOr.getDependedToTypes().contains(DependencyType.AddingCreatureType));
    Assert.assertTrue("must have depend from tree predicate", effectTree.getDependedToTypes().contains(DependencyType.AddingCreatureType));
    Assert.assertTrue("must have depend from not-tree predicate", effectNotTree.getDependedToTypes().contains(DependencyType.AddingCreatureType));
}
Also used : NamePredicate(mage.filter.predicate.mageobject.NamePredicate) FilterPermanent(mage.filter.FilterPermanent) ContinuousEffectImpl(mage.abilities.effects.ContinuousEffectImpl) GainAbilityAllEffect(mage.abilities.effects.common.continuous.GainAbilityAllEffect) Test(org.junit.Test)

Example 5 with GainAbilityAllEffect

use of mage.abilities.effects.common.continuous.GainAbilityAllEffect in project mage by magefree.

the class CrownOfFuryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    // Enchanted creature ...
    ContinuousEffect effect = new BoostEnchantedEffect(1, 0, Duration.EndOfTurn);
    game.addEffect(effect, source);
    effect = new GainAbilityAttachedEffect(FirstStrikeAbility.getInstance(), AttachmentType.AURA, Duration.EndOfTurn);
    game.addEffect(effect, source);
    // ... and other creatures that share a creature type with it ...
    Permanent enchantedCreature = game.getPermanent(source.getSourcePermanentOrLKI(game).getAttachedTo());
    FilterCreaturePermanent filter = new FilterCreaturePermanent();
    filter.add(new CrownOfFuryPredicate(enchantedCreature));
    filter.add(Predicates.not(new MageObjectReferencePredicate(new MageObjectReference(enchantedCreature, game))));
    game.addEffect(new BoostAllEffect(1, 0, Duration.EndOfTurn, filter, false), source);
    game.addEffect(new GainAbilityAllEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn, filter), source);
    // ... get +1/+0 and gain first strike until end of turn.
    return true;
}
Also used : FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) BoostEnchantedEffect(mage.abilities.effects.common.continuous.BoostEnchantedEffect) MageObjectReferencePredicate(mage.filter.predicate.mageobject.MageObjectReferencePredicate) GainAbilityAttachedEffect(mage.abilities.effects.common.continuous.GainAbilityAttachedEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) BoostAllEffect(mage.abilities.effects.common.continuous.BoostAllEffect) GainAbilityAllEffect(mage.abilities.effects.common.continuous.GainAbilityAllEffect) MageObjectReference(mage.MageObjectReference)

Aggregations

GainAbilityAllEffect (mage.abilities.effects.common.continuous.GainAbilityAllEffect)5 ContinuousEffect (mage.abilities.effects.ContinuousEffect)3 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)3 BoostAllEffect (mage.abilities.effects.common.continuous.BoostAllEffect)2 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)2 Permanent (mage.game.permanent.Permanent)2 HashSet (java.util.HashSet)1 UUID (java.util.UUID)1 MageObject (mage.MageObject)1 MageObjectReference (mage.MageObjectReference)1 ContinuousEffectImpl (mage.abilities.effects.ContinuousEffectImpl)1 UntapAllEffect (mage.abilities.effects.common.UntapAllEffect)1 BoostEnchantedEffect (mage.abilities.effects.common.continuous.BoostEnchantedEffect)1 GainAbilityAttachedEffect (mage.abilities.effects.common.continuous.GainAbilityAttachedEffect)1 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)1 FilterPermanent (mage.filter.FilterPermanent)1 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)1 MageObjectReferencePredicate (mage.filter.predicate.mageobject.MageObjectReferencePredicate)1 NamePredicate (mage.filter.predicate.mageobject.NamePredicate)1 Player (mage.players.Player)1