diff --git a/Mage.Sets/src/mage/cards/i/IrohTeaMaster.java b/Mage.Sets/src/mage/cards/i/IrohTeaMaster.java new file mode 100644 index 00000000000..4bf0edd1053 --- /dev/null +++ b/Mage.Sets/src/mage/cards/i/IrohTeaMaster.java @@ -0,0 +1,148 @@ +package mage.cards.i; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.delayed.ReflexiveTriggeredAbility; +import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.continuous.GainControlTargetEffect; +import mage.abilities.hint.Hint; +import mage.abilities.hint.ValueHint; +import mage.abilities.triggers.BeginningOfCombatTriggeredAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.counters.CounterType; +import mage.filter.FilterPermanent; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.permanent.token.AllyToken; +import mage.game.permanent.token.FoodToken; +import mage.game.permanent.token.Token; +import mage.players.Player; +import mage.target.common.TargetControlledPermanent; +import mage.target.common.TargetOpponent; +import mage.target.targetpointer.EachTargetPointer; +import mage.target.targetpointer.FixedTarget; + +import java.util.Optional; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class IrohTeaMaster extends CardImpl { + + public IrohTeaMaster(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}{W}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.CITIZEN); + this.subtype.add(SubType.ALLY); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // When Iroh enters, create a Food token. + this.addAbility(new EntersBattlefieldTriggeredAbility(new CreateTokenEffect(new FoodToken()))); + + // At the beginning of combat on your turn, you may have target opponent gain control of target permanent you control. When you do, create a 1/1 white Ally creature token. Put a +1/+1 counter on that token for each permanent you own that your opponents control. + Ability ability = new BeginningOfCombatTriggeredAbility(new IrohTeaMasterControlEffect()); + ability.addTarget(new TargetOpponent()); + ability.addTarget(new TargetControlledPermanent()); + this.addAbility(ability.addHint(IrohTeaMasterTokenEffect.getHint())); + } + + private IrohTeaMaster(final IrohTeaMaster card) { + super(card); + } + + @Override + public IrohTeaMaster copy() { + return new IrohTeaMaster(this); + } +} + +class IrohTeaMasterControlEffect extends OneShotEffect { + + IrohTeaMasterControlEffect() { + super(Outcome.Benefit); + staticText = "have target opponent gain control of target permanent you control. " + + "When you do, create a 1/1 white Ally creature token. " + + "Put a +1/+1 counter on that token for each permanent you own that your opponents control"; + this.setTargetPointer(new EachTargetPointer()); + } + + private IrohTeaMasterControlEffect(final IrohTeaMasterControlEffect effect) { + super(effect); + } + + @Override + public IrohTeaMasterControlEffect copy() { + return new IrohTeaMasterControlEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); + Permanent permanent = game.getPermanent(getTargetPointer().getTargets(game, source).get(0)); + if (player == null || permanent == null) { + return false; + } + game.addEffect(new GainControlTargetEffect(Duration.Custom, true, player.getId()) + .setTargetPointer(new FixedTarget(permanent, game)), source); + game.fireReflexiveTriggeredAbility(new ReflexiveTriggeredAbility(new IrohTeaMasterTokenEffect(), false), source); + return true; + } +} + +class IrohTeaMasterTokenEffect extends OneShotEffect { + + private static final FilterPermanent filter = new FilterPermanent(); + + static { + filter.add(TargetController.YOU.getOwnerPredicate()); + filter.add(TargetController.OPPONENT.getControllerPredicate()); + } + + private static final Hint hint = new ValueHint( + "Permanents you own that your opponents control", new PermanentsOnBattlefieldCount(filter) + ); + + public static Hint getHint() { + return hint; + } + + IrohTeaMasterTokenEffect() { + super(Outcome.Benefit); + staticText = "create a 1/1 white Ally creature token. Put a +1/+1 counter " + + "on that token for each permanent you own that your opponents control"; + } + + private IrohTeaMasterTokenEffect(final IrohTeaMasterTokenEffect effect) { + super(effect); + } + + @Override + public IrohTeaMasterTokenEffect copy() { + return new IrohTeaMasterTokenEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Token token = new AllyToken(); + token.putOntoBattlefield(1, game, source); + int count = game.getBattlefield().count(filter, source.getControllerId(), source, game); + if (count < 1) { + return true; + } + for (UUID tokenId : token.getLastAddedTokenIds()) { + Optional.ofNullable(tokenId) + .map(game::getPermanent) + .ifPresent(permanent -> permanent.addCounters(CounterType.P1P1.createInstance(count), source, game)); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/AvatarTheLastAirbender.java b/Mage.Sets/src/mage/sets/AvatarTheLastAirbender.java index 74d6a9e4cec..d4598fd7793 100644 --- a/Mage.Sets/src/mage/sets/AvatarTheLastAirbender.java +++ b/Mage.Sets/src/mage/sets/AvatarTheLastAirbender.java @@ -211,6 +211,8 @@ public final class AvatarTheLastAirbender extends ExpansionSet { cards.add(new SetCardInfo("Iroh's Demonstration", 141, Rarity.UNCOMMON, mage.cards.i.IrohsDemonstration.class)); cards.add(new SetCardInfo("Iroh, Grand Lotus", 227, Rarity.RARE, mage.cards.i.IrohGrandLotus.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Iroh, Grand Lotus", 349, Rarity.RARE, mage.cards.i.IrohGrandLotus.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Iroh, Tea Master", 228, Rarity.RARE, mage.cards.i.IrohTeaMaster.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Iroh, Tea Master", 381, Rarity.RARE, mage.cards.i.IrohTeaMaster.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Island", 283, Rarity.LAND, mage.cards.basiclands.Island.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Island", 288, Rarity.LAND, mage.cards.basiclands.Island.class, FULL_ART_BFZ_VARIOUS)); cards.add(new SetCardInfo("Island", 293, Rarity.LAND, mage.cards.basiclands.Island.class, FULL_ART_BFZ_VARIOUS));