foul-magics/Mage/src/main/java/mage/abilities/effects/common/LookLibraryMayPutToBottomEffect.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

53 lines
1.7 KiB
Java

package mage.abilities.effects.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardsImpl;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
/**
*
* @author LevelX2
*/
public class LookLibraryMayPutToBottomEffect extends OneShotEffect {
public LookLibraryMayPutToBottomEffect() {
super(Outcome.DrawCard);
this.staticText = "Look at the top card of your library. You may put that card on the bottom of your library.";
}
public LookLibraryMayPutToBottomEffect(final LookLibraryMayPutToBottomEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source);
if (sourceObject == null || controller == null) {
return false;
}
if (controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().getFromTop(game);
if (card == null) {
return false;
}
controller.lookAtCards(sourceObject.getName(), new CardsImpl(card), game);
boolean toBottom = controller.chooseUse(outcome, "Put card on the bottom of your library?", source, game);
return controller.moveCardToLibraryWithInfo(card, source, game, Zone.LIBRARY, !toBottom, false);
}
return true;
}
@Override
public LookLibraryMayPutToBottomEffect copy() {
return new LookLibraryMayPutToBottomEffect(this);
}
}