refactored zone changes, letters G and H

reworked Gift of the Gargantuan to allow cleaner choice
This commit is contained in:
Evan Kranzler 2021-02-24 15:57:57 -05:00
parent 756ca46718
commit 16306eb428
4 changed files with 125 additions and 104 deletions

View file

@ -1,12 +1,9 @@
package mage.cards.g;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
@ -16,16 +13,18 @@ import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.util.RandomUtil;
import mage.target.TargetCard;
import mage.target.common.TargetCardInYourGraveyard;
import java.util.UUID;
/**
*
* @author North
*/
public final class Ghoulraiser extends CardImpl {
public Ghoulraiser(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{B}{B}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}{B}");
this.subtype.add(SubType.ZOMBIE);
this.power = new MageInt(2);
@ -47,12 +46,18 @@ public final class Ghoulraiser extends CardImpl {
class GhoulraiserEffect extends OneShotEffect {
public GhoulraiserEffect() {
private static final FilterCard filter = new FilterCard();
static {
filter.add(SubType.ZOMBIE.getPredicate());
}
GhoulraiserEffect() {
super(Outcome.ReturnToHand);
this.staticText = "return a Zombie card at random from your graveyard to your hand";
}
public GhoulraiserEffect(final GhoulraiserEffect effect) {
private GhoulraiserEffect(final GhoulraiserEffect effect) {
super(effect);
}
@ -64,17 +69,13 @@ class GhoulraiserEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
FilterCard filter = new FilterCard("Zombie card");
filter.add(SubType.ZOMBIE.getPredicate());
Card[] cards = player.getGraveyard().getCards(filter, game).toArray(new Card[0]);
if (cards.length > 0) {
Card card = cards[RandomUtil.nextInt(cards.length)];
card.moveToZone(Zone.HAND, source, game, true);
game.informPlayers(card.getName() + "returned to the hand of" + player.getLogName());
return true;
}
if (player == null || player.getGraveyard().count(filter, game) < 1) {
return false;
}
return false;
TargetCard target = new TargetCardInYourGraveyard(filter);
target.setNotTarget(true);
target.setRandom(true);
player.choose(outcome, target, source.getSourceId(), game);
return player.moveCards(game.getCard(target.getFirstTarget()), Zone.HAND, source, game);
}
}

View file

@ -1,21 +1,22 @@
package mage.cards.g;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.CardTypeAssignment;
import mage.abilities.effects.OneShotEffect;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.filter.common.FilterLandCard;
import mage.filter.FilterCard;
import mage.filter.predicate.Predicates;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInLibrary;
import java.util.UUID;
/**
*
* @author North
*/
public final class GiftOfTheGargantuan extends CardImpl {
@ -39,12 +40,14 @@ public final class GiftOfTheGargantuan extends CardImpl {
class GiftOfTheGargantuanEffect extends OneShotEffect {
public GiftOfTheGargantuanEffect() {
GiftOfTheGargantuanEffect() {
super(Outcome.DrawCard);
this.staticText = "Look at the top four cards of your library. You may reveal a creature card and/or a land card from among them and put the revealed cards into your hand. Put the rest on the bottom of your library in any order";
this.staticText = "Look at the top four cards of your library. You may reveal a creature card " +
"and/or a land card from among them and put the revealed cards into your hand. " +
"Put the rest on the bottom of your library in any order";
}
public GiftOfTheGargantuanEffect(final GiftOfTheGargantuanEffect effect) {
private GiftOfTheGargantuanEffect(final GiftOfTheGargantuanEffect effect) {
super(effect);
}
@ -60,32 +63,60 @@ class GiftOfTheGargantuanEffect extends OneShotEffect {
return false;
}
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 4));
player.lookAtCards(source, null, cards, game);
Cards revealedCards = new CardsImpl();
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCreatureCard("creature card to reveal and put into your hand"));
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)
&& player.choose(Outcome.DrawCard, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.HAND, source, game, false);
revealedCards.add(card);
}
}
target = new TargetCard(Zone.LIBRARY, new FilterLandCard("land card to reveal and put into your hand"));
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)
&& player.choose(Outcome.DrawCard, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.HAND, source, game, false);
revealedCards.add(card);
}
}
if (!revealedCards.isEmpty()) {
player.revealCards(source, revealedCards, game);
}
TargetCard target = new GiftOfTheGargantuanTarget();
player.choose(outcome, cards, target, game);
Cards toHand = new CardsImpl();
toHand.addAll(target.getTargets());
player.revealCards(source, toHand, game);
player.moveCards(toHand, Zone.HAND, source, game);
cards.removeAll(toHand);
player.putCardsOnBottomOfLibrary(cards, game, source, true);
return true;
}
}
class GiftOfTheGargantuanTarget extends TargetCardInLibrary {
private static final FilterCard filter
= new FilterCard("a creature card and/or a land card");
static {
filter.add(Predicates.or(
CardType.CREATURE.getPredicate(),
CardType.LAND.getPredicate()
));
}
private static final CardTypeAssignment cardTypeAssigner
= new CardTypeAssignment(CardType.CREATURE, CardType.LAND);
GiftOfTheGargantuanTarget() {
super(0, 2, filter);
}
private GiftOfTheGargantuanTarget(final GiftOfTheGargantuanTarget target) {
super(target);
}
@Override
public GiftOfTheGargantuanTarget copy() {
return new GiftOfTheGargantuanTarget(this);
}
@Override
public boolean canTarget(UUID playerId, UUID id, Ability source, Game game) {
if (!super.canTarget(playerId, id, source, game)) {
return false;
}
Card card = game.getCard(id);
if (card == null) {
return false;
}
if (this.getTargets().isEmpty()) {
return true;
}
Cards cards = new CardsImpl(this.getTargets());
cards.add(card);
return cardTypeAssigner.getRoleCount(cards, game) >= cards.size();
}
}

