Refactor LookLibraryAndPickControllerEffect (#8841)

This commit is contained in:
Alex W. Jackson 2022-04-16 00:32:24 -04:00 committed by GitHub
parent 7db8dd11b4
commit dc7dcec39a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
195 changed files with 1463 additions and 3526 deletions

View file

@ -1,5 +1,3 @@
package mage.abilities.effects.common;
import mage.abilities.Ability;
@ -14,13 +12,21 @@ import mage.players.Player;
*/
public class ShuffleLibrarySourceEffect extends OneShotEffect {
private boolean optional;
public ShuffleLibrarySourceEffect() {
this(false);
}
public ShuffleLibrarySourceEffect(boolean optional) {
super(Outcome.Neutral);
this.staticText = "Shuffle your library";
this.optional = optional;
this.staticText = optional ? "you may shuffle" : "shuffle your library";
}
public ShuffleLibrarySourceEffect(final ShuffleLibrarySourceEffect effect) {
super(effect);
this.optional = effect.optional;
}
@Override
@ -32,7 +38,9 @@ public class ShuffleLibrarySourceEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.shuffleLibrary(source, game);
if (!optional || player.chooseUse(Outcome.Benefit, "Shuffle your library?", source, game)) {
player.shuffleLibrary(source, game);
}
return true;
}
return false;