From eff6ea131f92da532e02dc9b0469998c6bf53e9d Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 31 Jan 2013 21:56:11 +0100 Subject: [PATCH 1/4] Added possibility that opponent can activate activateted ability to activatedAbility. Minor changes. --- Mage/src/mage/abilities/AbilityImpl.java | 7 ++++++- .../src/mage/abilities/ActivatedAbilityImpl.java | 16 +++++++++++++++- .../costs/common/RemoveCounterCost.java | 2 -- .../continious/ControlEnchantedEffect.java | 2 +- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Mage/src/mage/abilities/AbilityImpl.java b/Mage/src/mage/abilities/AbilityImpl.java index d9c649101c2..1b0aab70994 100644 --- a/Mage/src/mage/abilities/AbilityImpl.java +++ b/Mage/src/mage/abilities/AbilityImpl.java @@ -196,6 +196,7 @@ public abstract class AbilityImpl> implements Ability { // 20121001 - 601.2b // If the spell has a variable cost that will be paid as it's being cast (such as an {X} in // its mana cost; see rule 107.3), the player announces the value of that variable. + // TODO: Handle announcing other variable costs here like: RemoveVariableCountersSourceCost if (game.getPlayer(this.controllerId).isHuman()) { // AI can't handle this yet. Uses old way of playXMana VariableManaCost manaX = null; @@ -276,7 +277,11 @@ public abstract class AbilityImpl> implements Ability { } //20100716 - 601.2g - if (!costs.pay(this, game, sourceId, controllerId, noMana)) { + UUID activatorId = controllerId; + if (this instanceof ActivatedAbilityImpl) { + activatorId = ((ActivatedAbilityImpl)this).getActivatorId(); + } + if (!costs.pay(this, game, sourceId, activatorId, noMana)) { logger.debug("activate failed - non mana costs"); return false; } diff --git a/Mage/src/mage/abilities/ActivatedAbilityImpl.java b/Mage/src/mage/abilities/ActivatedAbilityImpl.java index 018da30aa41..40eda30fb00 100644 --- a/Mage/src/mage/abilities/ActivatedAbilityImpl.java +++ b/Mage/src/mage/abilities/ActivatedAbilityImpl.java @@ -54,6 +54,8 @@ import mage.target.Target; public abstract class ActivatedAbilityImpl> extends AbilityImpl implements ActivatedAbility { protected TimingRule timing = TimingRule.INSTANT; + protected boolean onlyOpponentCanActivate = false; + protected UUID activatorId; protected ActivatedAbilityImpl(AbilityType abilityType, Zone zone) { super(abilityType, zone); @@ -62,6 +64,8 @@ public abstract class ActivatedAbilityImpl> ex public ActivatedAbilityImpl(ActivatedAbilityImpl ability) { super(ability); timing = ability.timing; + onlyOpponentCanActivate = ability.onlyOpponentCanActivate; + activatorId = ability.activatorId; } public ActivatedAbilityImpl(Zone zone) { @@ -152,12 +156,14 @@ public abstract class ActivatedAbilityImpl> ex @Override public boolean canActivate(UUID playerId, Game game) { //20091005 - 602.2 - if (!controlsAbility(playerId, game)) { + if ((!onlyOpponentCanActivate && !controlsAbility(playerId, game)) || + (onlyOpponentCanActivate && !game.getOpponents(controllerId).contains(playerId))) { return false; } //20091005 - 602.5d/602.5e if (timing == TimingRule.INSTANT || game.canPlaySorcery(playerId)) { if (costs.canPay(sourceId, controllerId, game) && canChooseTarget(game)) { + this.activatorId = playerId; return true; } } @@ -230,4 +236,12 @@ public abstract class ActivatedAbilityImpl> ex } return sb.toString(); } + + public void setOnlyOpponentCanActivate(boolean onlyOpponentCanActivate) { + this.onlyOpponentCanActivate = onlyOpponentCanActivate; + } + + public UUID getActivatorId() { + return this.activatorId; + } } diff --git a/Mage/src/mage/abilities/costs/common/RemoveCounterCost.java b/Mage/src/mage/abilities/costs/common/RemoveCounterCost.java index 420054d2474..4ec5de3f3df 100644 --- a/Mage/src/mage/abilities/costs/common/RemoveCounterCost.java +++ b/Mage/src/mage/abilities/costs/common/RemoveCounterCost.java @@ -51,7 +51,6 @@ import mage.target.TargetPermanent; public class RemoveCounterCost extends CostImpl { private TargetPermanent target; - private int amount; private String name; private CounterType counterTypeToRemove; @@ -68,7 +67,6 @@ public class RemoveCounterCost extends CostImpl { public RemoveCounterCost(final RemoveCounterCost cost) { super(cost); this.target = cost.target.copy(); - this.amount = cost.amount; this.name = cost.name; } diff --git a/Mage/src/mage/abilities/effects/common/continious/ControlEnchantedEffect.java b/Mage/src/mage/abilities/effects/common/continious/ControlEnchantedEffect.java index 24e045e4b04..0a039f5c1b9 100644 --- a/Mage/src/mage/abilities/effects/common/continious/ControlEnchantedEffect.java +++ b/Mage/src/mage/abilities/effects/common/continious/ControlEnchantedEffect.java @@ -12,7 +12,7 @@ import mage.game.permanent.Permanent; public class ControlEnchantedEffect extends ContinuousEffectImpl { public ControlEnchantedEffect() { - super(Constants.Duration.WhileOnBattlefield, Constants.Outcome.Detriment); + super(Constants.Duration.WhileOnBattlefield, Constants.Outcome.GainControl); staticText = "You control enchanted creature"; } From 7ff893a57af75427799a7a0ffd6ed39c3b462354 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 31 Jan 2013 21:56:46 +0100 Subject: [PATCH 2/4] New RemoveVariableCountersTargetCost. --- .../RemoveVariableCountersTargetCost.java | 163 ++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 Mage/src/mage/abilities/costs/common/RemoveVariableCountersTargetCost.java diff --git a/Mage/src/mage/abilities/costs/common/RemoveVariableCountersTargetCost.java b/Mage/src/mage/abilities/costs/common/RemoveVariableCountersTargetCost.java new file mode 100644 index 00000000000..d45d7f0b6ad --- /dev/null +++ b/Mage/src/mage/abilities/costs/common/RemoveVariableCountersTargetCost.java @@ -0,0 +1,163 @@ +/* + * 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.abilities.costs.common; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.UUID; +import mage.Constants.Outcome; +import mage.abilities.Ability; +import mage.abilities.costs.CostImpl; +import mage.abilities.costs.VariableCost; +import mage.choices.Choice; +import mage.choices.ChoiceImpl; +import mage.counters.Counter; +import mage.counters.CounterType; +import mage.filter.FilterMana; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; + +/** + * + * @author LevelX + */ +public class RemoveVariableCountersTargetCost extends CostImpl implements VariableCost { + + protected int amountPaid = 0; + protected TargetPermanent target; + protected String name; + protected CounterType counterTypeToRemove; + + public RemoveVariableCountersTargetCost(TargetPermanent target) { + this(target, null); + } + + public RemoveVariableCountersTargetCost(TargetPermanent target, CounterType counterTypeToRemove) { + this.target = target; + this.counterTypeToRemove = counterTypeToRemove; + text = setText(); + } + + public RemoveVariableCountersTargetCost(final RemoveVariableCountersTargetCost cost) { + super(cost); + this.target = cost.target.copy(); + this.name = cost.name; + } + + @Override + public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) { + paid = false; + Player controller = game.getPlayer(controllerId); + if (target.choose(Outcome.UnboostCreature, controllerId, sourceId, game)) { + for (UUID targetId: (List)target.getTargets()) { + Permanent permanent = game.getPermanent(targetId); + if (permanent != null) { + if (permanent.getCounters().size() > 0 && (counterTypeToRemove == null || permanent.getCounters().containsKey(counterTypeToRemove))) { + String counterName = null; + if (counterTypeToRemove != null) { + counterName = counterTypeToRemove.getName(); + } else { + if (permanent.getCounters().size() > 1 && counterTypeToRemove == null) { + Choice choice = new ChoiceImpl(true); + Set choices = new HashSet(); + for (Counter counter : permanent.getCounters().values()) { + if (permanent.getCounters().getCount(counter.getName()) > 0) { + choices.add(counter.getName()); + } + } + choice.setChoices(choices); + choice.setMessage("Choose a counter to remove from " + permanent.getName()); + controller.choose(Outcome.UnboostCreature, choice, game); + counterName = choice.getChoice(); + } else { + for (Counter counter : permanent.getCounters().values()) { + if (counter.getCount() > 0) { + counterName = counter.getName(); + } + } + } + } + if (counterName != null) { + int countersToRemove = 1; + if (permanent.getCounters().getCount(counterName) > 1) { + countersToRemove = controller.getAmount(1, permanent.getCounters().getCount(counterName),"Remove how many counters from " + permanent.getName(), game); + } + permanent.removeCounters(counterName, countersToRemove, game); + if (permanent.getCounters().getCount(counterName) == 0 ){ + permanent.getCounters().removeCounter(counterName); + } + this.amountPaid += countersToRemove; + this.paid = true; + game.informPlayers(new StringBuilder(controller.getName()).append(" removes ").append(countersToRemove).append(" ").append(counterName).append(" counter from ").append(permanent.getName()).toString()); + } + } + } + } + } + target.clearChosen(); + return paid; + } + + @Override + public int getAmount() { + return amountPaid; + } + + @Override + public void setAmount(int amount) { + amountPaid = amount; + } + + @Override + public void setFilter(FilterMana filter) { + } + + @Override + public boolean canPay(UUID sourceId, UUID controllerId, Game game) { + return target.canChoose(controllerId, game); + } + + private String setText() { + // Remove one or more +1/+1 counters from among creatures you control + StringBuilder sb = new StringBuilder("Remove one or more "); + if (counterTypeToRemove != null) { + sb.append(counterTypeToRemove.getName()).append(" "); + } + sb.append("counter from among ").append(target.getTargetName()); + return sb.toString(); + } + + @Override + public RemoveVariableCountersTargetCost copy() { + return new RemoveVariableCountersTargetCost(this); + } +} From eec06e7aee1aff81f4edf6e106d27082eda8b272 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 31 Jan 2013 21:57:14 +0100 Subject: [PATCH 3/4] Small fix to Miming Slime. --- Mage.Sets/src/mage/sets/gatecrash/MimingSlime.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage.Sets/src/mage/sets/gatecrash/MimingSlime.java b/Mage.Sets/src/mage/sets/gatecrash/MimingSlime.java index 77816a5ecee..affbc8535a9 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/MimingSlime.java +++ b/Mage.Sets/src/mage/sets/gatecrash/MimingSlime.java @@ -96,7 +96,7 @@ class MimingSlimeEffect extends OneShotEffect { amount = power; } } - MysticGenesisOozeToken oozeToken = new MysticGenesisOozeToken(); + OozeToken oozeToken = new OozeToken(); oozeToken.getPower().setValue(amount); oozeToken.getToughness().setValue(amount); oozeToken.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId()); From 62552ef11b2a0c693e577228d335fe3922d0b4d5 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 31 Jan 2013 21:58:00 +0100 Subject: [PATCH 4/4] [GTC] Ooze Flux, Soul Ransom, Simic Manipulator --- .../src/mage/sets/gatecrash/OozeFlux.java | 113 ++++++++++++++ .../mage/sets/gatecrash/SimicManipulator.java | 138 ++++++++++++++++++ .../src/mage/sets/gatecrash/SoulRansom.java | 93 ++++++++++++ 3 files changed, 344 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/gatecrash/OozeFlux.java create mode 100644 Mage.Sets/src/mage/sets/gatecrash/SimicManipulator.java create mode 100644 Mage.Sets/src/mage/sets/gatecrash/SoulRansom.java diff --git a/Mage.Sets/src/mage/sets/gatecrash/OozeFlux.java b/Mage.Sets/src/mage/sets/gatecrash/OozeFlux.java new file mode 100644 index 00000000000..9f8219841d8 --- /dev/null +++ b/Mage.Sets/src/mage/sets/gatecrash/OozeFlux.java @@ -0,0 +1,113 @@ +/* + * 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.sets.gatecrash; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Outcome; +import mage.Constants.Rarity; +import mage.Constants.Zone; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.Cost; +import mage.abilities.costs.common.RemoveVariableCountersTargetCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.counters.CounterType; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.game.Game; +import mage.game.permanent.token.Token; +import mage.target.common.TargetControlledCreaturePermanent; + +/** + * + * @author LevelX2 + */ +public class OozeFlux extends CardImpl { + + public OozeFlux(UUID ownerId) { + super(ownerId, 128, "Ooze Flux", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{G}"); + this.expansionSetCode = "GTC"; + + this.color.setGreen(true); + + // {1}{G}, Remove one or more +1/+1 counters from among creatures you control: Put an X/X green Ooze creature token onto the battlefield, where X is the number of +1/+1 counters removed this way. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new OozeFluxCreateTokenEffect(new OozeToken()),new ManaCostsImpl("{1}{G}")); + ability.addCost(new RemoveVariableCountersTargetCost( + new TargetControlledCreaturePermanent(1,Integer.MAX_VALUE,new FilterControlledCreaturePermanent(), true), CounterType.P1P1)); + this.addAbility(ability); + } + + public OozeFlux(final OozeFlux card) { + super(card); + } + + @Override + public OozeFlux copy() { + return new OozeFlux(this); + } +} + +class OozeFluxCreateTokenEffect extends OneShotEffect { + + private Token token; + + public OozeFluxCreateTokenEffect(Token token) { + super(Outcome.PutCreatureInPlay); + this.token = token; + staticText = "Put an X/X green Ooze creature token onto the battlefield, where X is the number of +1/+1 counters removed this way"; + } + + public OozeFluxCreateTokenEffect(final OozeFluxCreateTokenEffect effect) { + super(effect); + this.token = effect.token.copy(); + } + + @Override + public OozeFluxCreateTokenEffect copy() { + return new OozeFluxCreateTokenEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + int xValue = 0; + for (Cost cost : source.getCosts()) { + if (cost instanceof RemoveVariableCountersTargetCost) { + xValue = ((RemoveVariableCountersTargetCost) cost).getAmount(); + break; + } + } + Token tokenCopy = token.copy(); + tokenCopy.getAbilities().newId(); + tokenCopy.getPower().setValue(xValue); + tokenCopy.getToughness().setValue(xValue); + tokenCopy.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId()); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/gatecrash/SimicManipulator.java b/Mage.Sets/src/mage/sets/gatecrash/SimicManipulator.java new file mode 100644 index 00000000000..7ab0de306d6 --- /dev/null +++ b/Mage.Sets/src/mage/sets/gatecrash/SimicManipulator.java @@ -0,0 +1,138 @@ +/* +* 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.sets.gatecrash; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Duration; +import mage.Constants.Layer; +import mage.Constants.Outcome; +import mage.Constants.Rarity; +import mage.Constants.SubLayer; +import mage.Constants.Zone; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.Cost; +import mage.abilities.costs.common.RemoveVariableCountersSourceCost; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.keyword.EvolveAbility; +import mage.cards.CardImpl; +import mage.counters.CounterType; +import mage.filter.common.FilterCreaturePermanent; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.common.TargetCreaturePermanent; + +/** +* Gatecrash FAQ (01.2013) +* +* The power of the target creature is checked both as you target it and as the ability +* resolves. If the power of the target creature when the ability resolves is greater +* than the number of +1/+1 counters removed from Simic Manipulator, the ability will +* be countered and none of its effects will happen. You won't gain control of any +* creature, but the counters removed as a cost remain removed. +* +* @author LevelX2 +*/ +public class SimicManipulator extends CardImpl { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with power less than or equal to the number of +1/+1 counters removed this way"); + + public SimicManipulator(UUID ownerId) { + super(ownerId, 50, "Simic Manipulator", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{1}{U}{U}"); + this.expansionSetCode = "GTC"; + this.subtype.add("Mutant"); + this.subtype.add("Wizard"); + + this.color.setBlue(true); + this.power = new MageInt(0); + this.toughness = new MageInt(1); + + // Evolve + this.addAbility(new EvolveAbility()); + + // {tap}, Remove one or more +1/+1 counters from Simic Manipulator: Gain control of target creature with power less than or equal to the number of +1/+1 counters removed this way. + // TODO: Improve targeting, that only valid targets (power <= removed counters) can be choosen + // Disadvante now is, that a creature can be targeted that couldn't be targeted by rules. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new SimicManipulatorGainControlTargetEffect(Duration.WhileOnBattlefield), new TapSourceCost()); + ability.addTarget(new TargetCreaturePermanent(filter)); + ability.addCost(new RemoveVariableCountersSourceCost(CounterType.P1P1.createInstance(),1)); + this.addAbility(ability); + } + + public SimicManipulator(final SimicManipulator card) { + super(card); + } + + @Override + public SimicManipulator copy() { + return new SimicManipulator(this); + } +} + +class SimicManipulatorGainControlTargetEffect extends ContinuousEffectImpl { + + public SimicManipulatorGainControlTargetEffect(Duration duration) { + super(duration, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl); + } + + public SimicManipulatorGainControlTargetEffect(final SimicManipulatorGainControlTargetEffect effect) { + super(effect); + } + + @Override + public SimicManipulatorGainControlTargetEffect copy() { + return new SimicManipulatorGainControlTargetEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(source.getFirstTarget()); + if (permanent != null) { + int maxPower = 0; + for (Cost cost : source.getCosts()) { + if (cost instanceof RemoveVariableCountersSourceCost) { + maxPower = ((RemoveVariableCountersSourceCost) cost).getAmount(); + break; + } + } + if (permanent.getPower().getValue() <= maxPower) { + return permanent.changeControllerId(source.getControllerId(), game); + } + } + return false; + } + + @Override + public String getText(Mode mode) { + return "Gain control of target " + mode.getTargets().get(0).getTargetName() + " " + duration.toString(); + } +} diff --git a/Mage.Sets/src/mage/sets/gatecrash/SoulRansom.java b/Mage.Sets/src/mage/sets/gatecrash/SoulRansom.java new file mode 100644 index 00000000000..a5904d83d05 --- /dev/null +++ b/Mage.Sets/src/mage/sets/gatecrash/SoulRansom.java @@ -0,0 +1,93 @@ +/* + * 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.sets.gatecrash; + +import java.util.UUID; +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.common.DiscardTargetCost; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.DrawCardControllerEffect; +import mage.abilities.effects.common.SacrificeSourceEffect; +import mage.abilities.effects.common.continious.ControlEnchantedEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.cards.CardImpl; +import mage.filter.FilterCard; +import mage.target.TargetPermanent; +import mage.target.common.TargetCardInHand; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author LevelX2 + */ +public class SoulRansom extends CardImpl { + + public SoulRansom(UUID ownerId) { + super(ownerId, 198, "Soul Ransom", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}{B}"); + this.expansionSetCode = "GTC"; + this.subtype.add("Aura"); + + this.color.setBlue(true); + this.color.setBlack(true); + + // Enchant creature + TargetPermanent auraTarget = new TargetCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Constants.Outcome.AddAbility)); + Ability ability = new EnchantAbility(auraTarget.getTargetName()); + this.addAbility(ability); + // You control enchanted creature. + this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new ControlEnchantedEffect())); + + // Discard two cards: Soul Ransom's controller sacrifices it, then draws two cards. Only any opponent may activate this ability. + Effect effect = new SacrificeSourceEffect(); + effect.setText("{this}'s controller sacrifices it."); + SimpleActivatedAbility ability2 = new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, effect , new DiscardTargetCost(new TargetCardInHand(2,2, new FilterCard("two cards")))); + effect = new DrawCardControllerEffect(2); + effect.setText("Then draws two cards. Only any opponent may activate this ability"); + ability2.addEffect(effect); + ability2.setOnlyOpponentCanActivate(true); + this.addAbility(ability2); + + } + + public SoulRansom(final SoulRansom card) { + super(card); + } + + @Override + public SoulRansom copy() { + return new SoulRansom(this); + } +}