[DMU] Implemented Urborg Lhurgoyf

This commit is contained in:
Evan Kranzler 2022-08-29 20:02:30 -04:00
parent 4deb9176f9
commit 2e94364b2a
3 changed files with 106 additions and 8 deletions

View file

@ -1,6 +1,9 @@
package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.game.Game;
@ -13,12 +16,15 @@ import mage.util.CardUtil;
public class MillCardsControllerEffect extends OneShotEffect {
private final int numberCards;
private final DynamicValue numberCards;
public MillCardsControllerEffect(int numberCards) {
this(StaticValue.get(numberCards));
}
public MillCardsControllerEffect(DynamicValue numberCards) {
super(Outcome.Discard);
this.numberCards = numberCards;
this.staticText = setText();
}
public MillCardsControllerEffect(final MillCardsControllerEffect effect) {
@ -34,13 +40,17 @@ public class MillCardsControllerEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
return !controller.millCards(numberCards, source, game).isEmpty();
}
return false;
return controller != null && !controller.millCards(
numberCards.calculate(game, source, this), source, game
).isEmpty();
}
private String setText() {
return "mill " + (numberCards == 1 ? "a card" : CardUtil.numberToText(numberCards) + " cards");
@Override
public String getText(Mode mode) {
if (numberCards instanceof StaticValue) {
return "mill " + (((StaticValue) numberCards).getValue() > 1 ?
CardUtil.numberToText(numberCards.toString()) + " cards" : "a card");
}
return "mill X cards, where X is " + numberCards.getMessage();
}
}