Fix looking at face-down creatures; implement [MKM] Lumbering Laundry (#12479)

This commit is contained in:
ssk97 2024-06-18 19:23:50 -07:00 committed by GitHub
parent 1b3ac1fc7f
commit 32d7122e59
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 137 additions and 250 deletions

View file

@ -0,0 +1,59 @@
package mage.abilities.effects.common.continuous;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.*;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.card.FaceDownPredicate;
import mage.game.Game;
import mage.players.Player;
/**
* @author notgreat
*/
public class LookAtOpponentFaceDownCreaturesAnyTimeEffect extends ContinuousEffectImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("face-down creatures you don't control");
static {
filter.add(FaceDownPredicate.instance);
filter.add(TargetController.NOT_YOU.getControllerPredicate());
}
public LookAtOpponentFaceDownCreaturesAnyTimeEffect() {
this(Duration.WhileOnBattlefield);
}
public LookAtOpponentFaceDownCreaturesAnyTimeEffect(Duration duration) {
super(duration, Layer.PlayerEffects, SubLayer.NA, Outcome.Benefit);
staticText = (duration.toString().isEmpty() ? "" : duration.toString() + ", ") + "you may look at face-down creatures you don't control any time";
}
protected LookAtOpponentFaceDownCreaturesAnyTimeEffect(final LookAtOpponentFaceDownCreaturesAnyTimeEffect effect) {
super(effect);
}
//Based on LookAtTopCardOfLibraryAnyTimeEffect
@Override
public boolean apply(Game game, Ability source) {
if (game.inCheckPlayableState()) { // Ignored - see https://github.com/magefree/mage/issues/6994
return false;
}
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Cards cards = new CardsImpl(game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game));
if (cards.isEmpty()) {
return false;
}
controller.lookAtCards(source, "Face Down Creatures", cards, game);
return true;
}
@Override
public LookAtOpponentFaceDownCreaturesAnyTimeEffect copy() {
return new LookAtOpponentFaceDownCreaturesAnyTimeEffect(this);
}
}