mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
Add a parameter to untap only other objects than the source to UntapAllContollerEffect since OtherPredicate does not work on the filter for it.
This commit is contained in:
parent
3c91b8d15f
commit
2b4e8c3e4c
1 changed files with 12 additions and 2 deletions
|
@ -44,32 +44,42 @@ import mage.players.Player;
|
|||
public class UntapAllControllerEffect extends OneShotEffect {
|
||||
|
||||
private final FilterPermanent filter;
|
||||
private final boolean includeSource;
|
||||
|
||||
public UntapAllControllerEffect(FilterPermanent filter) {
|
||||
this(filter, null);
|
||||
}
|
||||
|
||||
public UntapAllControllerEffect(FilterPermanent filter, String rule) {
|
||||
this(filter, rule, true);
|
||||
}
|
||||
|
||||
public UntapAllControllerEffect(FilterPermanent filter, String rule, boolean includeSource) {
|
||||
super(Outcome.Untap);
|
||||
if (rule == null || rule.isEmpty()) {
|
||||
staticText = "untap all " + filter.getMessage() + " you control";
|
||||
staticText = "untap all " + (includeSource ? "" : "other ") + filter.getMessage() + " you control";
|
||||
} else {
|
||||
staticText = rule;
|
||||
}
|
||||
this.filter = filter;
|
||||
this.includeSource = includeSource;
|
||||
}
|
||||
|
||||
public UntapAllControllerEffect(final UntapAllControllerEffect effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
this.includeSource = effect.includeSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (player != null) {
|
||||
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
|
||||
permanent.untap(game);
|
||||
if (includeSource || sourcePermanent == null || !sourcePermanent.getId().equals(permanent.getId())) {
|
||||
permanent.untap(game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue