moved CopyPermanentEffect and fixed some cards with copy

This commit is contained in:
BetaSteward 2012-01-16 18:45:11 -05:00
parent c1a02e9418
commit a13bb9acf5
5 changed files with 53 additions and 67 deletions

View file

@ -33,12 +33,12 @@ import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.CopyPermanentEffect;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.common.CopyPermanentEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.effects.common.continious.GainAbilitySourceEffect;
import mage.cards.CardImpl;

View file

@ -36,6 +36,7 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BecomesTargetTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CopyEffect;
import mage.abilities.effects.common.SacrificeSourceEffect;
@ -64,7 +65,7 @@ public class PhantasmalImage extends CardImpl<PhantasmalImage> {
this.power = new MageInt(0);
this.toughness = new MageInt(0);
Ability ability = new EntersBattlefieldAbility(new PhantasmalImageCopyEffect(), abilityText);
Ability ability = new EntersBattlefieldAbility(new EntersBattlefieldEffect(new PhantasmalImageCopyEffect(), abilityText));
this.addAbility(ability);
}

View file

@ -30,19 +30,22 @@ package mage.sets.newphyrexia;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Outcome;
import mage.Constants.Rarity;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.cards.Card;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CopyEffect;
import mage.cards.CardImpl;
import mage.filter.Filter;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.Target;
import mage.target.TargetPermanent;
/**
@ -50,13 +53,6 @@ import mage.target.TargetPermanent;
* @author Loki
*/
public class PhyrexianMetamorph extends CardImpl<PhyrexianMetamorph> {
private static FilterPermanent filter = new FilterPermanent("artifact or creature");
static {
filter.getCardType().add(CardType.ARTIFACT);
filter.getCardType().add(CardType.CREATURE);
filter.setScopeCardType(Filter.ComparisonScope.Any);
}
public PhyrexianMetamorph (UUID ownerId) {
super(ownerId, 42, "Phyrexian Metamorph", Rarity.RARE, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{3}{UP}");
@ -65,8 +61,7 @@ public class PhyrexianMetamorph extends CardImpl<PhyrexianMetamorph> {
this.color.setBlue(true);
this.power = new MageInt(0);
this.toughness = new MageInt(0);
Ability ability = new EntersBattlefieldAbility(new PhyrexianMetamorphEffect(), "You may have {this} enter the battlefield as a copy of any artifact or creature on the battlefield, except it's an artifact in addition to its other types");
ability.addTarget(new TargetPermanent());
Ability ability = new EntersBattlefieldAbility(new EntersBattlefieldEffect(new PhyrexianMetamorphEffect()), "You may have {this} enter the battlefield as a copy of any artifact or creature on the battlefield, except it's an artifact in addition to its other types");
this.addAbility(ability);
}
@ -81,59 +76,50 @@ public class PhyrexianMetamorph extends CardImpl<PhyrexianMetamorph> {
}
class PhyrexianMetamorphEffect extends ContinuousEffectImpl<PhyrexianMetamorphEffect> {
class PhyrexianMetamorphEffect extends OneShotEffect<PhyrexianMetamorphEffect> {
private static final FilterPermanent filter = new FilterPermanent("artifact or creature");
public PhyrexianMetamorphEffect() {
super(Constants.Duration.WhileOnBattlefield, Constants.Layer.CopyEffects_1, Constants.SubLayer.NA, Constants.Outcome.BecomeCreature);
staticText = "You may have {this} enter the battlefield as a copy of any artifact or creature on the battlefield, except it's an artifact in addition to its other types";
}
static {
filter.getCardType().add(CardType.ARTIFACT);
filter.getCardType().add(CardType.CREATURE);
filter.setScopeCardType(Filter.ComparisonScope.Any);
}
public PhyrexianMetamorphEffect() {
super(Outcome.Copy);
}
public PhyrexianMetamorphEffect(final PhyrexianMetamorphEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(source.getFirstTarget());
Permanent permanent = game.getPermanent(source.getSourceId());
if (card != null && permanent != null) {
permanent.setName(card.getName());
permanent.getColor().setColor(card.getColor());
permanent.getManaCost().clear();
permanent.getManaCost().add(card.getManaCost());
permanent.getCardType().clear();
for (CardType type: card.getCardType()) {
permanent.getCardType().add(type);
public PhyrexianMetamorphEffect(final PhyrexianMetamorphEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
//TODO: handle copying copies
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Target target = new TargetPermanent(filter);
if (target.canChoose(source.getControllerId(), game)) {
player.choose(Outcome.Copy, target, source.getSourceId(), game);
Permanent perm = game.getPermanent(target.getFirstTarget());
if (perm != null) {
perm = perm.copy();
perm.reset(game);
perm.assignNewId();
if (!perm.getCardType().contains(CardType.ARTIFACT))
perm.getCardType().add(CardType.ARTIFACT);
game.addEffect(new CopyEffect(perm), source);
return true;
}
}
if (!card.getCardType().contains(CardType.ARTIFACT)) {
card.getCardType().add(CardType.ARTIFACT);
}
permanent.getSubtype().clear();
for (String type: card.getSubtype()) {
permanent.getSubtype().add(type);
}
permanent.getSupertype().clear();
for (String type: card.getSupertype()) {
permanent.getSupertype().add(type);
}
permanent.setExpansionSetCode(card.getExpansionSetCode());
permanent.getAbilities().clear();
for (Ability ability0: card.getAbilities()) {
// Ability ability = ability0.copy();
// ability.newId();
// ability.setSourceId(card.getId());
permanent.addAbility(ability0);
}
permanent.getPower().setValue(card.getPower().getValue());
permanent.getToughness().setValue(card.getToughness().getValue());
}
return true;
}
@Override
public PhyrexianMetamorphEffect copy() {
return new PhyrexianMetamorphEffect(this);
}
return false;
}
@Override
public PhyrexianMetamorphEffect copy() {
return new PhyrexianMetamorphEffect(this);
}
}

View file

@ -33,9 +33,9 @@ import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.CopyPermanentEffect;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.common.CopyPermanentEffect;
import mage.cards.CardImpl;
/**

View file

@ -25,12 +25,11 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.common;
package mage.abilities.effects.common;
import mage.Constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CopyEffect;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;