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;
}
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;
}
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;
}
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));
}
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;
}
Aggregations