From 6fc78d1d782c0e0dc23caf026e13443b4c5ec2aa Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 6 Sep 2017 16:19:53 -0400 Subject: [PATCH] Implemented Pirate's Cutlass, changed text templating for creating token effects --- .../src/mage/cards/p/PiratesCutlass.java | 89 +++++++++++++++++++ Mage.Sets/src/mage/cards/t/TrustyMachete.java | 10 +-- Mage.Sets/src/mage/sets/Ixalan.java | 1 + .../effects/common/CreateTokenEffect.java | 12 ++- .../common/CreateTokenTargetEffect.java | 37 ++++++-- 5 files changed, 131 insertions(+), 18 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/p/PiratesCutlass.java diff --git a/Mage.Sets/src/mage/cards/p/PiratesCutlass.java b/Mage.Sets/src/mage/cards/p/PiratesCutlass.java new file mode 100644 index 0000000000..0c6b00b464 --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PiratesCutlass.java @@ -0,0 +1,89 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.cards.p; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.continuous.BoostEquippedEffect; +import mage.abilities.keyword.EquipAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.predicate.permanent.ControllerPredicate; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author TheElk801 + */ +public class PiratesCutlass extends CardImpl { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Pirate you control"); + + static { + filter.add(new SubtypePredicate(SubType.PIRATE)); + filter.add(new ControllerPredicate(TargetController.YOU)); + } + + public PiratesCutlass(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}"); + + this.subtype.add("Equipment"); + + // When Pirate's Cutlass enters the battlefield, attach it to target Pirate you control. + Ability ability = new EntersBattlefieldTriggeredAbility(new AttachEffect(Outcome.BoostCreature, "attach it to target Pirate you control"), false); + ability.addTarget(new TargetCreaturePermanent(filter)); + this.addAbility(ability); + + // Equipped creature gets +2/+1. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(2, 1))); + + // Equip 2 + this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(2))); + + } + + public PiratesCutlass(final PiratesCutlass card) { + super(card); + } + + @Override + public PiratesCutlass copy() { + return new PiratesCutlass(this); + } +} diff --git a/Mage.Sets/src/mage/cards/t/TrustyMachete.java b/Mage.Sets/src/mage/cards/t/TrustyMachete.java index ba0f973043..3f64f88a0f 100644 --- a/Mage.Sets/src/mage/cards/t/TrustyMachete.java +++ b/Mage.Sets/src/mage/cards/t/TrustyMachete.java @@ -25,7 +25,6 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.cards.t; import java.util.UUID; @@ -45,14 +44,15 @@ import mage.constants.Zone; */ public class TrustyMachete extends CardImpl { - public TrustyMachete (UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{1}"); + public TrustyMachete(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}"); this.subtype.add("Equipment"); - this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(2))); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(2, 1))); + this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(2))); } - public TrustyMachete (final TrustyMachete card) { + public TrustyMachete(final TrustyMachete card) { super(card); } diff --git a/Mage.Sets/src/mage/sets/Ixalan.java b/Mage.Sets/src/mage/sets/Ixalan.java index f771d2ec3f..a5abf0b667 100644 --- a/Mage.Sets/src/mage/sets/Ixalan.java +++ b/Mage.Sets/src/mage/sets/Ixalan.java @@ -85,6 +85,7 @@ public class Ixalan extends ExpansionSet { cards.add(new SetCardInfo("Opt", 65, Rarity.COMMON, mage.cards.o.Opt.class)); cards.add(new SetCardInfo("Overflowing Insight", 64, Rarity.MYTHIC, mage.cards.o.OverflowingInsight.class)); cards.add(new SetCardInfo("Pillar of Origins", 241, Rarity.UNCOMMON, mage.cards.p.PillarOfOrigins.class)); + cards.add(new SetCardInfo("Pirate's Cutlass", 242, Rarity.COMMON, mage.cards.p.PiratesCutlass.class)); cards.add(new SetCardInfo("Primal Amulet", 243, Rarity.RARE, mage.cards.p.PrimalAmulet.class)); cards.add(new SetCardInfo("Primal Wellspring", 243, Rarity.RARE, mage.cards.p.PrimalWellspring.class)); cards.add(new SetCardInfo("Prosperous Pirates", 69, Rarity.COMMON, mage.cards.p.ProsperousPirates.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/CreateTokenEffect.java b/Mage/src/main/java/mage/abilities/effects/common/CreateTokenEffect.java index 025cebb7ac..71deb80ab0 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/CreateTokenEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/CreateTokenEffect.java @@ -113,7 +113,7 @@ public class CreateTokenEffect extends OneShotEffect { public ArrayList getLastAddedTokenIds() { return lastAddedTokenIds; } - + public void exileTokensCreatedAtNextEndStep(Game game, Ability source) { for (UUID tokenId : this.getLastAddedTokenIds()) { Permanent tokenPermanent = game.getPermanent(tokenId); @@ -122,7 +122,7 @@ public class CreateTokenEffect extends OneShotEffect { exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game)); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source); } - } + } } public void exileTokensCreatedAtEndOfCombat(Game game, Ability source) { @@ -133,9 +133,9 @@ public class CreateTokenEffect extends OneShotEffect { exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game)); game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(exileEffect), source); } - } + } } - + private void setText() { StringBuilder sb = new StringBuilder("create "); if (amount.toString().equals("1")) { @@ -153,6 +153,10 @@ public class CreateTokenEffect extends OneShotEffect { if (token.getDescription().endsWith("token")) { sb.append("s "); } + int tokenLocation = sb.indexOf("token "); + if (tokenLocation != -1) { + sb.replace(tokenLocation, tokenLocation + 6, "tokens "); + } } if (attacking) { if (tapped) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/CreateTokenTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/CreateTokenTargetEffect.java index 863528dbbe..753a4a96f8 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/CreateTokenTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/CreateTokenTargetEffect.java @@ -67,25 +67,44 @@ public class CreateTokenTargetEffect extends OneShotEffect { if (staticText != null && !staticText.isEmpty()) { return staticText; } - StringBuilder sb = new StringBuilder("put "); - sb.append(CardUtil.numberToText(amount.toString(), "a")); - sb.append(' ').append(token.getDescription()).append(" onto the battlefield"); - if (tapped) { - sb.append(" tapped"); + StringBuilder sb = new StringBuilder(); + sb.append("target ").append(mode.getTargets().get(0).getTargetName()); + sb.append(" creates "); + if (amount.toString().equals("1")) { + sb.append("a "); + if (tapped && !attacking) { + sb.append("tapped "); + } + sb.append(token.getDescription()); + } else { + sb.append(CardUtil.numberToText(amount.toString())).append(' '); + if (tapped && !attacking) { + sb.append("tapped "); + } + sb.append(token.getDescription()); + if (token.getDescription().endsWith("token")) { + sb.append("s "); + } + int tokenLocation = sb.indexOf("token "); + if (tokenLocation != -1) { + sb.replace(tokenLocation, tokenLocation + 6, "tokens "); + } } if (attacking) { if (tapped) { - sb.append(" and"); + sb.append(" tapped and"); } sb.append(" attacking"); } String message = amount.getMessage(); if (!message.isEmpty()) { - sb.append(" for each "); + if (amount.toString().equals("X")) { + sb.append(", where X is "); + } else { + sb.append(" for each "); + } } sb.append(message); - sb.append(" under target ").append(mode.getTargets().get(0).getTargetName()); - sb.append("'s control"); return sb.toString(); } }