diff --git a/Mage.Sets/src/mage/cards/c/CutYourLosses.java b/Mage.Sets/src/mage/cards/c/CutYourLosses.java new file mode 100644 index 00000000000..544366fd4e1 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CutYourLosses.java @@ -0,0 +1,36 @@ +package mage.cards.c; + +import mage.abilities.effects.common.MillHalfLibraryTargetEffect; +import mage.abilities.keyword.CasualtyAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.target.TargetPlayer; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class CutYourLosses extends CardImpl { + + public CutYourLosses(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{U}{U}"); + + // Casualty 2 + this.addAbility(new CasualtyAbility(this, 2)); + + // Target player mills half their library, rounded down. + this.getSpellAbility().addEffect(new MillHalfLibraryTargetEffect(false)); + this.getSpellAbility().addTarget(new TargetPlayer()); + } + + private CutYourLosses(final CutYourLosses card) { + super(card); + } + + @Override + public CutYourLosses copy() { + return new CutYourLosses(this); + } +} diff --git a/Mage.Sets/src/mage/cards/f/FleetSwallower.java b/Mage.Sets/src/mage/cards/f/FleetSwallower.java index 8dd4df8346e..a28c3c629e3 100644 --- a/Mage.Sets/src/mage/cards/f/FleetSwallower.java +++ b/Mage.Sets/src/mage/cards/f/FleetSwallower.java @@ -1,22 +1,18 @@ - package mage.cards.f; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.AttacksTriggeredAbility; -import mage.abilities.effects.OneShotEffect; -import mage.constants.SubType; +import mage.abilities.effects.common.MillHalfLibraryTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; -import mage.game.Game; -import mage.players.Player; +import mage.constants.SubType; import mage.target.TargetPlayer; +import java.util.UUID; + /** - * * @author TheElk801 */ public final class FleetSwallower extends CardImpl { @@ -29,7 +25,7 @@ public final class FleetSwallower extends CardImpl { this.toughness = new MageInt(6); // Whenever Fleet Swallower attacks, target player puts the top half of their library, rounded up, into their graveyard. - Ability ability = new AttacksTriggeredAbility(new FleetSwallowerEffect(), false); + Ability ability = new AttacksTriggeredAbility(new MillHalfLibraryTargetEffect(true), false); ability.addTarget(new TargetPlayer()); this.addAbility(ability); } @@ -43,32 +39,3 @@ public final class FleetSwallower extends CardImpl { return new FleetSwallower(this); } } - -class FleetSwallowerEffect extends OneShotEffect { - - public FleetSwallowerEffect() { - super(Outcome.Detriment); - staticText = "target player mills half their library, rounded up"; - } - - public FleetSwallowerEffect(final FleetSwallowerEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getFirstTarget()); - if (player != null) { - int amount = (int) Math.ceil(player.getLibrary().size() * .5); - player.millCards(amount, source, game); - return true; - } - return false; - } - - @Override - public FleetSwallowerEffect copy() { - return new FleetSwallowerEffect(this); - } - -} diff --git a/Mage.Sets/src/mage/cards/t/Traumatize.java b/Mage.Sets/src/mage/cards/t/Traumatize.java index 9424480ae73..775d1ddd724 100644 --- a/Mage.Sets/src/mage/cards/t/Traumatize.java +++ b/Mage.Sets/src/mage/cards/t/Traumatize.java @@ -1,18 +1,14 @@ package mage.cards.t; -import java.util.UUID; -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.MillHalfLibraryTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; -import mage.game.Game; -import mage.players.Player; import mage.target.TargetPlayer; +import java.util.UUID; + /** - * * @author BetaSteward_at_googlemail.com */ public final class Traumatize extends CardImpl { @@ -21,7 +17,7 @@ public final class Traumatize extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}{U}"); this.getSpellAbility().addTarget(new TargetPlayer()); - this.getSpellAbility().addEffect(new TraumatizeEffect()); + this.getSpellAbility().addEffect(new MillHalfLibraryTargetEffect(false)); } private Traumatize(final Traumatize card) { @@ -33,32 +29,3 @@ public final class Traumatize extends CardImpl { return new Traumatize(this); } } - -class TraumatizeEffect extends OneShotEffect { - - public TraumatizeEffect() { - super(Outcome.Detriment); - staticText = "Target player mills half their library, rounded down"; - } - - public TraumatizeEffect(final TraumatizeEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getFirstTarget()); - if (player != null) { - int amount = player.getLibrary().size() / 2; - player.millCards(amount, source, game); - return true; - } - return false; - } - - @Override - public TraumatizeEffect copy() { - return new TraumatizeEffect(this); - } - -} diff --git a/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java b/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java index 7d7704f560f..2d58d93bb07 100644 --- a/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java +++ b/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java @@ -35,6 +35,7 @@ public final class StreetsOfNewCapenna extends ExpansionSet { cards.add(new SetCardInfo("Chrome Cat", 236, Rarity.COMMON, mage.cards.c.ChromeCat.class)); cards.add(new SetCardInfo("Cormela, Glamour Thief", 177, Rarity.UNCOMMON, mage.cards.c.CormelaGlamourThief.class)); cards.add(new SetCardInfo("Courier's Briefcase", 142, Rarity.UNCOMMON, mage.cards.c.CouriersBriefcase.class)); + cards.add(new SetCardInfo("Cut Your Losses", 38, Rarity.RARE, mage.cards.c.CutYourLosses.class)); cards.add(new SetCardInfo("Cut of the Profits", 72, Rarity.RARE, mage.cards.c.CutOfTheProfits.class)); cards.add(new SetCardInfo("Devilish Valet", 105, Rarity.RARE, mage.cards.d.DevilishValet.class)); cards.add(new SetCardInfo("Disciplined Duelist", 182, Rarity.UNCOMMON, mage.cards.d.DisciplinedDuelist.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/MillHalfLibraryTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/MillHalfLibraryTargetEffect.java new file mode 100644 index 00000000000..35df10deae2 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/MillHalfLibraryTargetEffect.java @@ -0,0 +1,50 @@ +package mage.abilities.effects.common; + +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.effects.OneShotEffect; +import mage.constants.Outcome; +import mage.game.Game; +import mage.players.Player; + +/** + * @author TheElk801 + */ +public class MillHalfLibraryTargetEffect extends OneShotEffect { + + private static boolean roundUp; + + public MillHalfLibraryTargetEffect(boolean roundUp) { + super(Outcome.Benefit); + this.roundUp = roundUp; + } + + private MillHalfLibraryTargetEffect(final MillHalfLibraryTargetEffect effect) { + super(effect); + this.roundUp = effect.roundUp; + } + + @Override + public MillHalfLibraryTargetEffect copy() { + return new MillHalfLibraryTargetEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); + if (player == null) { + return false; + } + int count = player.getLibrary().size(); + return player.millCards(count / 2 + (roundUp ? count % 2 : 0), source, game).size() > 0; + } + + @Override + public String getText(Mode mode) { + if (staticText != null && !staticText.isEmpty()) { + return staticText; + } + return "target " + (mode.getTargets().isEmpty() ? "that player" : mode.getTargets().get(0).getTargetName()) + + " mills half their library, rounded " + (roundUp ? "up" : "down"); + } +}