Untap All Lands Effect - Added Filter

This commit is contained in:
Styxo 2016-03-28 19:11:22 +02:00
parent c4081c8020
commit 1132bb8eb2

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.abilities.effects.common; package mage.abilities.effects.common;
import mage.constants.Outcome; import mage.constants.Outcome;
@ -40,23 +39,32 @@ import mage.players.Player;
* *
* @author Viserion * @author Viserion
*/ */
public class UntapAllLandsControllerEffect extends OneShotEffect { public class UntapAllLandsControllerEffect extends OneShotEffect {
private final FilterLandPermanent filter;
public UntapAllLandsControllerEffect() { public UntapAllLandsControllerEffect() {
super(Outcome.Untap); super(Outcome.Untap);
staticText = "Untap all lands you control"; staticText = "Untap all lands you control";
filter = new FilterLandPermanent();
} }
public UntapAllLandsControllerEffect(final UntapAllLandsControllerEffect effect) { public UntapAllLandsControllerEffect(final UntapAllLandsControllerEffect effect) {
super(effect); super(effect);
this.filter = effect.filter;
}
public UntapAllLandsControllerEffect(FilterLandPermanent filter) {
super(Outcome.Untap);
staticText = "Untap all " + filter.getMessage() + " you control";
this.filter = filter;
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null) { if (player != null) {
for (Permanent land: game.getBattlefield().getAllActivePermanents(new FilterLandPermanent(), player.getId(), game)) { for (Permanent land : game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
land.untap(game); land.untap(game);
} }
return true; return true;
@ -69,4 +77,4 @@ public class UntapAllLandsControllerEffect extends OneShotEffect {
return new UntapAllLandsControllerEffect(this); return new UntapAllLandsControllerEffect(this);
} }
} }