Unstable Shapeshifter fixed some bugs and clean up.

This commit is contained in:
LevelX2 2016-10-30 19:15:02 +01:00
parent 986560b81b
commit acbb3800a9

View file

@ -1,143 +1,107 @@
/* /*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are * Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met: * permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this list of * 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list * 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 * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution. * provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * 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 * 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 * 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 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * 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 * 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 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* The views and conclusions contained in the software and documentation are those of the * 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 * 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.cards.u; package mage.cards.u;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.EntersBattlefieldAllTriggeredAbility;
import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl;
import mage.cards.CardImpl; import mage.cards.CardSetInfo;
import mage.cards.CardSetInfo; import mage.constants.CardType;
import mage.constants.CardType; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.SetTargetPointer;
import mage.game.Game; import mage.constants.Zone;
import mage.game.events.GameEvent; import mage.filter.common.FilterCreaturePermanent;
import mage.game.events.GameEvent.EventType; import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.permanent.Permanent; import mage.game.Game;
import mage.target.targetpointer.FixedTarget; import mage.game.permanent.Permanent;
import mage.util.functions.EmptyApplyToPermanent; import mage.util.functions.EmptyApplyToPermanent;
/**
/** *
* * @author HCrescent
* @author HCrescent */
*/ public class UnstableShapeshifter extends CardImpl {
public class UnstableShapeshifter extends CardImpl {
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent();
public UnstableShapeshifter(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{U}"); static {
this.subtype.add("Shapeshifter"); filter.add(new AnotherPredicate());
}
this.power = new MageInt(0);
this.toughness = new MageInt(1); public UnstableShapeshifter(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{U}");
// Whenever another creature enters the battlefield under your control, you may have Renegade Doppelganger become a copy of that creature until end of turn. this.subtype.add("Shapeshifter");
this.addAbility(new UnstableShapeshifterTriggeredAbility());
} this.power = new MageInt(0);
this.toughness = new MageInt(1);
public UnstableShapeshifter(final UnstableShapeshifter card) {
super(card); // Whenever another creature enters the battlefield under your control, you may have Renegade Doppelganger become a copy of that creature until end of turn.
} this.addAbility(new EntersBattlefieldAllTriggeredAbility(Zone.BATTLEFIELD, new UnstableShapeshifterEffect(), filter, true, SetTargetPointer.PERMANENT, ""));
}
@Override
public UnstableShapeshifter copy() { public UnstableShapeshifter(final UnstableShapeshifter card) {
return new UnstableShapeshifter(this); super(card);
} }
}
@Override
class UnstableShapeshifterTriggeredAbility extends TriggeredAbilityImpl { public UnstableShapeshifter copy() {
return new UnstableShapeshifter(this);
UnstableShapeshifterTriggeredAbility() { }
super(Zone.BATTLEFIELD, new UnstableShapeshifterEffect(), false); }
}
class UnstableShapeshifterEffect extends OneShotEffect {
UnstableShapeshifterTriggeredAbility(final UnstableShapeshifterTriggeredAbility ability) {
super(ability); public UnstableShapeshifterEffect() {
} super(Outcome.Copy);
this.staticText = "you may have {this} become a copy of that creature until end of turn";
@Override }
public UnstableShapeshifterTriggeredAbility copy() {
return new UnstableShapeshifterTriggeredAbility(this); public UnstableShapeshifterEffect(final UnstableShapeshifterEffect effect) {
} super(effect);
}
@Override
public boolean checkEventType(GameEvent event, Game game) { @Override
return event.getType() == EventType.ENTERS_THE_BATTLEFIELD; public UnstableShapeshifterEffect copy() {
} return new UnstableShapeshifterEffect(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) { @Override
if (!event.getTargetId().equals(this.getSourceId())) { public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(event.getTargetId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)) { Permanent targetCreature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
for (Effect effect : this.getEffects()) { if (targetCreature != null && permanent != null) {
effect.setTargetPointer(new FixedTarget(permanent.getId())); game.copyPermanent(Duration.EndOfTurn, targetCreature, permanent.getId(), source, new EmptyApplyToPermanent());
} return true;
return true; }
} return false;
} }
return false; }
}
@Override
public String getRule() {
return "Whenever another creature enters the battlefield, {this} becomes a copy of that creature and gains this ability.";
}
}
class UnstableShapeshifterEffect extends OneShotEffect {
public UnstableShapeshifterEffect() {
super(Outcome.Copy);
this.staticText = "have {this} become a copy of that creature and gain this ability";
}
public UnstableShapeshifterEffect(final UnstableShapeshifterEffect effect) {
super(effect);
}
@Override
public UnstableShapeshifterEffect copy() {
return new UnstableShapeshifterEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetCreature == null) {
targetCreature = (Permanent) game.getLastKnownInformation(getTargetPointer().getFirst(game, source), Zone.BATTLEFIELD);
}
Permanent newPermanent = game.copyPermanent( targetCreature, permanent.getId(), source, new EmptyApplyToPermanent());
newPermanent.addAbility(new UnstableShapeshifterTriggeredAbility() , source.getSourceId(), game);
return false;
}
}