simplified and condensed various effects which discard variable amounts of cards

This commit is contained in:
Evan Kranzler 2021-03-29 21:35:27 -04:00
parent 6c54dde7d2
commit 97af948932
15 changed files with 163 additions and 364 deletions

View file

@ -0,0 +1,44 @@
package mage.abilities.effects.common.discard;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
import mage.util.CardUtil;
/**
* @author TheElk801
*/
public class DiscardAndDrawThatManyEffect extends OneShotEffect {
private final int amount;
public DiscardAndDrawThatManyEffect(int amount) {
super(Outcome.DrawCard);
this.amount = amount;
staticText = "discard "
+ (amount == Integer.MAX_VALUE ? "any number of" : "up to" + CardUtil.numberToText(amount))
+ " cards, then draw that many cards";
}
private DiscardAndDrawThatManyEffect(final DiscardAndDrawThatManyEffect effect) {
super(effect);
this.amount = effect.amount;
}
@Override
public DiscardAndDrawThatManyEffect copy() {
return new DiscardAndDrawThatManyEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
player.drawCards(player.discard(0, amount, false, source, game).size(), source, game);
return true;
}
}