diff --git a/Mage.Sets/src/mage/cards/g/GarlandRoyalKidnapper.java b/Mage.Sets/src/mage/cards/g/GarlandRoyalKidnapper.java new file mode 100644 index 00000000000..87c5118efa6 --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GarlandRoyalKidnapper.java @@ -0,0 +1,172 @@ +package mage.cards.g; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.common.BecomesMonarchTargetEffect; +import mage.abilities.effects.common.continuous.BoostAllEffect; +import mage.abilities.effects.common.continuous.GainControlTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.FilterPermanent; +import mage.filter.StaticFilters; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.ControllerIdPredicate; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetOpponent; + +import java.util.Optional; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class GarlandRoyalKidnapper extends CardImpl { + + private static final FilterControlledCreaturePermanent filter + = new FilterControlledCreaturePermanent("creatures you control but don't own"); + + static { + filter.add(TargetController.NOT_YOU.getOwnerPredicate()); + } + + public GarlandRoyalKidnapper(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}{B}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.KNIGHT); + this.power = new MageInt(3); + this.toughness = new MageInt(4); + + // When Garland enters, target opponent becomes the monarch. + Ability ability = new EntersBattlefieldTriggeredAbility(new BecomesMonarchTargetEffect()); + ability.addTarget(new TargetOpponent()); + this.addAbility(ability); + + // Whenever an opponent becomes the monarch, gain control of target creature that player controls for as long as they're the monarch. + this.addAbility(new GarlandRoyalKidnapperTriggeredAbility()); + + // Creatures you control but don't own get +2/+2 and can't be sacrificed. + ability = new SimpleStaticAbility(new BoostAllEffect( + 2, 2, Duration.WhileOnBattlefield, filter, false + )); + ability.addEffect(new GarlandRoyalKidnapperSacrificeEffect()); + this.addAbility(ability); + } + + private GarlandRoyalKidnapper(final GarlandRoyalKidnapper card) { + super(card); + } + + @Override + public GarlandRoyalKidnapper copy() { + return new GarlandRoyalKidnapper(this); + } +} + +class GarlandRoyalKidnapperTriggeredAbility extends TriggeredAbilityImpl { + + GarlandRoyalKidnapperTriggeredAbility() { + super(Zone.BATTLEFIELD, new GarlandRoyalKidnapperControlEffect()); + this.addTarget(new TargetOpponent()); + this.setTriggerPhrase("Whenever an opponent becomes the monarch, "); + } + + private GarlandRoyalKidnapperTriggeredAbility(final GarlandRoyalKidnapperTriggeredAbility ability) { + super(ability); + } + + @Override + public GarlandRoyalKidnapperTriggeredAbility copy() { + return new GarlandRoyalKidnapperTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.BECOMES_MONARCH; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + Player player = game.getPlayer(event.getTargetId()); + if (player == null || !game.getOpponents(getControllerId()).contains(player.getId())) { + return false; + } + FilterPermanent filter = new FilterCreaturePermanent("creature controlled by " + player.getName()); + filter.add(new ControllerIdPredicate(player.getId())); + this.getTargets().clear(); + this.addTarget(new TargetPermanent(filter)); + this.getEffects().setValue("monarchId", player.getId()); + return true; + } +} + +class GarlandRoyalKidnapperControlEffect extends GainControlTargetEffect { + + GarlandRoyalKidnapperControlEffect() { + super(Duration.Custom, true); + staticText = "gain control of target creature that player controls for as long as they're the monarch"; + } + + private GarlandRoyalKidnapperControlEffect(final GarlandRoyalKidnapperControlEffect effect) { + super(effect); + } + + @Override + public GarlandRoyalKidnapperControlEffect copy() { + return new GarlandRoyalKidnapperControlEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (permanent != null + && Optional + .ofNullable((UUID) getValue("monarchId")) + .filter(uuid -> uuid.equals(game.getMonarchId())) + .isPresent()) { + return super.apply(game, source); + } + discard(); + return false; + } +} + +class GarlandRoyalKidnapperSacrificeEffect extends ContinuousEffectImpl { + + GarlandRoyalKidnapperSacrificeEffect() { + super(Duration.WhileOnBattlefield, Layer.RulesEffects, SubLayer.NA, Outcome.Benefit); + staticText = "and can't be sacrificed"; + } + + private GarlandRoyalKidnapperSacrificeEffect(final GarlandRoyalKidnapperSacrificeEffect effect) { + super(effect); + } + + @Override + public GarlandRoyalKidnapperSacrificeEffect copy() { + return new GarlandRoyalKidnapperSacrificeEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + for (Permanent permanent : game.getBattlefield().getActivePermanents( + StaticFilters.FILTER_CONTROLLED_CREATURE, source.getControllerId(), source, game + )) { + if (!permanent.isOwnedBy(source.getControllerId())) { + permanent.setCanBeSacrificed(true); + } + } + return true; + } +} diff --git a/Mage.Sets/src/mage/cards/j/JaredCarthalionTrueHeir.java b/Mage.Sets/src/mage/cards/j/JaredCarthalionTrueHeir.java index f23761bd6e5..83c076a64c7 100644 --- a/Mage.Sets/src/mage/cards/j/JaredCarthalionTrueHeir.java +++ b/Mage.Sets/src/mage/cards/j/JaredCarthalionTrueHeir.java @@ -34,8 +34,7 @@ public final class JaredCarthalionTrueHeir extends CardImpl { this.toughness = new MageInt(3); // When Jared Carthalion, True Heir enters the battlefield, target opponent becomes the monarch. You can't become the monarch this turn. - Ability ability = new EntersBattlefieldTriggeredAbility(new BecomesMonarchTargetEffect() - .setText("target opponent becomes the monarch")); + Ability ability = new EntersBattlefieldTriggeredAbility(new BecomesMonarchTargetEffect()); ability.addEffect(new JaredCarthalionTrueHeirMonarchEffect()); ability.addTarget(new TargetOpponent()); ability.addHint(MonarchHint.instance); diff --git a/Mage.Sets/src/mage/sets/FinalFantasyCommander.java b/Mage.Sets/src/mage/sets/FinalFantasyCommander.java index 483a1b2442c..d1dee7c25a5 100644 --- a/Mage.Sets/src/mage/sets/FinalFantasyCommander.java +++ b/Mage.Sets/src/mage/sets/FinalFantasyCommander.java @@ -187,6 +187,7 @@ public final class FinalFantasyCommander extends ExpansionSet { cards.add(new SetCardInfo("G'raha Tia, Scion Reborn", 222, Rarity.MYTHIC, mage.cards.g.GrahaTiaScionReborn.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("G'raha Tia, Scion Reborn", 3, Rarity.MYTHIC, mage.cards.g.GrahaTiaScionReborn.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Game Trail", 398, Rarity.RARE, mage.cards.g.GameTrail.class)); + cards.add(new SetCardInfo("Garland, Royal Kidnapper", 442, Rarity.RARE, mage.cards.g.GarlandRoyalKidnapper.class)); cards.add(new SetCardInfo("Gatta and Luzzu", 134, Rarity.RARE, mage.cards.g.GattaAndLuzzu.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Gatta and Luzzu", 19, Rarity.RARE, mage.cards.g.GattaAndLuzzu.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Gau, Feral Youth", 152, Rarity.RARE, mage.cards.g.GauFeralYouth.class, NON_FULL_USE_VARIOUS)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/BecomesMonarchTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/BecomesMonarchTargetEffect.java index b8a7b236791..5aeef1bd8d4 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/BecomesMonarchTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/BecomesMonarchTargetEffect.java @@ -13,7 +13,7 @@ public class BecomesMonarchTargetEffect extends OneShotEffect { public BecomesMonarchTargetEffect() { super(Outcome.Benefit); - staticText = "target player becomes the monarch"; + staticText = "target opponent becomes the monarch"; } protected BecomesMonarchTargetEffect(final BecomesMonarchTargetEffect effect) { @@ -34,5 +34,4 @@ public class BecomesMonarchTargetEffect extends OneShotEffect { } return false; } - }