diff --git a/Mage.Sets/src/mage/sets/fifthedition/PrimalClay.java b/Mage.Sets/src/mage/sets/fifthedition/PrimalClay.java index 20ffbe9ad6..86e783c8e3 100644 --- a/Mage.Sets/src/mage/sets/fifthedition/PrimalClay.java +++ b/Mage.Sets/src/mage/sets/fifthedition/PrimalClay.java @@ -27,21 +27,30 @@ */ package mage.sets.fifthedition; -import java.util.Set; import java.util.UUID; - -import mage.constants.*; import mage.MageInt; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ContinuousEffectImpl; -import mage.abilities.effects.EntersBattlefieldEffect; +import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.keyword.DefenderAbility; import mage.abilities.keyword.FlyingAbility; +import mage.cards.Card; import mage.cards.CardImpl; +import mage.choices.Choice; import mage.choices.ChoiceImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; +import mage.game.permanent.PermanentCard; +import mage.game.permanent.PermanentToken; +import mage.game.permanent.token.Token; import mage.players.Player; /** @@ -59,7 +68,7 @@ public class PrimalClay extends CardImpl { this.toughness = new MageInt(0); // As Primal Clay enters the battlefield, it becomes your choice of a 3/3 artifact creature, a 2/2 artifact creature with flying, or a 1/6 Wall artifact creature with defender in addition to its other types. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new EntersBattlefieldEffect(new PrimalClayEffect(), "As {this} enters the battlefield, it becomes your choice of a 3/3 artifact creature, a 2/2 artifact creature with flying, or a 1/6 Wall artifact creature with defender in addition to its other types"))); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PrimalPlasmaReplacementEffect())); } public PrimalClay(final PrimalClay card) { @@ -72,87 +81,35 @@ public class PrimalClay extends CardImpl { } } -class PrimalClayEffect extends ContinuousEffectImpl { +class PrimalPlasmaReplacementEffect extends ReplacementEffectImpl { - private final static String choice1 = "a 3/3 artifact creature"; - private final static String choice2 = "a 2/2 artifact creature with flying"; - private final static String choice3 = "a 1/6 Wall artifact creature with defender"; + private final String choice33 = "a 3/3 creature"; + private final String choice22 = "a 2/2 creature with flying"; + private final String choice16 = "a 1/6 creature with defender"; - String choice; - - PrimalClayEffect() { - super(Duration.WhileOnBattlefield, Outcome.BecomeCreature); + public PrimalPlasmaReplacementEffect() { + super(Duration.WhileOnBattlefield, Outcome.Benefit); + staticText = "As {this} enters the battlefield, it becomes your choice of a 3/3 artifact creature, a 2/2 artifact creature with flying, or a 1/6 Wall artifact creature with defender in addition to its other types"; } - PrimalClayEffect(final PrimalClayEffect effect) { + public PrimalPlasmaReplacementEffect(PrimalPlasmaReplacementEffect effect) { super(effect); - this.choice = effect.choice; } @Override - public void init(Ability source, Game game) { - super.init(source, game); - Player controller = game.getPlayer(source.getControllerId()); - Permanent permanent = game.getPermanent(source.getSourceId()); - if (controller != null && permanent != null) { - ChoiceImpl primalClayChoice = new ChoiceImpl(); - Set choices = primalClayChoice.getChoices(); - choices.add(choice1); - choices.add(choice2); - choices.add(choice3); - primalClayChoice.setMessage("Choose for " + permanent.getLogName() + " to be"); - while (!primalClayChoice.isChosen()) { - if (!controller.isInGame()) { - discard(); - return; - } - controller.choose(outcome, primalClayChoice, game); + public boolean checksEventType(GameEvent event, Game game) { + return event.getType().equals(EventType.ENTERS_THE_BATTLEFIELD); + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (event.getTargetId().equals(source.getSourceId())) { + Permanent sourcePermanent = game.getPermanent(source.getSourceId()); + if (sourcePermanent != null && !sourcePermanent.isFaceDown()) { + return true; } - this.choice = primalClayChoice.getChoice(); - return; } - discard(); - } - - - @Override - public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { - Permanent permanent = game.getPermanent(source.getSourceId()); - if (permanent == null) { - discard(); - return false; - } - switch (layer) { - case PTChangingEffects_7: - if (sublayer.equals(SubLayer.SetPT_7b)) { - switch (choice) { - case choice1: - permanent.getPower().setValue(3); - permanent.getToughness().setValue(3); - break; - case choice2: - permanent.getPower().setValue(2); - permanent.getToughness().setValue(2); - break; - case choice3: - permanent.getPower().setValue(1); - permanent.getToughness().setValue(6); - break; - } - } - break; - case AbilityAddingRemovingEffects_6: - switch (choice) { - case choice2: - permanent.addAbility(FlyingAbility.getInstance(), source.getSourceId(), game); - break; - case choice3: - permanent.addAbility(DefenderAbility.getInstance(), source.getSourceId(), game); - break; - } - break; - } - return true; + return false; } @Override @@ -161,12 +118,61 @@ class PrimalClayEffect extends ContinuousEffectImpl { } @Override - public boolean hasLayer(Layer layer) { - return layer == Layer.PTChangingEffects_7 || layer == Layer.AbilityAddingRemovingEffects_6 || layer == Layer.TypeChangingEffects_4; + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + Permanent permanent = game.getPermanent(source.getSourceId()); + if (permanent != null) { + Choice choice = new ChoiceImpl(true); + choice.setMessage("Choose what the creature becomes to"); + choice.getChoices().add(choice33); + choice.getChoices().add(choice22); + choice.getChoices().add(choice16); + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + while(!choice.isChosen()) { + controller.choose(Outcome.Neutral, choice, game); + if (!controller.isInGame()) { + return false; + } + } + } + MageObject mageObject; + if (permanent instanceof PermanentCard) { + mageObject = ((PermanentCard) permanent).getCard(); + } else { + mageObject = ((PermanentToken) permanent).getToken(); + } + switch (choice.getChoice()) { + case choice33: + mageObject.getPower().setValue(3); + mageObject.getToughness().setValue(3); + break; + case choice22: + mageObject.getPower().setValue(2); + mageObject.getToughness().setValue(2); + if (mageObject instanceof Card) { + ((Card)mageObject).addAbility(FlyingAbility.getInstance()); + } else { + ((Token)mageObject).addAbility(FlyingAbility.getInstance()); + } + break; + case choice16: + mageObject.getPower().setValue(1); + mageObject.getToughness().setValue(6); + if (mageObject instanceof Card) { + ((Card)mageObject).addAbility(DefenderAbility.getInstance()); + } else { + ((Token)mageObject).addAbility(DefenderAbility.getInstance()); + } + break; + } + } + return false; + } @Override - public PrimalClayEffect copy() { - return new PrimalClayEffect(this); + public PrimalPlasmaReplacementEffect copy() { + return new PrimalPlasmaReplacementEffect(this); } + } diff --git a/Mage.Sets/src/mage/sets/planarchaos/AquamorphEntity.java b/Mage.Sets/src/mage/sets/planarchaos/AquamorphEntity.java new file mode 100644 index 0000000000..35206590bd --- /dev/null +++ b/Mage.Sets/src/mage/sets/planarchaos/AquamorphEntity.java @@ -0,0 +1,52 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.planarchaos; + +import java.util.UUID; + +/** + * + * @author LevelX2 + */ +public class AquamorphEntity extends mage.sets.speedvscunning.AquamorphEntity { + + public AquamorphEntity(UUID ownerId) { + super(ownerId); + this.cardNumber = 33; + this.expansionSetCode = "PLC"; + } + + public AquamorphEntity(final AquamorphEntity card) { + super(card); + } + + @Override + public AquamorphEntity copy() { + return new AquamorphEntity(this); + } +} diff --git a/Mage.Sets/src/mage/sets/planechase2012/PrimalPlasma.java b/Mage.Sets/src/mage/sets/planechase2012/PrimalPlasma.java index 5bf59b9bef..5c737db700 100644 --- a/Mage.Sets/src/mage/sets/planechase2012/PrimalPlasma.java +++ b/Mage.Sets/src/mage/sets/planechase2012/PrimalPlasma.java @@ -28,19 +28,30 @@ package mage.sets.planechase2012; import java.util.UUID; - -import mage.constants.*; import mage.MageInt; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ContinuousEffectImpl; -import mage.abilities.effects.EntersBattlefieldEffect; +import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.keyword.DefenderAbility; import mage.abilities.keyword.FlyingAbility; +import mage.cards.Card; import mage.cards.CardImpl; +import mage.choices.Choice; import mage.choices.ChoiceImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; +import mage.game.permanent.PermanentCard; +import mage.game.permanent.PermanentToken; +import mage.game.permanent.token.Token; +import mage.players.Player; /** * @@ -54,14 +65,11 @@ public class PrimalPlasma extends CardImpl { this.subtype.add("Elemental"); this.subtype.add("Shapeshifter"); - this.color.setBlue(true); this.power = new MageInt(0); this.toughness = new MageInt(0); // As Primal Plasma enters the battlefield, it becomes your choice of a 3/3 creature, a 2/2 creature with flying, or a 1/6 creature with defender. - Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new EntersBattlefieldEffect(new PrimalPlasmaEffect(), "As {this} enters the battlefield, it becomes your choice of a 3/3 creature, a 2/2 creature with flying, or a 1/6 creature with defender")); - ability.addChoice(new PrimalPlasmaChoice()); - this.addAbility(ability); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PrimalPlasmaReplacementEffect())); } public PrimalPlasma(final PrimalPlasma card) { @@ -74,47 +82,35 @@ public class PrimalPlasma extends CardImpl { } } -class PrimalPlasmaEffect extends ContinuousEffectImpl { - PrimalPlasmaEffect() { - super(Duration.WhileOnBattlefield, Outcome.BecomeCreature); +class PrimalPlasmaReplacementEffect extends ReplacementEffectImpl { + + private final String choice33 = "a 3/3 creature"; + private final String choice22 = "a 2/2 creature with flying"; + private final String choice16 = "a 1/6 creature with defender"; + + public PrimalPlasmaReplacementEffect() { + super(Duration.WhileOnBattlefield, Outcome.Benefit); + staticText = "As {this} enters the battlefield, it becomes your choice of a 3/3 creature, a 2/2 creature with flying, or a 1/6 creature with defender"; } - PrimalPlasmaEffect(final PrimalPlasmaEffect effect) { + public PrimalPlasmaReplacementEffect(PrimalPlasmaReplacementEffect effect) { super(effect); } @Override - public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { - Permanent permanent = game.getPermanent(source.getSourceId()); - PrimalPlasmaChoice choice = (PrimalPlasmaChoice) source.getChoices().get(0); - if (permanent == null) { - return false; - } + public boolean checksEventType(GameEvent event, Game game) { + return event.getType().equals(EventType.ENTERS_THE_BATTLEFIELD); + } - switch (layer) { - case PTChangingEffects_7: - if (sublayer.equals(SubLayer.SetPT_7b)) { - if (choice.getChoice().equals("a 3/3 creature")) { - permanent.getPower().setValue(3); - permanent.getToughness().setValue(3); - } else if (choice.getChoice().equals("a 2/2 creature with flying")) { - permanent.getPower().setValue(2); - permanent.getToughness().setValue(2); - } else if (choice.getChoice().equals("a 1/6 creature with defender")) { - permanent.getPower().setValue(1); - permanent.getToughness().setValue(6); - } - } - break; - case AbilityAddingRemovingEffects_6: - if (choice.getChoice().equals("a 2/2 creature with flying")) { - permanent.addAbility(FlyingAbility.getInstance(), game); - } else if (choice.getChoice().equals("a 1/6 creature with defender")) { - permanent.addAbility(DefenderAbility.getInstance(), game); - } - break; + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (event.getTargetId().equals(source.getSourceId())) { + Permanent sourcePermanent = game.getPermanent(source.getSourceId()); + if (sourcePermanent != null && !sourcePermanent.isFaceDown()) { + return true; + } } - return true; + return false; } @Override @@ -123,29 +119,61 @@ class PrimalPlasmaEffect extends ContinuousEffectImpl { } @Override - public boolean hasLayer(Layer layer) { - return layer == Layer.PTChangingEffects_7 || layer == Layer.AbilityAddingRemovingEffects_6 || layer == Layer.TypeChangingEffects_4; + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + Permanent permanent = game.getPermanent(source.getSourceId()); + if (permanent != null) { + Choice choice = new ChoiceImpl(true); + choice.setMessage("Choose what the creature becomes to"); + choice.getChoices().add(choice33); + choice.getChoices().add(choice22); + choice.getChoices().add(choice16); + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + while(!choice.isChosen()) { + controller.choose(Outcome.Neutral, choice, game); + if (!controller.isInGame()) { + return false; + } + } + } + MageObject mageObject; + if (permanent instanceof PermanentCard) { + mageObject = ((PermanentCard) permanent).getCard(); + } else { + mageObject = ((PermanentToken) permanent).getToken(); + } + switch (choice.getChoice()) { + case choice33: + mageObject.getPower().setValue(3); + mageObject.getToughness().setValue(3); + break; + case choice22: + mageObject.getPower().setValue(2); + mageObject.getToughness().setValue(2); + if (mageObject instanceof Card) { + ((Card)mageObject).addAbility(FlyingAbility.getInstance()); + } else { + ((Token)mageObject).addAbility(FlyingAbility.getInstance()); + } + break; + case choice16: + mageObject.getPower().setValue(1); + mageObject.getToughness().setValue(6); + if (mageObject instanceof Card) { + ((Card)mageObject).addAbility(DefenderAbility.getInstance()); + } else { + ((Token)mageObject).addAbility(DefenderAbility.getInstance()); + } + break; + } + } + return false; + } @Override - public PrimalPlasmaEffect copy() { - return new PrimalPlasmaEffect(this); + public PrimalPlasmaReplacementEffect copy() { + return new PrimalPlasmaReplacementEffect(this); } + } -class PrimalPlasmaChoice extends ChoiceImpl { - PrimalPlasmaChoice() { - super(true); - this.choices.add("a 3/3 creature"); - this.choices.add("a 2/2 creature with flying"); - this.choices.add("a 1/6 creature with defender"); - } - - PrimalPlasmaChoice(final PrimalPlasmaChoice choice) { - super(choice); - } - - @Override - public PrimalPlasmaChoice copy() { - return new PrimalPlasmaChoice(this); - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/speedvscunning/AquamorphEntity.java b/Mage.Sets/src/mage/sets/speedvscunning/AquamorphEntity.java new file mode 100644 index 0000000000..fe236f7b99 --- /dev/null +++ b/Mage.Sets/src/mage/sets/speedvscunning/AquamorphEntity.java @@ -0,0 +1,179 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.speedvscunning; + +import java.util.UUID; +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.keyword.MorphAbility; +import mage.cards.CardImpl; +import mage.choices.Choice; +import mage.choices.ChoiceImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; +import mage.game.permanent.Permanent; +import mage.game.permanent.PermanentCard; +import mage.game.permanent.PermanentToken; +import mage.players.Player; + +/** + * + * @author LevelX2 + */ +public class AquamorphEntity extends CardImpl { + + public AquamorphEntity(UUID ownerId) { + super(ownerId, 54, "Aquamorph Entity", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{2}{U}{U}"); + this.expansionSetCode = "DDN"; + this.subtype.add("Shapeshifter"); + this.power = new MageInt(0); + this.toughness = new MageInt(0); + + // As Aquamorph Entity enters the battlefield or is turned face up, it becomes your choice of 5/1 or 1/5. + Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new AquamorphEntityReplacementEffect()); + ability.setWorksFaceDown(true); + this.addAbility(ability); + + + // Morph {2}{U} + this.addAbility(new MorphAbility(this, new ManaCostsImpl("{2}{U}"))); + } + + public AquamorphEntity(final AquamorphEntity card) { + super(card); + } + + @Override + public AquamorphEntity copy() { + return new AquamorphEntity(this); + } +} + + +class AquamorphEntityReplacementEffect extends ReplacementEffectImpl { + + private final String choice51 = "a 5/1 creature"; + private final String choice15 = "a 1/5 creature"; + + public AquamorphEntityReplacementEffect() { + super(Duration.WhileOnBattlefield, Outcome.Benefit); + staticText = "as {this} enters the battlefield or is turned face up, it becomes your choice of 5/1 or 1/5"; + } + + public AquamorphEntityReplacementEffect(AquamorphEntityReplacementEffect effect) { + super(effect); + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + switch(event.getType()) { + case ENTERS_THE_BATTLEFIELD: + case TURNFACEUP: + return true; + default: + return false; + } + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (event.getType() == EventType.ENTERS_THE_BATTLEFIELD) { + if (event.getTargetId().equals(source.getSourceId())) { + Permanent sourcePermanent = game.getPermanent(source.getSourceId()); + if (sourcePermanent != null && !sourcePermanent.isFaceDown()) { + return true; + } + } + } + if (event.getType().equals(EventType.TURNFACEUP)) { + if (event.getTargetId().equals(source.getSourceId())) { + return true; + } + } + return false; + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + Permanent permanent = game.getPermanent(source.getSourceId()); + if (permanent != null) { + Choice choice = new ChoiceImpl(true); + choice.setMessage("Choose what the creature becomes to"); + choice.getChoices().add(choice51); + choice.getChoices().add(choice15); + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + while(!choice.isChosen()) { + controller.choose(Outcome.Neutral, choice, game); + if (!controller.isInGame()) { + return false; + } + } + } + MageObject mageObject; + if (permanent instanceof PermanentCard) { + mageObject = ((PermanentCard) permanent).getCard(); + } else { + mageObject = ((PermanentToken) permanent).getToken(); + } + switch (choice.getChoice()) { + case choice51: + mageObject.getPower().setValue(5); + mageObject.getToughness().setValue(1); + break; + case choice15: + mageObject.getPower().setValue(1); + mageObject.getToughness().setValue(5); + break; + } + } + return false; + + } + + @Override + public AquamorphEntityReplacementEffect copy() { + return new AquamorphEntityReplacementEffect(this); + } + +}