Merge pull request #5408 from davidmfritz/cleartheland

Implementation of the card Clear the Land
This commit is contained in:
Oleg Agafonov 2018-11-01 14:57:56 +04:00 committed by GitHub
commit d6b40d1654
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 93 additions and 0 deletions

View file

@ -0,0 +1,92 @@
package mage.cards.c;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Library;
import mage.players.Player;
/**
*
* @author davidmfritz
*/
public final class ClearTheLand extends CardImpl {
public ClearTheLand(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{G}");
// Each player reveals the top five cards of his or her library, puts all land cards revealed this way onto the battlefield tapped, and exiles the rest.
getSpellAbility().addEffect(new ClearTheLandEffect());
}
public ClearTheLand(final ClearTheLand card) {
super(card);
}
@Override
public ClearTheLand copy() {
return new ClearTheLand(this);
}
}
class ClearTheLandEffect extends OneShotEffect {
public ClearTheLandEffect() {
super(Outcome.Benefit);
this.staticText = "Each player reveals the top five cards of his or her library, puts all land cards revealed this way onto the battlefield tapped, and exiles the rest.";
}
public ClearTheLandEffect(final ClearTheLandEffect effect) {
super(effect);
}
@Override
public ClearTheLandEffect copy() {
return new ClearTheLandEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
boolean tapped = true;
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
Library library = player.getLibrary();
Cards cardsToReveal = new CardsImpl();
cardsToReveal.addAll(library.getTopCards(game, 5));
if (!cardsToReveal.isEmpty()) {
player.revealCards(source, "Revealed cards for " + player.getName(), cardsToReveal, game);
Cards cardsToPutOnBattlefield = new CardsImpl();
Cards cardsToExile = new CardsImpl();
for (Card card : cardsToReveal.getCards(game)) {
if (card.isLand()) {
cardsToPutOnBattlefield.add(card);
} else {
cardsToExile.add(card);
}
}
player.moveCards(cardsToPutOnBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, tapped, false, true, null);
player.moveCards(cardsToExile.getCards(game), Zone.EXILED, source, game);
}
}
}
return true;
}
return false;
}
}

View file

@ -75,6 +75,7 @@ public final class MercadianMasques extends ExpansionSet {
cards.add(new SetCardInfo("Cho-Manno, Revolutionary", 11, Rarity.RARE, mage.cards.c.ChoMannoRevolutionary.class));
cards.add(new SetCardInfo("Cho-Manno's Blessing", 12, Rarity.COMMON, mage.cards.c.ChoMannosBlessing.class));
cards.add(new SetCardInfo("Cinder Elemental", 183, Rarity.UNCOMMON, mage.cards.c.CinderElemental.class));
cards.add(new SetCardInfo("Clear the Land", 235, Rarity.RARE, mage.cards.c.ClearTheLand.class));
cards.add(new SetCardInfo("Close Quarters", 184, Rarity.UNCOMMON, mage.cards.c.CloseQuarters.class));
cards.add(new SetCardInfo("Cloud Sprite", 67, Rarity.COMMON, mage.cards.c.CloudSprite.class));
cards.add(new SetCardInfo("Coastal Piracy", 68, Rarity.UNCOMMON, mage.cards.c.CoastalPiracy.class));