fixed text on various cards which draw and discard

This commit is contained in:
Evan Kranzler 2022-02-14 21:56:07 -05:00
parent c28da75ac1
commit 8da3a78273
10 changed files with 52 additions and 38 deletions

View file

@ -1,7 +1,7 @@
package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.game.Game;
@ -9,19 +9,22 @@ import mage.players.Player;
import mage.util.CardUtil;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class DrawDiscardControllerEffect extends OneShotEffect {
private int cardsToDraw;
private int cardsToDiscard;
private boolean optional;
private final int cardsToDraw;
private final int cardsToDiscard;
private final boolean optional;
public DrawDiscardControllerEffect() {
this(1, 1);
}
public DrawDiscardControllerEffect(boolean optional) {
this(1, 1, optional);
}
public DrawDiscardControllerEffect(int cardsToDraw, int cardsToDiscard) {
this(cardsToDraw, cardsToDiscard, false);
}
@ -31,14 +34,6 @@ public class DrawDiscardControllerEffect extends OneShotEffect {
this.cardsToDraw = cardsToDraw;
this.cardsToDiscard = cardsToDiscard;
this.optional = optional;
staticText = new StringBuilder(optional ? "you may " : "")
.append("draw ")
.append(cardsToDraw == 1 ? "a" : CardUtil.numberToText(cardsToDraw))
.append(" card").append(cardsToDraw == 1 ? "" : "s")
.append(optional ? ", if you do" : ", then")
.append(" discard ")
.append(cardsToDiscard == 1 ? "a" : CardUtil.numberToText(cardsToDiscard))
.append(" card").append(cardsToDiscard == 1 ? "" : "s").toString();
}
public DrawDiscardControllerEffect(final DrawDiscardControllerEffect effect) {
@ -56,14 +51,31 @@ public class DrawDiscardControllerEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
if (!optional || player.chooseUse(outcome, "Use draw, then discard effect?", source, game)) {
player.drawCards(cardsToDraw, source, game);
player.discard(cardsToDiscard, false, false, source, game);
}
if (player == null) {
return false;
}
if (optional && !player.chooseUse(outcome, "Draw, then discard?", source, game)) {
return true;
}
return false;
player.drawCards(cardsToDraw, source, game);
player.discard(cardsToDiscard, false, false, source, game);
return true;
}
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
return (optional ? "you may " : "") +
"draw " +
(cardsToDraw == 1 ? "a" : CardUtil.numberToText(cardsToDraw)) +
" card" +
(cardsToDraw == 1 ? "" : "s") +
(optional ? ". If you do," : ", then") +
" discard " +
(cardsToDiscard == 1 ? "a" : CardUtil.numberToText(cardsToDiscard)) +
" card" +
(cardsToDiscard == 1 ? "" : "s");
}
}