Fixed that the X value of permanents like Hangbar Walker isn't used again if the permanent enters the battlefield later without beeing cast (e.g. returning from leaving Oblivion Ring).

This commit is contained in:
LevelX2 2015-08-19 11:21:22 +02:00
parent 454bd5ca57
commit 2cf5907189
29 changed files with 219 additions and 197 deletions

View file

@ -77,6 +77,7 @@ public class AstralCornucopia extends CardImpl {
} }
class AstralCornucopiaEffect extends OneShotEffect { class AstralCornucopiaEffect extends OneShotEffect {
public AstralCornucopiaEffect() { public AstralCornucopiaEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
} }
@ -90,9 +91,8 @@ class AstralCornucopiaEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
// delete to prevent using it again if put into battlefield from other effect && permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
setValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY, null);
int amount = ((SpellAbility) obj).getManaCostsToPay().getX(); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
permanent.addCounters(CounterType.CHARGE.createInstance(amount), game); permanent.addCounters(CounterType.CHARGE.createInstance(amount), game);
@ -130,7 +130,7 @@ class AstralCornucopiaManaAbility extends ManaAbility {
if (sourcePermanent != null) { if (sourcePermanent != null) {
int counters = sourcePermanent.getCounters().getCount(CounterType.CHARGE.getName()); int counters = sourcePermanent.getCounters().getCount(CounterType.CHARGE.getName());
if (counters > 0) { if (counters > 0) {
netMana.add(new Mana(0,0,0,0,0,0,counters)); netMana.add(new Mana(0, 0, 0, 0, 0, 0, counters));
} }
} }
return netMana; return netMana;

View file

@ -28,10 +28,6 @@
package mage.sets.championsofkamigawa; package mage.sets.championsofkamigawa;
import java.util.UUID; 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.Ability;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.common.EntersBattlefieldAbility;
@ -43,6 +39,10 @@ import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -61,7 +61,7 @@ public class OrochiHatchery extends CardImpl {
this.addAbility(new EntersBattlefieldAbility(new OrochiHatcheryEffect(), "with X charge counters on it")); this.addAbility(new EntersBattlefieldAbility(new OrochiHatcheryEffect(), "with X charge counters on it"));
// {5}, {T}: Put a 1/1 green Snake creature token onto the battlefield for each charge counter on Orochi Hatchery. // {5}, {T}: Put a 1/1 green Snake creature token onto the battlefield for each charge counter on Orochi Hatchery.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateTokenEffect(new SnakeToken(),new CountersCount(CounterType.CHARGE)), new GenericManaCost(5)); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateTokenEffect(new SnakeToken(), new CountersCount(CounterType.CHARGE)), new GenericManaCost(5));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
this.addAbility(ability); this.addAbility(ability);
} }
@ -78,6 +78,7 @@ public class OrochiHatchery extends CardImpl {
} }
class OrochiHatcheryEffect extends OneShotEffect { class OrochiHatcheryEffect extends OneShotEffect {
public OrochiHatcheryEffect() { public OrochiHatcheryEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
} }
@ -91,9 +92,8 @@ class OrochiHatcheryEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
// delete to prevent using it again if put into battlefield from other effect && permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {;
setValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY, null);
int amount = ((SpellAbility) obj).getManaCostsToPay().getX(); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
permanent.addCounters(CounterType.CHARGE.createInstance(amount), game); permanent.addCounters(CounterType.CHARGE.createInstance(amount), game);

View file

