foul-magics/Mage/src/main/java/mage/abilities/effects/common/TapAllEffect.java
Evan Kranzler 80e11b2052
(WIP) Replacing blocking/blocked by predicates (#8729)
* replaced blocking/blocked by predicates

* added test for knight of dusk (currently fails)

* added source parameter to filters and everything else that needs it

* some changes to various predicates

* test fix

* small changes to filter code

* merge fix

* fixed a test failure

* small change to Karn, Scion of Urza

* removed sourceId from filter methods and other similar places

* added new getobject method to fix some test failures

* a few more fixes

* fixed merge conflicts

* merge fix
2022-03-23 18:45:02 -04:00

50 lines
1.1 KiB
Java

package mage.abilities.effects.common;
import mage.constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class TapAllEffect extends OneShotEffect {
protected FilterPermanent filter;
public TapAllEffect(FilterPermanent filter) {
super(Outcome.Tap);
this.filter = filter;
setText();
}
public TapAllEffect(final TapAllEffect effect) {
super(effect);
this.filter = effect.filter.copy();
}
@Override
public TapAllEffect copy() {
return new TapAllEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
permanent.tap(source, game);
}
return true;
}
private void setText() {
staticText = "tap all " + filter.getMessage();
}
}