foul-magics/Mage/src/main/java/mage/abilities/effects/common/ShuffleLibrarySourceEffect.java
Susucre f75b1c9f0a
Code cleanup: protect all copy constructors (#10750)
* apply regex to change public copy constructors to protected
* cleanup code using now protected constructors
* fix manaBuilder weird casting of Mana into ConditionalMana
2023-08-04 19:34:58 -04:00

47 lines
1.3 KiB
Java

package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
/**
* @author emerald000
*/
public class ShuffleLibrarySourceEffect extends OneShotEffect {
private boolean optional;
public ShuffleLibrarySourceEffect() {
this(false);
}
public ShuffleLibrarySourceEffect(boolean optional) {
super(Outcome.Neutral);
this.optional = optional;
this.staticText = optional ? "you may shuffle" : "shuffle your library";
}
protected ShuffleLibrarySourceEffect(final ShuffleLibrarySourceEffect effect) {
super(effect);
this.optional = effect.optional;
}
@Override
public ShuffleLibrarySourceEffect copy() {
return new ShuffleLibrarySourceEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
if (!optional || player.chooseUse(Outcome.Benefit, "Shuffle your library?", source, game)) {
player.shuffleLibrary(source, game);
}
return true;
}
return false;
}
}