mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
NPH - Spellskite
This commit is contained in:
parent
a73d04af1a
commit
61638f6453
3 changed files with 134 additions and 0 deletions
127
Mage.Sets/src/mage/sets/newphyrexia/Spellskite.java
Normal file
127
Mage.Sets/src/mage/sets/newphyrexia/Spellskite.java
Normal file
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
* 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.newphyrexia;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetStackObject;
|
||||
import mage.target.Targets;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward
|
||||
*/
|
||||
public class Spellskite extends CardImpl<Spellskite> {
|
||||
|
||||
public Spellskite(UUID ownerId) {
|
||||
super(ownerId, 159, "Spellskite", Rarity.RARE, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{2}");
|
||||
this.expansionSetCode = "NPH";
|
||||
this.subtype.add("Horror");
|
||||
this.power = new MageInt(0);
|
||||
this.toughness = new MageInt(4);
|
||||
|
||||
// {UP}: Change a target of target spell or ability to Spellskite.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new SpellskiteEffect(), new ManaCostsImpl("{UP}"));
|
||||
ability.addTarget(new TargetStackObject());
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
public Spellskite(final Spellskite card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Spellskite copy() {
|
||||
return new Spellskite(this);
|
||||
}
|
||||
}
|
||||
|
||||
class SpellskiteEffect extends OneShotEffect<SpellskiteEffect> {
|
||||
|
||||
public SpellskiteEffect() {
|
||||
super(Outcome.Neutral);
|
||||
staticText = "Change a target of target spell or ability to {this}";
|
||||
}
|
||||
|
||||
public SpellskiteEffect(final SpellskiteEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Spell spell = game.getStack().getSpell(source.getFirstTarget());
|
||||
if (spell != null) {
|
||||
Targets targets = spell.getSpellAbility().getTargets();
|
||||
if (targets.size() == 1 && targets.get(0).getTargets().size() == 1) {
|
||||
targets.get(0).clearChosen();
|
||||
targets.get(0).add(source.getSourceId(), game);
|
||||
}
|
||||
else {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
for (Target target: targets) {
|
||||
for (UUID targetId: target.getTargets()) {
|
||||
MageObject object = game.getObject(targetId);
|
||||
String name = null;
|
||||
if (object == null) {
|
||||
Player targetPlayer = game.getPlayer(targetId);
|
||||
name = targetPlayer.getName();
|
||||
} else {
|
||||
name = object.getName();
|
||||
}
|
||||
if (name != null && player.chooseUse(Outcome.Neutral, "Change target from " + name + " to {this}?", game)) {
|
||||
target.remove(targetId);
|
||||
target.addTarget(source.getSourceId(), source, game);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellskiteEffect copy() {
|
||||
return new SpellskiteEffect(this);
|
||||
}
|
||||
|
||||
}
|
|
@ -65,6 +65,7 @@ public interface Target extends Serializable {
|
|||
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game);
|
||||
public boolean choose(Outcome outcome, UUID playerId, Game game);
|
||||
public void add(UUID id, Game game);
|
||||
public void remove(UUID targetId);
|
||||
|
||||
public String getMessage();
|
||||
public String getTargetName();
|
||||
|
|
|
@ -166,6 +166,12 @@ public abstract class TargetImpl<T extends TargetImpl<T>> implements Target {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(UUID id) {
|
||||
if (targets.containsKey(id))
|
||||
targets.remove(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTarget(UUID id, Ability source, Game game) {
|
||||
|
|
Loading…
Reference in a new issue