diff --git a/Mage.Sets/src/mage/cards/l/LifeOfTheParty.java b/Mage.Sets/src/mage/cards/l/LifeOfTheParty.java index 0c7345f43cb..86c13e6ed56 100644 --- a/Mage.Sets/src/mage/cards/l/LifeOfTheParty.java +++ b/Mage.Sets/src/mage/cards/l/LifeOfTheParty.java @@ -4,14 +4,15 @@ import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.AttacksTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility; -import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; +import mage.abilities.condition.Condition; +import mage.abilities.condition.common.SourceMatchesFilterCondition; import mage.abilities.dynamicvalue.common.CreaturesYouControlCount; import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.CreateTokenCopyTargetEffect; import mage.abilities.effects.common.combat.GoadTargetEffect; import mage.abilities.effects.common.continuous.BoostSourceEffect; -import mage.abilities.hint.ValueHint; +import mage.abilities.hint.common.CreaturesYouControlHint; import mage.abilities.keyword.FirstStrikeAbility; import mage.abilities.keyword.HasteAbility; import mage.abilities.keyword.TrampleAbility; @@ -21,13 +22,14 @@ import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Outcome; import mage.constants.SubType; +import mage.filter.FilterPermanent; +import mage.filter.predicate.permanent.TokenPredicate; import mage.game.Game; import mage.game.permanent.Permanent; -import mage.game.permanent.PermanentToken; import mage.target.targetpointer.FixedTargets; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import java.util.UUID; /** @@ -35,6 +37,14 @@ import java.util.UUID; */ public final class LifeOfTheParty extends CardImpl { + private static final FilterPermanent filter = new FilterPermanent("it's not a token"); + + static { + filter.add(TokenPredicate.FALSE); + } + + private static final Condition condition = new SourceMatchesFilterCondition(filter); + public LifeOfTheParty(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}"); @@ -55,15 +65,11 @@ public final class LifeOfTheParty extends CardImpl { this.addAbility(new AttacksTriggeredAbility(new BoostSourceEffect( CreaturesYouControlCount.instance, StaticValue.get(0), Duration.EndOfTurn, "it" - ).setText("it gets +X/+0 until end of turn, where X is the number of creatures you control") - ).addHint(new ValueHint("Creatures you control", CreaturesYouControlCount.instance))); + ).setText("it gets +X/+0 until end of turn, where X is the number of creatures you control")) + .addHint(CreaturesYouControlHint.instance)); // When Life of the Party enters the battlefield, if it's not a token, each opponent creates a token that's a copy of it. The tokens are goaded for the rest of the game. - this.addAbility(new ConditionalInterveningIfTriggeredAbility( - new EntersBattlefieldTriggeredAbility(new LifeOfThePartyEffect()), LifeOfTheParty::checkSource, - "When {this} enters, if it's not a token, each opponent creates a " + - "token that's a copy of it. The tokens are goaded for the rest of the game." - )); + this.addAbility(new EntersBattlefieldTriggeredAbility(new LifeOfThePartyEffect()).withInterveningIf(condition)); } private LifeOfTheParty(final LifeOfTheParty card) { @@ -74,16 +80,13 @@ public final class LifeOfTheParty extends CardImpl { public LifeOfTheParty copy() { return new LifeOfTheParty(this); } - - static boolean checkSource(Game game, Ability source) { - return !(source.getSourcePermanentOrLKI(game) instanceof PermanentToken); - } } class LifeOfThePartyEffect extends OneShotEffect { LifeOfThePartyEffect() { super(Outcome.Benefit); + staticText = "each opponent creates a token that's a copy of it. The tokens are goaded for the rest of the game"; } private LifeOfThePartyEffect(final LifeOfThePartyEffect effect) { @@ -101,7 +104,7 @@ class LifeOfThePartyEffect extends OneShotEffect { if (permanent == null) { return false; } - List permanents = new ArrayList<>(); + Set permanents = new HashSet<>(); for (UUID playerId : game.getOpponents(source.getControllerId())) { CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(playerId); effect.setSavedPermanent(permanent); @@ -111,12 +114,8 @@ class LifeOfThePartyEffect extends OneShotEffect { if (permanents.isEmpty()) { return false; } - game.addEffect( - new GoadTargetEffect() - .setDuration(Duration.EndOfGame) - .setTargetPointer(new FixedTargets(permanents, game)), - source - ); + game.addEffect(new GoadTargetEffect(Duration.EndOfGame) + .setTargetPointer(new FixedTargets(permanents, game)), source); return true; } }