@ -95,7 +95,8 @@ class LifebloodHydraComesIntoPlayEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && !permanent.isFaceDown(game)) { if (permanent != null && !permanent.isFaceDown(game)) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX(); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game); permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
@ -111,6 +112,7 @@ class LifebloodHydraComesIntoPlayEffect extends OneShotEffect {
} }
} }
class LifebloodHydraEffect extends OneShotEffect { class LifebloodHydraEffect extends OneShotEffect {
public LifebloodHydraEffect() { public LifebloodHydraEffect() {

View file

@ -27,8 +27,7 @@
*/ */
package mage.sets.conflux; package mage.sets.conflux;
import mage.constants.CardType; import java.util.UUID;
import mage.constants.Rarity;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
@ -40,15 +39,15 @@ import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.target.common.TargetCreatureOrPlayer; import mage.target.common.TargetCreatureOrPlayer;
import java.util.UUID;
/** /**
* *
* @author Loki * @author Loki
@ -83,6 +82,7 @@ public class ApocalypseHydra extends CardImpl {
} }
class ApocalypseHydraEffect extends OneShotEffect { class ApocalypseHydraEffect extends OneShotEffect {
ApocalypseHydraEffect() { ApocalypseHydraEffect() {
super(Outcome.BoostCreature); super(Outcome.BoostCreature);
staticText = "with X +1/+1 counters on it. If X is 5 or more, it enters the battlefield with an additional X +1/+1 counters on it"; staticText = "with X +1/+1 counters on it. If X is 5 or more, it enters the battlefield with an additional X +1/+1 counters on it";
@ -97,10 +97,9 @@ class ApocalypseHydraEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
// delete to prevent using it again if put into battlefield from other effect && permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
setValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY, null); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
int amount = ((SpellAbility)obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
if (amount < 5) { if (amount < 5) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game); permanent.addCounters(CounterType.P1P1.createInstance(amount), game);

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.sets.conspiracy; package mage.sets.conspiracy;
import java.util.UUID; import java.util.UUID;
@ -49,14 +48,13 @@ import mage.counters.CounterType;
import mage.filter.common.FilterInstantOrSorceryCard; import mage.filter.common.FilterInstantOrSorceryCard;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.target.common.TargetCreatureOrPlayer;
/** /**
* *
* @author andyfries * @author andyfries
*/ */
public class AcademyElite extends CardImpl { public class AcademyElite extends CardImpl {
public AcademyElite(UUID ownerId) { public AcademyElite(UUID ownerId) {
super(ownerId, 20, "Academy Elite", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{3}{U}"); super(ownerId, 20, "Academy Elite", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{3}{U}");
this.expansionSetCode = "CNS"; this.expansionSetCode = "CNS";
@ -76,7 +74,6 @@ public class AcademyElite extends CardImpl {
this.addAbility(ability); this.addAbility(ability);
} }
public AcademyElite(final AcademyElite card) { public AcademyElite(final AcademyElite card) {
super(card); super(card);
} }
@ -104,7 +101,8 @@ class AcademyEliteEffect1 extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
CardsInAllGraveyardsCount instantsAndSorceries = new CardsInAllGraveyardsCount(new FilterInstantOrSorceryCard("instant or sorcery cards")); CardsInAllGraveyardsCount instantsAndSorceries = new CardsInAllGraveyardsCount(new FilterInstantOrSorceryCard("instant or sorcery cards"));
int instantsAndSorceriesCount = instantsAndSorceries.calculate(game, source, this); int instantsAndSorceriesCount = instantsAndSorceries.calculate(game, source, this);
if (instantsAndSorceriesCount > 0) { if (instantsAndSorceriesCount > 0) {
@ -120,4 +118,3 @@ class AcademyEliteEffect1 extends OneShotEffect {
return new AcademyEliteEffect1(this); return new AcademyEliteEffect1(this);
} }
} }

View file

@ -95,9 +95,8 @@ class GrenzoDungeonWardenEtBEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
// delete to prevent using it again if put into battlefield from other effect && permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
setValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY, null);
int amount = ((Ability) obj).getManaCostsToPay().getX(); int amount = ((Ability) obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game); permanent.addCounters(CounterType.P1P1.createInstance(amount), game);

View file

@ -28,10 +28,6 @@
package mage.sets.dragonsmaze; package mage.sets.dragonsmaze;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
@ -42,7 +38,10 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.keyword.DoubleStrikeAbility; import mage.abilities.keyword.DoubleStrikeAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -97,10 +96,11 @@ class SavageBornHydraEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
// delete to prevent using it again if put into battlefield from other effect // delete to prevent using it again if put into battlefield from other effect
setValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY, null); setValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY, null);
int amount = ((SpellAbility)obj).getManaCostsToPay().getX(); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game); permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
} }

View file

@ -28,9 +28,6 @@
package mage.sets.gatecrash; package mage.sets.gatecrash;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
@ -38,7 +35,9 @@ import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -89,10 +88,9 @@ class NimbusSwimmerEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
// delete to prevent using it again if put into battlefield from other effect && permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
setValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY, null); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
int amount = ((SpellAbility)obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game); permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
} }

View file