View file

@ -1,41 +1,40 @@
package mage.cards.g;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
import java.util.UUID;
/**
*
* @author maurer.it_at_gmail.com
*/
public final class GlintHawk extends CardImpl {
public GlintHawk(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{W}");
this.subtype.add(SubType.BIRD);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
// When Glint Hawk enters the battlefield, sacrifice it unless you return an artifact you control to its owner's hand.
// Flying
this.addAbility(FlyingAbility.getInstance());
// When Glint Hawk enters the battlefield, sacrifice it unless you return an artifact you control to its owner's hand.
this.addAbility(new EntersBattlefieldTriggeredAbility(new GlintHawkEffect()));
}
@ -51,49 +50,40 @@ public final class GlintHawk extends CardImpl {
class GlintHawkEffect extends OneShotEffect {
private static final FilterControlledPermanent filter;
private static final String effectText = "sacrifice it unless you return an artifact you control to its owner's hand";
static {
filter = new FilterControlledPermanent();
filter.add(CardType.ARTIFACT.getPredicate());
}
GlintHawkEffect ( ) {
GlintHawkEffect() {
super(Outcome.Sacrifice);
staticText = effectText;
}
GlintHawkEffect ( GlintHawkEffect effect ) {
private GlintHawkEffect(final GlintHawkEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
boolean targetChosen = false;
TargetPermanent target = new TargetPermanent(1, 1, filter, true);
if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.chooseUse(outcome, "Return an artifact you control to its owner's hand?", source, game)) {
controller.chooseTarget(Outcome.Sacrifice, target, source, game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
targetChosen = true;
permanent.moveToZone(Zone.HAND, source, game, false);
}
}
if (!targetChosen) {
new SacrificeSourceEffect().apply(game, source);
}
return true;
if (controller == null) {
return false;
}
return false;
TargetPermanent target = new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT);
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), controller.getId(), game)
&& controller.chooseUse(outcome, "Return an artifact you control to its owner's hand?", source, game)) {
controller.chooseTarget(Outcome.ReturnToHand, target, source, game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
controller.moveCards(permanent, Zone.HAND, source, game);
return true;
}
}
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
return permanent != null && permanent.sacrifice(source, game);
}
@Override
public GlintHawkEffect copy() {
return new GlintHawkEffect(this);
}
}
}

View file

@ -1,6 +1,5 @@
package mage.cards.h;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeSourceCost;
@ -8,7 +7,6 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.mana.ColorlessManaAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
@ -17,10 +15,12 @@ import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import mage.util.RandomUtil;
import mage.target.TargetCard;
import mage.target.common.TargetCardInYourGraveyard;
import java.util.UUID;
/**
*
* @author North
*/
public final class HauntedFengraf extends CardImpl {
@ -30,8 +30,9 @@ public final class HauntedFengraf extends CardImpl {
// {tap}: Add {C}.
this.addAbility(new ColorlessManaAbility());
// {3}, {tap}, Sacrifice Haunted Fengraf: Return a creature card at random from your graveyard to your hand.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new HauntedFengrafEffect(), new GenericManaCost(3));
Ability ability = new SimpleActivatedAbility(new HauntedFengrafEffect(), new GenericManaCost(3));
ability.addCost(new TapSourceCost());
ability.addCost(new SacrificeSourceCost());
this.addAbility(ability);
@ -49,12 +50,12 @@ public final class HauntedFengraf extends CardImpl {
class HauntedFengrafEffect extends OneShotEffect {
public HauntedFengrafEffect() {
HauntedFengrafEffect() {
super(Outcome.ReturnToHand);
this.staticText = "Return a creature card at random from your graveyard to your hand";
}
public HauntedFengrafEffect(final HauntedFengrafEffect effect) {
private HauntedFengrafEffect(final HauntedFengrafEffect effect) {
super(effect);
}
@ -66,15 +67,13 @@ class HauntedFengrafEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Card[] cards = player.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game).toArray(new Card[0]);
if (cards.length > 0) {
Card card = cards[RandomUtil.nextInt(cards.length)];
card.moveToZone(Zone.HAND, source, game, true);
game.informPlayers(card.getName() + " returned to the hand of " + player.getLogName());
return true;
}
if (player == null || player.getGraveyard().count(StaticFilters.FILTER_CARD_CREATURE, game) < 1) {
return false;
}
return false;
TargetCard target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE);
target.setNotTarget(true);
target.setRandom(true);
player.choose(outcome, target, source.getSourceId(), game);
return player.moveCards(game.getCard(target.getFirstTarget()), Zone.HAND, source, game);
}
}