diff --git a/Mage.Sets/src/mage/cards/a/AKillerAmongUs.java b/Mage.Sets/src/mage/cards/a/AKillerAmongUs.java index 9b468396bfd..37d3c617423 100644 --- a/Mage.Sets/src/mage/cards/a/AKillerAmongUs.java +++ b/Mage.Sets/src/mage/cards/a/AKillerAmongUs.java @@ -208,7 +208,7 @@ class AKillerAmongUsEffect extends OneShotEffect { class AKillerAmongUsCost extends CostImpl { AKillerAmongUsCost() { - this.text = "Reveal the chosen creature type"; + this.text = "Reveal the creature type you chose"; } private AKillerAmongUsCost(final AKillerAmongUsCost cost) { diff --git a/Mage.Sets/src/mage/cards/a/AkromasWill.java b/Mage.Sets/src/mage/cards/a/AkromasWill.java index 77ec2e648c2..f9ea1387a8d 100644 --- a/Mage.Sets/src/mage/cards/a/AkromasWill.java +++ b/Mage.Sets/src/mage/cards/a/AkromasWill.java @@ -31,7 +31,7 @@ public final class AkromasWill extends CardImpl { // Choose one. If you control a commander as you cast this spell, you may choose both. this.getSpellAbility().getModes().setChooseText( - "Choose one. If you control a commander as you cast this spell, you may choose both." + "Choose one. If you control a commander as you cast this spell, you may choose both instead." ); this.getSpellAbility().getModes().setMoreCondition(ControlACommanderCondition.instance); diff --git a/Mage.Sets/src/mage/cards/a/AmaliaBenavidesAguirre.java b/Mage.Sets/src/mage/cards/a/AmaliaBenavidesAguirre.java index 615b694504e..abe9a318d30 100644 --- a/Mage.Sets/src/mage/cards/a/AmaliaBenavidesAguirre.java +++ b/Mage.Sets/src/mage/cards/a/AmaliaBenavidesAguirre.java @@ -27,7 +27,7 @@ import java.util.UUID; */ public final class AmaliaBenavidesAguirre extends CardImpl { - private final static FilterPermanent filter = new FilterCreaturePermanent("other creatures"); + private static final FilterPermanent filter = new FilterCreaturePermanent("other creatures"); static { filter.add(AnotherPredicate.instance); @@ -50,7 +50,7 @@ public final class AmaliaBenavidesAguirre extends CardImpl { ability.addEffect(new ConditionalOneShotEffect( new DestroyAllEffect(filter), AmaliaBenavidesAguirreCondition.instance - ).setText("Then, destroy all other creatures if its power is exactly 20")); + ).setText("Then destroy all other creatures if its power is exactly 20")); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/a/AnzragTheQuakeMole.java b/Mage.Sets/src/mage/cards/a/AnzragTheQuakeMole.java index 6f60bc9ba4f..35550291020 100644 --- a/Mage.Sets/src/mage/cards/a/AnzragTheQuakeMole.java +++ b/Mage.Sets/src/mage/cards/a/AnzragTheQuakeMole.java @@ -40,8 +40,7 @@ public final class AnzragTheQuakeMole extends CardImpl { Ability ability = new BecomesBlockedSourceTriggeredAbility( new UntapAllEffect(filter), false ); - ability.addEffect(new AdditionalCombatPhaseEffect() - .setText("After this combat phase, there is an additional combat phase")); + ability.addEffect(new AdditionalCombatPhaseEffect()); this.addAbility(ability); // {3}{R}{R}{G}{G}: Anzrag must be blocked each combat this turn if able. diff --git a/Mage.Sets/src/mage/cards/a/AzraBladeseeker.java b/Mage.Sets/src/mage/cards/a/AzraBladeseeker.java index e88d4fbd397..955facafbc1 100644 --- a/Mage.Sets/src/mage/cards/a/AzraBladeseeker.java +++ b/Mage.Sets/src/mage/cards/a/AzraBladeseeker.java @@ -90,7 +90,7 @@ class AzraBladeseekerEffect extends OneShotEffect { return true; } - class PlayerCard { + static class PlayerCard { private final Player player; private final Card card; diff --git a/Mage.Sets/src/mage/cards/b/BazaarTrader.java b/Mage.Sets/src/mage/cards/b/BazaarTrader.java index 46c8358f5cc..e74f8049d9a 100644 --- a/Mage.Sets/src/mage/cards/b/BazaarTrader.java +++ b/Mage.Sets/src/mage/cards/b/BazaarTrader.java @@ -1,24 +1,22 @@ - package mage.cards.b; -import java.util.UUID; import mage.MageInt; -import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.TapSourceCost; -import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.common.TargetPlayerGainControlTargetPermanentEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.*; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.Zone; import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.Predicates; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; import mage.target.TargetPlayer; import mage.target.common.TargetControlledPermanent; +import java.util.UUID; + /** * * @author North @@ -42,7 +40,7 @@ public final class BazaarTrader extends CardImpl { this.toughness = new MageInt(1); // {tap}: Target player gains control of target artifact, creature, or land you control. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BazaarTraderEffect(), new TapSourceCost()); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new TargetPlayerGainControlTargetPermanentEffect(), new TapSourceCost()); ability.addTarget(new TargetPlayer()); ability.addTarget(new TargetControlledPermanent(filter)); this.addAbility(ability); @@ -57,41 +55,3 @@ public final class BazaarTrader extends CardImpl { return new BazaarTrader(this); } } - -class BazaarTraderEffect extends ContinuousEffectImpl { - - MageObjectReference targetPermanentReference; - - public BazaarTraderEffect() { - super(Duration.Custom, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl); - this.staticText = "Target player gains control of target artifact, creature, or land you control"; - } - - private BazaarTraderEffect(final BazaarTraderEffect effect) { - super(effect); - this.targetPermanentReference = effect.targetPermanentReference; - } - - @Override - public BazaarTraderEffect copy() { - return new BazaarTraderEffect(this); - } - - @Override - public void init(Ability source, Game game) { - super.init(source, game); - targetPermanentReference = new MageObjectReference(source.getTargets().get(1).getFirstTarget(), game); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getFirstTarget()); - Permanent permanent = targetPermanentReference.getPermanent(game); - if (player != null && permanent != null) { - return permanent.changeControllerId(player.getId(), game, source); - } else { - discard(); - } - return false; - } -} diff --git a/Mage.Sets/src/mage/cards/b/BillFernyBreeSwindler.java b/Mage.Sets/src/mage/cards/b/BillFernyBreeSwindler.java index 313560e5825..9baef301cc1 100644 --- a/Mage.Sets/src/mage/cards/b/BillFernyBreeSwindler.java +++ b/Mage.Sets/src/mage/cards/b/BillFernyBreeSwindler.java @@ -68,7 +68,7 @@ class BillFernyEffect extends OneShotEffect { private static final Effect create3TreasureTokens = new CreateTokenEffect(new TreasureToken(), 3); private static final Effect removeFromCombat = new RemoveFromCombatSourceEffect(); - public BillFernyEffect() { + BillFernyEffect() { super(Outcome.Benefit); this.staticText = "Target opponent gains control of target Horse you control. If they do, remove Bill Ferny from combat and create three Treasure tokens."; } diff --git a/Mage.Sets/src/mage/cards/b/BlanketOfNight.java b/Mage.Sets/src/mage/cards/b/BlanketOfNight.java index 6b071f0b61c..a2a7254a22b 100644 --- a/Mage.Sets/src/mage/cards/b/BlanketOfNight.java +++ b/Mage.Sets/src/mage/cards/b/BlanketOfNight.java @@ -1,16 +1,11 @@ - package mage.cards.b; -import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.common.continuous.AddCardSubtypeAllEffect; -import mage.abilities.effects.common.continuous.GainAbilityAllEffect; -import mage.abilities.mana.BlackManaAbility; +import mage.abilities.effects.common.continuous.AddBasicLandTypeAllLandsEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.*; -import mage.filter.StaticFilters; -import mage.filter.common.FilterLandPermanent; +import mage.constants.CardType; +import mage.constants.SubType; import java.util.UUID; @@ -22,13 +17,9 @@ public final class BlanketOfNight extends CardImpl { public BlanketOfNight(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{B}{B}"); - // Each land is a Swamp in addition to its other land types. - Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAllEffect(new BlackManaAbility(), Duration.WhileOnBattlefield, new FilterLandPermanent(), - "Each land is a Swamp in addition to its other land types")); - ability.addEffect(new AddCardSubtypeAllEffect(StaticFilters.FILTER_LAND, SubType.SWAMP, DependencyType.BecomeSwamp)); - this.addAbility(ability); + this.addAbility(new SimpleStaticAbility(new AddBasicLandTypeAllLandsEffect(SubType.SWAMP))); } private BlanketOfNight(final BlanketOfNight card) { diff --git a/Mage.Sets/src/mage/cards/b/BrambleFamiliar.java b/Mage.Sets/src/mage/cards/b/BrambleFamiliar.java index 7188cdab4ea..0229ac3003a 100644 --- a/Mage.Sets/src/mage/cards/b/BrambleFamiliar.java +++ b/Mage.Sets/src/mage/cards/b/BrambleFamiliar.java @@ -84,8 +84,8 @@ class FetchQuestEffect extends OneShotEffect { FetchQuestEffect() { super(Outcome.Benefit); - staticText = "mill seven cards, then put a creature, enchantment, or land card " - + "from among cards milled this way onto the battlefield"; + staticText = "mill seven cards. Then put a creature, enchantment, or land card " + + "from among the milled cards onto the battlefield"; } private FetchQuestEffect(final FetchQuestEffect effect) { @@ -115,4 +115,4 @@ class FetchQuestEffect extends OneShotEffect { return true; } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/c/CrystalGrotto.java b/Mage.Sets/src/mage/cards/c/CrystalGrotto.java index 643dde55e58..a11715d3416 100644 --- a/Mage.Sets/src/mage/cards/c/CrystalGrotto.java +++ b/Mage.Sets/src/mage/cards/c/CrystalGrotto.java @@ -22,7 +22,7 @@ public final class CrystalGrotto extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.LAND}, ""); // When Crystal Grotto enters the battlefield, scry 1. - this.addAbility(new EntersBattlefieldTriggeredAbility(new ScryEffect(1))); + this.addAbility(new EntersBattlefieldTriggeredAbility(new ScryEffect(1, false))); // {T}: Add {C}. this.addAbility(new ColorlessManaAbility()); diff --git a/Mage.Sets/src/mage/cards/d/DavrosDalekCreator.java b/Mage.Sets/src/mage/cards/d/DavrosDalekCreator.java index 419e23c33d7..629bf5f1d89 100644 --- a/Mage.Sets/src/mage/cards/d/DavrosDalekCreator.java +++ b/Mage.Sets/src/mage/cards/d/DavrosDalekCreator.java @@ -43,7 +43,8 @@ public final class DavrosDalekCreator extends CardImpl { Ability ability = new BeginningOfEndStepTriggeredAbility( new ConditionalOneShotEffect( new CreateTokenEffect(new DalekToken()), - new OpponentLostLifeCondition(ComparisonType.OR_GREATER, 3) + new OpponentLostLifeCondition(ComparisonType.OR_GREATER, 3), + "create a 3/3 black Dalek artifact creature token with menace if an opponent lost 3 or more life this turn" ), TargetController.YOU, false ); diff --git a/Mage.Sets/src/mage/cards/d/Disarm.java b/Mage.Sets/src/mage/cards/d/Disarm.java index b4b722435ff..4c683f26764 100644 --- a/Mage.Sets/src/mage/cards/d/Disarm.java +++ b/Mage.Sets/src/mage/cards/d/Disarm.java @@ -1,4 +1,3 @@ - package mage.cards.d; import java.util.UUID; @@ -39,39 +38,40 @@ public final class Disarm extends CardImpl { return new Disarm(this); } - class DisarmEffect extends OneShotEffect { +} - public DisarmEffect() { - super(Outcome.UnboostCreature); - this.staticText = "Unattach all Equipment from target creature"; - } +class DisarmEffect extends OneShotEffect { - private DisarmEffect(final DisarmEffect effect) { - super(effect); - } + DisarmEffect() { + super(Outcome.UnboostCreature); + this.staticText = "Unattach all Equipment from target creature"; + } - @Override - public DisarmEffect copy() { - return new DisarmEffect(this); - } + private DisarmEffect(final DisarmEffect effect) { + super(effect); + } - @Override - public boolean apply(Game game, Ability source) { - Permanent creature = game.getPermanent(targetPointer.getFirst(game, source)); - if (creature != null) { - FilterPermanent creatureFilter = new FilterPermanent(); - creatureFilter.add(new PermanentIdPredicate(creature.getId())); + @Override + public DisarmEffect copy() { + return new DisarmEffect(this); + } - FilterPermanent equipmentFilter = new FilterPermanent(); - equipmentFilter.add(new AttachedToPredicate(creatureFilter)); - equipmentFilter.add(SubType.EQUIPMENT.getPredicate()); + @Override + public boolean apply(Game game, Ability source) { + Permanent creature = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (creature != null) { + FilterPermanent creatureFilter = new FilterPermanent(); + creatureFilter.add(new PermanentIdPredicate(creature.getId())); - for (Permanent equipment : game.getBattlefield().getAllActivePermanents(equipmentFilter, game)) { - creature.removeAttachment(equipment.getId(), source, game); - } - return true; + FilterPermanent equipmentFilter = new FilterPermanent(); + equipmentFilter.add(new AttachedToPredicate(creatureFilter)); + equipmentFilter.add(SubType.EQUIPMENT.getPredicate()); + + for (Permanent equipment : game.getBattlefield().getAllActivePermanents(equipmentFilter, game)) { + creature.removeAttachment(equipment.getId(), source, game); } - return false; + return true; } + return false; } } diff --git a/Mage.Sets/src/mage/cards/d/DiscerningFinancier.java b/Mage.Sets/src/mage/cards/d/DiscerningFinancier.java index 83c3d30546a..5c61701cd1a 100644 --- a/Mage.Sets/src/mage/cards/d/DiscerningFinancier.java +++ b/Mage.Sets/src/mage/cards/d/DiscerningFinancier.java @@ -66,7 +66,7 @@ public final class DiscerningFinancier extends CardImpl { // {2}{W}: Choose another player. That player gains control of target Treasure you control. You draw a card. Ability ability = new SimpleActivatedAbility( new DiscerningFinancierEffect(), - new ManaCostsImpl("{2}{W}") + new ManaCostsImpl<>("{2}{W}") ); ability.addTarget(new TargetControlledPermanent(filter)); ability.addEffect(new DrawCardSourceControllerEffect(1, "you")); @@ -126,4 +126,4 @@ class DiscerningFinancierEffect extends OneShotEffect { return true; } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/d/Donate.java b/Mage.Sets/src/mage/cards/d/Donate.java index c8636d12ef2..38a79b8d1ab 100644 --- a/Mage.Sets/src/mage/cards/d/Donate.java +++ b/Mage.Sets/src/mage/cards/d/Donate.java @@ -1,22 +1,13 @@ - package mage.cards.d; -import java.util.UUID; -import mage.abilities.Ability; -import mage.abilities.effects.ContinuousEffect; -import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.continuous.GainControlTargetEffect; +import mage.abilities.effects.common.TargetPlayerGainControlTargetPermanentEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Outcome; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; import mage.target.TargetPlayer; import mage.target.common.TargetControlledPermanent; -import mage.target.targetpointer.FixedTarget; + +import java.util.UUID; /** * @@ -28,7 +19,7 @@ public final class Donate extends CardImpl { super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{U}"); // Target player gains control of target permanent you control. - this.getSpellAbility().addEffect(new DonateEffect()); + this.getSpellAbility().addEffect(new TargetPlayerGainControlTargetPermanentEffect()); this.getSpellAbility().addTarget(new TargetPlayer()); this.getSpellAbility().addTarget(new TargetControlledPermanent()); } @@ -42,33 +33,3 @@ public final class Donate extends CardImpl { return new Donate(this); } } - -class DonateEffect extends OneShotEffect { - - DonateEffect() { - super(Outcome.Detriment); - this.staticText = "Target player gains control of target permanent you control"; - } - - private DonateEffect(final DonateEffect effect) { - super(effect); - } - - @Override - public DonateEffect copy() { - return new DonateEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); - Permanent permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget()); - if (targetPlayer != null && permanent != null) { - ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, targetPlayer.getId()); - effect.setTargetPointer(new FixedTarget(permanent, game)); - game.addEffect(effect, source); - } - return true; - } - -} diff --git a/Mage.Sets/src/mage/cards/e/EdgewallInn.java b/Mage.Sets/src/mage/cards/e/EdgewallInn.java index 2e72ec5aaea..4c7058081b6 100644 --- a/Mage.Sets/src/mage/cards/e/EdgewallInn.java +++ b/Mage.Sets/src/mage/cards/e/EdgewallInn.java @@ -49,7 +49,7 @@ public final class EdgewallInn extends CardImpl { // {3}, {T}, Sacrifice Edgewall Inn: Return target card that has an Adventure from your graveyard to your hand. Ability ability = new SimpleActivatedAbility( new ReturnFromGraveyardToHandTargetEffect(), - new ManaCostsImpl("{3}") + new ManaCostsImpl<>("{3}") ); ability.addCost(new TapSourceCost()); ability.addCost(new SacrificeSourceCost()); diff --git a/Mage.Sets/src/mage/cards/f/FallOfCairAndros.java b/Mage.Sets/src/mage/cards/f/FallOfCairAndros.java index 55c252915be..83646f7a6ed 100644 --- a/Mage.Sets/src/mage/cards/f/FallOfCairAndros.java +++ b/Mage.Sets/src/mage/cards/f/FallOfCairAndros.java @@ -31,7 +31,7 @@ public final class FallOfCairAndros extends CardImpl { this.addAbility(new FallOfCairAndrosTriggeredAbility()); // {7}{R}: Fall of Cair Andros deals 7 damage to target creature. - Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(7), new ManaCostsImpl("{7}{R}")); + Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(7), new ManaCostsImpl<>("{7}{R}")); ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/cards/f/FathomTrawl.java b/Mage.Sets/src/mage/cards/f/FathomTrawl.java index 523d62d71e9..ea48e7f553e 100644 --- a/Mage.Sets/src/mage/cards/f/FathomTrawl.java +++ b/Mage.Sets/src/mage/cards/f/FathomTrawl.java @@ -1,4 +1,3 @@ - package mage.cards.f; import java.util.UUID; @@ -34,51 +33,54 @@ public final class FathomTrawl extends CardImpl { return new FathomTrawl(this); } - class FathomTrawlEffect extends OneShotEffect { +} - public FathomTrawlEffect() { - super(Outcome.DrawCard); - this.staticText = "Reveal cards from the top of your library until you reveal three nonland cards. Put the nonland cards revealed this way into your hand, then put the rest of the revealed cards on the bottom of your library in any order"; +class FathomTrawlEffect extends OneShotEffect { + + FathomTrawlEffect() { + super(Outcome.DrawCard); + this.staticText = "Reveal cards from the top of your library until you reveal three nonland cards. " + + "Put the nonland cards revealed this way into your hand, then put the rest of the revealed " + + "cards on the bottom of your library in any order"; + } + + private FathomTrawlEffect(final FathomTrawlEffect effect) { + super(effect); + } + + @Override + public FathomTrawlEffect copy() { + return new FathomTrawlEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + MageObject sourceObject = game.getObject(source); + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null || sourceObject == null) { + return false; } - - private FathomTrawlEffect(final FathomTrawlEffect effect) { - super(effect); - } - - @Override - public FathomTrawlEffect copy() { - return new FathomTrawlEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - MageObject sourceObject = game.getObject(source); - Player controller = game.getPlayer(source.getControllerId()); - if (controller == null || sourceObject == null) { - return false; - } - Cards cards = new CardsImpl(); - Cards nonlandCards = new CardsImpl(); - Cards landCards = new CardsImpl(); - for (Card card : controller.getLibrary().getCards(game)) { - if (card != null) { - cards.add(card); - if (!card.isLand(game)) { - nonlandCards.add(card); - if (nonlandCards.size() == 3) { - break; - } - } else { - landCards.add(card); + Cards cards = new CardsImpl(); + Cards nonlandCards = new CardsImpl(); + Cards landCards = new CardsImpl(); + for (Card card : controller.getLibrary().getCards(game)) { + if (card != null) { + cards.add(card); + if (!card.isLand(game)) { + nonlandCards.add(card); + if (nonlandCards.size() == 3) { + break; } } else { - break; + landCards.add(card); } + } else { + break; } - controller.revealCards(sourceObject.getName(), cards, game); - controller.moveCards(nonlandCards, Zone.HAND, source, game); - controller.putCardsOnBottomOfLibrary(landCards, game, source, true); - return true; } + controller.revealCards(sourceObject.getName(), cards, game); + controller.moveCards(nonlandCards, Zone.HAND, source, game); + controller.putCardsOnBottomOfLibrary(landCards, game, source, true); + return true; } } diff --git a/Mage.Sets/src/mage/cards/f/ForgottenAncient.java b/Mage.Sets/src/mage/cards/f/ForgottenAncient.java index 16cc37ad86a..da6ef78de1a 100644 --- a/Mage.Sets/src/mage/cards/f/ForgottenAncient.java +++ b/Mage.Sets/src/mage/cards/f/ForgottenAncient.java @@ -1,4 +1,3 @@ - package mage.cards.f; import mage.MageInt; @@ -28,11 +27,6 @@ import java.util.UUID; * @author Blinke */ public final class ForgottenAncient extends CardImpl { - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature"); - - static { - filter.add(AnotherPredicate.instance); - } public ForgottenAncient(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}"); @@ -58,82 +52,89 @@ public final class ForgottenAncient extends CardImpl { return new ForgottenAncient(this); } - class CounterMovement { +} + +class ForgottenAncientEffect extends OneShotEffect { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature"); + + static { + filter.add(AnotherPredicate.instance); + } + + ForgottenAncientEffect() { + super(Outcome.Benefit); + this.staticText = "you may move any number of +1/+1 counters from {this} onto other creatures."; + } + + private ForgottenAncientEffect(final ForgottenAncientEffect effect) { + super(effect); + } + + @Override + public ForgottenAncientEffect copy() { + return new ForgottenAncientEffect(this); + } + + static class CounterMovement { public UUID target; public int counters; } - class ForgottenAncientEffect extends OneShotEffect { + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Permanent sourcePermanent = game.getPermanent(source.getSourceId()); - public ForgottenAncientEffect() { - super(Outcome.Benefit); - this.staticText = "you may move any number of +1/+1 counters from {this} onto other creatures."; + if (controller == null || sourcePermanent == null) { + return false; } - private ForgottenAncientEffect(final ForgottenAncientEffect effect) { - super(effect); + int numCounters = sourcePermanent.getCounters(game).getCount(CounterType.P1P1); + if (numCounters == 0) { + return false; } - @Override - public ForgottenAncientEffect copy() { - return new ForgottenAncientEffect(this); - } + List counterMovements = new ArrayList<>(); - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - Permanent sourcePermanent = game.getPermanent(source.getSourceId()); - - if (controller == null || sourcePermanent == null) { - return false; + do { + Target target = new TargetCreaturePermanent(1, 1, filter, true); + if (!target.canChoose(controller.getId(), source, game)) { + break; } - int numCounters = sourcePermanent.getCounters(game).getCount(CounterType.P1P1); - if (numCounters == 0) { - return false; + if (!target.choose(Outcome.BoostCreature, source.getControllerId(), source.getSourceId(), source, game)) { + break; } - List counterMovements = new ArrayList<>(); + int amountToMove = controller.getAmount(0, numCounters, "Choose how many counters to move (" + numCounters + " counters remaining.)", game); + if (amountToMove == 0) { + break; + } - do { - Target target = new TargetCreaturePermanent(1, 1, filter, true); - if (!target.canChoose(controller.getId(), source, game)) { - break; - } - - if (!target.choose(Outcome.BoostCreature, source.getControllerId(), source.getSourceId(), source, game)) { - break; - } - - int amountToMove = controller.getAmount(0, numCounters, "Choose how many counters to move (" + numCounters + " counters remaining.)", game); - if (amountToMove == 0) { - break; - } - - boolean previouslyChosen = false; - for (CounterMovement cm : counterMovements) { - if (cm.target.equals(target.getFirstTarget())) { - cm.counters += amountToMove; - previouslyChosen = true; - } - } - if (!previouslyChosen) { - CounterMovement cm = new CounterMovement(); - cm.target = target.getFirstTarget(); - cm.counters = amountToMove; - counterMovements.add(cm); - } - - numCounters -= amountToMove; - - } while (numCounters > 0 && controller.chooseUse(Outcome.Benefit, "Move additional counters?", source, game)); - - //Move all the counters for each chosen creature + boolean previouslyChosen = false; for (CounterMovement cm : counterMovements) { - sourcePermanent.removeCounters(CounterType.P1P1.createInstance(cm.counters), source, game); - game.getPermanent(cm.target).addCounters(CounterType.P1P1.createInstance(cm.counters), source.getControllerId(), source, game); + if (cm.target.equals(target.getFirstTarget())) { + cm.counters += amountToMove; + previouslyChosen = true; + } } - return true; + if (!previouslyChosen) { + CounterMovement cm = new CounterMovement(); + cm.target = target.getFirstTarget(); + cm.counters = amountToMove; + counterMovements.add(cm); + } + + numCounters -= amountToMove; + + } while (numCounters > 0 && controller.chooseUse(Outcome.Benefit, "Move additional counters?", source, game)); + + //Move all the counters for each chosen creature + for (CounterMovement cm : counterMovements) { + sourcePermanent.removeCounters(CounterType.P1P1.createInstance(cm.counters), source, game); + game.getPermanent(cm.target).addCounters(CounterType.P1P1.createInstance(cm.counters), source.getControllerId(), source, game); } + return true; } } diff --git a/Mage.Sets/src/mage/cards/f/FulgentDistraction.java b/Mage.Sets/src/mage/cards/f/FulgentDistraction.java index 8991951f4f4..1fa0cb7e906 100644 --- a/Mage.Sets/src/mage/cards/f/FulgentDistraction.java +++ b/Mage.Sets/src/mage/cards/f/FulgentDistraction.java @@ -1,5 +1,3 @@ - - package mage.cards.f; import java.util.ArrayList; @@ -42,14 +40,12 @@ public final class FulgentDistraction extends CardImpl { class FulgentDistractionEffect extends OneShotEffect { - private static String text = "Choose two target creatures. Tap those creatures, then unattach all Equipment from them"; - - FulgentDistractionEffect ( ) { + FulgentDistractionEffect() { super(Outcome.Tap); - staticText = text; + staticText = "Choose two target creatures. Tap those creatures, then unattach all Equipment from them"; } - FulgentDistractionEffect ( FulgentDistractionEffect effect ) { + private FulgentDistractionEffect(FulgentDistractionEffect effect) { super(effect); } @@ -63,13 +59,14 @@ class FulgentDistractionEffect extends OneShotEffect { Permanent equipment = game.getPermanent(equipmentId); boolean isEquipment = false; - for ( Ability ability : equipment.getAbilities() ) { - if ( ability instanceof EquipAbility ) { + for (Ability ability : equipment.getAbilities()) { + if (ability instanceof EquipAbility) { isEquipment = true; + break; } } - if ( isEquipment ) { + if (isEquipment) { creature.removeAttachment(equipmentId, source, game); } } diff --git a/Mage.Sets/src/mage/cards/g/GoddricCloakedReveler.java b/Mage.Sets/src/mage/cards/g/GoddricCloakedReveler.java index fed13379ba3..acf329b9259 100644 --- a/Mage.Sets/src/mage/cards/g/GoddricCloakedReveler.java +++ b/Mage.Sets/src/mage/cards/g/GoddricCloakedReveler.java @@ -46,7 +46,7 @@ public final class GoddricCloakedReveler extends CardImpl { // Celebration -- As long as two or more nonland permanents entered the battlefield under your control this turn, Goddric, Cloaked Reveler is a Dragon with base power and toughness 4/4, flying, and "{R}: Dragons you control get +1/+0 until end of turn." Ability dragonFirebreath = new SimpleActivatedAbility( new BoostAllEffect(1, 0, Duration.EndOfTurn, filter, false), - new ManaCostsImpl("{R}") + new ManaCostsImpl<>("{R}") ); Ability ability = new SimpleStaticAbility(new ConditionalContinuousEffect( diff --git a/Mage.Sets/src/mage/cards/h/HarmlessOffering.java b/Mage.Sets/src/mage/cards/h/HarmlessOffering.java index aab9af32bf1..528c41807f1 100644 --- a/Mage.Sets/src/mage/cards/h/HarmlessOffering.java +++ b/Mage.Sets/src/mage/cards/h/HarmlessOffering.java @@ -1,22 +1,14 @@ - package mage.cards.h; -import java.util.UUID; -import mage.abilities.Ability; -import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.common.TargetPlayerGainControlTargetPermanentEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Layer; -import mage.constants.Outcome; -import mage.constants.SubLayer; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; import mage.target.common.TargetControlledPermanent; import mage.target.common.TargetOpponent; +import java.util.UUID; + /** * * @author fireshoes @@ -27,7 +19,7 @@ public final class HarmlessOffering extends CardImpl { super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{R}"); // Target opponent gains control of target permanent you control. - this.getSpellAbility().addEffect(new HarmlessOfferingEffect()); + this.getSpellAbility().addEffect(new TargetPlayerGainControlTargetPermanentEffect()); this.getSpellAbility().addTarget(new TargetOpponent()); this.getSpellAbility().addTarget(new TargetControlledPermanent()); } @@ -41,34 +33,3 @@ public final class HarmlessOffering extends CardImpl { return new HarmlessOffering(this); } } - -class HarmlessOfferingEffect extends ContinuousEffectImpl { - - HarmlessOfferingEffect() { - super(Duration.EndOfGame, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.Benefit); - this.staticText = "Target opponent gains control of target permanent you control"; - } - - private HarmlessOfferingEffect(final HarmlessOfferingEffect effect) { - super(effect); - } - - @Override - public HarmlessOfferingEffect copy() { - return new HarmlessOfferingEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - UUID controllerId = source.getTargets().get(0).getFirstTarget(); - Player controller = game.getPlayer(controllerId); - Permanent permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget()); - if (controller != null && permanent != null) { - permanent.changeControllerId(controllerId, game, source); - } else { - this.discard(); - } - return true; - } - -} diff --git a/Mage.Sets/src/mage/cards/h/HopelessNightmare.java b/Mage.Sets/src/mage/cards/h/HopelessNightmare.java index 22cd32369c7..da709b03af5 100644 --- a/Mage.Sets/src/mage/cards/h/HopelessNightmare.java +++ b/Mage.Sets/src/mage/cards/h/HopelessNightmare.java @@ -34,7 +34,7 @@ public final class HopelessNightmare extends CardImpl { this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new ScryEffect(2, false))); // {2}{B}: Sacrifice Hopeless Nightmare. - this.addAbility(new SimpleActivatedAbility(new SacrificeSourceEffect(), new ManaCostsImpl("{2}{B}"))); + this.addAbility(new SimpleActivatedAbility(new SacrificeSourceEffect(), new ManaCostsImpl<>("{2}{B}"))); } private HopelessNightmare(final HopelessNightmare card) { diff --git a/Mage.Sets/src/mage/cards/i/IntiSeneschalOfTheSun.java b/Mage.Sets/src/mage/cards/i/IntiSeneschalOfTheSun.java index a801b3e110b..3ebf9c7aa5a 100644 --- a/Mage.Sets/src/mage/cards/i/IntiSeneschalOfTheSun.java +++ b/Mage.Sets/src/mage/cards/i/IntiSeneschalOfTheSun.java @@ -62,7 +62,8 @@ public final class IntiSeneschalOfTheSun extends CardImpl { class IntiSeneschalOfTheSunTriggeredAbility extends TriggeredAbilityImpl { IntiSeneschalOfTheSunTriggeredAbility() { - super(Zone.BATTLEFIELD, new ExileTopXMayPlayUntilEffect(1, Duration.UntilYourNextEndStep)); + super(Zone.BATTLEFIELD, new ExileTopXMayPlayUntilEffect(1, Duration.UntilYourNextEndStep) + .withTextOptions("that card", true)); this.setTriggerPhrase("Whenever you discard one or more cards, "); } diff --git a/Mage.Sets/src/mage/cards/j/JeskasWill.java b/Mage.Sets/src/mage/cards/j/JeskasWill.java index f3856429ded..7cde1f4968b 100644 --- a/Mage.Sets/src/mage/cards/j/JeskasWill.java +++ b/Mage.Sets/src/mage/cards/j/JeskasWill.java @@ -27,7 +27,7 @@ public final class JeskasWill extends CardImpl { // Choose one. If you control a commander as you cast this spell, you may choose both. this.getSpellAbility().getModes().setChooseText( - "Choose one. If you control a commander as you cast this spell, you may choose both." + "Choose one. If you control a commander as you cast this spell, you may choose both instead." ); this.getSpellAbility().getModes().setMoreCondition(ControlACommanderCondition.instance); @@ -70,7 +70,7 @@ class JeskasWillEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getFirstTarget()); - if (controller == null || player == null || player.getHand().size() < 1) { + if (controller == null || player == null || player.getHand().isEmpty()) { return false; } controller.getManaPool().addMana(Mana.RedMana(player.getHand().size()), game, source); diff --git a/Mage.Sets/src/mage/cards/k/KrenkosBuzzcrusher.java b/Mage.Sets/src/mage/cards/k/KrenkosBuzzcrusher.java new file mode 100644 index 00000000000..bbbb410d135 --- /dev/null +++ b/Mage.Sets/src/mage/cards/k/KrenkosBuzzcrusher.java @@ -0,0 +1,132 @@ +package mage.cards.k; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.TrampleAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SuperType; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.filter.common.FilterLandPermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.permanent.ControllerIdPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetCardInLibrary; + +/** + * + * @author DominionSpy + */ +public final class KrenkosBuzzcrusher extends CardImpl { + + public KrenkosBuzzcrusher(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{2}{R}{R}"); + + this.subtype.add(SubType.INSECT); + this.subtype.add(SubType.THOPTER); + this.power = new MageInt(4); + this.toughness = new MageInt(4); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Trample + this.addAbility(TrampleAbility.getInstance()); + + // When Krenko's Buzzcrusher enters the battlefield, for each player, destroy up to one nonbasic land that player controls. For each land destroyed this way, its controller may search their library for a basic land card, put it onto the battlefield tapped, then shuffle. + this.addAbility(new EntersBattlefieldTriggeredAbility(new KrenkosBuzzcrusherEffect())); + } + + private KrenkosBuzzcrusher(final KrenkosBuzzcrusher card) { + super(card); + } + + @Override + public KrenkosBuzzcrusher copy() { + return new KrenkosBuzzcrusher(this); + } +} + +class KrenkosBuzzcrusherEffect extends OneShotEffect { + + KrenkosBuzzcrusherEffect() { + super(Outcome.DestroyPermanent); + staticText = "for each player, destroy up to one nonbasic land that player controls. " + + "For each land destroyed this way, its controller may search their library for a basic land card, " + + "put it onto the battlefield tapped, then shuffle"; + } + + private KrenkosBuzzcrusherEffect(final KrenkosBuzzcrusherEffect effect) { + super(effect); + } + + @Override + public KrenkosBuzzcrusherEffect copy() { + return new KrenkosBuzzcrusherEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + + List chosenLands = new ArrayList<>(); + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { + Player player = game.getPlayer(playerId); + if (player == null) { + continue; + } + + FilterLandPermanent filter = new FilterLandPermanent("nonbasic land " + player.getName() + " controls"); + filter.add(new ControllerIdPredicate(playerId)); + filter.add(Predicates.not(SuperType.BASIC.getPredicate())); + TargetPermanent target = new TargetPermanent(0, 1, filter); + target.withNotTarget(true); + + controller.chooseTarget(outcome, target, source, game); + Permanent land = game.getPermanent(target.getFirstTarget()); + if (land != null) { + chosenLands.add(land); + } + } + + List destroyedLands = new ArrayList<>(); + for (Permanent land : chosenLands) { + if (land.destroy(source, game)) { + destroyedLands.add(land); + } + } + + for (Permanent land : destroyedLands) { + Player player = game.getPlayer(land.getControllerId()); + if (player == null) { + continue; + } + TargetCardInLibrary target = new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND_A); + if (!player.chooseUse(Outcome.PutLandInPlay, "Search your library for " + target.getDescription() + "?", source, game)) { + continue; + } + if (player.searchLibrary(target, source, game)) { + player.moveCards(game.getCard(target.getFirstTarget()), Zone.BATTLEFIELD, + source, game, true, false, false, null); + player.shuffleLibrary(source, game); + } + } + return true; + } +} diff --git a/Mage.Sets/src/mage/cards/m/Melting.java b/Mage.Sets/src/mage/cards/m/Melting.java index 18ae08341a6..80ca0686085 100644 --- a/Mage.Sets/src/mage/cards/m/Melting.java +++ b/Mage.Sets/src/mage/cards/m/Melting.java @@ -6,7 +6,7 @@ import mage.abilities.effects.ContinuousEffectImpl; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; -import mage.filter.common.FilterLandPermanent; +import mage.filter.StaticFilters; import mage.game.Game; import mage.game.permanent.Permanent; @@ -36,9 +36,7 @@ public final class Melting extends CardImpl { class MeltingEffect extends ContinuousEffectImpl { - private static final FilterLandPermanent filter = new FilterLandPermanent(); - - public MeltingEffect() { + MeltingEffect() { super(Duration.WhileOnBattlefield, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Detriment); this.staticText = "All lands are no longer snow"; } @@ -54,7 +52,7 @@ class MeltingEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_LAND, source.getControllerId(), source, game)) { permanent.removeSuperType(game, SuperType.SNOW); } return true; diff --git a/Mage.Sets/src/mage/cards/p/PortRazer.java b/Mage.Sets/src/mage/cards/p/PortRazer.java index efd905191f2..e1553eaa2e6 100644 --- a/Mage.Sets/src/mage/cards/p/PortRazer.java +++ b/Mage.Sets/src/mage/cards/p/PortRazer.java @@ -41,8 +41,7 @@ public final class PortRazer extends CardImpl { "untap each creature you control" ), false ); - ability.addEffect(new AdditionalCombatPhaseEffect() - .setText("After this combat phase, there is an additional combat phase.")); + ability.addEffect(new AdditionalCombatPhaseEffect()); this.addAbility(ability); // Port Razer can't attack a player it has already attacked this turn. diff --git a/Mage.Sets/src/mage/cards/p/ProteanHydra.java b/Mage.Sets/src/mage/cards/p/ProteanHydra.java index 5c21bfbac93..335e9602a78 100644 --- a/Mage.Sets/src/mage/cards/p/ProteanHydra.java +++ b/Mage.Sets/src/mage/cards/p/ProteanHydra.java @@ -1,4 +1,3 @@ - package mage.cards.p; import java.util.UUID; @@ -53,67 +52,68 @@ public final class ProteanHydra extends CardImpl { return new ProteanHydra(this); } - class ProteanHydraAbility extends TriggeredAbilityImpl { - - public ProteanHydraAbility() { - super(Zone.BATTLEFIELD, new CreateDelayedTriggeredAbilityEffect(new ProteanHydraDelayedTriggeredAbility()), false); - } - - private ProteanHydraAbility(final ProteanHydraAbility ability) { - super(ability); - } - - @Override - public ProteanHydraAbility copy() { - return new ProteanHydraAbility(this); - } - - @Override - public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.COUNTER_REMOVED; - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - return event.getData().equals(CounterType.P1P1.getName()) && event.getTargetId().equals(this.getSourceId()); - } - - @Override - public String getRule() { - return "Whenever a +1/+1 counter is removed from {this}, put two +1/+1 counters on it at the beginning of the next end step."; - } - - } - - static class ProteanHydraDelayedTriggeredAbility extends DelayedTriggeredAbility { - - public ProteanHydraDelayedTriggeredAbility() { - super(new AddCountersSourceEffect(CounterType.P1P1.createInstance(2))); - } - - private ProteanHydraDelayedTriggeredAbility(final ProteanHydraDelayedTriggeredAbility ability) { - super(ability); - } - - @Override - public ProteanHydraDelayedTriggeredAbility copy() { - return new ProteanHydraDelayedTriggeredAbility(this); - } - - @Override - public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.END_TURN_STEP_PRE; - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - return true; - } - - @Override - public String getRule() { - return "Put two +1/+1 counters on {this} at the beginning of the next end step"; - } - - } +} + +class ProteanHydraAbility extends TriggeredAbilityImpl { + + ProteanHydraAbility() { + super(Zone.BATTLEFIELD, new CreateDelayedTriggeredAbilityEffect(new ProteanHydraDelayedTriggeredAbility()), false); + } + + private ProteanHydraAbility(final ProteanHydraAbility ability) { + super(ability); + } + + @Override + public ProteanHydraAbility copy() { + return new ProteanHydraAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.COUNTER_REMOVED; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + return event.getData().equals(CounterType.P1P1.getName()) && event.getTargetId().equals(this.getSourceId()); + } + + @Override + public String getRule() { + return "Whenever a +1/+1 counter is removed from {this}, put two +1/+1 counters on it at the beginning of the next end step."; + } + +} + +class ProteanHydraDelayedTriggeredAbility extends DelayedTriggeredAbility { + + ProteanHydraDelayedTriggeredAbility() { + super(new AddCountersSourceEffect(CounterType.P1P1.createInstance(2))); + } + + private ProteanHydraDelayedTriggeredAbility(final ProteanHydraDelayedTriggeredAbility ability) { + super(ability); + } + + @Override + public ProteanHydraDelayedTriggeredAbility copy() { + return new ProteanHydraDelayedTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.END_TURN_STEP_PRE; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + return true; + } + + @Override + public String getRule() { + return "Put two +1/+1 counters on {this} at the beginning of the next end step"; + } + } diff --git a/Mage.Sets/src/mage/cards/r/RampagingRaptor.java b/Mage.Sets/src/mage/cards/r/RampagingRaptor.java index 82a445a0ffc..bf4ee11f65b 100644 --- a/Mage.Sets/src/mage/cards/r/RampagingRaptor.java +++ b/Mage.Sets/src/mage/cards/r/RampagingRaptor.java @@ -47,7 +47,7 @@ public final class RampagingRaptor extends CardImpl { // {2}{R}: Rampaging Raptor gets +2/+0 until end of turn. this.addAbility(new SimpleActivatedAbility( - new BoostSourceEffect(2, 0, Duration.EndOfTurn), new ManaCostsImpl("{2}{R}") + new BoostSourceEffect(2, 0, Duration.EndOfTurn), new ManaCostsImpl<>("{2}{R}") )); // Whenever Rampaging Raptor deals combat damage to an opponent, it deals that much damage to target planeswalker that player controls or battle that player protects. diff --git a/Mage.Sets/src/mage/cards/r/RatchetBomb.java b/Mage.Sets/src/mage/cards/r/RatchetBomb.java index e698fb916f0..85c8b1a7feb 100644 --- a/Mage.Sets/src/mage/cards/r/RatchetBomb.java +++ b/Mage.Sets/src/mage/cards/r/RatchetBomb.java @@ -1,5 +1,3 @@ - - package mage.cards.r; import java.util.UUID; @@ -15,6 +13,7 @@ import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Zone; import mage.counters.CounterType; +import mage.filter.StaticFilters; import mage.game.Game; import mage.game.permanent.Permanent; @@ -45,42 +44,40 @@ public final class RatchetBomb extends CardImpl { return new RatchetBomb(this); } - class RatchetBombEffect extends OneShotEffect { +} - public RatchetBombEffect() { - super(Outcome.DestroyPermanent); - staticText = "Destroy each nonland permanent with mana value equal to the number of charge counters on {this}"; - } +class RatchetBombEffect extends OneShotEffect { - private RatchetBombEffect(final RatchetBombEffect effect) { - super(effect); - } + RatchetBombEffect() { + super(Outcome.DestroyPermanent); + staticText = "Destroy each nonland permanent with mana value equal to the number of charge counters on {this}"; + } - @Override - public boolean apply(Game game, Ability source) { - Permanent p = game.getBattlefield().getPermanent(source.getSourceId()); + private RatchetBombEffect(final RatchetBombEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent p = game.getBattlefield().getPermanent(source.getSourceId()); + if (p == null) { + p = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); if (p == null) { - p = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (p == null) { - return false; - } + return false; } - - int count = p.getCounters(game).getCount(CounterType.CHARGE); - for (Permanent perm: game.getBattlefield().getAllActivePermanents()) { - if (perm.getManaValue() == count && !(perm.isLand(game))) { - perm.destroy(source, game, false); - } + } + int count = p.getCounters(game).getCount(CounterType.CHARGE); + for (Permanent perm : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_NON_LAND, source.getControllerId(), source, game)) { + if (perm.getManaValue() == count) { + perm.destroy(source, game, false); } - - return true; - } - - @Override - public RatchetBombEffect copy() { - return new RatchetBombEffect(this); } + return true; + } + @Override + public RatchetBombEffect copy() { + return new RatchetBombEffect(this); } } diff --git a/Mage.Sets/src/mage/cards/r/RuinsRecluse.java b/Mage.Sets/src/mage/cards/r/RuinsRecluse.java index e4d40dc9814..f4a51cab9eb 100644 --- a/Mage.Sets/src/mage/cards/r/RuinsRecluse.java +++ b/Mage.Sets/src/mage/cards/r/RuinsRecluse.java @@ -34,7 +34,7 @@ public final class RuinsRecluse extends CardImpl { // {3}{G}: Put a +1/+1 counter on Ruins Recluse. this.addAbility(new SimpleActivatedAbility( - new AddCountersSourceEffect(CounterType.P1P1.createInstance()), new ManaCostsImpl("{3}{G}") + new AddCountersSourceEffect(CounterType.P1P1.createInstance()), new ManaCostsImpl<>("{3}{G}") )); } diff --git a/Mage.Sets/src/mage/cards/s/StormtideLeviathan.java b/Mage.Sets/src/mage/cards/s/StormtideLeviathan.java index 5da70e371a4..79cd384b4d8 100644 --- a/Mage.Sets/src/mage/cards/s/StormtideLeviathan.java +++ b/Mage.Sets/src/mage/cards/s/StormtideLeviathan.java @@ -1,22 +1,19 @@ package mage.cards.s; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.common.combat.CantAttackAnyPlayerAllEffect; +import mage.abilities.effects.common.continuous.AddBasicLandTypeAllLandsEffect; import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.IslandwalkAbility; -import mage.abilities.mana.BlueManaAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.*; -import mage.filter.StaticFilters; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.SubType; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.AbilityPredicate; -import mage.game.Game; -import mage.game.permanent.Permanent; import java.util.UUID; @@ -44,7 +41,8 @@ public final class StormtideLeviathan extends CardImpl { this.addAbility(new IslandwalkAbility()); // All lands are Islands in addition to their other types. - this.addAbility(new SimpleStaticAbility(new StormtideLeviathanEffect())); + this.addAbility(new SimpleStaticAbility(new AddBasicLandTypeAllLandsEffect(SubType.ISLAND) + .setText("all lands are Islands in addition to their other types"))); // Creatures without flying or islandwalk can't attack. this.addAbility(new SimpleStaticAbility(new CantAttackAnyPlayerAllEffect(Duration.WhileOnBattlefield, filter))); @@ -59,35 +57,4 @@ public final class StormtideLeviathan extends CardImpl { return new StormtideLeviathan(this); } - class StormtideLeviathanEffect extends ContinuousEffectImpl { - - private StormtideLeviathanEffect() { - super(Duration.WhileOnBattlefield, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Neutral); - staticText = "All lands are Islands in addition to their other types"; - this.dependencyTypes.add(DependencyType.BecomeIsland); - } - - private StormtideLeviathanEffect(final StormtideLeviathanEffect effect) { - super(effect); - } - - @Override - public StormtideLeviathanEffect copy() { - return new StormtideLeviathanEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - for (Permanent land : game.getBattlefield().getActivePermanents( - StaticFilters.FILTER_LAND, source.getControllerId(), game - )) { - // land abilities are intrinsic, so add them here, not in layer 6 - land.addSubType(game, SubType.ISLAND); - if (!land.getAbilities(game).containsClass(BlueManaAbility.class)) { - land.addAbility(new BlueManaAbility(), source.getSourceId(), game); - } - } - return true; - } - } } diff --git a/Mage.Sets/src/mage/cards/t/TempleOfCivilization.java b/Mage.Sets/src/mage/cards/t/TempleOfCivilization.java index 2fa4a1e9f63..ee18a2fb64a 100644 --- a/Mage.Sets/src/mage/cards/t/TempleOfCivilization.java +++ b/Mage.Sets/src/mage/cards/t/TempleOfCivilization.java @@ -35,7 +35,7 @@ public final class TempleOfCivilization extends CardImpl { Ability ability = new ActivateIfConditionActivatedAbility( Zone.BATTLEFIELD, new TransformSourceEffect(), - new ManaCostsImpl("{2}{W}"), + new ManaCostsImpl<>("{2}{W}"), TempleOfCivilizationCondition.instance, TimingRule.SORCERY ); diff --git a/Mage.Sets/src/mage/cards/t/TempleOfCultivation.java b/Mage.Sets/src/mage/cards/t/TempleOfCultivation.java index b1d9b365e29..60d3c9327a3 100644 --- a/Mage.Sets/src/mage/cards/t/TempleOfCultivation.java +++ b/Mage.Sets/src/mage/cards/t/TempleOfCultivation.java @@ -37,7 +37,7 @@ public final class TempleOfCultivation extends CardImpl { Ability ability = new ActivateIfConditionActivatedAbility( Zone.BATTLEFIELD, new TransformSourceEffect(), - new ManaCostsImpl("{2}{G}"), + new ManaCostsImpl<>("{2}{G}"), new TempleOfCultivationCondition(), TimingRule.SORCERY ); diff --git a/Mage.Sets/src/mage/cards/t/TempleOfTheDead.java b/Mage.Sets/src/mage/cards/t/TempleOfTheDead.java index 9e326692c93..7c0bf16f60b 100644 --- a/Mage.Sets/src/mage/cards/t/TempleOfTheDead.java +++ b/Mage.Sets/src/mage/cards/t/TempleOfTheDead.java @@ -35,7 +35,7 @@ public final class TempleOfTheDead extends CardImpl { Ability ability = new ActivateIfConditionActivatedAbility( Zone.BATTLEFIELD, new TransformSourceEffect(), - new ManaCostsImpl("{2}{B}"), + new ManaCostsImpl<>("{2}{B}"), TempleOfTheDeadCondition.instance, TimingRule.SORCERY ); diff --git a/Mage.Sets/src/mage/cards/t/TheBlackGate.java b/Mage.Sets/src/mage/cards/t/TheBlackGate.java index deabaa52370..43b131be0ef 100644 --- a/Mage.Sets/src/mage/cards/t/TheBlackGate.java +++ b/Mage.Sets/src/mage/cards/t/TheBlackGate.java @@ -53,7 +53,7 @@ public final class TheBlackGate extends CardImpl { // {1}{B}, {T}: Choose a player with the most life or tied for most life. Target creature can't be blocked by creatures that player controls this turn. ActivatedAbility ability = new SimpleActivatedAbility( new BlackGateEffect(), - new ManaCostsImpl("{1}{B}") + new ManaCostsImpl<>("{1}{B}") ); ability.addCost(new TapSourceCost()); ability.addTarget(new TargetCreaturePermanent()); @@ -148,4 +148,4 @@ class BlackGateEffect extends OneShotEffect { return true; } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/t/TolarianEntrancer.java b/Mage.Sets/src/mage/cards/t/TolarianEntrancer.java index 3e866c8ff5f..3f38f6ef320 100644 --- a/Mage.Sets/src/mage/cards/t/TolarianEntrancer.java +++ b/Mage.Sets/src/mage/cards/t/TolarianEntrancer.java @@ -1,4 +1,3 @@ - package mage.cards.t; import java.util.UUID; @@ -14,7 +13,6 @@ import mage.constants.SubType; import mage.constants.Duration; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; /** * @@ -42,34 +40,35 @@ public final class TolarianEntrancer extends CardImpl { return new TolarianEntrancer(this); } - class TolarianEntrancerDelayedTriggeredAbility extends DelayedTriggeredAbility { +} - public TolarianEntrancerDelayedTriggeredAbility() { - super(new GainControlTargetEffect(Duration.EndOfGame)); - } +class TolarianEntrancerDelayedTriggeredAbility extends DelayedTriggeredAbility { - private TolarianEntrancerDelayedTriggeredAbility(final TolarianEntrancerDelayedTriggeredAbility ability) { - super(ability); - } + TolarianEntrancerDelayedTriggeredAbility() { + super(new GainControlTargetEffect(Duration.EndOfGame)); + } - @Override - public TolarianEntrancerDelayedTriggeredAbility copy() { - return new TolarianEntrancerDelayedTriggeredAbility(this); - } + private TolarianEntrancerDelayedTriggeredAbility(final TolarianEntrancerDelayedTriggeredAbility ability) { + super(ability); + } - @Override - public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.END_COMBAT_STEP_POST; - } + @Override + public TolarianEntrancerDelayedTriggeredAbility copy() { + return new TolarianEntrancerDelayedTriggeredAbility(this); + } - @Override - public boolean checkTrigger(GameEvent event, Game game) { - return true; - } + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.END_COMBAT_STEP_POST; + } - @Override - public String getRule() { - return "gain control of that creature at end of combat"; - } + @Override + public boolean checkTrigger(GameEvent event, Game game) { + return true; + } + + @Override + public String getRule() { + return "gain control of that creature at end of combat"; } } diff --git a/Mage.Sets/src/mage/cards/w/WindZendikon.java b/Mage.Sets/src/mage/cards/w/WindZendikon.java index 57ac77d6a60..8325b480e7f 100644 --- a/Mage.Sets/src/mage/cards/w/WindZendikon.java +++ b/Mage.Sets/src/mage/cards/w/WindZendikon.java @@ -1,4 +1,3 @@ - package mage.cards.w; import java.util.UUID; @@ -57,22 +56,24 @@ public final class WindZendikon extends CardImpl { return new WindZendikon(this); } - class WindZendikonElementalToken extends TokenImpl { - WindZendikonElementalToken() { - super("", "2/2 blue Elemental creature with flying"); - cardType.add(CardType.CREATURE); - color.setBlue(true); - subtype.add(SubType.ELEMENTAL); - power = new MageInt(2); - toughness = new MageInt(2); - addAbility(FlyingAbility.getInstance()); - } - private WindZendikonElementalToken(final WindZendikonElementalToken token) { - super(token); - } +} - public WindZendikonElementalToken copy() { - return new WindZendikonElementalToken(this); - } +class WindZendikonElementalToken extends TokenImpl { + + WindZendikonElementalToken() { + super("", "2/2 blue Elemental creature with flying"); + cardType.add(CardType.CREATURE); + color.setBlue(true); + subtype.add(SubType.ELEMENTAL); + power = new MageInt(2); + toughness = new MageInt(2); + addAbility(FlyingAbility.getInstance()); + } + private WindZendikonElementalToken(final WindZendikonElementalToken token) { + super(token); + } + + public WindZendikonElementalToken copy() { + return new WindZendikonElementalToken(this); } } diff --git a/Mage.Sets/src/mage/cards/w/WrongTurn.java b/Mage.Sets/src/mage/cards/w/WrongTurn.java index fd4b1457c2f..80d8f72470e 100644 --- a/Mage.Sets/src/mage/cards/w/WrongTurn.java +++ b/Mage.Sets/src/mage/cards/w/WrongTurn.java @@ -1,17 +1,11 @@ package mage.cards.w; -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.continuous.GainControlTargetEffect; +import mage.abilities.effects.common.TargetPlayerGainControlTargetPermanentEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Outcome; -import mage.game.Game; import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetOpponent; -import mage.target.targetpointer.FixedTarget; import java.util.UUID; @@ -24,7 +18,7 @@ public final class WrongTurn extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}"); // Target opponent gains control of target creature. - this.getSpellAbility().addEffect(new WrongTurnEffect()); + this.getSpellAbility().addEffect(new TargetPlayerGainControlTargetPermanentEffect()); this.getSpellAbility().addTarget(new TargetOpponent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent()); } @@ -38,28 +32,3 @@ public final class WrongTurn extends CardImpl { return new WrongTurn(this); } } - -class WrongTurnEffect extends OneShotEffect { - - WrongTurnEffect() { - super(Outcome.Benefit); - staticText = "target opponent gains control of target creature"; - } - - private WrongTurnEffect(final WrongTurnEffect effect) { - super(effect); - } - - @Override - public WrongTurnEffect copy() { - return new WrongTurnEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - game.addEffect(new GainControlTargetEffect( - Duration.Custom, true, source.getFirstTarget() - ).setTargetPointer(new FixedTarget(source.getTargets().get(1).getFirstTarget(), game)), source); - return true; - } -} diff --git a/Mage.Sets/src/mage/cards/y/YasminKhan.java b/Mage.Sets/src/mage/cards/y/YasminKhan.java index 519b47c937c..da57de39a92 100644 --- a/Mage.Sets/src/mage/cards/y/YasminKhan.java +++ b/Mage.Sets/src/mage/cards/y/YasminKhan.java @@ -31,7 +31,7 @@ public final class YasminKhan extends CardImpl { // {T}: Exile the top card of your library. Until your next end step, you may play it. this.addAbility(new SimpleActivatedAbility(new ExileTopXMayPlayUntilEffect( 1, Duration.UntilYourNextEndStep - ), new TapSourceCost())); + ).withTextOptions("it", false), new TapSourceCost())); // Doctor's companion this.addAbility(DoctorsCompanionAbility.getInstance()); diff --git a/Mage.Sets/src/mage/cards/z/ZedruuTheGreathearted.java b/Mage.Sets/src/mage/cards/z/ZedruuTheGreathearted.java index d432142f053..dc895db40b8 100644 --- a/Mage.Sets/src/mage/cards/z/ZedruuTheGreathearted.java +++ b/Mage.Sets/src/mage/cards/z/ZedruuTheGreathearted.java @@ -1,26 +1,23 @@ - package mage.cards.z; -import java.util.UUID; import mage.MageInt; -import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.dynamicvalue.common.PermanentsYouOwnThatOpponentsControlCount; -import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.Effect; import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.GainLifeEffect; +import mage.abilities.effects.common.TargetPlayerGainControlTargetPermanentEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; -import mage.game.Game; -import mage.game.permanent.Permanent; import mage.target.common.TargetControlledPermanent; import mage.target.common.TargetOpponent; +import java.util.UUID; + /** * * @author andyfries @@ -44,7 +41,7 @@ public final class ZedruuTheGreathearted extends CardImpl { this.addAbility(ability); // {R}{W}{U}: Target opponent gains control of target permanent you control. - ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ZedruuTheGreatheartedEffect(), new ManaCostsImpl<>("{U}{R}{W}")); + ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new TargetPlayerGainControlTargetPermanentEffect(), new ManaCostsImpl<>("{U}{R}{W}")); ability.addTarget(new TargetOpponent()); ability.addTarget(new TargetControlledPermanent()); this.addAbility(ability); @@ -59,40 +56,4 @@ public final class ZedruuTheGreathearted extends CardImpl { return new ZedruuTheGreathearted(this); } - class ZedruuTheGreatheartedEffect extends ContinuousEffectImpl { - - private MageObjectReference targetPermanentReference; - - public ZedruuTheGreatheartedEffect() { - super(Duration.Custom, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl); - this.staticText = "Target opponent gains control of target permanent you control"; - } - - private ZedruuTheGreatheartedEffect(final ZedruuTheGreatheartedEffect effect) { - super(effect); - this.targetPermanentReference = effect.targetPermanentReference; - } - - @Override - public ZedruuTheGreatheartedEffect copy() { - return new ZedruuTheGreatheartedEffect(this); - } - - @Override - public void init(Ability source, Game game) { - super.init(source, game); - targetPermanentReference = new MageObjectReference(source.getTargets().get(1).getFirstTarget(), game); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent permanent = targetPermanentReference.getPermanent(game); - if (permanent != null) { - return permanent.changeControllerId(source.getFirstTarget(), game, source); - } else { - discard(); - } - return false; - } - } } diff --git a/Mage.Sets/src/mage/sets/MurdersAtKarlovManor.java b/Mage.Sets/src/mage/sets/MurdersAtKarlovManor.java index f447d946096..ee9548ee5cf 100644 --- a/Mage.Sets/src/mage/sets/MurdersAtKarlovManor.java +++ b/Mage.Sets/src/mage/sets/MurdersAtKarlovManor.java @@ -139,6 +139,7 @@ public final class MurdersAtKarlovManor extends ExpansionSet { cards.add(new SetCardInfo("Jaded Analyst", 62, Rarity.COMMON, mage.cards.j.JadedAnalyst.class)); cards.add(new SetCardInfo("Knife", 134, Rarity.UNCOMMON, mage.cards.k.Knife.class)); cards.add(new SetCardInfo("Kraul Whipcracker", 213, Rarity.UNCOMMON, mage.cards.k.KraulWhipcracker.class)); + cards.add(new SetCardInfo("Krenko's Buzzcrusher", 136, Rarity.RARE, mage.cards.k.KrenkosBuzzcrusher.class)); cards.add(new SetCardInfo("Krenko, Baron of Tin Street", 135, Rarity.RARE, mage.cards.k.KrenkoBaronOfTinStreet.class)); cards.add(new SetCardInfo("Krovod Haunch", 21, Rarity.UNCOMMON, mage.cards.k.KrovodHaunch.class)); cards.add(new SetCardInfo("Kylox, Visionary Inventor", 214, Rarity.RARE, mage.cards.k.KyloxVisionaryInventor.class)); diff --git a/Mage.Sets/src/mage/sets/MurdersAtKarlovManorCommander.java b/Mage.Sets/src/mage/sets/MurdersAtKarlovManorCommander.java index d77cefe15fd..b48e580ea67 100644 --- a/Mage.Sets/src/mage/sets/MurdersAtKarlovManorCommander.java +++ b/Mage.Sets/src/mage/sets/MurdersAtKarlovManorCommander.java @@ -133,7 +133,7 @@ public final class MurdersAtKarlovManorCommander extends ExpansionSet { cards.add(new SetCardInfo("Krosan Colossus", 176, Rarity.RARE, mage.cards.k.KrosanColossus.class)); cards.add(new SetCardInfo("Krosan Verge", 271, Rarity.UNCOMMON, mage.cards.k.KrosanVerge.class)); cards.add(new SetCardInfo("Labyrinth of Skophos", 272, Rarity.RARE, mage.cards.l.LabyrinthOfSkophos.class)); - cards.add(new SetCardInfo("Lazav, the Multifarious", 214, Rarity.RARE, mage.cards.l.LazavTheMultifarious.class)); + cards.add(new SetCardInfo("Lazav, the Multifarious", 214, Rarity.MYTHIC, mage.cards.l.LazavTheMultifarious.class)); cards.add(new SetCardInfo("Lifecrafter's Bestiary", 231, Rarity.RARE, mage.cards.l.LifecraftersBestiary.class)); cards.add(new SetCardInfo("Lonely Sandbar", 273, Rarity.UNCOMMON, mage.cards.l.LonelySandbar.class)); cards.add(new SetCardInfo("Lonis, Cryptozoologist", 215, Rarity.RARE, mage.cards.l.LonisCryptozoologist.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/TargetPlayerGainControlTargetPermanentEffect.java b/Mage/src/main/java/mage/abilities/effects/common/TargetPlayerGainControlTargetPermanentEffect.java new file mode 100644 index 00000000000..87936456eaa --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/TargetPlayerGainControlTargetPermanentEffect.java @@ -0,0 +1,67 @@ +package mage.abilities.effects.common; + +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.GainControlTargetEffect; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.targetpointer.FixedTarget; + +/** + * @author xenohedron + */ +public class TargetPlayerGainControlTargetPermanentEffect extends OneShotEffect { + + private final String playerDescription; + + public TargetPlayerGainControlTargetPermanentEffect() { + this(""); + } + + public TargetPlayerGainControlTargetPermanentEffect(String playerDescription) { + super(Outcome.Benefit); + this.playerDescription = playerDescription; + } + + protected TargetPlayerGainControlTargetPermanentEffect(final TargetPlayerGainControlTargetPermanentEffect effect) { + super(effect); + this.playerDescription = effect.playerDescription; + } + + @Override + public boolean apply(Game game, Ability source) { + if (source.getTargets().size() != 2) { + throw new IllegalStateException("It must have two targets, but found " + source.getTargets().size()); + } + Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); + Permanent permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget()); + if (player == null || permanent == null) { + return false; + } + game.addEffect(new GainControlTargetEffect( + Duration.Custom, true, player.getId() + ).setTargetPointer(new FixedTarget(permanent, game)), source); + return true; + } + + @Override + public TargetPlayerGainControlTargetPermanentEffect copy() { + return new TargetPlayerGainControlTargetPermanentEffect(this); + } + + @Override + public String getText(Mode mode) { + if (staticText != null && !staticText.isEmpty()) { + return staticText; + } + if (mode.getTargets().size() != 2) { + throw new IllegalStateException("It must have two targets, but found " + mode.getTargets().size()); + } + return (playerDescription.isEmpty() ? mode.getTargets().get(0).getDescription() : playerDescription) + + " gains control of " + mode.getTargets().get(1).getDescription(); + } +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainControlTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainControlTargetEffect.java index 3549d825d8c..833f3f48c0e 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainControlTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainControlTargetEffect.java @@ -21,7 +21,7 @@ import java.util.UUID; public class GainControlTargetEffect extends ContinuousEffectImpl { protected UUID controllingPlayerId; - private boolean fixedControl; + private final boolean fixedControl; private boolean firstControlChange = true; private final Condition condition; @@ -63,6 +63,7 @@ public class GainControlTargetEffect extends ContinuousEffectImpl { this.controllingPlayerId = effect.controllingPlayerId; this.fixedControl = effect.fixedControl; this.condition = effect.condition; + this.firstControlChange = effect.firstControlChange; } @Override