@ -27,8 +27,7 @@
*/ */
package mage.sets.innistrad; package mage.sets.innistrad;
import mage.constants.CardType; import java.util.UUID;
import mage.constants.Rarity;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
@ -42,7 +41,9 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersAllEffect; import mage.abilities.effects.common.counter.AddCountersAllEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
@ -50,8 +51,6 @@ import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import java.util.UUID;
/** /**
* @author nantuko * @author nantuko
*/ */
@ -112,7 +111,8 @@ class MikaeusTheLunarchEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX(); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game); permanent.addCounters(CounterType.P1P1.createInstance(amount), game);

View file

@ -35,11 +35,9 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.RemoveCountersSourceCost; import mage.abilities.costs.common.RemoveCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.Effect;
import mage.abilities.effects.EntersBattlefieldEffect; import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.combat.CantAttackBlockTargetEffect; import mage.abilities.effects.common.combat.CantAttackBlockTargetEffect;
import mage.abilities.effects.common.combat.CantAttackTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
@ -83,6 +81,7 @@ public class BribersPurse extends CardImpl {
} }
class BribersPurseEffect extends OneShotEffect { class BribersPurseEffect extends OneShotEffect {
public BribersPurseEffect() { public BribersPurseEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
} }
@ -96,7 +95,8 @@ class BribersPurseEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX(); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
permanent.addCounters(new Counter("gem", amount), game); permanent.addCounters(new Counter("gem", amount), game);

View file

@ -112,7 +112,8 @@ class HoodedHydraEffect1 extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && !permanent.isFaceDown(game)) { if (permanent != null && !permanent.isFaceDown(game)) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX(); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game); permanent.addCounters(CounterType.P1P1.createInstance(amount), game);

View file

