mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Implemented Shifty Doppelganger
This commit is contained in:
parent
3d2b9093b2
commit
d28de9e357
3 changed files with 178 additions and 2 deletions
174
Mage.Sets/src/mage/cards/s/ShiftyDoppelganger.java
Normal file
174
Mage.Sets/src/mage/cards/s/ShiftyDoppelganger.java
Normal file
|
@ -0,0 +1,174 @@
|
|||
/*
|
||||
* 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.cards.s;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||
import mage.abilities.costs.common.ExileSourceCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
|
||||
import mage.abilities.keyword.HasteAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class ShiftyDoppelganger extends CardImpl {
|
||||
|
||||
public ShiftyDoppelganger(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}");
|
||||
|
||||
this.subtype.add("Shapeshifter");
|
||||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
// {3}{U}, Exile Shifty Doppelganger: You may put a creature card from your hand onto the battlefield. If you do, that creature gains haste until end of turn. At the beginning of the next end step, sacrifice that creature. If you do, return Shifty Doppelganger to the battlefield.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ShiftyDoppelgangerExileEffect(), new ManaCostsImpl("{3}{U}"));
|
||||
ability.addCost(new ExileSourceCost(true));
|
||||
this.addAbility(ability);
|
||||
|
||||
}
|
||||
|
||||
public ShiftyDoppelganger(final ShiftyDoppelganger card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShiftyDoppelganger copy() {
|
||||
return new ShiftyDoppelganger(this);
|
||||
}
|
||||
}
|
||||
|
||||
class ShiftyDoppelgangerExileEffect extends OneShotEffect {
|
||||
|
||||
public ShiftyDoppelgangerExileEffect() {
|
||||
super(Outcome.PutCreatureInPlay);
|
||||
this.staticText = "You may put a creature card from your hand onto the battlefield. If you do, that creature gains haste until end of turn. At the beginning of the next end step, sacrifice that creature. If you do, return {this} to the battlefield";
|
||||
}
|
||||
|
||||
public ShiftyDoppelgangerExileEffect(final ShiftyDoppelgangerExileEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShiftyDoppelgangerExileEffect copy() {
|
||||
return new ShiftyDoppelgangerExileEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
FilterCreatureCard filter = new FilterCreatureCard("a creature card");
|
||||
boolean putCreature = false;
|
||||
UUID creatureId = UUID.randomUUID();
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player.chooseUse(Outcome.PutCardInPlay, "Put " + filter.getMessage() + " from your hand onto the battlefield?", source, game)) {
|
||||
TargetCardInHand target = new TargetCardInHand(filter);
|
||||
if (player.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null) {
|
||||
putCreature = player.moveCards(card, Zone.BATTLEFIELD, source, game);
|
||||
if (putCreature) {
|
||||
creatureId = card.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (putCreature) {
|
||||
Permanent creature = game.getPermanent(creatureId);
|
||||
if (creature != null) {
|
||||
ContinuousEffect hasteEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
|
||||
hasteEffect.setTargetPointer(new FixedTarget(creature, game));
|
||||
game.addEffect(hasteEffect, source);
|
||||
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(
|
||||
new ShiftyDoppelgangerReturnEffect(creature.getId(), creature.getZoneChangeCounter(game), (int) game.getState().getValue(source.getSourceId().toString())));
|
||||
game.addDelayedTriggeredAbility(delayedAbility, source);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class ShiftyDoppelgangerReturnEffect extends OneShotEffect {
|
||||
|
||||
private final UUID creatureId;
|
||||
private final int creatureZoneCount;
|
||||
private final int sourceZoneCount;
|
||||
|
||||
ShiftyDoppelgangerReturnEffect(UUID creatureId, int creatureZoneCount, int sourceZoneCount) {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "sacrifice that creature. If you do, return {this} to the battlefield";
|
||||
this.creatureId = creatureId;
|
||||
this.creatureZoneCount = creatureZoneCount;
|
||||
this.sourceZoneCount = sourceZoneCount;
|
||||
}
|
||||
|
||||
ShiftyDoppelgangerReturnEffect(final ShiftyDoppelgangerReturnEffect effect) {
|
||||
super(effect);
|
||||
this.creatureId = effect.creatureId;
|
||||
this.creatureZoneCount = effect.creatureZoneCount;
|
||||
this.sourceZoneCount = effect.sourceZoneCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShiftyDoppelgangerReturnEffect copy() {
|
||||
return new ShiftyDoppelgangerReturnEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent creature = game.getPermanent(creatureId);
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (creature != null && creature.getZoneChangeCounter(game) == this.creatureZoneCount && creature.sacrifice(source.getSourceId(), game)) {
|
||||
if (player != null && sourceObject != null && sourceObject.getZoneChangeCounter(game) == this.sourceZoneCount) {
|
||||
player.moveCards(game.getCard(source.getSourceId()), Zone.BATTLEFIELD, source, game);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -302,6 +302,7 @@ public class Odyssey extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Shadowblood Ridge", 326, Rarity.RARE, mage.cards.s.ShadowbloodRidge.class));
|
||||
cards.add(new SetCardInfo("Shadowmage Infiltrator", 294, Rarity.RARE, mage.cards.s.ShadowmageInfiltrator.class));
|
||||
cards.add(new SetCardInfo("Shelter", 46, Rarity.COMMON, mage.cards.s.Shelter.class));
|
||||
cards.add(new SetCardInfo("Shifty Doppelganger", 101, Rarity.RARE, mage.cards.s.ShiftyDoppelganger.class));
|
||||
cards.add(new SetCardInfo("Shower of Coals", 221, Rarity.UNCOMMON, mage.cards.s.ShowerOfCoals.class));
|
||||
cards.add(new SetCardInfo("Simplify", 269, Rarity.COMMON, mage.cards.s.Simplify.class));
|
||||
cards.add(new SetCardInfo("Skeletal Scrying", 161, Rarity.UNCOMMON, mage.cards.s.SkeletalScrying.class));
|
||||
|
|
|
@ -47,7 +47,7 @@ public class ExileSourceCost extends CostImpl {
|
|||
private boolean toUniqueExileZone;
|
||||
|
||||
public ExileSourceCost() {
|
||||
this.text = "Exile {this}";
|
||||
this.text = "exile {this}";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,7 +57,7 @@ public class ExileSourceCost extends CostImpl {
|
|||
* Deadeye Navigator) can identify the card
|
||||
*/
|
||||
public ExileSourceCost(boolean toUniqueExileZone) {
|
||||
this.text = "Exile {this}";
|
||||
this.text = "exile {this}";
|
||||
this.toUniqueExileZone = toUniqueExileZone;
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,7 @@ public class ExileSourceCost extends CostImpl {
|
|||
if (toUniqueExileZone) {
|
||||
exileZoneId = CardUtil.getExileZoneId(game, ability.getSourceId(), ability.getSourceObjectZoneChangeCounter());
|
||||
exileZoneName = sourceObject.getName();
|
||||
game.getState().setValue(sourceObject.getId().toString(), ability.getSourceObjectZoneChangeCounter());
|
||||
}
|
||||
controller.moveCardToExileWithInfo((Card) sourceObject, exileZoneId, exileZoneName, sourceId, game, game.getState().getZone(sourceObject.getId()), true);
|
||||
// 117.11. The actions performed when paying a cost may be modified by effects.
|
||||
|
|
Loading…
Reference in a new issue