diff --git a/Mage.Sets/src/mage/cards/l/LifeOfTheParty.java b/Mage.Sets/src/mage/cards/l/LifeOfTheParty.java new file mode 100644 index 00000000000..92fc81c5865 --- /dev/null +++ b/Mage.Sets/src/mage/cards/l/LifeOfTheParty.java @@ -0,0 +1,118 @@ +package mage.cards.l; + +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.dynamicvalue.common.CreaturesYouControlCount; +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.keyword.FirstStrikeAbility; +import mage.abilities.keyword.HasteAbility; +import mage.abilities.keyword.TrampleAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.SubType; +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.UUID; + +/** + * @author TheElk801 + */ +public final class LifeOfTheParty extends CardImpl { + + public LifeOfTheParty(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}"); + + this.subtype.add(SubType.ELEMENTAL); + this.power = new MageInt(0); + this.toughness = new MageInt(1); + + // First strike + this.addAbility(FirstStrikeAbility.getInstance()); + + // Trample + this.addAbility(TrampleAbility.getInstance()); + + // Haste + this.addAbility(HasteAbility.getInstance()); + + // Whenever Life of the Party attacks, it gets +X/+0 until end of turn, where X is the number of creatures you control. + this.addAbility(new AttacksTriggeredAbility(new BoostSourceEffect( + CreaturesYouControlCount.instance, CreaturesYouControlCount.instance, Duration.EndOfTurn + ))); + + // 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 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." + )); + } + + private LifeOfTheParty(final LifeOfTheParty card) { + super(card); + } + + @Override + 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); + } + + private LifeOfThePartyEffect(final LifeOfThePartyEffect effect) { + super(effect); + } + + @Override + public LifeOfThePartyEffect copy() { + return new LifeOfThePartyEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = (Permanent) getValue("permanentEnteredBattlefield"); + if (permanent == null) { + return false; + } + List permanents = new ArrayList<>(); + for (UUID playerId : game.getOpponents(source.getControllerId())) { + CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(playerId); + effect.setSavedPermanent(permanent); + effect.apply(game, source); + permanents.addAll(effect.getAddedPermanents()); + } + if (permanents.isEmpty()) { + return false; + } + game.addEffect( + new GoadTargetEffect() + .setDuration(Duration.EndOfGame) + .setTargetPointer(new FixedTargets(permanents, game)), + source + ); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/NewCapennaCommander.java b/Mage.Sets/src/mage/sets/NewCapennaCommander.java index ec4442051ff..b2a0f6fd389 100644 --- a/Mage.Sets/src/mage/sets/NewCapennaCommander.java +++ b/Mage.Sets/src/mage/sets/NewCapennaCommander.java @@ -174,6 +174,7 @@ public final class NewCapennaCommander extends ExpansionSet { cards.add(new SetCardInfo("Kresh the Bloodbraided", 345, Rarity.MYTHIC, mage.cards.k.KreshTheBloodbraided.class)); cards.add(new SetCardInfo("Leafkin Druid", 299, Rarity.COMMON, mage.cards.l.LeafkinDruid.class)); cards.add(new SetCardInfo("Life Insurance", 74, Rarity.RARE, mage.cards.l.LifeInsurance.class)); + cards.add(new SetCardInfo("Life of the Party", 48, Rarity.RARE, mage.cards.l.LifeOfTheParty.class)); cards.add(new SetCardInfo("Life's Legacy", 300, Rarity.RARE, mage.cards.l.LifesLegacy.class)); cards.add(new SetCardInfo("Lifecrafter's Bestiary", 370, Rarity.RARE, mage.cards.l.LifecraftersBestiary.class)); cards.add(new SetCardInfo("Lightning Greaves", 371, Rarity.UNCOMMON, mage.cards.l.LightningGreaves.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/ContinuousEffect.java b/Mage/src/main/java/mage/abilities/effects/ContinuousEffect.java index 11356d4fe7e..03b551a9a71 100644 --- a/Mage/src/main/java/mage/abilities/effects/ContinuousEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/ContinuousEffect.java @@ -25,7 +25,7 @@ public interface ContinuousEffect extends Effect { void discard(); - void setDuration(Duration duration); + ContinuousEffect setDuration(Duration duration); Duration getDuration(); diff --git a/Mage/src/main/java/mage/abilities/effects/ContinuousEffectImpl.java b/Mage/src/main/java/mage/abilities/effects/ContinuousEffectImpl.java index 172003483fe..57525a7dbf6 100644 --- a/Mage/src/main/java/mage/abilities/effects/ContinuousEffectImpl.java +++ b/Mage/src/main/java/mage/abilities/effects/ContinuousEffectImpl.java @@ -99,8 +99,9 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu } @Override - public void setDuration(Duration duration) { + public ContinuousEffectImpl setDuration(Duration duration) { this.duration = duration; + return this; } @Override