@ -25,9 +25,9 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.sets.magic2010; package mage.sets.magic2010;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility; import mage.abilities.DelayedTriggeredAbility;
@ -37,20 +37,22 @@ import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.EntersBattlefieldEffect; import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.PreventionEffectData;
import mage.abilities.effects.PreventionEffectImpl; import mage.abilities.effects.PreventionEffectImpl;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.*; import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import java.util.UUID;
import mage.abilities.effects.PreventionEffectData;
/** /**
* *
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
@ -65,7 +67,6 @@ public class ProteanHydra extends CardImpl {
this.power = new MageInt(0); this.power = new MageInt(0);
this.toughness = new MageInt(0); this.toughness = new MageInt(0);
// Protean Hydra enters the battlefield with X +1/+1 counters on it. // Protean Hydra enters the battlefield with X +1/+1 counters on it.
this.addAbility(new EntersBattlefieldAbility(new ProteanHydraEffect1(), "with X +1/+1 counters on it")); this.addAbility(new EntersBattlefieldAbility(new ProteanHydraEffect1(), "with X +1/+1 counters on it"));
@ -102,8 +103,9 @@ public class ProteanHydra extends CardImpl {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
int amount = ((SpellAbility)obj).getManaCostsToPay().getX(); && permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game); permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
} }

View file

@ -27,8 +27,7 @@
*/ */
package mage.sets.magic2012; package mage.sets.magic2012;
import java.util.UUID;
import mage.constants.*;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
@ -42,12 +41,15 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.GainAbilitySourceEffect; import mage.abilities.effects.common.continuous.GainAbilitySourceEffect;
import mage.abilities.keyword.TrampleAbility; import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import java.util.UUID;
/** /**
* *
* @author Loki * @author Loki
@ -83,6 +85,7 @@ public class PrimordialHydra extends CardImpl {
} }
class PrimordialHydraEntersEffect extends OneShotEffect { class PrimordialHydraEntersEffect extends OneShotEffect {
public PrimordialHydraEntersEffect() { public PrimordialHydraEntersEffect() {
super(Outcome.BoostCreature); super(Outcome.BoostCreature);
} }
@ -96,7 +99,8 @@ class PrimordialHydraEntersEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX(); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game); permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
@ -113,6 +117,7 @@ class PrimordialHydraEntersEffect extends OneShotEffect {
} }
class PrimordialHydraDoubleEffect extends OneShotEffect { class PrimordialHydraDoubleEffect extends OneShotEffect {
PrimordialHydraDoubleEffect() { PrimordialHydraDoubleEffect() {
super(Outcome.BoostCreature); super(Outcome.BoostCreature);
staticText = "double the number of +1/+1 counters on {this}"; staticText = "double the number of +1/+1 counters on {this}";

View file

@ -42,7 +42,6 @@ import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerPredicate; import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game; import mage.game.Game;
@ -57,6 +56,7 @@ import mage.target.common.TargetCreaturePermanentAmount;
public class VastwoodHydra extends CardImpl { public class VastwoodHydra extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures you control"); private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures you control");
static { static {
filter.add(new ControllerPredicate(TargetController.YOU)); filter.add(new ControllerPredicate(TargetController.YOU));
} }
@ -103,9 +103,8 @@ class VastwoodHydraEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
// delete to prevent using it again if put into battlefield from other effect && permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
setValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY, null);
int amount = ((SpellAbility) obj).getManaCostsToPay().getX(); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game); permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
@ -142,7 +141,7 @@ class VastwoodHydraDistributeEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
if (source.getTargets().size() > 0) { if (source.getTargets().size() > 0) {
Target multiTarget = source.getTargets().get(0); Target multiTarget = source.getTargets().get(0);
for (UUID target: multiTarget.getTargets()) { for (UUID target : multiTarget.getTargets()) {
Permanent permanent = game.getPermanent(target); Permanent permanent = game.getPermanent(target);
if (permanent != null) { if (permanent != null) {
permanent.addCounters(CounterType.P1P1.createInstance(multiTarget.getTargetAmount(target)), game); permanent.addCounters(CounterType.P1P1.createInstance(multiTarget.getTargetAmount(target)), game);

View file

@ -27,6 +27,7 @@
*/ */
package mage.sets.magic2015; package mage.sets.magic2015;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
@ -54,10 +55,6 @@ import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetCard; import mage.target.TargetCard;
import java.util.UUID;
/** /**
* *
* @author LevelX2 * @author LevelX2
@ -73,7 +70,6 @@ public class GenesisHydra extends CardImpl {
this.power = new MageInt(0); this.power = new MageInt(0);
this.toughness = new MageInt(0); this.toughness = new MageInt(0);
// When you cast Genesis Hydra, reveal the top X cards of your library. You may put a nonland permanent card with converted mana cost X or less from among them onto the battlefield. Then shuffle the rest into your library. // When you cast Genesis Hydra, reveal the top X cards of your library. You may put a nonland permanent card with converted mana cost X or less from among them onto the battlefield. Then shuffle the rest into your library.
this.addAbility(new CastSourceTriggeredAbility(new GenesisHydraPutOntoBattlefieldEffect(), false)); this.addAbility(new CastSourceTriggeredAbility(new GenesisHydraPutOntoBattlefieldEffect(), false));
// Genesis Hydra enters the battlefield with X +1/+1 counters on it. // Genesis Hydra enters the battlefield with X +1/+1 counters on it.
@ -106,9 +102,8 @@ class GenesisHydraEntersBattlefieldEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
// delete to prevent using it again if put into battlefield from other effect && permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
setValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY, null);
SpellAbility spellAbility = (SpellAbility) obj; SpellAbility spellAbility = (SpellAbility) obj;
if (spellAbility.getSourceId().equals(source.getSourceId())) { // put into play by normal cast if (spellAbility.getSourceId().equals(source.getSourceId())) { // put into play by normal cast
int amount = spellAbility.getManaCostsToPay().getX(); int amount = spellAbility.getManaCostsToPay().getX();

View file

@ -102,7 +102,8 @@ class HangarbackWalkerEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX(); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game); permanent.addCounters(CounterType.P1P1.createInstance(amount), game);

View file

@ -74,8 +74,8 @@ public class ChaliceOfTheVoid extends CardImpl {
} }
} }
class ChaliceOfTheVoidEffect extends OneShotEffect { class ChaliceOfTheVoidEffect extends OneShotEffect {
public ChaliceOfTheVoidEffect() { public ChaliceOfTheVoidEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
} }
@ -89,9 +89,8 @@ class ChaliceOfTheVoidEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
// delete to prevent using it again if put into battlefield from other effect && permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
setValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY, null);
int amount = ((SpellAbility) obj).getManaCostsToPay().getX(); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
permanent.addCounters(CounterType.CHARGE.createInstance(amount), game); permanent.addCounters(CounterType.CHARGE.createInstance(amount), game);
@ -109,12 +108,10 @@ class ChaliceOfTheVoidEffect extends OneShotEffect {
class ChaliceOfTheVoidTriggeredAbility extends TriggeredAbilityImpl { class ChaliceOfTheVoidTriggeredAbility extends TriggeredAbilityImpl {
public ChaliceOfTheVoidTriggeredAbility() { public ChaliceOfTheVoidTriggeredAbility() {
super(Zone.BATTLEFIELD, new CounterEffect()); super(Zone.BATTLEFIELD, new CounterEffect());
} }
public ChaliceOfTheVoidTriggeredAbility(final ChaliceOfTheVoidTriggeredAbility abiltity) { public ChaliceOfTheVoidTriggeredAbility(final ChaliceOfTheVoidTriggeredAbility abiltity) {
super(abiltity); super(abiltity);
} }
@ -133,7 +130,7 @@ class ChaliceOfTheVoidTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
Permanent chalice = game.getPermanent(getSourceId()); Permanent chalice = game.getPermanent(getSourceId());
Spell spell = game.getStack().getSpell(event.getTargetId()); Spell spell = game.getStack().getSpell(event.getTargetId());
if(spell != null && chalice != null && spell.getConvertedManaCost() == chalice.getCounters().getCount(CounterType.CHARGE)){ if (spell != null && chalice != null && spell.getConvertedManaCost() == chalice.getCounters().getCount(CounterType.CHARGE)) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId())); effect.setTargetPointer(new FixedTarget(event.getTargetId()));
} }
@ -148,7 +145,6 @@ class ChaliceOfTheVoidTriggeredAbility extends TriggeredAbilityImpl {
} }
} }
class CounterEffect extends OneShotEffect { class CounterEffect extends OneShotEffect {
public CounterEffect() { public CounterEffect() {

View file

@ -137,7 +137,8 @@ public class WorldheartPhoenix extends CardImpl {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
// TODO: No perfect solution because there could be other effects that allow to cast the card for this mana cost // TODO: No perfect solution because there could be other effects that allow to cast the card for this mana cost
if (((SpellAbility) obj).getManaCosts().getText().equals("{W}{U}{B}{R}{G}")) { if (((SpellAbility) obj).getManaCosts().getText().equals("{W}{U}{B}{R}{G}")) {
permanent.addCounters(CounterType.P1P1.createInstance(2), game); permanent.addCounters(CounterType.P1P1.createInstance(2), game);

View file

@ -32,10 +32,8 @@ import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
import mage.abilities.effects.EntersBattlefieldEffect; import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
@ -59,7 +57,7 @@ public class IvyElemental extends CardImpl {
this.toughness = new MageInt(0); this.toughness = new MageInt(0);
// Ivy Elemental enters the battlefield with X +1/+1 counters on it. // Ivy Elemental enters the battlefield with X +1/+1 counters on it.
this.addAbility(new EntersBattlefieldAbility(new IvyElementalEntersBattlefieldEffect() ,"with X +1/+1 counters on it")); this.addAbility(new EntersBattlefieldAbility(new IvyElementalEntersBattlefieldEffect(), "with X +1/+1 counters on it"));
} }
public IvyElemental(final IvyElemental card) { public IvyElemental(final IvyElemental card) {
@ -88,9 +86,8 @@ class IvyElementalEntersBattlefieldEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
// delete to prevent using it again if put into battlefield from other effect && permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
setValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY, null);
SpellAbility spellAbility = (SpellAbility) obj; SpellAbility spellAbility = (SpellAbility) obj;
if (spellAbility.getSourceId().equals(source.getSourceId())) { // put into play by normal cast if (spellAbility.getSourceId().equals(source.getSourceId())) { // put into play by normal cast
int amount = spellAbility.getManaCostsToPay().getX(); int amount = spellAbility.getManaCostsToPay().getX();

View file

@ -38,7 +38,6 @@ import mage.abilities.costs.Costs;
import mage.abilities.costs.CostsImpl; import mage.abilities.costs.CostsImpl;
import mage.abilities.costs.common.DiscardCardCost; import mage.abilities.costs.common.DiscardCardCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.EntersBattlefieldEffect; import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.GainAbilitySourceEffect; import mage.abilities.effects.common.continuous.GainAbilitySourceEffect;
@ -114,7 +113,8 @@ class DralnusPetEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (controller != null && permanent != null) { if (controller != null && permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int cmc = 0; int cmc = 0;
for (Cost cost : ((SpellAbility) obj).getCosts()) { for (Cost cost : ((SpellAbility) obj).getCosts()) {
if (cost instanceof DiscardCardCost && ((DiscardCardCost) cost).getCards().size() > 0) { if (cost instanceof DiscardCardCost && ((DiscardCardCost) cost).getCards().size() > 0) {

View file

@ -25,15 +25,9 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.sets.returntoravnica; package mage.sets.returntoravnica;
import java.util.UUID; 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.Ability;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
import mage.abilities.TriggeredAbility; import mage.abilities.TriggeredAbility;
@ -48,7 +42,11 @@ import mage.abilities.effects.common.AddManaOfAnyColorEffect;
import mage.abilities.effects.common.ReturnToHandSourceEffect; import mage.abilities.effects.common.ReturnToHandSourceEffect;
import mage.abilities.mana.ActivateOncePerTurnManaAbility; import mage.abilities.mana.ActivateOncePerTurnManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -61,13 +59,12 @@ public class ManaBloom extends CardImpl {
static final String rule = "with X charge counters on it"; static final String rule = "with X charge counters on it";
public ManaBloom (UUID ownerId) { public ManaBloom(UUID ownerId) {
super(ownerId, 130, "Mana Bloom", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{X}{G}"); super(ownerId, 130, "Mana Bloom", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{X}{G}");
this.expansionSetCode = "RTR"; this.expansionSetCode = "RTR";
// Mana Bloom enters the battlefield with X charge counters on it. // Mana Bloom enters the battlefield with X charge counters on it.
this.addAbility(new EntersBattlefieldAbility(new ManaBloomEffect(),rule)); this.addAbility(new EntersBattlefieldAbility(new ManaBloomEffect(), rule));
// Remove a charge counter from Mana Bloom: Add one mana of any color to your mana pool. Activate this ability only once each turn. // Remove a charge counter from Mana Bloom: Add one mana of any color to your mana pool. Activate this ability only once each turn.
Ability ability = new ActivateOncePerTurnManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(), new RemoveCountersSourceCost(CounterType.CHARGE.createInstance())); Ability ability = new ActivateOncePerTurnManaAbility(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(), new RemoveCountersSourceCost(CounterType.CHARGE.createInstance()));
@ -75,11 +72,11 @@ public class ManaBloom extends CardImpl {
// At the beginning of your upkeep, if Mana Bloom has no charge counters on it, return it to its owner's hand. // At the beginning of your upkeep, if Mana Bloom has no charge counters on it, return it to its owner's hand.
TriggeredAbility triggeredAbility = new BeginningOfUpkeepTriggeredAbility(new ReturnToHandSourceEffect(true), TargetController.YOU, false); TriggeredAbility triggeredAbility = new BeginningOfUpkeepTriggeredAbility(new ReturnToHandSourceEffect(true), TargetController.YOU, false);
this.addAbility(new ConditionalTriggeredAbility(triggeredAbility, new SourceHasCounterCondition(CounterType.CHARGE, 0,0), "At the beginning of your upkeep, if Mana Bloom has no charge counters on it, return it to its owner's hand.")); this.addAbility(new ConditionalTriggeredAbility(triggeredAbility, new SourceHasCounterCondition(CounterType.CHARGE, 0, 0), "At the beginning of your upkeep, if Mana Bloom has no charge counters on it, return it to its owner's hand."));
} }
public ManaBloom (final ManaBloom card) { public ManaBloom(final ManaBloom card) {
super(card); super(card);
} }
@ -90,6 +87,7 @@ public class ManaBloom extends CardImpl {
} }
class ManaBloomEffect extends OneShotEffect { class ManaBloomEffect extends OneShotEffect {
public ManaBloomEffect() { public ManaBloomEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
} }
@ -103,7 +101,8 @@ class ManaBloomEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
// delete to prevent using it again if put into battlefield from other effect // delete to prevent using it again if put into battlefield from other effect
setValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY, null); setValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY, null);
int amount = ((SpellAbility) obj).getManaCostsToPay().getX(); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();

View file

@ -98,7 +98,8 @@ class MagaTraitorToMortalsEnterBattlefieldEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX(); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game); permanent.addCounters(CounterType.P1P1.createInstance(amount), game);

View file

@ -27,11 +27,7 @@
*/ */
package mage.sets.scarsofmirrodin; package mage.sets.scarsofmirrodin;
import mage.constants.CardType; import java.util.UUID;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
@ -45,13 +41,16 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BecomesCreatureSourceEffect; import mage.abilities.effects.common.continuous.BecomesCreatureSourceEffect;
import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect; import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.game.permanent.token.Token; import mage.game.permanent.token.Token;
import java.util.UUID;
/** /**
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
@ -80,6 +79,7 @@ public class ChimericMass extends CardImpl {
} }
class ChimericMassEffect extends OneShotEffect { class ChimericMassEffect extends OneShotEffect {
public ChimericMassEffect() { public ChimericMassEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
} }
@ -93,9 +93,8 @@ class ChimericMassEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
// delete to prevent using it again if put into battlefield from other effect && permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
setValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY, null);
int amount = ((SpellAbility) obj).getManaCostsToPay().getX(); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
permanent.addCounters(CounterType.CHARGE.createInstance(amount), game); permanent.addCounters(CounterType.CHARGE.createInstance(amount), game);

View file

@ -28,7 +28,6 @@
package mage.sets.shardsofalara; package mage.sets.shardsofalara;
import java.util.UUID; import java.util.UUID;
import static javax.xml.bind.JAXBIntrospector.getValue;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
@ -66,7 +65,7 @@ public class FeralHydra extends CardImpl {
// Feral Hydra enters the battlefield with X +1/+1 counters on it. // Feral Hydra enters the battlefield with X +1/+1 counters on it.
this.addAbility(new EntersBattlefieldAbility(new FeralHydraEffect(), true)); this.addAbility(new EntersBattlefieldAbility(new FeralHydraEffect(), true));
// {3}: Put a +1/+1 counter on Feral Hydra. Any player may activate this ability. // {3}: Put a +1/+1 counter on Feral Hydra. Any player may activate this ability.
SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.P1P1.createInstance()) , new ManaCostsImpl("{3}")); SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.P1P1.createInstance()), new ManaCostsImpl("{3}"));
ability.setMayActivate(TargetController.ANY); ability.setMayActivate(TargetController.ANY);
ability.addEffect(new InfoEffect("Any player may activate this ability")); ability.addEffect(new InfoEffect("Any player may activate this ability"));
this.addAbility(ability); this.addAbility(ability);
@ -82,7 +81,6 @@ public class FeralHydra extends CardImpl {
} }
} }
class FeralHydraEffect extends OneShotEffect { class FeralHydraEffect extends OneShotEffect {
public FeralHydraEffect() { public FeralHydraEffect() {
@ -99,10 +97,9 @@ class FeralHydraEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
// delete to prevent using it again if put into battlefield from other effect && permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
setValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY, null); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
int amount = ((SpellAbility)obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game); permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
} }

View file

@ -25,14 +25,9 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.sets.shardsofalara; package mage.sets.shardsofalara;
import java.util.UUID; 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.Ability;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.common.EntersBattlefieldAbility;
@ -44,11 +39,14 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BoostEquippedEffect; import mage.abilities.effects.common.continuous.BoostEquippedEffect;
import mage.abilities.keyword.EquipAbility; import mage.abilities.keyword.EquipAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
/** /**
* @author Loki * @author Loki
*/ */
@ -82,6 +80,7 @@ public class SigilOfDistinction extends CardImpl {
} }
class SigilOfDistinctionEffect extends OneShotEffect { class SigilOfDistinctionEffect extends OneShotEffect {
public SigilOfDistinctionEffect() { public SigilOfDistinctionEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
} }
@ -95,9 +94,8 @@ class SigilOfDistinctionEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
// delete to prevent using it again if put into battlefield from other effect && permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
setValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY, null);
int amount = ((SpellAbility) obj).getManaCostsToPay().getX(); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
permanent.addCounters(CounterType.CHARGE.createInstance(amount), game); permanent.addCounters(CounterType.CHARGE.createInstance(amount), game);

