Untapping lands in response to a trigger is somewhat painful. Allow lands to be targeted automatically.

This commit is contained in:
spjspj 2018-03-14 01:21:03 +11:00
parent fa53e1ef6f
commit 3953ad8b0b

View file

@ -64,15 +64,14 @@ public class UntapLandsEffect extends OneShotEffect {
TargetLandPermanent target = new TargetLandPermanent(0, amount, new FilterLandPermanent(), true); TargetLandPermanent target = new TargetLandPermanent(0, amount, new FilterLandPermanent(), true);
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
// UI Shortcut: Check if any lands are already tapped. If there are equal/fewer than amount, give the option to untap those ones now. // UI Shortcut: Check if any lands are already tapped. If there are equal/fewer than amount, give the option to add those in to be untapped now.
FilterPermanent filter = new FilterLandPermanent(); FilterPermanent filter = new FilterLandPermanent();
filter.add(new TappedPredicate()); filter.add(new TappedPredicate());
Player player = game.getPlayer(game.getActivePlayerId()); int tappedLands = game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game).size();
int tappedLands = game.getBattlefield().getAllActivePermanents(filter, game.getActivePlayerId(), game).size();
if (player != null && tappedLands <= amount) { if (tappedLands <= amount) {
if (player.chooseUse(outcome, "Include your tapped lands to untap?", source, game)) { if (controller.chooseUse(outcome, "Include your tapped lands to untap?", source, game)) {
for (Permanent land : game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) { for (Permanent land : game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) {
target.addTarget(land.getId(), source, game); target.addTarget(land.getId(), source, game);
} }
} }