Merge origin/master

This commit is contained in:
fireshoes 2015-09-01 21:02:47 -05:00
commit aa0021b43c
42 changed files with 544 additions and 309 deletions

View file

@ -90,10 +90,11 @@ class AstralCornucopiaEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.CHARGE.createInstance(amount), game);
}

View file

@ -91,10 +91,11 @@ class OrochiHatcheryEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {;
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.CHARGE.createInstance(amount), game);
}

View file

@ -29,23 +29,20 @@ package mage.sets.commander2013;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.GainLifeControllerTriggeredAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DamagePlayersEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DoIfCostPaid;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.LoseLifeOpponentsEffect;
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.game.Game;
/**
*
@ -65,11 +62,17 @@ public class OloroAgelessAscetic extends CardImpl {
// At the beginning of your upkeep, you gain 2 life.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new GainLifeEffect(2), TargetController.YOU, false));
// Whenever you gain life, you may pay {1}. If you do, draw a card and each opponent loses 1 life.
this.addAbility(new GainLifeControllerTriggeredAbility(new DoIfCostPaid(new OloroAgelessAsceticEffect(), new GenericManaCost(1)),false));
DoIfCostPaid effect = new DoIfCostPaid(new DrawCardSourceControllerEffect(1), new GenericManaCost(1));
Effect effectToAdd = new LoseLifeOpponentsEffect(1);
effectToAdd.setText("and each opponent loses 1 life");
effect.addEffect(effectToAdd);
this.addAbility(new GainLifeControllerTriggeredAbility(effect, false));
// At the beginning of your upkeep, if Oloro, Ageless Ascetic is in the command zone, you gain 2 life.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.COMMAND,
new GainLifeEffect(new StaticValue(2), "if Oloro, Ageless Ascetic is in the command zone, you gain 2 life"),TargetController.YOU, false));
new GainLifeEffect(new StaticValue(2), "if {this} is in the command zone, you gain 2 life"), TargetController.YOU, false));
}
public OloroAgelessAscetic(final OloroAgelessAscetic card) {
@ -81,27 +84,3 @@ public class OloroAgelessAscetic extends CardImpl {
return new OloroAgelessAscetic(this);
}
}
class OloroAgelessAsceticEffect extends OneShotEffect {
public OloroAgelessAsceticEffect() {
super(Outcome.Benefit);
this.staticText = "draw a card and each opponent loses 1 life";
}
public OloroAgelessAsceticEffect(final OloroAgelessAsceticEffect effect) {
super(effect);
}
@Override
public OloroAgelessAsceticEffect copy() {
return new OloroAgelessAsceticEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
new DrawCardSourceControllerEffect(1).apply(game, source);
new DamagePlayersEffect(1, TargetController.OPPONENT).apply(game, source);
return false;
}
}

View file

@ -94,10 +94,11 @@ class LifebloodHydraComesIntoPlayEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && !permanent.isFaceDown(game)) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
}

View file

@ -96,10 +96,11 @@ class ApocalypseHydraEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
if (amount < 5) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game);

View file

@ -100,9 +100,10 @@ class AcademyEliteEffect1 extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
CardsInAllGraveyardsCount instantsAndSorceries = new CardsInAllGraveyardsCount(new FilterInstantOrSorceryCard("instant or sorcery cards"));
int instantsAndSorceriesCount = instantsAndSorceries.calculate(game, source, this);
if (instantsAndSorceriesCount > 0) {

View file

@ -34,6 +34,7 @@ import mage.abilities.SpellAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
@ -94,10 +95,11 @@ class GrenzoDungeonWardenEtBEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((Ability) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
}

View file

@ -34,6 +34,7 @@ import mage.abilities.SpellAbility;
import mage.abilities.common.ActivateAsSorceryActivatedAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.keyword.DoubleStrikeAbility;
@ -95,12 +96,11 @@ class SavageBornHydraEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
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
setValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY, null);
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
}

View file

@ -28,11 +28,6 @@
package mage.sets.eventide;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
@ -42,6 +37,10 @@ import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.LifelinkAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
@ -57,15 +56,19 @@ public class DivinityOfPride extends CardImpl {
this.subtype.add("Spirit");
this.subtype.add("Avatar");
this.power = new MageInt(4);
this.toughness = new MageInt(4);
// Flying
this.addAbility(FlyingAbility.getInstance());
// Lifelink
this.addAbility(LifelinkAbility.getInstance());
// Divinity of Pride gets +4/+4 as long as you have 25 or more life.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
new ConditionalContinuousEffect(new BoostSourceEffect(4, 4, Duration.WhileOnBattlefield),
new DivinityOfPrideCondition(),
"Divinity of Pride gets +4/+4 as long as you have 25 or more life")));
new DivinityOfPrideCondition(),
"{this} gets +4/+4 as long as you have 25 or more life")));
}
public DivinityOfPride(final DivinityOfPride card) {
@ -85,4 +88,4 @@ class DivinityOfPrideCondition implements Condition {
Player player = game.getPlayer(source.getControllerId());
return player != null && player.getLife() >= 25;
}
}
}

View file

@ -87,10 +87,11 @@ class NimbusSwimmerEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
}

View file

@ -110,10 +110,11 @@ class MikaeusTheLunarchEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
}

View file

@ -94,10 +94,11 @@ class BribersPurseEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(new Counter("gem", amount), game);
}

View file

@ -111,10 +111,11 @@ class HoodedHydraEffect1 extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && !permanent.isFaceDown(game)) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
}

View file

@ -102,10 +102,11 @@ public class ProteanHydra extends CardImpl {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
}

View file

@ -98,10 +98,11 @@ class PrimordialHydraEntersEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
}

View file

@ -102,10 +102,11 @@ class VastwoodHydraEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
}

View file

@ -101,10 +101,10 @@ class GenesisHydraEntersBattlefieldEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
SpellAbility spellAbility = (SpellAbility) obj;
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
if (spellAbility.getSourceId().equals(source.getSourceId())) { // put into play by normal cast
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {

View file

@ -101,10 +101,11 @@ class HangarbackWalkerEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
}

View file

@ -88,10 +88,11 @@ class ChaliceOfTheVoidEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.CHARGE.createInstance(amount), game);
}

View file

@ -25,17 +25,19 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.mirrodinbesieged;
import mage.constants.CardType;
import mage.constants.Rarity;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CopyEffect;
import mage.cards.CardImpl;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game;
@ -43,12 +45,11 @@ import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import mage.util.functions.ApplyToPermanent;
import java.util.UUID;
/**
* @author Loki
*/
public class Cryptoplasm extends CardImpl {
final static FilterCreaturePermanent filter = new FilterCreaturePermanent();
static {
@ -64,7 +65,7 @@ public class Cryptoplasm extends CardImpl {
this.toughness = new MageInt(2);
// At the beginning of your upkeep, you may have Cryptoplasm become a copy of another target creature. If you do, Cryptoplasm gains this ability.
Ability ability = new BeginningOfUpkeepTriggeredAbility(new CryptoplasmTransformEffect(), TargetController.YOU, true);
Ability ability = new BeginningOfUpkeepTriggeredAbility(new CryptoplasmEffect(), TargetController.YOU, true);
ability.addTarget(new TargetCreaturePermanent(filter));
this.addAbility(ability);
}
@ -80,43 +81,39 @@ public class Cryptoplasm extends CardImpl {
}
class CryptoplasmTransformEffect extends ContinuousEffectImpl {
class CryptoplasmEffect extends OneShotEffect {
CryptoplasmTransformEffect() {
super(Duration.WhileOnBattlefield, Layer.CopyEffects_1, SubLayer.NA, Outcome.Copy);
staticText = "you may have {this} become a copy of another target creature. If you do, {this} gains this ability";
public CryptoplasmEffect() {
super(Outcome.Copy);
this.staticText = "you may have {this} become a copy of another target creature. If you do, {this} gains this ability";
}
CryptoplasmTransformEffect(final CryptoplasmTransformEffect effect) {
public CryptoplasmEffect(final CryptoplasmEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, final Ability source) {
Permanent creature = game.getPermanent(targetPointer.getFirst(game, source));
Permanent permanent = game.getPermanent(source.getSourceId());
if (creature == null || permanent == null) {
return false;
}
game.copyPermanent(creature, permanent, source, new ApplyToPermanent() {
@Override
public Boolean apply(Game game, Permanent permanent) {
Ability upkeepAbility = new BeginningOfUpkeepTriggeredAbility(new CryptoplasmTransformEffect(), TargetController.YOU, true);
upkeepAbility.addTarget(new TargetCreaturePermanent());
permanent.addAbility(upkeepAbility, source.getSourceId(), game);
return true;
}
});
return true;
public CryptoplasmEffect copy() {
return new CryptoplasmEffect(this);
}
@Override
public CryptoplasmTransformEffect copy() {
return new CryptoplasmTransformEffect(this);
}
public boolean apply(Game game, final Ability source) {
Permanent creatureToCopy = game.getPermanent(getTargetPointer().getFirst(game, source));
if (creatureToCopy != null) {
CopyEffect effect = new CopyEffect(creatureToCopy, source.getSourceId());
effect.setApplier(new ApplyToPermanent() {
@Override
public Boolean apply(Game game, Permanent permanent) {
Ability upkeepAbility = new BeginningOfUpkeepTriggeredAbility(new CryptoplasmEffect(), TargetController.YOU, true);
upkeepAbility.addTarget(new TargetCreaturePermanent());
permanent.addAbility(upkeepAbility, source.getSourceId(), game);
return true;
}
});
game.addEffect(effect, source);
}
return true;
}
}

View file

@ -136,11 +136,12 @@ public class WorldheartPhoenix extends CardImpl {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
// 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.getManaCosts().getText().equals("{W}{U}{B}{R}{G}")) {
permanent.addCounters(CounterType.P1P1.createInstance(2), game);
}
}

View file

@ -85,10 +85,10 @@ class IvyElementalEntersBattlefieldEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
SpellAbility spellAbility = (SpellAbility) obj;
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
if (spellAbility.getSourceId().equals(source.getSourceId())) { // put into play by normal cast
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {

View file

@ -112,11 +112,12 @@ class DralnusPetEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (controller != null && permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int cmc = 0;
for (Cost cost : ((SpellAbility) obj).getCosts()) {
for (Cost cost : spellAbility.getCosts()) {
if (cost instanceof DiscardCardCost && ((DiscardCardCost) cost).getCards().size() > 0) {
cmc = ((DiscardCardCost) cost).getCards().get(0).getManaCost().convertedManaCost();
}

View file

@ -30,8 +30,10 @@ package mage.sets.ravnica;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.OnEventTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.PutTokenOntoBattlefieldCopyTargetEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -40,15 +42,14 @@ import mage.constants.Rarity;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.EmptyToken;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
import mage.util.CardUtil;
import mage.target.targetpointer.FixedTarget;
/**
*
* @author LoneFox
*
*/
public class FollowedFootsteps extends CardImpl {
@ -99,10 +100,9 @@ class FollowedFootstepsEffect extends OneShotEffect {
Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
Permanent target = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo());
if (target != null) {
EmptyToken token = new EmptyToken();
CardUtil.copyTo(token).from(target);
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
return true;
Effect effect = new PutTokenOntoBattlefieldCopyTargetEffect();
effect.setTargetPointer(new FixedTarget(enchantment.getAttachedTo()));
return effect.apply(game, source);
}
return false;
}

View file

@ -100,12 +100,13 @@ class ManaBloomEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
// delete to prevent using it again if put into battlefield from other effect
setValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY, null);
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.CHARGE.createInstance(amount), game);
return true;

View file

@ -97,10 +97,11 @@ class MagaTraitorToMortalsEnterBattlefieldEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
}

View file

@ -92,10 +92,11 @@ class ChimericMassEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.CHARGE.createInstance(amount), game);
}

View file

@ -34,6 +34,7 @@ import mage.abilities.SpellAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.InfoEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
@ -96,10 +97,11 @@ class FeralHydraEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
}

View file

@ -93,10 +93,11 @@ class SigilOfDistinctionEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.CHARGE.createInstance(amount), game);
return true;

View file

@ -34,6 +34,7 @@ import mage.abilities.SpellAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.RegenerateSourceEffect;
import mage.cards.CardImpl;
@ -90,10 +91,11 @@ class KrakilinEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
}

View file

@ -34,6 +34,7 @@ import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.common.CantBeCounteredAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.HasteAbility;
import mage.abilities.keyword.ProtectionAbility;
@ -102,10 +103,11 @@ class MistcutterHydraEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
Object obj = getValue(mage.abilities.effects.EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
}

View file

@ -96,10 +96,11 @@ class PhyrexianMarauderEntersEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && !permanent.isFaceDown(game)) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility
&& permanent.getZoneChangeCounter(game) - 1 == ((SpellAbility) obj).getSourceObjectZoneChangeCounter()) {
int amount = ((Ability) obj).getManaCostsToPay().getX();
SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (spellAbility != null
&& spellAbility.getSourceId().equals(source.getSourceId())
&& permanent.getZoneChangeCounter(game) - 1 == spellAbility.getSourceObjectZoneChangeCounter()) {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), game);
}