use of mage.filter.common.FilterCreaturePermanent 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.filter.common.FilterCreaturePermanent in project mage by magefree.
the class ReinsOfTheVinesteedEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Card aura = game.getCard(source.getSourceId());
if (aura != null && game.getState().getZone(aura.getId()) == Zone.GRAVEYARD) {
Player controller = game.getPlayer(source.getControllerId());
Permanent lastStateAura = (Permanent) game.getLastKnownInformation(aura.getId(), Zone.BATTLEFIELD);
Permanent lastStateCreature = game.getPermanentOrLKIBattlefield(lastStateAura.getAttachedTo());
if (lastStateCreature == null) {
return false;
}
FilterPermanent FILTER = new FilterCreaturePermanent("creature that shares a creature type with " + lastStateCreature.getName());
FILTER.add(new SharesCreatureTypePredicate(lastStateCreature));
TargetPermanent target = new TargetPermanent(FILTER);
target.setNotTarget(true);
if (controller != null && controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) {
Permanent targetPermanent = game.getPermanent(target.getFirstTarget());
if (!targetPermanent.cantBeAttachedBy(aura, source, game, false)) {
game.getState().setValue("attachTo:" + aura.getId(), targetPermanent);
controller.moveCards(aura, Zone.BATTLEFIELD, source, game);
return targetPermanent.addAttachment(aura.getId(), source, game);
}
}
}
return false;
}
use of mage.filter.common.FilterCreaturePermanent in project mage by magefree.
the class RumblingRuinEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
int counter = 1;
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(source.getControllerId())) {
if (permanent == null || !permanent.isCreature(game)) {
continue;
}
counter += permanent.getCounters(game).getCount(CounterType.P1P1);
}
FilterCreaturePermanent filter = new FilterOpponentsCreaturePermanent();
filter.add(new PowerPredicate(ComparisonType.FEWER_THAN, counter));
game.addEffect(new CantBlockAllEffect(filter, Duration.EndOfTurn), source);
return true;
}
use of mage.filter.common.FilterCreaturePermanent in project mage by magefree.
the class RowanKenrithDamageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(TappedPredicate.TAPPED);
filter.add(new ControllerIdPredicate(source.getFirstTarget()));
return new DamageAllEffect(3, filter).apply(game, source);
}
use of mage.filter.common.FilterCreaturePermanent in project mage by magefree.
the class SearingRaysEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
ChoiceColor choice = new ChoiceColor();
if (controller != null && controller.choose(outcome, choice, game) && choice.getColor() != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent(choice.getColor().getDescription() + " creatures");
filter.add(new ColorPredicate(choice.getColor()));
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
int amount = game.getBattlefield().countAll(filter, playerId, game);
if (amount > 0) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.damage(amount, source.getSourceId(), source, game);
}
}
}
return true;
}
return false;
}
Aggregations