Merge pull request #735 from myersn024/master

Create SkyshipWeatherlight.java
This commit is contained in:
LevelX2 2015-02-18 23:36:40 +01:00
commit 34082a06d2
2 changed files with 217 additions and 0 deletions

View file

@ -0,0 +1,80 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.sets.fifthdawn;
import java.util.UUID;
import mage.constants.*;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.players.Player;
/**
*
* @author nick.myers
*/
public class EonHub extends CardImpl {
public EonHub(UUID ownerId) {
super(ownerId, 120, "Eon Hub", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{5}");
this.expansionSetCode = "5DN";
// Players skip their upkeep steps.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SkipUpkeepStepEffect()));
}
public EonHub(final EonHub card) {
super(card);
}
@Override
public EonHub copy() {
return new EonHub(this);
}
}
class SkipUpkeepStepEffect extends ReplacementEffectImpl {
public SkipUpkeepStepEffect() {
super(Duration.WhileOnBattlefield, Outcome.Neutral);
staticText = "Players skip their upkeep steps";
}
public SkipUpkeepStepEffect(final SkipUpkeepStepEffect effect) {
super(effect);
}
@Override
public SkipUpkeepStepEffect copy() {
return new SkipUpkeepStepEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.UPKEEP_STEP;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
return controller != null && controller.getInRange().contains(event.getPlayerId());
}
}

View file

@ -0,0 +1,137 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.sets.planeshift;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.SearchEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.game.ExileZone;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
import mage.util.CardUtil;
/**
*
* @author nick.myers
*/
public class SkyshipWeatherlight extends CardImpl {
public SkyshipWeatherlight(UUID ownerId) {
super(ownerId, 133, "Skyship Weatherlight", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{4}");
this.expansionSetCode = "PLS";
this.supertype.add("Legendary");
// When Skyship Weatherlight enters the battlefield, search your library for any number of artifact and/or creature cards and exile them. Then shuffle your library.
this.addAbility(new EntersBattlefieldTriggeredAbility(new SkyshipWeatherlightEffect(), false));
// {4}, {tap}, Choose a card at random that was removed from the game with Skyship Weatherlight. Put that card into your hand.
SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new SkyshipWeatherlightEffect2(), new GenericManaCost(4));
ability.addCost(new TapSourceCost());
this.addAbility(ability);
}
public SkyshipWeatherlight(final SkyshipWeatherlight card) {
super(card);
}
@Override
public SkyshipWeatherlight copy() {
return new SkyshipWeatherlight(this);
}
}
class SkyshipWeatherlightEffect extends SearchEffect {
private static final FilterCard filter = new FilterCard("artifact and/or creature card");
static {
filter.add(Predicates.or(
new CardTypePredicate(CardType.ARTIFACT),
new CardTypePredicate(CardType.CREATURE)));
}
public SkyshipWeatherlightEffect() {
super(new TargetCardInLibrary(0, Integer.MAX_VALUE, filter), Outcome.Neutral);
this.staticText = "search your library for any number of artifact and/or creature cards and remove them from the game. Then shuffle your library.";
}
public SkyshipWeatherlightEffect(final SkyshipWeatherlightEffect effect) {
super(effect);
}
@Override
public SkyshipWeatherlightEffect copy() {
return new SkyshipWeatherlightEffect(this);
}
@Override
public boolean apply (Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
if (you != null) {
if (you.searchLibrary(target, game)) {
UUID exileZone = CardUtil.getCardExileZoneId(game, source);
if (target.getTargets().size() > 0) {
for (UUID cardID : target.getTargets()) {
Card card = you.getLibrary().getCard(cardID, game);
if (card != null) {
card.moveToExile(exileZone, "Skyship Weatherlight", source.getSourceId(), game);
}
}
}
}
you.shuffleLibrary(game);
}
return false;
}
}
class SkyshipWeatherlightEffect2 extends OneShotEffect {
public SkyshipWeatherlightEffect2() {
super(Outcome.ReturnToHand);
this.staticText = "Choose a card at random that was removed from the game with Skyship Weatherlight. Put that card into your hand.";
}
public SkyshipWeatherlightEffect2(final SkyshipWeatherlightEffect2 effect) {
super(effect);
}
@Override
public SkyshipWeatherlightEffect2 copy() {
return new SkyshipWeatherlightEffect2(this);
}
@Override
public boolean apply(Game game, Ability source) {
ExileZone exZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
if (exZone != null) {
Card card = exZone.getRandom(game);
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
}
return true;
}
}