View file

@ -91,10 +91,9 @@ class KrakilinEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
// delete to prevent using it again if put into battlefield from other effect && permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
setValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY, null); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
int amount = ((SpellAbility)obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game); permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
} }

View file

@ -54,6 +54,7 @@ import mage.game.permanent.Permanent;
public class MistcutterHydra extends CardImpl { public class MistcutterHydra extends CardImpl {
private static final FilterObject filter = new FilterObject("from blue"); private static final FilterObject filter = new FilterObject("from blue");
static { static {
filter.add(new ColorPredicate(ObjectColor.BLUE)); filter.add(new ColorPredicate(ObjectColor.BLUE));
} }
@ -102,10 +103,9 @@ class MistcutterHydraEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
Object obj = getValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
// delete to prevent using it again if put into battlefield from other effect && permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
setValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY, null); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
int amount = ((SpellAbility)obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game); permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
} }

View file

@ -97,7 +97,8 @@ class PhyrexianMarauderEntersEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && !permanent.isFaceDown(game)) { if (permanent != null && !permanent.isFaceDown(game)) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((Ability) obj).getManaCostsToPay().getX(); int amount = ((Ability) obj).getManaCostsToPay().getX();
if (amount > 0) { if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game); permanent.addCounters(CounterType.P1P1.createInstance(amount), game);

View file

@ -8,13 +8,15 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
/** /**
* @author noxx * @author noxx
* *
* Card: When Oblivion Ring enters the battlefield, exile another target nonland permanent. * Card: When Oblivion Ring enters the battlefield, exile another target nonland
* When Oblivion Ring leaves the battlefield, return the exiled card to the battlefield under its owner's control. * permanent. When Oblivion Ring leaves the battlefield, return the exiled card
* to the battlefield under its owner's control.
*/ */
public class OblivionRingTest extends CardTestPlayerBase { public class OblivionRingTest extends CardTestPlayerBase {
/** /**
* When Oblivion Ring enters the battlefield, exile another target nonland permanent. * When Oblivion Ring enters the battlefield, exile another target nonland
* permanent.
*/ */
@Test @Test
public void testFirstTriggeredAbility() { public void testFirstTriggeredAbility() {
@ -24,7 +26,7 @@ public class OblivionRingTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Oblivion Ring"); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Oblivion Ring");
setStopAt(2, PhaseStep.END_TURN); setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute(); execute();
assertLife(playerA, 20); assertLife(playerA, 20);
@ -34,7 +36,8 @@ public class OblivionRingTest extends CardTestPlayerBase {
} }
/** /**
* When Oblivion Ring leaves the battlefield, return the exiled card to the battlefield under its owner's control. * When Oblivion Ring leaves the battlefield, return the exiled card to the
* battlefield under its owner's control.
*/ */
@Test @Test
public void testSecondTriggeredAbility() { public void testSecondTriggeredAbility() {
@ -79,7 +82,8 @@ public class OblivionRingTest extends CardTestPlayerBase {
} }
/** /**
* Tests that when Oblivion Ring gets destroyed planeswalker returns with new counters and can be used second time at the same turn * Tests that when Oblivion Ring gets destroyed planeswalker returns with
* new counters and can be used second time at the same turn
*/ */
@Test @Test
public void testExilePlaneswalker() { public void testExilePlaneswalker() {
@ -100,4 +104,36 @@ public class OblivionRingTest extends CardTestPlayerBase {
assertPermanentCount(playerA, "Jace Beleren", 1); // returns back assertPermanentCount(playerA, "Jace Beleren", 1); // returns back
assertHandCount(playerA, 2); // can use ability twice assertHandCount(playerA, 2); // can use ability twice
} }
/**
* Oblivion Ring leaves from battlefield Effect brings Hangarback Walker
* back with counters. But with rules it should come back with no counters
*/
@Test
public void testReturningHangarbackWalker() {
addCard(Zone.BATTLEFIELD, playerA, "Forest", 4);
// Hangarback Walker enters the battlefield with X +1/+1 counters on it.
// When Hangarback Walker dies, put a 1/1 colorless Thopter artifact creature token with flying onto the battlefield for each +1/+1 counter on Hangarback Walker.
// {1}, {t}: Put a +1/+1 counter on Hangarback Walker.
addCard(Zone.HAND, playerA, "Hangarback Walker"); // {X}{X}
addCard(Zone.HAND, playerA, "Naturalize");
addCard(Zone.BATTLEFIELD, playerB, "Plains", 3);
addCard(Zone.HAND, playerB, "Oblivion Ring");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Hangarback Walker");
setChoice(playerA, "X=2");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Oblivion Ring");
castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Naturalize", "Oblivion Ring");
setStopAt(3, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerB, "Oblivion Ring", 0);
assertGraveyardCount(playerB, "Oblivion Ring", 1);
assertPermanentCount(playerA, "Hangarback Walker", 0);
assertGraveyardCount(playerA, "Hangarback Walker", 1);
}
} }