From 32359386a03b39c9a1de2b2594dd6a0b6c1c9243 Mon Sep 17 00:00:00 2001 From: Zzooouhh Date: Thu, 14 Sep 2017 12:27:05 +0200 Subject: [PATCH 1/4] Added Scarwood Bandits --- .../src/mage/cards/s/ScarwoodBandits.java | 134 ++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/s/ScarwoodBandits.java diff --git a/Mage.Sets/src/mage/cards/s/ScarwoodBandits.java b/Mage.Sets/src/mage/cards/s/ScarwoodBandits.java new file mode 100644 index 0000000000..226defb05f --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/ScarwoodBandits.java @@ -0,0 +1,134 @@ +/* + * 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.s; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.condition.common.SourceOnBattlefieldCondition; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.Cost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.decorator.ConditionalContinuousEffect; +import mage.abilities.effects.common.continuous.GainControlTargetEffect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.ForestwalkAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetArtifactPermanent; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author L_J + */ +public class ScarwoodBandits extends CardImpl { + + public ScarwoodBandits(UUID ownerId, CardSetInfo setInfo) { + super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{G}{G}"); + this.subtype.add("Human"); + this.subtype.add("Rogue"); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // Forestwalk + this.addAbility(new ForestwalkAbility()); + + // {2}{G}, {tap}: Unless an opponent pays {2}, gain control of target artifact for as long as Scarwood Bandits remains on the battlefield. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ScarwoodBanditsEffect(new GenericManaCost(2)), new ManaCostsImpl("{2}{G}")); + ability.addCost(new TapSourceCost()); + ability.addTarget(new TargetArtifactPermanent()); + this.addAbility(ability); + } + + public ScarwoodBandits(final ScarwoodBandits card) { + super(card); + } + + @Override + public ScarwoodBandits copy() { + return new ScarwoodBandits(this); + } +} + +class ScarwoodBanditsEffect extends OneShotEffect { + + protected Cost cost; + + public ScarwoodBanditsEffect(Cost cost) { + super(Outcome.Detriment); + this.staticText = "Unless an opponent pays {2}, gain control of target artifact for as long as Scarwood Bandits remains on the battlefield"; + this.cost = cost; + } + + public ScarwoodBanditsEffect(final ScarwoodBanditsEffect effect) { + super(effect); + this.cost = effect.cost.copy(); + } + + @Override + public ScarwoodBanditsEffect copy() { + return new ScarwoodBanditsEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Permanent targetArtifact = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (targetArtifact != null) { + Player player = game.getPlayer(targetArtifact.getControllerId()); + if (player != null) { + cost.clearPaid(); + if (player.chooseUse(Outcome.Benefit, "Pay {2}? (Otherwise Scarwood Bandits' controller gains control of" + targetArtifact.getLogName() + ")", source, game)) { + cost.pay(source, game, targetArtifact.getControllerId(), targetArtifact.getControllerId(), false, null); + } + if (!cost.isPaid()) { + ConditionalContinuousEffect effect = new ConditionalContinuousEffect( + new GainControlTargetEffect(Duration.Custom), + new SourceOnBattlefieldCondition(), + "Gain control of target artifact for as long as Scarwood Bandits remains on the battlefield."); + effect.setTargetPointer(new FixedTarget(targetArtifact.getId())); + game.addEffect(effect, source); + } + } + } + return true; + } + return false; + } +} From e65cb0f018ca96f90762456aeba04c5a2c0eea88 Mon Sep 17 00:00:00 2001 From: Zzooouhh Date: Thu, 14 Sep 2017 12:28:27 +0200 Subject: [PATCH 2/4] Added Scarwood Bandits --- Mage.Sets/src/mage/sets/TheDark.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Mage.Sets/src/mage/sets/TheDark.java b/Mage.Sets/src/mage/sets/TheDark.java index 7ff996766d..293189e1d4 100644 --- a/Mage.Sets/src/mage/sets/TheDark.java +++ b/Mage.Sets/src/mage/sets/TheDark.java @@ -68,7 +68,7 @@ public class TheDark extends ExpansionSet { cards.add(new SetCardInfo("Carnivorous Plant", 38, Rarity.COMMON, mage.cards.c.CarnivorousPlant.class)); cards.add(new SetCardInfo("Cave People", 59, Rarity.UNCOMMON, mage.cards.c.CavePeople.class)); cards.add(new SetCardInfo("City of Shadows", 113, Rarity.RARE, mage.cards.c.CityOfShadows.class)); - cards.add(new SetCardInfo("Cleansing", 77, Rarity.RARE, mage.cards.c.Cleansing.class)); + cards.add(new SetCardInfo("Cleansing", 77, Rarity.RARE, mage.cards.c.Cleansing.class)); cards.add(new SetCardInfo("Coal Golem", 96, Rarity.UNCOMMON, mage.cards.c.CoalGolem.class)); cards.add(new SetCardInfo("Dance of Many", 21, Rarity.RARE, mage.cards.d.DanceOfMany.class)); cards.add(new SetCardInfo("Dark Heart of the Wood", 117, Rarity.COMMON, mage.cards.d.DarkHeartOfTheWood.class)); @@ -105,7 +105,7 @@ public class TheDark extends ExpansionSet { cards.add(new SetCardInfo("Marsh Viper", 44, Rarity.COMMON, mage.cards.m.MarshViper.class)); cards.add(new SetCardInfo("Maze of Ith", 114, Rarity.UNCOMMON, mage.cards.m.MazeOfIth.class)); cards.add(new SetCardInfo("Merfolk Assassin", 31, Rarity.UNCOMMON, mage.cards.m.MerfolkAssassin.class)); - cards.add(new SetCardInfo("Mind Bomb", 32, Rarity.RARE, mage.cards.m.MindBomb.class)); + cards.add(new SetCardInfo("Mind Bomb", 32, Rarity.RARE, mage.cards.m.MindBomb.class)); cards.add(new SetCardInfo("Morale", 87, Rarity.COMMON, mage.cards.m.Morale.class)); cards.add(new SetCardInfo("Murk Dwellers", 11, Rarity.COMMON, mage.cards.m.MurkDwellers.class)); cards.add(new SetCardInfo("Niall Silvain", 45, Rarity.RARE, mage.cards.n.NiallSilvain.class)); @@ -116,6 +116,7 @@ public class TheDark extends ExpansionSet { cards.add(new SetCardInfo("Riptide", 34, Rarity.COMMON, mage.cards.r.Riptide.class)); cards.add(new SetCardInfo("Safe Haven", 115, Rarity.RARE, mage.cards.s.SafeHaven.class)); cards.add(new SetCardInfo("Savaen Elves", 47, Rarity.COMMON, mage.cards.s.SavaenElves.class)); + cards.add(new SetCardInfo("Scarwood Bandits", 48, Rarity.RARE, mage.cards.s.ScarwoodBandits.class)); cards.add(new SetCardInfo("Scarwood Goblins", 119, Rarity.COMMON, mage.cards.s.ScarwoodGoblins.class)); cards.add(new SetCardInfo("Scarwood Hag", 49, Rarity.UNCOMMON, mage.cards.s.ScarwoodHag.class)); cards.add(new SetCardInfo("Scavenger Folk", 50, Rarity.COMMON, mage.cards.s.ScavengerFolk.class)); From 9b25dc15c6499e683282c5f81fd088a809015cc5 Mon Sep 17 00:00:00 2001 From: Zzooouhh Date: Thu, 14 Sep 2017 15:38:58 +0200 Subject: [PATCH 3/4] Updated Scarwood Bandits' subtypes and condition --- .../src/mage/cards/s/ScarwoodBandits.java | 117 +++++++++++++----- 1 file changed, 87 insertions(+), 30 deletions(-) diff --git a/Mage.Sets/src/mage/cards/s/ScarwoodBandits.java b/Mage.Sets/src/mage/cards/s/ScarwoodBandits.java index 226defb05f..02573e4d6a 100644 --- a/Mage.Sets/src/mage/cards/s/ScarwoodBandits.java +++ b/Mage.Sets/src/mage/cards/s/ScarwoodBandits.java @@ -29,6 +29,7 @@ package mage.cards.s; import java.util.UUID; import mage.MageInt; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.condition.common.SourceOnBattlefieldCondition; @@ -38,19 +39,24 @@ import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.decorator.ConditionalContinuousEffect; import mage.abilities.effects.common.continuous.GainControlTargetEffect; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.Effect; +import mage.abilities.effects.Effects; import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.ForestwalkAbility; +import mage.abilities.Mode; 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.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetArtifactPermanent; -import mage.target.targetpointer.FixedTarget; +import mage.util.CardUtil; /** * @@ -60,8 +66,8 @@ public class ScarwoodBandits extends CardImpl { public ScarwoodBandits(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{G}{G}"); - this.subtype.add("Human"); - this.subtype.add("Rogue"); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.ROGUE); this.power = new MageInt(2); this.toughness = new MageInt(2); @@ -69,7 +75,14 @@ public class ScarwoodBandits extends CardImpl { this.addAbility(new ForestwalkAbility()); // {2}{G}, {tap}: Unless an opponent pays {2}, gain control of target artifact for as long as Scarwood Bandits remains on the battlefield. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ScarwoodBanditsEffect(new GenericManaCost(2)), new ManaCostsImpl("{2}{G}")); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, + new DoUnlessAnyOpponentPaysEffect( + new ConditionalContinuousEffect( + new GainControlTargetEffect(Duration.Custom, true), + new SourceOnBattlefieldCondition(), + "gain control of target artifact for as long as {this} remains on the battlefield"), + new GenericManaCost(2)), + new ManaCostsImpl("{2}{G}")); ability.addCost(new TapSourceCost()); ability.addTarget(new TargetArtifactPermanent()); this.addAbility(ability); @@ -85,50 +98,94 @@ public class ScarwoodBandits extends CardImpl { } } -class ScarwoodBanditsEffect extends OneShotEffect { +class DoUnlessAnyOpponentPaysEffect extends OneShotEffect { - protected Cost cost; + protected Effects executingEffects = new Effects(); + private final Cost cost; + private String chooseUseText; - public ScarwoodBanditsEffect(Cost cost) { - super(Outcome.Detriment); - this.staticText = "Unless an opponent pays {2}, gain control of target artifact for as long as Scarwood Bandits remains on the battlefield"; + public DoUnlessAnyOpponentPaysEffect(Effect effect, Cost cost) { + this(effect, cost, null); + } + + public DoUnlessAnyOpponentPaysEffect(Effect effect, Cost cost, String chooseUseText) { + super(Outcome.Benefit); + this.executingEffects.add(effect); this.cost = cost; + this.chooseUseText = chooseUseText; } - public ScarwoodBanditsEffect(final ScarwoodBanditsEffect effect) { + public DoUnlessAnyOpponentPaysEffect(final DoUnlessAnyOpponentPaysEffect effect) { super(effect); + this.executingEffects = effect.executingEffects.copy(); this.cost = effect.cost.copy(); + this.chooseUseText = effect.chooseUseText; } - @Override - public ScarwoodBanditsEffect copy() { - return new ScarwoodBanditsEffect(this); + public void addEffect(Effect effect) { + executingEffects.add(effect); } @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - Permanent targetArtifact = game.getPermanent(getTargetPointer().getFirst(game, source)); - if (targetArtifact != null) { - Player player = game.getPlayer(targetArtifact.getControllerId()); - if (player != null) { + MageObject sourceObject = game.getObject(source.getSourceId()); + if (controller != null && sourceObject != null) { + String message; + if (chooseUseText == null) { + String effectText = executingEffects.getText(source.getModes().getMode()); + message = "Pay " + cost.getText() + " to prevent (" + effectText.substring(0, effectText.length() - 1) + ")?"; + } else { + message = chooseUseText; + } + message = CardUtil.replaceSourceName(message, sourceObject.getName()); + boolean result = true; + boolean doEffect = true; + // check if any opponent is willing to pay + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { + Player player = game.getPlayer(playerId); + if (player != null && player != controller && cost.canPay(source, source.getSourceId(), player.getId(), game) && player.chooseUse(Outcome.Detriment, message, source, game)) { cost.clearPaid(); - if (player.chooseUse(Outcome.Benefit, "Pay {2}? (Otherwise Scarwood Bandits' controller gains control of" + targetArtifact.getLogName() + ")", source, game)) { - cost.pay(source, game, targetArtifact.getControllerId(), targetArtifact.getControllerId(), false, null); - } - if (!cost.isPaid()) { - ConditionalContinuousEffect effect = new ConditionalContinuousEffect( - new GainControlTargetEffect(Duration.Custom), - new SourceOnBattlefieldCondition(), - "Gain control of target artifact for as long as Scarwood Bandits remains on the battlefield."); - effect.setTargetPointer(new FixedTarget(targetArtifact.getId())); - game.addEffect(effect, source); + if (cost.pay(source, game, source.getSourceId(), player.getId(), false, null)) { + if (!game.isSimulation()) { + game.informPlayers(player.getLogName() + " pays the cost to prevent the effect"); + } + doEffect = false; + break; } } - } - return true; + } + // do the effects if nobody paid + if (doEffect) { + for (Effect effect : executingEffects) { + effect.setTargetPointer(this.targetPointer); + if (effect instanceof OneShotEffect) { + result &= effect.apply(game, source); + } else { + game.addEffect((ContinuousEffect) effect, source); + } + } + } + return result; } return false; } + + protected Player getPayingPlayer(Game game, Ability source) { + return game.getPlayer(source.getControllerId()); + } + + @Override + public String getText(Mode mode) { + if (!staticText.isEmpty()) { + return staticText; + } + String effectsText = executingEffects.getText(mode); + return effectsText.substring(0, effectsText.length() - 1) + " unless any opponent pays " + cost.getText(); + } + + @Override + public DoUnlessAnyOpponentPaysEffect copy() { + return new DoUnlessAnyOpponentPaysEffect(this); + } } From f569331e2da494106508fe8568ccb978f2bb5ff2 Mon Sep 17 00:00:00 2001 From: Zzooouhh Date: Thu, 14 Sep 2017 15:53:15 +0200 Subject: [PATCH 4/4] Updated Scarwood Bandits --- Mage.Sets/src/mage/cards/s/ScarwoodBandits.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Mage.Sets/src/mage/cards/s/ScarwoodBandits.java b/Mage.Sets/src/mage/cards/s/ScarwoodBandits.java index 02573e4d6a..d6fd2a6c25 100644 --- a/Mage.Sets/src/mage/cards/s/ScarwoodBandits.java +++ b/Mage.Sets/src/mage/cards/s/ScarwoodBandits.java @@ -151,7 +151,6 @@ class DoUnlessAnyOpponentPaysEffect extends OneShotEffect { game.informPlayers(player.getLogName() + " pays the cost to prevent the effect"); } doEffect = false; - break; } } }