diff --git a/Mage.Sets/src/mage/cards/u/UrborgLhurgoyf.java b/Mage.Sets/src/mage/cards/u/UrborgLhurgoyf.java new file mode 100644 index 0000000000..3e01b75269 --- /dev/null +++ b/Mage.Sets/src/mage/cards/u/UrborgLhurgoyf.java @@ -0,0 +1,87 @@ +package mage.cards.u; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.dynamicvalue.common.MultikickerCount; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.common.MillCardsControllerEffect; +import mage.abilities.keyword.KickerAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.players.Player; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class UrborgLhurgoyf extends CardImpl { + + public UrborgLhurgoyf(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}"); + + this.subtype.add(SubType.LHURGOYF); + this.power = new MageInt(0); + this.toughness = new MageInt(1); + + // Kicker {U} and/or {B} + KickerAbility kickerAbility = new KickerAbility("{U}"); + kickerAbility.addKickerCost("{B}"); + this.addAbility(kickerAbility); + + // As Urborg Lhurgoyf enters the battlefield, mill three cards for each time it was kicked. + this.addAbility(new EntersBattlefieldAbility( + new MillCardsControllerEffect(MultikickerCount.instance), null, + "As {this} enters the battlefield, " + + "mill three cards for each time it was kicked.", "" + )); + + // Urborg Lhurgoyf's power is equal to the number of creature cards in your graveyard and its toughness is equal to that number plus 1. + this.addAbility(new SimpleStaticAbility(Zone.ALL, new UrborgLhurgoyfEffect())); + } + + private UrborgLhurgoyf(final UrborgLhurgoyf card) { + super(card); + } + + @Override + public UrborgLhurgoyf copy() { + return new UrborgLhurgoyf(this); + } +} + +class UrborgLhurgoyfEffect extends ContinuousEffectImpl { + + public UrborgLhurgoyfEffect() { + super(Duration.EndOfGame, Layer.PTChangingEffects_7, SubLayer.CharacteristicDefining_7a, Outcome.BoostCreature); + staticText = "{this}'s power is equal to the number of creature cards in your graveyard and its toughness is equal to that number plus 1"; + } + + public UrborgLhurgoyfEffect(final UrborgLhurgoyfEffect effect) { + super(effect); + } + + @Override + public UrborgLhurgoyfEffect copy() { + return new UrborgLhurgoyfEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + MageObject sourceObject = source.getSourceObject(game); + if (player == null || sourceObject == null) { + return false; + } + int number = player.getGraveyard().count(StaticFilters.FILTER_CARD_CREATURE, game); + sourceObject.getPower().setValue(number); + sourceObject.getToughness().setValue(number + 1); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/DominariaUnited.java b/Mage.Sets/src/mage/sets/DominariaUnited.java index 083258bf7b..23c271e2fe 100644 --- a/Mage.Sets/src/mage/sets/DominariaUnited.java +++ b/Mage.Sets/src/mage/sets/DominariaUnited.java @@ -225,6 +225,7 @@ public final class DominariaUnited extends ExpansionSet { cards.add(new SetCardInfo("Toxic Abomination", 112, Rarity.COMMON, mage.cards.t.ToxicAbomination.class)); cards.add(new SetCardInfo("Tura Kennerud, Skyknight", 224, Rarity.UNCOMMON, mage.cards.t.TuraKennerudSkyknight.class)); cards.add(new SetCardInfo("Twinferno", 149, Rarity.UNCOMMON, mage.cards.t.Twinferno.class)); + cards.add(new SetCardInfo("Urborg Lhurgoyf", 186, Rarity.RARE, mage.cards.u.UrborgLhurgoyf.class)); cards.add(new SetCardInfo("Urza Assembles the Titans", 37, Rarity.RARE, mage.cards.u.UrzaAssemblesTheTitans.class)); cards.add(new SetCardInfo("Uurg, Spawn of Turg", 225, Rarity.UNCOMMON, mage.cards.u.UurgSpawnOfTurg.class)); cards.add(new SetCardInfo("Valiant Veteran", 38, Rarity.RARE, mage.cards.v.ValiantVeteran.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/MillCardsControllerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/MillCardsControllerEffect.java index 6c859ea8c5..6ec19874f6 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/MillCardsControllerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/MillCardsControllerEffect.java @@ -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(); } }